diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-02-18 11:27:26 +0100 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2021-02-26 01:53:01 +0100 |
commit | 32ab57cbb4877ce7e6b4eb3f9b3cfbb0ff7cd10b (patch) | |
tree | 91e75951efa936b26e3a636b9a0daf90d60182b0 /crypto/sm2 | |
parent | Fix external symbols related to dsa keys (diff) | |
download | openssl-32ab57cbb4877ce7e6b4eb3f9b3cfbb0ff7cd10b.tar.xz openssl-32ab57cbb4877ce7e6b4eb3f9b3cfbb0ff7cd10b.zip |
Fix external symbols related to ec & sm2 keys
Partial fix for #12964
This adds ossl_ names for the following symbols:
ec_*, ecx_*, ecdh_*, ecdsa_*, sm2_*
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14231)
Diffstat (limited to 'crypto/sm2')
-rw-r--r-- | crypto/sm2/sm2_crypt.c | 42 | ||||
-rw-r--r-- | crypto/sm2/sm2_key.c | 2 | ||||
-rw-r--r-- | crypto/sm2/sm2_sign.c | 58 |
3 files changed, 52 insertions, 50 deletions
diff --git a/crypto/sm2/sm2_crypt.c b/crypto/sm2/sm2_crypt.c index 9201d712c1..5e455d0613 100644 --- a/crypto/sm2/sm2_crypt.c +++ b/crypto/sm2/sm2_crypt.c @@ -17,7 +17,7 @@ #include "crypto/sm2.h" #include "crypto/sm2err.h" -#include "crypto/ec.h" /* ecdh_KDF_X9_63() */ +#include "crypto/ec.h" /* ossl_ecdh_kdf_X9_63() */ #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/bn.h> @@ -67,8 +67,8 @@ static size_t ec_field_size(const EC_GROUP *group) return field_size; } -int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *pt_size) +int ossl_sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, + size_t msg_len, size_t *pt_size) { const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); const int md_size = EVP_MD_size(digest); @@ -93,8 +93,8 @@ int sm2_plaintext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, return 1; } -int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, - size_t *ct_size) +int ossl_sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, + size_t msg_len, size_t *ct_size) { const size_t field_size = ec_field_size(EC_KEY_get0_group(key)); const int md_size = EVP_MD_size(digest); @@ -113,10 +113,10 @@ int sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest, size_t msg_len, return 1; } -int sm2_encrypt(const EC_KEY *key, - const EVP_MD *digest, - const uint8_t *msg, - size_t msg_len, uint8_t *ciphertext_buf, size_t *ciphertext_len) +int ossl_sm2_encrypt(const EC_KEY *key, + const EVP_MD *digest, + const uint8_t *msg, size_t msg_len, + uint8_t *ciphertext_buf, size_t *ciphertext_len) { int rc = 0, ciphertext_leni; size_t i; @@ -139,8 +139,8 @@ int sm2_encrypt(const EC_KEY *key, size_t field_size; const int C3_size = EVP_MD_size(digest); EVP_MD *fetched_digest = NULL; - OSSL_LIB_CTX *libctx = ec_key_get_libctx(key); - const char *propq = ec_key_get0_propq(key); + OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); + const char *propq = ossl_ec_key_get0_propq(key); /* NULL these before any "goto done" */ ctext_struct.C2 = NULL; @@ -213,8 +213,8 @@ int sm2_encrypt(const EC_KEY *key, } /* X9.63 with no salt happens to match the KDF used in SM2 */ - if (!ecdh_KDF_X9_63(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0, - digest, libctx, propq)) { + if (!ossl_ecdh_kdf_X9_63(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0, + digest, libctx, propq)) { ERR_raise(ERR_LIB_SM2, ERR_R_EVP_LIB); goto done; } @@ -275,10 +275,10 @@ int sm2_encrypt(const EC_KEY *key, return rc; } -int sm2_decrypt(const EC_KEY *key, - const EVP_MD *digest, - const uint8_t *ciphertext, - size_t ciphertext_len, uint8_t *ptext_buf, size_t *ptext_len) +int ossl_sm2_decrypt(const EC_KEY *key, + const EVP_MD *digest, + const uint8_t *ciphertext, size_t ciphertext_len, + uint8_t *ptext_buf, size_t *ptext_len) { int rc = 0; int i; @@ -297,8 +297,8 @@ int sm2_decrypt(const EC_KEY *key, const uint8_t *C3 = NULL; int msg_len = 0; EVP_MD_CTX *hash = NULL; - OSSL_LIB_CTX *libctx = ec_key_get_libctx(key); - const char *propq = ec_key_get0_propq(key); + OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); + const char *propq = ossl_ec_key_get0_propq(key); if (field_size == 0 || hash_size <= 0) goto done; @@ -362,8 +362,8 @@ int sm2_decrypt(const EC_KEY *key, if (BN_bn2binpad(x2, x2y2, field_size) < 0 || BN_bn2binpad(y2, x2y2 + field_size, field_size) < 0 - || !ecdh_KDF_X9_63(msg_mask, msg_len, x2y2, 2 * field_size, NULL, 0, - digest, libctx, propq)) { + || !ossl_ecdh_kdf_X9_63(msg_mask, msg_len, x2y2, 2 * field_size, + NULL, 0, digest, libctx, propq)) { ERR_raise(ERR_LIB_SM2, ERR_R_INTERNAL_ERROR); goto done; } diff --git a/crypto/sm2/sm2_key.c b/crypto/sm2/sm2_key.c index ec96737a84..9d0b9208fa 100644 --- a/crypto/sm2/sm2_key.c +++ b/crypto/sm2/sm2_key.c @@ -19,7 +19,7 @@ * crypto/ec/ec_key.c */ -int sm2_key_private_check(const EC_KEY *eckey) +int ossl_sm2_key_private_check(const EC_KEY *eckey) { int ret = 0; BIGNUM *max = NULL; diff --git a/crypto/sm2/sm2_sign.c b/crypto/sm2/sm2_sign.c index e36e0710b7..d9e16e1f98 100644 --- a/crypto/sm2/sm2_sign.c +++ b/crypto/sm2/sm2_sign.c @@ -13,7 +13,7 @@ #include "crypto/sm2.h" #include "crypto/sm2err.h" -#include "crypto/ec.h" /* ec_group_do_inverse_ord() */ +#include "crypto/ec.h" /* ossl_ec_group_do_inverse_ord() */ #include "internal/numbers.h" #include <openssl/err.h> #include <openssl/evp.h> @@ -21,11 +21,11 @@ #include <openssl/bn.h> #include <string.h> -int sm2_compute_z_digest(uint8_t *out, - const EVP_MD *digest, - const uint8_t *id, - const size_t id_len, - const EC_KEY *key) +int ossl_sm2_compute_z_digest(uint8_t *out, + const EVP_MD *digest, + const uint8_t *id, + const size_t id_len, + const EC_KEY *key) { int rc = 0; const EC_GROUP *group = EC_KEY_get0_group(key); @@ -44,7 +44,7 @@ int sm2_compute_z_digest(uint8_t *out, uint8_t e_byte = 0; hash = EVP_MD_CTX_new(); - ctx = BN_CTX_new_ex(ec_key_get_libctx(key)); + ctx = BN_CTX_new_ex(ossl_ec_key_get_libctx(key)); if (hash == NULL || ctx == NULL) { ERR_raise(ERR_LIB_SM2, ERR_R_MALLOC_FAILURE); goto done; @@ -149,8 +149,8 @@ static BIGNUM *sm2_compute_msg_hash(const EVP_MD *digest, uint8_t *z = NULL; BIGNUM *e = NULL; EVP_MD *fetched_digest = NULL; - OSSL_LIB_CTX *libctx = ec_key_get_libctx(key); - const char *propq = ec_key_get0_propq(key); + OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); + const char *propq = ossl_ec_key_get0_propq(key); if (md_size < 0) { ERR_raise(ERR_LIB_SM2, SM2_R_INVALID_DIGEST); @@ -169,7 +169,7 @@ static BIGNUM *sm2_compute_msg_hash(const EVP_MD *digest, goto done; } - if (!sm2_compute_z_digest(z, fetched_digest, id, id_len, key)) { + if (!ossl_sm2_compute_z_digest(z, fetched_digest, id, id_len, key)) { /* SM2err already called */ goto done; } @@ -208,7 +208,7 @@ static ECDSA_SIG *sm2_sig_gen(const EC_KEY *key, const BIGNUM *e) BIGNUM *s = NULL; BIGNUM *x1 = NULL; BIGNUM *tmp = NULL; - OSSL_LIB_CTX *libctx = ec_key_get_libctx(key); + OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); kG = EC_POINT_new(group); ctx = BN_CTX_new_ex(libctx); @@ -266,7 +266,7 @@ static ECDSA_SIG *sm2_sig_gen(const EC_KEY *key, const BIGNUM *e) continue; if (!BN_add(s, dA, BN_value_one()) - || !ec_group_do_inverse_ord(group, s, s, ctx) + || !ossl_ec_group_do_inverse_ord(group, s, s, ctx) || !BN_mod_mul(tmp, dA, r, order, ctx) || !BN_sub(tmp, k, tmp) || !BN_mod_mul(s, s, tmp, order, ctx)) { @@ -308,7 +308,7 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, BIGNUM *x1 = NULL; const BIGNUM *r = NULL; const BIGNUM *s = NULL; - OSSL_LIB_CTX *libctx = ec_key_get_libctx(key); + OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); ctx = BN_CTX_new_ex(libctx); pt = EC_POINT_new(group); @@ -375,11 +375,11 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, return ret; } -ECDSA_SIG *sm2_do_sign(const EC_KEY *key, - const EVP_MD *digest, - const uint8_t *id, - const size_t id_len, - const uint8_t *msg, size_t msg_len) +ECDSA_SIG *ossl_sm2_do_sign(const EC_KEY *key, + const EVP_MD *digest, + const uint8_t *id, + const size_t id_len, + const uint8_t *msg, size_t msg_len) { BIGNUM *e = NULL; ECDSA_SIG *sig = NULL; @@ -397,12 +397,12 @@ ECDSA_SIG *sm2_do_sign(const EC_KEY *key, return sig; } -int sm2_do_verify(const EC_KEY *key, - const EVP_MD *digest, - const ECDSA_SIG *sig, - const uint8_t *id, - const size_t id_len, - const uint8_t *msg, size_t msg_len) +int ossl_sm2_do_verify(const EC_KEY *key, + const EVP_MD *digest, + const ECDSA_SIG *sig, + const uint8_t *id, + const size_t id_len, + const uint8_t *msg, size_t msg_len) { BIGNUM *e = NULL; int ret = 0; @@ -420,8 +420,9 @@ int sm2_do_verify(const EC_KEY *key, return ret; } -int sm2_internal_sign(const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, EC_KEY *eckey) +int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen, + unsigned char *sig, unsigned int *siglen, + EC_KEY *eckey) { BIGNUM *e = NULL; ECDSA_SIG *s = NULL; @@ -455,8 +456,9 @@ int sm2_internal_sign(const unsigned char *dgst, int dgstlen, return ret; } -int sm2_internal_verify(const unsigned char *dgst, int dgstlen, - const unsigned char *sig, int sig_len, EC_KEY *eckey) +int ossl_sm2_internal_verify(const unsigned char *dgst, int dgstlen, + const unsigned char *sig, int sig_len, + EC_KEY *eckey) { ECDSA_SIG *s = NULL; BIGNUM *e = NULL; |