mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #4228 from miyazakh/EVP_blake2xx
add EVP_blake2 compatibility layer APIpull/4255/head
commit
2dac9a2a81
24
tests/api.c
24
tests/api.c
|
@ -46066,6 +46066,29 @@ static void test_wolfSSL_ERR_strings(void)
|
|||
AssertIntEQ((*err == ('\0')), 1);
|
||||
#endif
|
||||
printf(resultFmt, passed);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test_EVP_blake2()
|
||||
{
|
||||
#if defined(OPENSSL_EXTRA) && (defined(HAVE_BLAKE2) || defined(HAVE_BLAKE2S))
|
||||
printf(testingFmt, "test_EVP_blake2");
|
||||
|
||||
const EVP_MD* md = NULL;
|
||||
(void)md;
|
||||
|
||||
#if defined(HAVE_BLAKE2)
|
||||
md = EVP_blake2b512();
|
||||
AssertTrue(md != NULL);
|
||||
AssertIntEQ(XSTRNCMP(md, "BLAKE2B512", XSTRLEN("BLAKE2B512")), 0);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_BLAKE2S)
|
||||
md = EVP_blake2s256();
|
||||
AssertTrue(md != NULL);
|
||||
AssertIntEQ(XSTRNCMP(md, "BLAKE2S256", XSTRLEN("BLAKE2S256")), 0);
|
||||
#endif
|
||||
printf(resultFmt, passed);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -46090,6 +46113,7 @@ void ApiTest(void)
|
|||
test_for_double_Free();
|
||||
#endif
|
||||
test_wolfSSL_ERR_strings();
|
||||
test_EVP_blake2();
|
||||
test_wolfSSL_CTX_use_certificate_file();
|
||||
AssertIntEQ(test_wolfSSL_CTX_use_certificate_buffer(), WOLFSSL_SUCCESS);
|
||||
test_wolfSSL_CTX_use_PrivateKey_file();
|
||||
|
|
|
@ -2345,6 +2345,12 @@ static const struct s_ent {
|
|||
#endif
|
||||
#ifndef WOLFSSL_NOSHA3_512
|
||||
{WC_HASH_TYPE_SHA3_512, NID_sha3_512, "SHA3_512"},
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2
|
||||
{WC_HASH_TYPE_BLAKE2B, NID_blake2b512, "BLAKE2B512"},
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2S
|
||||
{WC_HASH_TYPE_BLAKE2S, NID_blake2s256, "BLAKE2S256"},
|
||||
#endif
|
||||
{WC_HASH_TYPE_NONE, 0, NULL}
|
||||
};
|
||||
|
@ -3539,6 +3545,12 @@ const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name)
|
|||
{"MD5", "ssl3-md5"},
|
||||
{"SHA1", "ssl3-sha1"},
|
||||
{"SHA1", "SHA"},
|
||||
#ifdef HAVE_BLAKE2
|
||||
{"BLAKE2b512", "blake2b512"},
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2S
|
||||
{"BLAKE2s256", "blake2s256"},
|
||||
#endif
|
||||
{ NULL, NULL}
|
||||
};
|
||||
char nameUpper[15]; /* 15 bytes should be enough for any name */
|
||||
|
@ -3603,6 +3615,32 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
|||
|
||||
#endif /* !NO_MD5 */
|
||||
|
||||
#ifdef HAVE_BLAKE2
|
||||
/* return EVP_MD
|
||||
* @param none
|
||||
* @return "blake2b512"
|
||||
*/
|
||||
const WOLFSSL_EVP_MD* wolfSSL_EVP_blake2b512()
|
||||
{
|
||||
WOLFSSL_ENTER("EVP_blake2b512");
|
||||
return EVP_get_digestbyname("BLAKE2b512");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLAKE2S
|
||||
/* return EVP_MD
|
||||
* @param none
|
||||
* @return "blake2s256"
|
||||
*/
|
||||
const WOLFSSL_EVP_MD* wolfSSL_EVP_blake2s256()
|
||||
{
|
||||
WOLFSSL_ENTER("EVP_blake2s256");
|
||||
return EVP_get_digestbyname("BLAKE2s256");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NO_WOLFSSL_STUB
|
||||
void wolfSSL_EVP_set_pw_prompt(const char *prompt)
|
||||
|
@ -7213,6 +7251,8 @@ int wolfSSL_EVP_PKEY_assign_DH(EVP_PKEY* pkey, WOLFSSL_DH* key)
|
|||
}
|
||||
#endif /* !NO_DH */
|
||||
|
||||
|
||||
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
||||
|
|
|
@ -291,6 +291,8 @@ enum {
|
|||
NID_sha3_256 = 1097,
|
||||
NID_sha3_384 = 1098,
|
||||
NID_sha3_512 = 1099,
|
||||
NID_blake2b512 = 1056,
|
||||
NID_blake2s256 = 1057,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -414,6 +416,9 @@ WOLFSSL_API int wolfSSL_EVP_DecodeFinal(WOLFSSL_EVP_ENCODE_CTX* ctx,
|
|||
unsigned char*out, int *outl);
|
||||
#endif /* WOLFSSL_BASE64_DECODE */
|
||||
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_blake2b512(void);
|
||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_blake2s256(void);
|
||||
|
||||
typedef int WOLFSSL_ENGINE ;
|
||||
typedef WOLFSSL_ENGINE ENGINE;
|
||||
typedef WOLFSSL_EVP_PKEY_CTX EVP_PKEY_CTX;
|
||||
|
@ -1009,6 +1014,9 @@ typedef WOLFSSL_ASN1_PCTX ASN1_PCTX;
|
|||
#define EVP_DecodeFinal wolfSSL_EVP_DecodeFinal
|
||||
#endif /* WOLFSSL_BASE64_DECODE */
|
||||
|
||||
#define EVP_blake2b512 wolfSSL_EVP_blake2b512
|
||||
#define EVP_blake2s256 wolfSSL_EVP_blake2s256
|
||||
|
||||
WOLFSSL_API void printPKEY(WOLFSSL_EVP_PKEY *k);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue