diff --git a/tests/api.c b/tests/api.c index 26c97e609..07b895ecb 100644 --- a/tests/api.c +++ b/tests/api.c @@ -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), diff --git a/tests/api/test_evp.c b/tests/api/test_evp.c index 614a977b1..0f6f90a9d 100644 --- a/tests/api/test_evp.c +++ b/tests/api/test_evp.c @@ -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(); +} + diff --git a/tests/api/test_evp.h b/tests/api/test_evp.h index 9c18941e5..839ce84e5 100644 --- a/tests/api/test_evp.h +++ b/tests/api/test_evp.h @@ -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 */ diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index f6827b40d..79547e0b1 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -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;