diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-03-09 11:53:33 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2021-03-18 17:52:37 +1000 |
commit | 8a6e9125200223fa2294d3634d3dfec24857264b (patch) | |
tree | 456f123f76f8d213acc195450d4a8502cd2fda23 /crypto | |
parent | 7bbadfc15a446134d15d8fd0aa5362628b8c96be (diff) |
Add ossl_ symbols for sm3 and sm4
Partial fix for #12964
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14473)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/evp/e_sm4.c | 16 | ||||
-rw-r--r-- | crypto/sm3/legacy_sm3.c | 2 | ||||
-rw-r--r-- | crypto/sm3/sm3.c | 5 | ||||
-rw-r--r-- | crypto/sm3/sm3_local.h | 12 | ||||
-rw-r--r-- | crypto/sm4/sm4.c | 6 |
5 files changed, 20 insertions, 21 deletions
diff --git a/crypto/evp/e_sm4.c b/crypto/evp/e_sm4.c index 5a164eff75..4e6c1cdceb 100644 --- a/crypto/evp/e_sm4.c +++ b/crypto/evp/e_sm4.c @@ -24,7 +24,7 @@ typedef struct { static int sm4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - SM4_set_key(key, EVP_CIPHER_CTX_get_cipher_data(ctx)); + ossl_sm4_set_key(key, EVP_CIPHER_CTX_get_cipher_data(ctx)); return 1; } @@ -34,10 +34,10 @@ static void sm4_cbc_encrypt(const unsigned char *in, unsigned char *out, { if (enc) CRYPTO_cbc128_encrypt(in, out, len, key, ivec, - (block128_f)SM4_encrypt); + (block128_f)ossl_sm4_encrypt); else CRYPTO_cbc128_decrypt(in, out, len, key, ivec, - (block128_f)SM4_decrypt); + (block128_f)ossl_sm4_decrypt); } static void sm4_cfb128_encrypt(const unsigned char *in, unsigned char *out, @@ -45,16 +45,16 @@ static void sm4_cfb128_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num, const int enc) { CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc, - (block128_f)SM4_encrypt); + (block128_f)ossl_sm4_encrypt); } static void sm4_ecb_encrypt(const unsigned char *in, unsigned char *out, const SM4_KEY *key, const int enc) { if (enc) - SM4_encrypt(in, out, key); + ossl_sm4_encrypt(in, out, key); else - SM4_decrypt(in, out, key); + ossl_sm4_decrypt(in, out, key); } static void sm4_ofb128_encrypt(const unsigned char *in, unsigned char *out, @@ -62,7 +62,7 @@ static void sm4_ofb128_encrypt(const unsigned char *in, unsigned char *out, unsigned char *ivec, int *num) { CRYPTO_ofb128_encrypt(in, out, length, key, ivec, num, - (block128_f)SM4_encrypt); + (block128_f)ossl_sm4_encrypt); } IMPLEMENT_BLOCK_CIPHER(sm4, ks, sm4, EVP_SM4_KEY, NID_sm4, @@ -77,7 +77,7 @@ static int sm4_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, CRYPTO_ctr128_encrypt(in, out, len, &dat->ks, ctx->iv, EVP_CIPHER_CTX_buf_noconst(ctx), &num, - (block128_f)SM4_encrypt); + (block128_f)ossl_sm4_encrypt); EVP_CIPHER_CTX_set_num(ctx, num); return 1; } diff --git a/crypto/sm3/legacy_sm3.c b/crypto/sm3/legacy_sm3.c index da07aed12a..e91e59d504 100644 --- a/crypto/sm3/legacy_sm3.c +++ b/crypto/sm3/legacy_sm3.c @@ -13,7 +13,7 @@ #include "../evp/legacy_meth.h" #include "internal/sm3.h" -IMPLEMENT_LEGACY_EVP_MD_METH_LC(sm3_int, sm3) +IMPLEMENT_LEGACY_EVP_MD_METH_LC(sm3_int, ossl_sm3) static const EVP_MD sm3_md = { NID_sm3, diff --git a/crypto/sm3/sm3.c b/crypto/sm3/sm3.c index ef03150cab..37a494b69b 100644 --- a/crypto/sm3/sm3.c +++ b/crypto/sm3/sm3.c @@ -12,7 +12,7 @@ #include <openssl/e_os2.h> #include "sm3_local.h" -int sm3_init(SM3_CTX *c) +int ossl_sm3_init(SM3_CTX *c) { memset(c, 0, sizeof(*c)); c->A = SM3_A; @@ -26,7 +26,7 @@ int sm3_init(SM3_CTX *c) return 1; } -void sm3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) +void ossl_sm3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) { const unsigned char *data = p; register unsigned MD32_REG_T A, B, C, D, E, F, G, H; @@ -193,4 +193,3 @@ void sm3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) ctx->H ^= H; } } - diff --git a/crypto/sm3/sm3_local.h b/crypto/sm3/sm3_local.h index 07def19cf1..3325eac745 100644 --- a/crypto/sm3/sm3_local.h +++ b/crypto/sm3/sm3_local.h @@ -17,9 +17,9 @@ #define HASH_LONG SM3_WORD #define HASH_CTX SM3_CTX #define HASH_CBLOCK SM3_CBLOCK -#define HASH_UPDATE sm3_update -#define HASH_TRANSFORM sm3_transform -#define HASH_FINAL sm3_final +#define HASH_UPDATE ossl_sm3_update +#define HASH_TRANSFORM ossl_sm3_transform +#define HASH_FINAL ossl_sm3_final #define HASH_MAKE_STRING(c, s) \ do { \ unsigned long ll; \ @@ -32,10 +32,10 @@ ll=(c)->G; (void)HOST_l2c(ll, (s)); \ ll=(c)->H; (void)HOST_l2c(ll, (s)); \ } while (0) -#define HASH_BLOCK_DATA_ORDER sm3_block_data_order +#define HASH_BLOCK_DATA_ORDER ossl_sm3_block_data_order -void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num); -void sm3_transform(SM3_CTX *c, const unsigned char *data); +void ossl_sm3_block_data_order(SM3_CTX *c, const void *p, size_t num); +void ossl_sm3_transform(SM3_CTX *c, const unsigned char *data); #include "crypto/md32_common.h" diff --git a/crypto/sm4/sm4.c b/crypto/sm4/sm4.c index a62993c272..5e525d96e5 100644 --- a/crypto/sm4/sm4.c +++ b/crypto/sm4/sm4.c @@ -129,7 +129,7 @@ static ossl_inline uint32_t SM4_T(uint32_t X) rotl(SM4_SBOX_T[(uint8_t)X], 8); } -int SM4_set_key(const uint8_t *key, SM4_KEY *ks) +int ossl_sm4_set_key(const uint8_t *key, SM4_KEY *ks) { /* * Family Key @@ -184,7 +184,7 @@ int SM4_set_key(const uint8_t *key, SM4_KEY *ks) B3 ^= F(B0 ^ B1 ^ B2 ^ ks->rk[k3]); \ } while(0) -void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks) +void ossl_sm4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks) { uint32_t B0 = load_u32_be(in, 0); uint32_t B1 = load_u32_be(in, 1); @@ -210,7 +210,7 @@ void SM4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks) store_u32_be(B0, out + 12); } -void SM4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks) +void ossl_sm4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks) { uint32_t B0 = load_u32_be(in, 0); uint32_t B1 = load_u32_be(in, 1); |