EVP: add tests for openssl block size (including RC4)

This commit is contained in:
Elms
2021-01-05 13:02:12 -08:00
parent 0cccf58fec
commit a6535528f3
2 changed files with 32 additions and 3 deletions

View File

@ -34619,6 +34619,24 @@ static void test_wolfSSL_EVP_X_STATE_LEN(void)
printf(resultFmt, passed);
#endif
}
static void test_wolfSSL_EVP_CIPHER_block_size(void)
{
#if defined(OPENSSL_ALL)
#ifdef WOLFSSL_AES_OFB
#ifdef WOLFSSL_AES_192
AssertIntEQ(EVP_CIPHER_block_size(EVP_aes_192_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)
{
#if defined(OPENSSL_ALL)
@ -40145,6 +40163,7 @@ void ApiTest(void)
test_wolfSSL_EVP_PKEY_get0_EC_KEY();
test_wolfSSL_EVP_X_STATE();
test_wolfSSL_EVP_X_STATE_LEN();
test_wolfSSL_EVP_CIPHER_block_size();
test_wolfSSL_EVP_CIPHER_iv_length();
test_wolfSSL_EVP_SignInit_ex();
test_wolfSSL_EVP_DigestFinal_ex();

View File

@ -1136,8 +1136,12 @@ static unsigned int cipherType(const WOLFSSL_EVP_CIPHER *cipher)
return AES_256_OFB_TYPE;
#endif
#endif
#endif /* !NO_AES */
#ifndef NO_RC4
else if (XSTRNCMP(cipher, EVP_ARC4, EVP_ARC4_SIZE) == 0)
return ARC4_TYPE;
#endif
else return 0;
}
@ -1194,12 +1198,18 @@ int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
return 1;
#endif
#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_EDE3_CBC_TYPE: return 8;
case DES_ECB_TYPE: return 8;
case DES_EDE3_ECB_TYPE: return 8;
#endif
#endif
default:
return 0;
}