mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Merge pull request #3627 from elms/EVP/ofb_rc4_size
EVP: return proper cipher type and block size
This commit is contained in:
73
tests/api.c
73
tests/api.c
@ -34620,6 +34620,78 @@ static void test_wolfSSL_EVP_X_STATE_LEN(void)
|
|||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_wolfSSL_EVP_CIPHER_block_size(void)
|
||||||
|
{
|
||||||
|
#if defined(OPENSSL_ALL)
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_CBC
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_cbc()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_cbc()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_cbc()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_AES_GCM
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_gcm()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_gcm()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_gcm()), 1);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_AES_COUNTER
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_ctr()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_ctr()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ctr()), 1);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_AES_ECB
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_ecb()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_ecb()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ecb()), AES_BLOCK_SIZE);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_AES_OFB
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_128_ofb()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_ofb()), 1);
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_256_ofb()), 1);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_RC4
|
||||||
|
AssertIntEQ(EVP_CIPHER_block_size(wolfSSL_EVP_rc4()), 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* OPENSSL_ALL */
|
||||||
|
}
|
||||||
|
|
||||||
static void test_wolfSSL_EVP_CIPHER_iv_length(void)
|
static void test_wolfSSL_EVP_CIPHER_iv_length(void)
|
||||||
{
|
{
|
||||||
#if defined(OPENSSL_ALL)
|
#if defined(OPENSSL_ALL)
|
||||||
@ -40146,6 +40218,7 @@ void ApiTest(void)
|
|||||||
test_wolfSSL_EVP_PKEY_get0_EC_KEY();
|
test_wolfSSL_EVP_PKEY_get0_EC_KEY();
|
||||||
test_wolfSSL_EVP_X_STATE();
|
test_wolfSSL_EVP_X_STATE();
|
||||||
test_wolfSSL_EVP_X_STATE_LEN();
|
test_wolfSSL_EVP_X_STATE_LEN();
|
||||||
|
test_wolfSSL_EVP_CIPHER_block_size();
|
||||||
test_wolfSSL_EVP_CIPHER_iv_length();
|
test_wolfSSL_EVP_CIPHER_iv_length();
|
||||||
test_wolfSSL_EVP_SignInit_ex();
|
test_wolfSSL_EVP_SignInit_ex();
|
||||||
test_wolfSSL_EVP_DigestFinal_ex();
|
test_wolfSSL_EVP_DigestFinal_ex();
|
||||||
|
@ -1122,7 +1122,26 @@ static unsigned int cipherType(const WOLFSSL_EVP_CIPHER *cipher)
|
|||||||
return AES_256_CFB128_TYPE;
|
return AES_256_CFB128_TYPE;
|
||||||
#endif
|
#endif
|
||||||
#endif /*HAVE_AES_CBC */
|
#endif /*HAVE_AES_CBC */
|
||||||
|
#if defined(WOLFSSL_AES_OFB)
|
||||||
|
#ifdef WOLFSSL_AES_128
|
||||||
|
else if (XSTRNCMP(cipher, EVP_AES_128_OFB, EVP_AES_SIZE) == 0)
|
||||||
|
return AES_128_OFB_TYPE;
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_192
|
||||||
|
else if (XSTRNCMP(cipher, EVP_AES_192_OFB, EVP_AES_SIZE) == 0)
|
||||||
|
return AES_192_OFB_TYPE;
|
||||||
|
#endif
|
||||||
|
#ifdef WOLFSSL_AES_256
|
||||||
|
else if (XSTRNCMP(cipher, EVP_AES_256_OFB, EVP_AES_SIZE) == 0)
|
||||||
|
return AES_256_OFB_TYPE;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif /* !NO_AES */
|
#endif /* !NO_AES */
|
||||||
|
|
||||||
|
#ifndef NO_RC4
|
||||||
|
else if (XSTRNCMP(cipher, EVP_ARC4, EVP_ARC4_SIZE) == 0)
|
||||||
|
return ARC4_TYPE;
|
||||||
|
#endif
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1147,7 +1166,7 @@ int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
|
|||||||
case AES_128_CTR_TYPE:
|
case AES_128_CTR_TYPE:
|
||||||
case AES_192_CTR_TYPE:
|
case AES_192_CTR_TYPE:
|
||||||
case AES_256_CTR_TYPE:
|
case AES_256_CTR_TYPE:
|
||||||
return AES_BLOCK_SIZE;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_AES_ECB)
|
#if defined(HAVE_AES_ECB)
|
||||||
case AES_128_ECB_TYPE:
|
case AES_128_ECB_TYPE:
|
||||||
@ -1179,12 +1198,18 @@ int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
|
|||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
#endif /* NO_AES */
|
#endif /* NO_AES */
|
||||||
#ifndef NO_DES3
|
|
||||||
|
#ifndef NO_RC4
|
||||||
|
case ARC4_TYPE:
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
case DES_CBC_TYPE: return 8;
|
case DES_CBC_TYPE: return 8;
|
||||||
case DES_EDE3_CBC_TYPE: return 8;
|
case DES_EDE3_CBC_TYPE: return 8;
|
||||||
case DES_ECB_TYPE: return 8;
|
case DES_ECB_TYPE: return 8;
|
||||||
case DES_EDE3_ECB_TYPE: return 8;
|
case DES_EDE3_ECB_TYPE: return 8;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user