diff --git a/tests/api.c b/tests/api.c index 536760c4e0..9eeee65df6 100644 --- a/tests/api.c +++ b/tests/api.c @@ -59072,21 +59072,21 @@ static int test_wolfSSL_EVP_Digest_all(void) "SHA512", #endif #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_224) - "SHA512_224", + "SHA512-224", #endif #if defined(WOLFSSL_SHA512) && !defined(WOLFSSL_NOSHA512_256) - "SHA512_256", + "SHA512-256", #endif #ifdef WOLFSSL_SHA3 #ifndef WOLFSSL_NOSHA3_224 - "SHA3_224", + "SHA3-224", #endif #ifndef WOLFSSL_NOSHA3_256 - "SHA3_256", + "SHA3-256", #endif - "SHA3_384", + "SHA3-384", #ifndef WOLFSSL_NOSHA3_512 - "SHA3_512", + "SHA3-512", #endif #endif /* WOLFSSL_SHA3 */ NULL @@ -59116,7 +59116,7 @@ static int test_wolfSSL_EVP_MD_size(void) #ifndef WOLFSSL_NOSHA3_224 wolfSSL_EVP_MD_CTX_init(&mdCtx); - ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3_224"), 1); + ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3-224"), 1); ExpectIntEQ(wolfSSL_EVP_MD_CTX_size(&mdCtx), WC_SHA3_224_DIGEST_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_block_size(&mdCtx), WC_SHA3_224_BLOCK_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); @@ -59124,21 +59124,21 @@ static int test_wolfSSL_EVP_MD_size(void) #ifndef WOLFSSL_NOSHA3_256 wolfSSL_EVP_MD_CTX_init(&mdCtx); - ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3_256"), 1); + ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3-256"), 1); ExpectIntEQ(wolfSSL_EVP_MD_CTX_size(&mdCtx), WC_SHA3_256_DIGEST_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_block_size(&mdCtx), WC_SHA3_256_BLOCK_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); #endif wolfSSL_EVP_MD_CTX_init(&mdCtx); - ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3_384"), 1); + ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3-384"), 1); ExpectIntEQ(wolfSSL_EVP_MD_CTX_size(&mdCtx), WC_SHA3_384_DIGEST_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_block_size(&mdCtx), WC_SHA3_384_BLOCK_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); #ifndef WOLFSSL_NOSHA3_512 wolfSSL_EVP_MD_CTX_init(&mdCtx); - ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3_512"), 1); + ExpectIntEQ(wolfSSL_EVP_DigestInit(&mdCtx, "SHA3-512"), 1); ExpectIntEQ(wolfSSL_EVP_MD_CTX_size(&mdCtx), WC_SHA3_512_DIGEST_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_block_size(&mdCtx), WC_SHA3_512_BLOCK_SIZE); ExpectIntEQ(wolfSSL_EVP_MD_CTX_cleanup(&mdCtx), 1); @@ -93447,12 +93447,12 @@ static int test_EVP_blake2(void) #if defined(HAVE_BLAKE2) ExpectNotNull(md = EVP_blake2b512()); - ExpectIntEQ(XSTRNCMP(md, "BLAKE2B512", XSTRLEN("BLAKE2B512")), 0); + ExpectIntEQ(XSTRNCMP(md, "BLAKE2b512", XSTRLEN("BLAKE2b512")), 0); #endif #if defined(HAVE_BLAKE2S) ExpectNotNull(md = EVP_blake2s256()); - ExpectIntEQ(XSTRNCMP(md, "BLAKE2S256", XSTRLEN("BLAKE2S256")), 0); + ExpectIntEQ(XSTRNCMP(md, "BLAKE2s256", XSTRLEN("BLAKE2s256")), 0); #endif #endif diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index d76c8df5e0..c31f71c113 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -103,7 +103,7 @@ static const struct s_ent { {WC_HASH_TYPE_SM3, WC_NID_sm3, WC_SN_sm3}, #endif /* WOLFSSL_SHA512 */ #ifdef HAVE_BLAKE2 - {WC_HASH_TYPE_BLAKE2B, WC_NID_blake2b512, WC_SN_blakeb512}, + {WC_HASH_TYPE_BLAKE2B, WC_NID_blake2b512, WC_SN_blake2b512}, #endif #ifdef HAVE_BLAKE2S {WC_HASH_TYPE_BLAKE2S, WC_NID_blake2s256, WC_SN_blake2s256}, @@ -9950,40 +9950,30 @@ static const struct alias { {WC_SN_sha3_384, "sha3_384"}, {WC_SN_sha3_512, "sha3_512"}, {WC_SN_sm3, "sm3"}, - {"BLAKE2B512", "blake2b512"}, - {"BLAKE2S256", "blake2s256"}, - {"SHAKE128", "shake128"}, - {"SHAKE256", "shake256"}, + {WC_SN_blake2b512, "blake2b512"}, + {WC_SN_blake2s256, "blake2s256"}, + {WC_SN_shake128, "shake128"}, + {WC_SN_shake256, "shake256"}, { NULL, NULL} }; const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name) { - char nameUpper[15]; /* 15 bytes should be enough for any name */ - size_t i; - const struct alias *al; const struct s_ent *ent; - for (i = 0; i < sizeof(nameUpper) && name[i] != '\0'; i++) { - nameUpper[i] = (char)XTOUPPER((unsigned char) name[i]); - } - if (i < sizeof(nameUpper)) - nameUpper[i] = '\0'; - else - return NULL; - - name = nameUpper; - for (al = digest_alias_tbl; al->name != NULL; al++) + for (al = digest_alias_tbl; al->name != NULL; al++) { if(XSTRCMP(name, al->alias) == 0) { name = al->name; break; } + } - for (ent = md_tbl; ent->name != NULL; ent++) + for (ent = md_tbl; ent->name != NULL; ent++) { if(XSTRCMP(name, ent->name) == 0) { return (WOLFSSL_EVP_MD *)ent->name; } + } return NULL; } @@ -10040,8 +10030,8 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type) */ const WOLFSSL_EVP_MD* wolfSSL_EVP_blake2b512(void) { - WOLFSSL_ENTER("EVP_blake2b512"); - return wolfSSL_EVP_get_digestbyname("BLAKE2b512"); + WOLFSSL_ENTER("wolfSSL_EVP_blake2b512"); + return wolfSSL_EVP_get_digestbyname(WC_SN_blake2b512); } #endif