diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/ecdh/ecdhtest.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdh/ech_ossl.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecdsatest.c | 14 | 
3 files changed, 16 insertions, 6 deletions
| diff --git a/src/lib/libcrypto/ecdh/ecdhtest.c b/src/lib/libcrypto/ecdh/ecdhtest.c index 212a87efa4..823d7baa65 100644 --- a/src/lib/libcrypto/ecdh/ecdhtest.c +++ b/src/lib/libcrypto/ecdh/ecdhtest.c | |||
| @@ -158,11 +158,13 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) | |||
| 158 | if (!EC_POINT_get_affine_coordinates_GFp(group, | 158 | if (!EC_POINT_get_affine_coordinates_GFp(group, | 
| 159 | EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; | 159 | EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; | 
| 160 | } | 160 | } | 
| 161 | #ifndef OPENSSL_NO_EC2M | ||
| 161 | else | 162 | else | 
| 162 | { | 163 | { | 
| 163 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 164 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 
| 164 | EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; | 165 | EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err; | 
| 165 | } | 166 | } | 
| 167 | #endif | ||
| 166 | #ifdef NOISY | 168 | #ifdef NOISY | 
| 167 | BIO_puts(out," pri 1="); | 169 | BIO_puts(out," pri 1="); | 
| 168 | BN_print(out,a->priv_key); | 170 | BN_print(out,a->priv_key); | 
| @@ -183,11 +185,13 @@ static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) | |||
| 183 | if (!EC_POINT_get_affine_coordinates_GFp(group, | 185 | if (!EC_POINT_get_affine_coordinates_GFp(group, | 
| 184 | EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; | 186 | EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; | 
| 185 | } | 187 | } | 
| 188 | #ifndef OPENSSL_NO_EC2M | ||
| 186 | else | 189 | else | 
| 187 | { | 190 | { | 
| 188 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 191 | if (!EC_POINT_get_affine_coordinates_GF2m(group, | 
| 189 | EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; | 192 | EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err; | 
| 190 | } | 193 | } | 
| 194 | #endif | ||
| 191 | 195 | ||
| 192 | #ifdef NOISY | 196 | #ifdef NOISY | 
| 193 | BIO_puts(out," pri 2="); | 197 | BIO_puts(out," pri 2="); | 
| @@ -324,6 +328,7 @@ int main(int argc, char *argv[]) | |||
| 324 | if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out)) goto err; | 328 | if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out)) goto err; | 
| 325 | if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) goto err; | 329 | if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) goto err; | 
| 326 | if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) goto err; | 330 | if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) goto err; | 
| 331 | #ifndef OPENSSL_NO_EC2M | ||
| 327 | /* NIST BINARY CURVES TESTS */ | 332 | /* NIST BINARY CURVES TESTS */ | 
| 328 | if (!test_ecdh_curve(NID_sect163k1, "NIST Binary-Curve K-163", ctx, out)) goto err; | 333 | if (!test_ecdh_curve(NID_sect163k1, "NIST Binary-Curve K-163", ctx, out)) goto err; | 
| 329 | if (!test_ecdh_curve(NID_sect163r2, "NIST Binary-Curve B-163", ctx, out)) goto err; | 334 | if (!test_ecdh_curve(NID_sect163r2, "NIST Binary-Curve B-163", ctx, out)) goto err; | 
| @@ -335,6 +340,7 @@ int main(int argc, char *argv[]) | |||
| 335 | if (!test_ecdh_curve(NID_sect409r1, "NIST Binary-Curve B-409", ctx, out)) goto err; | 340 | if (!test_ecdh_curve(NID_sect409r1, "NIST Binary-Curve B-409", ctx, out)) goto err; | 
| 336 | if (!test_ecdh_curve(NID_sect571k1, "NIST Binary-Curve K-571", ctx, out)) goto err; | 341 | if (!test_ecdh_curve(NID_sect571k1, "NIST Binary-Curve K-571", ctx, out)) goto err; | 
| 337 | if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out)) goto err; | 342 | if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out)) goto err; | 
| 343 | #endif | ||
| 338 | 344 | ||
| 339 | ret = 0; | 345 | ret = 0; | 
| 340 | 346 | ||
| diff --git a/src/lib/libcrypto/ecdh/ech_ossl.c b/src/lib/libcrypto/ecdh/ech_ossl.c index 2a40ff12df..4a30628fbc 100644 --- a/src/lib/libcrypto/ecdh/ech_ossl.c +++ b/src/lib/libcrypto/ecdh/ech_ossl.c | |||
| @@ -157,6 +157,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
| 157 | goto err; | 157 | goto err; | 
| 158 | } | 158 | } | 
| 159 | } | 159 | } | 
| 160 | #ifndef OPENSSL_NO_EC2M | ||
| 160 | else | 161 | else | 
| 161 | { | 162 | { | 
| 162 | if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) | 163 | if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx)) | 
| @@ -165,6 +166,7 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
| 165 | goto err; | 166 | goto err; | 
| 166 | } | 167 | } | 
| 167 | } | 168 | } | 
| 169 | #endif | ||
| 168 | 170 | ||
| 169 | buflen = (EC_GROUP_get_degree(group) + 7)/8; | 171 | buflen = (EC_GROUP_get_degree(group) + 7)/8; | 
| 170 | len = BN_num_bytes(x); | 172 | len = BN_num_bytes(x); | 
| diff --git a/src/lib/libcrypto/ecdsa/ecdsatest.c b/src/lib/libcrypto/ecdsa/ecdsatest.c index 54cfb8c753..537bb30362 100644 --- a/src/lib/libcrypto/ecdsa/ecdsatest.c +++ b/src/lib/libcrypto/ecdsa/ecdsatest.c | |||
| @@ -262,6 +262,7 @@ int x9_62_tests(BIO *out) | |||
| 262 | "3238135532097973577080787768312505059318910517550078427819" | 262 | "3238135532097973577080787768312505059318910517550078427819" | 
| 263 | "78505179448783")) | 263 | "78505179448783")) | 
| 264 | goto x962_err; | 264 | goto x962_err; | 
| 265 | #ifndef OPENSSL_NO_EC2M | ||
| 265 | if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1, | 266 | if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1, | 
| 266 | "87194383164871543355722284926904419997237591535066528048", | 267 | "87194383164871543355722284926904419997237591535066528048", | 
| 267 | "308992691965804947361541664549085895292153777025772063598")) | 268 | "308992691965804947361541664549085895292153777025772063598")) | 
| @@ -272,7 +273,7 @@ int x9_62_tests(BIO *out) | |||
| 272 | "1970303740007316867383349976549972270528498040721988191026" | 273 | "1970303740007316867383349976549972270528498040721988191026" | 
| 273 | "49413465737174")) | 274 | "49413465737174")) | 
| 274 | goto x962_err; | 275 | goto x962_err; | 
| 275 | 276 | #endif | |
| 276 | ret = 1; | 277 | ret = 1; | 
| 277 | x962_err: | 278 | x962_err: | 
| 278 | if (!restore_rand()) | 279 | if (!restore_rand()) | 
| @@ -289,7 +290,8 @@ int test_builtin(BIO *out) | |||
| 289 | ECDSA_SIG *ecdsa_sig = NULL; | 290 | ECDSA_SIG *ecdsa_sig = NULL; | 
| 290 | unsigned char digest[20], wrong_digest[20]; | 291 | unsigned char digest[20], wrong_digest[20]; | 
| 291 | unsigned char *signature = NULL; | 292 | unsigned char *signature = NULL; | 
| 292 | unsigned char *sig_ptr; | 293 | const unsigned char *sig_ptr; | 
| 294 | unsigned char *sig_ptr2; | ||
| 293 | unsigned char *raw_buf = NULL; | 295 | unsigned char *raw_buf = NULL; | 
| 294 | unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len; | 296 | unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len; | 
| 295 | int nid, ret = 0; | 297 | int nid, ret = 0; | 
| @@ -464,8 +466,8 @@ int test_builtin(BIO *out) | |||
| 464 | (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) | 466 | (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) | 
| 465 | goto builtin_err; | 467 | goto builtin_err; | 
| 466 | 468 | ||
| 467 | sig_ptr = signature; | 469 | sig_ptr2 = signature; | 
| 468 | sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr); | 470 | sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2); | 
| 469 | if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1) | 471 | if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1) | 
| 470 | { | 472 | { | 
| 471 | BIO_printf(out, " failed\n"); | 473 | BIO_printf(out, " failed\n"); | 
| @@ -477,8 +479,8 @@ int test_builtin(BIO *out) | |||
| 477 | (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) | 479 | (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL)) | 
| 478 | goto builtin_err; | 480 | goto builtin_err; | 
| 479 | 481 | ||
| 480 | sig_ptr = signature; | 482 | sig_ptr2 = signature; | 
| 481 | sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr); | 483 | sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2); | 
| 482 | if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1) | 484 | if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1) | 
| 483 | { | 485 | { | 
| 484 | BIO_printf(out, " failed\n"); | 486 | BIO_printf(out, " failed\n"); | 
