Skip to content

Commit ae17f1f

Browse files
olszomalmtrojnar
authored andcommitted
OpenSSL 1.0.2 compatibility fixes
1 parent fd441f8 commit ae17f1f

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

examples/eckeygen.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ static int parse_hex_key_id(const char *input, unsigned char **output, size_t *s
5555
return -1;
5656
}
5757
*size = len / 2;
58-
*output = OPENSSL_zalloc(*size);
58+
*output = OPENSSL_malloc(*size);
5959
if (!*output) {
6060
return -1;
6161
}
62+
memset(*output, 0, *size);
6263
for (i = 0; i < *size; i++) {
63-
sscanf(input + (i * 2), "%2hhx", &(*output)[i]);
64+
sscanf(input + (i * 2), "%2hhx", *output + i);
6465
}
6566
return 0;
6667
}

examples/rsakeygen.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ static int parse_hex_key_id(const char *input, unsigned char **output, size_t *s
5555
return -1;
5656
}
5757
*size = len / 2;
58-
*output = OPENSSL_zalloc(*size);
58+
*output = OPENSSL_malloc(*size);
5959
if (!*output) {
6060
return -1;
6161
}
62+
memset(*output, 0, *size);
6263
for (i = 0; i < *size; i++) {
63-
sscanf(input + (i * 2), "%2hhx", &(*output)[i]);
64+
sscanf(input + (i * 2), "%2hhx", *output + i);
6465
}
6566
return 0;
6667
}

src/p11_ec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ typedef int (*compute_key_fn)(void *, size_t,
6262
void *(*)(const void *, size_t, void *, size_t *));
6363
#endif
6464
static compute_key_fn ossl_ecdh_compute_key;
65+
66+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
6567
static void (*ossl_ec_finish)(EC_KEY *);
6668
static int (*ossl_ec_copy)(EC_KEY *, const EC_KEY *);
69+
#endif /* OPENSSL_VERSION_NUMBER */
6770

6871
static int ec_ex_index = 0;
6972

@@ -445,6 +448,8 @@ static int pkcs11_ecdsa_sign(const unsigned char *msg, unsigned int msg_len,
445448
return ck_sigsize;
446449
}
447450

451+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
452+
448453
static void pkcs11_ec_finish(EC_KEY *ec)
449454
{
450455
PKCS11_OBJECT_private *key;
@@ -458,6 +463,8 @@ static void pkcs11_ec_finish(EC_KEY *ec)
458463
ossl_ec_finish(ec);
459464
}
460465

466+
#endif /* OPENSSL_VERSION_NUMBER */
467+
461468
/**
462469
* ECDSA signing method (replaces ossl_ecdsa_sign_sig)
463470
*

0 commit comments

Comments
 (0)