diff options
author | tb <> | 2023-07-05 08:39:40 +0000 |
---|---|---|
committer | tb <> | 2023-07-05 08:39:40 +0000 |
commit | 788b0a1692618872b1e6c2f13445dbf7721f7c02 (patch) | |
tree | 3d68ee8afc0bc37ca16d301401e781acf405b6a6 | |
parent | 9d190ec0e534650cdc84b1cd4b55351f19456cbe (diff) | |
download | openbsd-788b0a1692618872b1e6c2f13445dbf7721f7c02.tar.gz openbsd-788b0a1692618872b1e6c2f13445dbf7721f7c02.tar.bz2 openbsd-788b0a1692618872b1e6c2f13445dbf7721f7c02.zip |
Drop useless ossl_ prefixes
discussed with jsing
-rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_kmeth.c | 16 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/ec_local.h | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdh/ech_key.c | 29 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdh/ech_lib.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_lib.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_local.h | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 13 |
8 files changed, 52 insertions, 40 deletions
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 1006d2d89d..a15d06b019 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_key.c,v 1.34 2023/07/03 09:35:26 tb Exp $ */ | 1 | /* $OpenBSD: ec_key.c,v 1.35 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -241,7 +241,7 @@ EC_KEY_generate_key(EC_KEY *eckey) | |||
241 | } | 241 | } |
242 | 242 | ||
243 | int | 243 | int |
244 | ossl_ec_key_gen(EC_KEY *eckey) | 244 | ec_key_gen(EC_KEY *eckey) |
245 | { | 245 | { |
246 | BIGNUM *priv_key = NULL; | 246 | BIGNUM *priv_key = NULL; |
247 | EC_POINT *pub_key = NULL; | 247 | EC_POINT *pub_key = NULL; |
diff --git a/src/lib/libcrypto/ec/ec_kmeth.c b/src/lib/libcrypto/ec/ec_kmeth.c index 4e296cfa68..65bf1f99c2 100644 --- a/src/lib/libcrypto/ec/ec_kmeth.c +++ b/src/lib/libcrypto/ec/ec_kmeth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_kmeth.c,v 1.8 2023/06/25 18:52:27 tb Exp $ */ | 1 | /* $OpenBSD: ec_kmeth.c,v 1.9 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
4 | * project. | 4 | * project. |
@@ -74,15 +74,15 @@ static const EC_KEY_METHOD openssl_ec_key_method = { | |||
74 | .set_private = NULL, | 74 | .set_private = NULL, |
75 | .set_public = NULL, | 75 | .set_public = NULL, |
76 | 76 | ||
77 | .keygen = ossl_ec_key_gen, | 77 | .keygen = ec_key_gen, |
78 | .compute_key = ossl_ecdh_compute_key, | 78 | .compute_key = ecdh_compute_key, |
79 | 79 | ||
80 | .sign = ossl_ecdsa_sign, | 80 | .sign = ecdsa_sign, |
81 | .sign_setup = ossl_ecdsa_sign_setup, | 81 | .sign_setup = ecdsa_sign_setup, |
82 | .sign_sig = ossl_ecdsa_sign_sig, | 82 | .sign_sig = ecdsa_sign_sig, |
83 | 83 | ||
84 | .verify = ossl_ecdsa_verify, | 84 | .verify = ecdsa_verify, |
85 | .verify_sig = ossl_ecdsa_verify_sig, | 85 | .verify_sig = ecdsa_verify_sig, |
86 | }; | 86 | }; |
87 | 87 | ||
88 | const EC_KEY_METHOD *default_ec_key_meth = &openssl_ec_key_method; | 88 | const EC_KEY_METHOD *default_ec_key_meth = &openssl_ec_key_method; |
diff --git a/src/lib/libcrypto/ec/ec_local.h b/src/lib/libcrypto/ec/ec_local.h index 0d219e8e21..7a1f90886d 100644 --- a/src/lib/libcrypto/ec/ec_local.h +++ b/src/lib/libcrypto/ec/ec_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_local.h,v 1.23 2023/07/03 07:26:40 tb Exp $ */ | 1 | /* $OpenBSD: ec_local.h,v 1.24 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -341,12 +341,12 @@ struct ec_key_method_st { | |||
341 | 341 | ||
342 | #define EC_KEY_METHOD_DYNAMIC 1 | 342 | #define EC_KEY_METHOD_DYNAMIC 1 |
343 | 343 | ||
344 | int ossl_ec_key_gen(EC_KEY *eckey); | 344 | int ec_key_gen(EC_KEY *eckey); |
345 | int ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, | 345 | int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, |
346 | void *(*KDF) (const void *in, size_t inlen, void *out, size_t *outlen)); | 346 | void *(*KDF) (const void *in, size_t inlen, void *out, size_t *outlen)); |
347 | int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, | 347 | int ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, |
348 | const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); | 348 | const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); |
349 | int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, | 349 | int ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, |
350 | const ECDSA_SIG *sig, EC_KEY *eckey); | 350 | const ECDSA_SIG *sig, EC_KEY *eckey); |
351 | 351 | ||
352 | /* | 352 | /* |
diff --git a/src/lib/libcrypto/ecdh/ech_key.c b/src/lib/libcrypto/ecdh/ech_key.c index bac5b6e28d..5efb49ba59 100644 --- a/src/lib/libcrypto/ecdh/ech_key.c +++ b/src/lib/libcrypto/ecdh/ech_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ech_key.c,v 1.32 2023/07/02 11:29:36 tb Exp $ */ | 1 | /* $OpenBSD: ech_key.c,v 1.33 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -85,12 +85,11 @@ | |||
85 | */ | 85 | */ |
86 | /* XXX - KDF handling moved to ECDH_compute_key(). See OpenSSL e2285d87. */ | 86 | /* XXX - KDF handling moved to ECDH_compute_key(). See OpenSSL e2285d87. */ |
87 | int | 87 | int |
88 | ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | 88 | ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *ecdh, |
89 | EC_KEY *ecdh, | ||
90 | void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) | 89 | void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)) |
91 | { | 90 | { |
92 | BN_CTX *ctx; | 91 | BN_CTX *ctx; |
93 | BIGNUM *x; | 92 | BIGNUM *cofactor, *x; |
94 | const BIGNUM *priv_key; | 93 | const BIGNUM *priv_key; |
95 | const EC_GROUP *group; | 94 | const EC_GROUP *group; |
96 | EC_POINT *point = NULL; | 95 | EC_POINT *point = NULL; |
@@ -111,11 +110,8 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
111 | 110 | ||
112 | if ((x = BN_CTX_get(ctx)) == NULL) | 111 | if ((x = BN_CTX_get(ctx)) == NULL) |
113 | goto err; | 112 | goto err; |
114 | 113 | if ((cofactor = BN_CTX_get(ctx)) == NULL) | |
115 | if ((priv_key = EC_KEY_get0_private_key(ecdh)) == NULL) { | ||
116 | ECDHerror(ECDH_R_NO_PRIVATE_VALUE); | ||
117 | goto err; | 114 | goto err; |
118 | } | ||
119 | 115 | ||
120 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) | 116 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) |
121 | goto err; | 117 | goto err; |
@@ -128,6 +124,23 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
128 | goto err; | 124 | goto err; |
129 | } | 125 | } |
130 | 126 | ||
127 | if ((priv_key = EC_KEY_get0_private_key(ecdh)) == NULL) { | ||
128 | ECDHerror(ECDH_R_NO_PRIVATE_VALUE); | ||
129 | goto err; | ||
130 | } | ||
131 | |||
132 | if ((EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH) != 0) { | ||
133 | if (!EC_GROUP_get_cofactor(group, cofactor, NULL)) { | ||
134 | ECDHerror(ERR_R_EC_LIB); | ||
135 | goto err; | ||
136 | } | ||
137 | if (!BN_mul(cofactor, cofactor, priv_key, ctx)) { | ||
138 | ECDHerror(ERR_R_BN_LIB); | ||
139 | goto err; | ||
140 | } | ||
141 | priv_key = cofactor; | ||
142 | } | ||
143 | |||
131 | if (!EC_POINT_mul(group, point, NULL, pub_key, priv_key, ctx)) { | 144 | if (!EC_POINT_mul(group, point, NULL, pub_key, priv_key, ctx)) { |
132 | ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE); | 145 | ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE); |
133 | goto err; | 146 | goto err; |
diff --git a/src/lib/libcrypto/ecdh/ech_lib.c b/src/lib/libcrypto/ecdh/ech_lib.c index eb1b6bfebc..52019b01c1 100644 --- a/src/lib/libcrypto/ecdh/ech_lib.c +++ b/src/lib/libcrypto/ecdh/ech_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ech_lib.c,v 1.22 2023/06/25 19:17:43 tb Exp $ */ | 1 | /* $OpenBSD: ech_lib.c,v 1.23 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -90,7 +90,7 @@ static const ECDH_METHOD *default_ECDH_method = NULL; | |||
90 | 90 | ||
91 | static const ECDH_METHOD openssl_ecdh_meth = { | 91 | static const ECDH_METHOD openssl_ecdh_meth = { |
92 | .name = "OpenSSL ECDH method", | 92 | .name = "OpenSSL ECDH method", |
93 | .compute_key = ossl_ecdh_compute_key, | 93 | .compute_key = ecdh_compute_key, |
94 | }; | 94 | }; |
95 | 95 | ||
96 | const ECDH_METHOD * | 96 | const ECDH_METHOD * |
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c index 743d517165..69aa1b732b 100644 --- a/src/lib/libcrypto/ecdsa/ecs_lib.c +++ b/src/lib/libcrypto/ecdsa/ecs_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_lib.c,v 1.22 2023/06/25 19:33:39 tb Exp $ */ | 1 | /* $OpenBSD: ecs_lib.c,v 1.23 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -70,9 +70,9 @@ static const ECDSA_METHOD *default_ECDSA_method = NULL; | |||
70 | 70 | ||
71 | static const ECDSA_METHOD openssl_ecdsa_meth = { | 71 | static const ECDSA_METHOD openssl_ecdsa_meth = { |
72 | .name = "OpenSSL ECDSA method", | 72 | .name = "OpenSSL ECDSA method", |
73 | .ecdsa_do_sign = ossl_ecdsa_sign_sig, | 73 | .ecdsa_do_sign = ecdsa_sign_sig, |
74 | .ecdsa_sign_setup = ossl_ecdsa_sign_setup, | 74 | .ecdsa_sign_setup = ecdsa_sign_setup, |
75 | .ecdsa_do_verify = ossl_ecdsa_verify_sig, | 75 | .ecdsa_do_verify = ecdsa_verify_sig, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | const ECDSA_METHOD * | 78 | const ECDSA_METHOD * |
diff --git a/src/lib/libcrypto/ecdsa/ecs_local.h b/src/lib/libcrypto/ecdsa/ecs_local.h index 20ad0c246e..4f1140483f 100644 --- a/src/lib/libcrypto/ecdsa/ecs_local.h +++ b/src/lib/libcrypto/ecdsa/ecs_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_local.h,v 1.3 2023/06/25 18:45:56 tb Exp $ */ | 1 | /* $OpenBSD: ecs_local.h,v 1.4 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -68,12 +68,12 @@ struct ECDSA_SIG_st { | |||
68 | BIGNUM *s; | 68 | BIGNUM *s; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | 71 | int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, |
72 | BIGNUM **rp); | 72 | BIGNUM **rp); |
73 | int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, | 73 | int ecdsa_sign(int type, const unsigned char *dgst, int dlen, |
74 | unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, | 74 | unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, |
75 | const BIGNUM *r, EC_KEY *eckey); | 75 | const BIGNUM *r, EC_KEY *eckey); |
76 | ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, | 76 | ECDSA_SIG *ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, |
77 | const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey); | 77 | const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey); |
78 | 78 | ||
79 | __END_HIDDEN_DECLS | 79 | __END_HIDDEN_DECLS |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 0ca2651f25..223cc655da 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_ossl.c,v 1.71 2023/07/04 15:09:31 tb Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.72 2023/07/05 08:39:40 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -97,7 +97,7 @@ ecdsa_prepare_digest(const unsigned char *digest, int digest_len, | |||
97 | } | 97 | } |
98 | 98 | ||
99 | int | 99 | int |
100 | ossl_ecdsa_sign(int type, const unsigned char *digest, int digest_len, | 100 | ecdsa_sign(int type, const unsigned char *digest, int digest_len, |
101 | unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv, | 101 | unsigned char *signature, unsigned int *signature_len, const BIGNUM *kinv, |
102 | const BIGNUM *r, EC_KEY *key) | 102 | const BIGNUM *r, EC_KEY *key) |
103 | { | 103 | { |
@@ -128,8 +128,7 @@ ossl_ecdsa_sign(int type, const unsigned char *digest, int digest_len, | |||
128 | */ | 128 | */ |
129 | 129 | ||
130 | int | 130 | int |
131 | ossl_ecdsa_sign_setup(EC_KEY *key, BN_CTX *in_ctx, BIGNUM **out_kinv, | 131 | ecdsa_sign_setup(EC_KEY *key, BN_CTX *in_ctx, BIGNUM **out_kinv, BIGNUM **out_r) |
132 | BIGNUM **out_r) | ||
133 | { | 132 | { |
134 | const EC_GROUP *group; | 133 | const EC_GROUP *group; |
135 | EC_POINT *point = NULL; | 134 | EC_POINT *point = NULL; |
@@ -392,7 +391,7 @@ ecdsa_compute_s(BIGNUM **out_s, const BIGNUM *e, const BIGNUM *kinv, | |||
392 | */ | 391 | */ |
393 | 392 | ||
394 | ECDSA_SIG * | 393 | ECDSA_SIG * |
395 | ossl_ecdsa_sign_sig(const unsigned char *digest, int digest_len, | 394 | ecdsa_sign_sig(const unsigned char *digest, int digest_len, |
396 | const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *key) | 395 | const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *key) |
397 | { | 396 | { |
398 | BN_CTX *ctx = NULL; | 397 | BN_CTX *ctx = NULL; |
@@ -485,7 +484,7 @@ ossl_ecdsa_sign_sig(const unsigned char *digest, int digest_len, | |||
485 | } | 484 | } |
486 | 485 | ||
487 | int | 486 | int |
488 | ossl_ecdsa_verify(int type, const unsigned char *digest, int digest_len, | 487 | ecdsa_verify(int type, const unsigned char *digest, int digest_len, |
489 | const unsigned char *sigbuf, int sig_len, EC_KEY *key) | 488 | const unsigned char *sigbuf, int sig_len, EC_KEY *key) |
490 | { | 489 | { |
491 | ECDSA_SIG *s; | 490 | ECDSA_SIG *s; |
@@ -522,7 +521,7 @@ ossl_ecdsa_verify(int type, const unsigned char *digest, int digest_len, | |||
522 | */ | 521 | */ |
523 | 522 | ||
524 | int | 523 | int |
525 | ossl_ecdsa_verify_sig(const unsigned char *digest, int digest_len, | 524 | ecdsa_verify_sig(const unsigned char *digest, int digest_len, |
526 | const ECDSA_SIG *sig, EC_KEY *key) | 525 | const ECDSA_SIG *sig, EC_KEY *key) |
527 | { | 526 | { |
528 | const EC_GROUP *group; | 527 | const EC_GROUP *group; |