@@ -10867,6 +10867,22 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1086710867 ret = WOLFSSL_FAILURE ;
1086810868 }
1086910869 } else
10870+ #endif
10871+ #ifdef HAVE_BLAKE2
10872+ if (XSTRCMP (md , WC_SN_blake2b512 ) == 0 ) {
10873+ if (wc_InitBlake2b (& ctx -> hash .digest .blake2b ,
10874+ WC_BLAKE2B_DIGEST_SIZE ) != 0 ) {
10875+ ret = WOLFSSL_FAILURE ;
10876+ }
10877+ } else
10878+ #endif
10879+ #ifdef HAVE_BLAKE2S
10880+ if (XSTRCMP (md , WC_SN_blake2s256 ) == 0 ) {
10881+ if (wc_InitBlake2s (& ctx -> hash .digest .blake2s ,
10882+ WC_BLAKE2S_DIGEST_SIZE ) != 0 ) {
10883+ ret = WOLFSSL_FAILURE ;
10884+ }
10885+ } else
1087010886 #endif
1087110887 {
1087210888 ctx -> macType = WC_HASH_TYPE_NONE ;
@@ -11002,12 +11018,32 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1100211018 ret = WOLFSSL_SUCCESS ;
1100311019 }
1100411020 break ;
11021+ #endif
11022+ #ifdef HAVE_BLAKE2
11023+ case WC_HASH_TYPE_BLAKE2B :
11024+ if (wc_Blake2bUpdate (& ctx -> hash .digest .blake2b ,
11025+ (const byte * )data , (word32 )sz ) == 0 ) {
11026+ ret = WOLFSSL_SUCCESS ;
11027+ }
11028+ break ;
11029+ #endif
11030+ #ifdef HAVE_BLAKE2S
11031+ case WC_HASH_TYPE_BLAKE2S :
11032+ if (wc_Blake2sUpdate (& ctx -> hash .digest .blake2s ,
11033+ (const byte * )data , (word32 )sz ) == 0 ) {
11034+ ret = WOLFSSL_SUCCESS ;
11035+ }
11036+ break ;
1100511037 #endif
1100611038 case WC_HASH_TYPE_NONE :
1100711039 case WC_HASH_TYPE_MD2 :
1100811040 case WC_HASH_TYPE_MD5_SHA :
11041+ #ifndef HAVE_BLAKE2
1100911042 case WC_HASH_TYPE_BLAKE2B :
11043+ #endif
11044+ #ifndef HAVE_BLAKE2S
1101011045 case WC_HASH_TYPE_BLAKE2S :
11046+ #endif
1101111047 default :
1101211048 return WOLFSSL_FAILURE ;
1101311049 }
@@ -11132,12 +11168,34 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1113211168 ret = WOLFSSL_SUCCESS ;
1113311169 }
1113411170 break ;
11171+ #endif
11172+ #ifdef HAVE_BLAKE2
11173+ case WC_HASH_TYPE_BLAKE2B :
11174+ if (wc_Blake2bFinal (& ctx -> hash .digest .blake2b , md ,
11175+ WC_BLAKE2B_DIGEST_SIZE ) == 0 ) {
11176+ if (s ) * s = WC_BLAKE2B_DIGEST_SIZE ;
11177+ ret = WOLFSSL_SUCCESS ;
11178+ }
11179+ break ;
11180+ #endif
11181+ #ifdef HAVE_BLAKE2S
11182+ case WC_HASH_TYPE_BLAKE2S :
11183+ if (wc_Blake2sFinal (& ctx -> hash .digest .blake2s , md ,
11184+ WC_BLAKE2S_DIGEST_SIZE ) == 0 ) {
11185+ if (s ) * s = WC_BLAKE2S_DIGEST_SIZE ;
11186+ ret = WOLFSSL_SUCCESS ;
11187+ }
11188+ break ;
1113511189 #endif
1113611190 case WC_HASH_TYPE_NONE :
1113711191 case WC_HASH_TYPE_MD2 :
1113811192 case WC_HASH_TYPE_MD5_SHA :
11193+ #ifndef HAVE_BLAKE2
1113911194 case WC_HASH_TYPE_BLAKE2B :
11195+ #endif
11196+ #ifndef HAVE_BLAKE2S
1114011197 case WC_HASH_TYPE_BLAKE2S :
11198+ #endif
1114111199 default :
1114211200 return WOLFSSL_FAILURE ;
1114311201 }
@@ -11172,12 +11230,22 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
1117211230 case WC_HASH_TYPE_SHA3_512 :
1117311231 #ifdef WOLFSSL_SM3
1117411232 case WC_HASH_TYPE_SM3 :
11233+ #endif
11234+ #ifdef HAVE_BLAKE2
11235+ case WC_HASH_TYPE_BLAKE2B :
11236+ #endif
11237+ #ifdef HAVE_BLAKE2S
11238+ case WC_HASH_TYPE_BLAKE2S :
1117511239 #endif
1117611240 case WC_HASH_TYPE_NONE :
1117711241 case WC_HASH_TYPE_MD2 :
1117811242 case WC_HASH_TYPE_MD5_SHA :
11243+ #ifndef HAVE_BLAKE2
1117911244 case WC_HASH_TYPE_BLAKE2B :
11245+ #endif
11246+ #ifndef HAVE_BLAKE2S
1118011247 case WC_HASH_TYPE_BLAKE2S :
11248+ #endif
1118111249 break ;
1118211250
1118311251 #if defined(WOLFSSL_SHA3 ) && defined(WOLFSSL_SHAKE128 )
0 commit comments