mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-02-22 19:54:59 +01:00
fix CAVP selftest build errors
This commit is contained in:
56
src/ssl.c
56
src/ssl.c
@@ -12697,29 +12697,29 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
|
||||
const char *name;
|
||||
} md_tbl[] = {
|
||||
#ifndef NO_MD4
|
||||
{MD4, "MD4"},
|
||||
{WC_HASH_TYPE_MD4, "MD4"},
|
||||
#endif /* NO_MD4 */
|
||||
|
||||
#ifndef NO_MD5
|
||||
{WC_MD5, "MD5"},
|
||||
{WC_HASH_TYPE_MD5, "MD5"},
|
||||
#endif /* NO_MD5 */
|
||||
|
||||
#ifndef NO_SHA
|
||||
{WC_SHA, "SHA"},
|
||||
{WC_HASH_TYPE_SHA, "SHA"},
|
||||
#endif /* NO_SHA */
|
||||
|
||||
#ifdef WOLFSSL_SHA224
|
||||
{WC_SHA224, "SHA224"},
|
||||
{WC_HASH_TYPE_SHA224, "SHA224"},
|
||||
#endif /* WOLFSSL_SHA224 */
|
||||
#ifndef NO_SHA256
|
||||
{WC_SHA256, "SHA256"},
|
||||
{WC_HASH_TYPE_SHA256, "SHA256"},
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
{WC_SHA384, "SHA384"},
|
||||
{WC_HASH_TYPE_SHA384, "SHA384"},
|
||||
#endif /* WOLFSSL_SHA384 */
|
||||
#ifdef WOLFSSL_SHA512
|
||||
{WC_SHA512, "SHA512"},
|
||||
{WC_HASH_TYPE_SHA512, "SHA512"},
|
||||
#endif /* WOLFSSL_SHA512 */
|
||||
{0, NULL}
|
||||
};
|
||||
@@ -13774,43 +13774,43 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
||||
#endif
|
||||
|
||||
if (XSTRNCMP(type, "SHA256", 6) == 0) {
|
||||
ctx->macType = WC_SHA256;
|
||||
ctx->macType = WC_HASH_TYPE_SHA256;
|
||||
ret = wolfSSL_SHA256_Init(&(ctx->hash.digest.sha256));
|
||||
}
|
||||
#ifdef WOLFSSL_SHA224
|
||||
else if (XSTRNCMP(type, "SHA224", 6) == 0) {
|
||||
ctx->macType = WC_SHA224;
|
||||
ctx->macType = WC_HASH_TYPE_SHA224;
|
||||
ret = wolfSSL_SHA224_Init(&(ctx->hash.digest.sha224));
|
||||
}
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA384
|
||||
else if (XSTRNCMP(type, "SHA384", 6) == 0) {
|
||||
ctx->macType = WC_SHA384;
|
||||
ctx->macType = WC_HASH_TYPE_SHA384;
|
||||
ret = wolfSSL_SHA384_Init(&(ctx->hash.digest.sha384));
|
||||
}
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
else if (XSTRNCMP(type, "SHA512", 6) == 0) {
|
||||
ctx->macType = WC_SHA512;
|
||||
ctx->macType = WC_HASH_TYPE_SHA512;
|
||||
ret = wolfSSL_SHA512_Init(&(ctx->hash.digest.sha512));
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_MD4
|
||||
else if (XSTRNCMP(type, "MD4", 3) == 0) {
|
||||
ctx->macType = MD4;
|
||||
ctx->macType = WC_HASH_TYPE_MD4;
|
||||
wolfSSL_MD4_Init(&(ctx->hash.digest.md4));
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
else if (XSTRNCMP(type, "MD5", 3) == 0) {
|
||||
ctx->macType = WC_MD5;
|
||||
ctx->macType = WC_HASH_TYPE_MD5;
|
||||
ret = wolfSSL_MD5_Init(&(ctx->hash.digest.md5));
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
/* has to be last since would pick or 224, 256, 384, or 512 too */
|
||||
else if (XSTRNCMP(type, "SHA", 3) == 0) {
|
||||
ctx->macType = WC_SHA;
|
||||
ctx->macType = WC_HASH_TYPE_SHA;
|
||||
ret = wolfSSL_SHA_Init(&(ctx->hash.digest.sha));
|
||||
}
|
||||
#endif /* NO_SHA */
|
||||
@@ -13829,43 +13829,43 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
||||
|
||||
switch (ctx->macType) {
|
||||
#ifndef NO_MD4
|
||||
case MD4:
|
||||
case WC_HASH_TYPE_MD4:
|
||||
wolfSSL_MD4_Update((MD4_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
case WC_MD5:
|
||||
case WC_HASH_TYPE_MD5:
|
||||
wolfSSL_MD5_Update((MD5_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
case WC_SHA:
|
||||
case WC_HASH_TYPE_SHA:
|
||||
wolfSSL_SHA_Update((SHA_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
case WC_SHA224:
|
||||
case WC_HASH_TYPE_SHA224:
|
||||
wolfSSL_SHA224_Update((SHA224_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
case WC_SHA256:
|
||||
case WC_HASH_TYPE_SHA256:
|
||||
wolfSSL_SHA256_Update((SHA256_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif /* !NO_SHA256 */
|
||||
#ifdef WOLFSSL_SHA384
|
||||
case WC_SHA384:
|
||||
case WC_HASH_TYPE_SHA384:
|
||||
wolfSSL_SHA384_Update((SHA384_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
case WC_SHA512:
|
||||
case WC_HASH_TYPE_SHA512:
|
||||
wolfSSL_SHA512_Update((SHA512_CTX*)&ctx->hash, data,
|
||||
(unsigned long)sz);
|
||||
break;
|
||||
@@ -13885,43 +13885,43 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
||||
WOLFSSL_ENTER("EVP_DigestFinal");
|
||||
switch (ctx->macType) {
|
||||
#ifndef NO_MD4
|
||||
case MD4:
|
||||
case WC_HASH_TYPE_MD4:
|
||||
wolfSSL_MD4_Final(md, (MD4_CTX*)&ctx->hash);
|
||||
if (s) *s = MD4_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_MD5
|
||||
case WC_MD5:
|
||||
case WC_HASH_TYPE_MD5:
|
||||
wolfSSL_MD5_Final(md, (MD5_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_MD5_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
case WC_SHA:
|
||||
case WC_HASH_TYPE_SHA:
|
||||
wolfSSL_SHA_Final(md, (SHA_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_SHA_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA224
|
||||
case WC_SHA224:
|
||||
case WC_HASH_TYPE_SHA224:
|
||||
wolfSSL_SHA224_Final(md, (SHA224_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_SHA224_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
case WC_SHA256:
|
||||
case WC_HASH_TYPE_SHA256:
|
||||
wolfSSL_SHA256_Final(md, (SHA256_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_SHA256_DIGEST_SIZE;
|
||||
break;
|
||||
#endif /* !NO_SHA256 */
|
||||
#ifdef WOLFSSL_SHA384
|
||||
case WC_SHA384:
|
||||
case WC_HASH_TYPE_SHA384:
|
||||
wolfSSL_SHA384_Final(md, (SHA384_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_SHA384_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SHA512
|
||||
case WC_SHA512:
|
||||
case WC_HASH_TYPE_SHA512:
|
||||
wolfSSL_SHA512_Final(md, (SHA512_CTX*)&ctx->hash);
|
||||
if (s) *s = WC_SHA512_DIGEST_SIZE;
|
||||
break;
|
||||
|
||||
@@ -19904,7 +19904,7 @@ static void test_wolfSSL_msg_callback(void)
|
||||
|
||||
static void test_wolfSSL_SHA(void)
|
||||
{
|
||||
#if defined(OPENSSL_EXTRA)
|
||||
#if defined(OPENSSL_EXTRA) && !defined(HAVE_SELFTEST)
|
||||
printf(testingFmt, "wolfSSL_SHA()");
|
||||
|
||||
#if !defined(NO_SHA)
|
||||
@@ -20066,7 +20066,7 @@ static void test_wolfSSL_AES_ecb_encrypt(void)
|
||||
static void test_wolfSSL_SHA256(void)
|
||||
{
|
||||
#if defined(OPENSSL_EXTRA) && !defined(NO_SHA256) && \
|
||||
defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS)
|
||||
defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
unsigned char input[] =
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
|
||||
unsigned char output[] =
|
||||
|
||||
@@ -124,6 +124,17 @@ ASN Options:
|
||||
|
||||
#define ERROR_OUT(err, eLabel) { ret = (err); goto eLabel; }
|
||||
|
||||
#ifdef HAVE_SELFTEST
|
||||
#ifndef WOLFSSL_AES_KEY_SIZE_ENUM
|
||||
enum Asn_Misc {
|
||||
AES_IV_SIZE = 16,
|
||||
AES_128_KEY_SIZE = 16,
|
||||
AES_192_KEY_SIZE = 24,
|
||||
AES_256_KEY_SIZE = 32
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
|
||||
word32 maxIdx)
|
||||
{
|
||||
|
||||
@@ -178,11 +178,11 @@ enum wc_HashType wc_OidGetHash(int oid)
|
||||
enum wc_HashType hash_type = WC_HASH_TYPE_NONE;
|
||||
switch (oid)
|
||||
{
|
||||
#ifdef WOLFSSL_MD2
|
||||
case MD2h:
|
||||
#ifdef WOLFSSL_MD2
|
||||
hash_type = WC_HASH_TYPE_MD2;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
case MD5h:
|
||||
#ifndef NO_MD5
|
||||
hash_type = WC_HASH_TYPE_MD5;
|
||||
|
||||
@@ -3005,7 +3005,7 @@ int hash_test(void)
|
||||
return -3094;
|
||||
|
||||
#ifndef NO_ASN
|
||||
#ifdef WOLFSSL_MD2
|
||||
#if defined(WOLFSSL_MD2) && !defined(HAVE_SELFTEST)
|
||||
ret = wc_GetCTC_HashOID(MD2);
|
||||
if (ret == 0)
|
||||
return -3095;
|
||||
@@ -10504,7 +10504,8 @@ static int rsa_keygen_test(WC_RNG* rng)
|
||||
/* If not using old FIPS, or not using FAST or USER RSA... */
|
||||
#if !defined(HAVE_FAST_RSA) && !defined(HAVE_USER_RSA) && \
|
||||
(!defined(HAVE_FIPS) || \
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
||||
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))) && \
|
||||
!defined(HAVE_SELFTEST)
|
||||
ret = wc_CheckRsaKey(&genKey);
|
||||
if (ret != 0) {
|
||||
ERROR_OUT(-8228, exit_rsa);
|
||||
@@ -11620,7 +11621,6 @@ static int dh_fips_generate_test(WC_RNG *rng)
|
||||
if (ret != MP_CMP_E) {
|
||||
ERROR_OUT(-8230, exit_gen_test);
|
||||
}
|
||||
#endif /* HAVE_SELFTEST */
|
||||
|
||||
#ifdef WOLFSSL_KEY_GEN
|
||||
wc_FreeDhKey(&key);
|
||||
@@ -11645,6 +11645,7 @@ static int dh_fips_generate_test(WC_RNG *rng)
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_KEY_GEN */
|
||||
#endif /* HAVE_SELFTEST */
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@@ -1275,9 +1275,11 @@ enum Misc {
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SELFTEST
|
||||
AES_256_KEY_SIZE = 32,
|
||||
#define WOLFSSL_AES_KEY_SIZE_ENUM
|
||||
AES_IV_SIZE = 16,
|
||||
AES_128_KEY_SIZE = 16,
|
||||
AES_192_KEY_SIZE = 24,
|
||||
AES_256_KEY_SIZE = 32,
|
||||
#endif
|
||||
|
||||
MAX_IV_SZ = AES_BLOCK_SIZE,
|
||||
|
||||
@@ -119,7 +119,7 @@ typedef WOLFSSL_SHA256_CTX SHA256_CTX;
|
||||
#define SHA256_Init wolfSSL_SHA256_Init
|
||||
#define SHA256_Update wolfSSL_SHA256_Update
|
||||
#define SHA256_Final wolfSSL_SHA256_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS)
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA256 is only available in non-fips mode because of SHA256 enum in FIPS
|
||||
* build. */
|
||||
#define SHA256 wolfSSL_SHA256
|
||||
@@ -148,7 +148,7 @@ typedef WOLFSSL_SHA384_CTX SHA384_CTX;
|
||||
#define SHA384_Init wolfSSL_SHA384_Init
|
||||
#define SHA384_Update wolfSSL_SHA384_Update
|
||||
#define SHA384_Final wolfSSL_SHA384_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS)
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA384 is only available in non-fips mode because of SHA384 enum in FIPS
|
||||
* build. */
|
||||
#define SHA384 wolfSSL_SHA384
|
||||
@@ -177,7 +177,7 @@ typedef WOLFSSL_SHA512_CTX SHA512_CTX;
|
||||
#define SHA512_Init wolfSSL_SHA512_Init
|
||||
#define SHA512_Update wolfSSL_SHA512_Update
|
||||
#define SHA512_Final wolfSSL_SHA512_Final
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS)
|
||||
#if defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
|
||||
/* SHA512 is only available in non-fips mode because of SHA512 enum in FIPS
|
||||
* build. */
|
||||
#define SHA512 wolfSSL_SHA512
|
||||
|
||||
@@ -528,6 +528,27 @@
|
||||
|
||||
/* hash types */
|
||||
enum wc_HashType {
|
||||
#ifdef HAVE_SELFTEST
|
||||
/* In selftest build, WC_* types are not mapped to WC_HASH_TYPE types.
|
||||
* Values here are based on old selftest hmac.h enum, with additions */
|
||||
WC_HASH_TYPE_NONE = 15,
|
||||
WC_HASH_TYPE_MD2 = 16,
|
||||
WC_HASH_TYPE_MD4 = 17,
|
||||
WC_HASH_TYPE_MD5 = 0,
|
||||
WC_HASH_TYPE_SHA = 1, /* SHA-1 (not old SHA-0) */
|
||||
WC_HASH_TYPE_SHA224 = 8,
|
||||
WC_HASH_TYPE_SHA256 = 2,
|
||||
WC_HASH_TYPE_SHA384 = 5,
|
||||
WC_HASH_TYPE_SHA512 = 4,
|
||||
WC_HASH_TYPE_MD5_SHA = 18,
|
||||
WC_HASH_TYPE_SHA3_224 = 10,
|
||||
WC_HASH_TYPE_SHA3_256 = 11,
|
||||
WC_HASH_TYPE_SHA3_384 = 12,
|
||||
WC_HASH_TYPE_SHA3_512 = 13,
|
||||
WC_HASH_TYPE_BLAKE2B = 14,
|
||||
|
||||
WC_HASH_TYPE_MAX = WC_HASH_TYPE_MD5_SHA
|
||||
#else
|
||||
WC_HASH_TYPE_NONE = 0,
|
||||
WC_HASH_TYPE_MD2 = 1,
|
||||
WC_HASH_TYPE_MD4 = 2,
|
||||
@@ -545,6 +566,7 @@
|
||||
WC_HASH_TYPE_BLAKE2B = 14,
|
||||
|
||||
WC_HASH_TYPE_MAX = WC_HASH_TYPE_BLAKE2B
|
||||
#endif /* HAVE_SELFTEST */
|
||||
};
|
||||
|
||||
/* cipher types */
|
||||
|
||||
Reference in New Issue
Block a user