mirror of https://github.com/wolfSSL/wolfssl.git
Rename parameter in wolfSSL_EVP_CIPHER_type_string and add test
Co-Authored-By: lealem@wolfssl.com <lealem@wolfssl.com>pull/8570/head
parent
af1f6543e1
commit
ec00f780ec
|
@ -89710,6 +89710,7 @@ TEST_CASE testCases[] = {
|
|||
TEST_DECL(test_wolfSSL_EVP_EncodeInit),
|
||||
TEST_DECL(test_wolfSSL_EVP_EncodeUpdate),
|
||||
TEST_DECL(test_wolfSSL_EVP_CipherUpdate_Null),
|
||||
TEST_DECL(test_wolfSSL_EVP_CIPHER_type_string),
|
||||
TEST_DECL(test_wolfSSL_EVP_EncodeFinal),
|
||||
TEST_DECL(test_wolfSSL_EVP_DecodeInit),
|
||||
TEST_DECL(test_wolfSSL_EVP_DecodeUpdate),
|
||||
|
|
|
@ -68,3 +68,38 @@ int test_wolfSSL_EVP_CipherUpdate_Null(void)
|
|||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
/* Test for wolfSSL_EVP_CIPHER_type_string() */
|
||||
int test_wolfSSL_EVP_CIPHER_type_string(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#ifdef OPENSSL_EXTRA
|
||||
const char* cipherStr;
|
||||
|
||||
/* Test with valid cipher types */
|
||||
#ifndef NO_AES
|
||||
#ifdef WOLFSSL_AES_128
|
||||
cipherStr = wolfSSL_EVP_CIPHER_type_string(WC_AES_128_CBC_TYPE);
|
||||
ExpectNotNull(cipherStr);
|
||||
ExpectStrEQ(cipherStr, "AES-128-CBC");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NO_DES3
|
||||
cipherStr = wolfSSL_EVP_CIPHER_type_string(WC_DES_CBC_TYPE);
|
||||
ExpectNotNull(cipherStr);
|
||||
ExpectStrEQ(cipherStr, "DES-CBC");
|
||||
#endif
|
||||
|
||||
/* Test with NULL cipher type */
|
||||
cipherStr = wolfSSL_EVP_CIPHER_type_string(WC_NULL_CIPHER_TYPE);
|
||||
ExpectNotNull(cipherStr);
|
||||
ExpectStrEQ(cipherStr, "NULL");
|
||||
|
||||
/* Test with invalid cipher type */
|
||||
cipherStr = wolfSSL_EVP_CIPHER_type_string(0xFFFF);
|
||||
ExpectNull(cipherStr);
|
||||
#endif /* OPENSSL_EXTRA */
|
||||
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
#define WOLFSSL_TEST_EVP_H
|
||||
|
||||
int test_wolfSSL_EVP_CipherUpdate_Null(void);
|
||||
int test_wolfSSL_EVP_CIPHER_type_string(void);
|
||||
|
||||
#endif /* WOLFSSL_TEST_EVP_H */
|
||||
|
|
|
@ -2056,15 +2056,15 @@ static unsigned int cipherType(const WOLFSSL_EVP_CIPHER *cipher)
|
|||
|
||||
/* Getter function for cipher type string
|
||||
*
|
||||
* type cipherType enum value to get string for
|
||||
* cipherType cipherType enum value to get string for
|
||||
*
|
||||
* Returns string representation of the cipher type or NULL if not found
|
||||
*/
|
||||
const char* wolfSSL_EVP_CIPHER_type_string(unsigned int type)
|
||||
const char* wolfSSL_EVP_CIPHER_type_string(unsigned int cipherType)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_type_string");
|
||||
|
||||
switch (type) {
|
||||
switch (cipherType) {
|
||||
#ifndef NO_DES3
|
||||
case WC_DES_CBC_TYPE: return EVP_DES_CBC;
|
||||
case WC_DES_EDE3_CBC_TYPE: return EVP_DES_EDE3_CBC;
|
||||
|
|
Loading…
Reference in New Issue