mirror of https://github.com/wolfSSL/wolfssl.git
add EVP_get_cipherbynid
parent
8f3aa49ef6
commit
e8f95b9252
63
src/ssl.c
63
src/ssl.c
|
@ -3220,6 +3220,68 @@ const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_get_cipherbyname(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return an EVP_CIPHER structure when cipher NID is passed.
|
||||||
|
*
|
||||||
|
* id cipher NID
|
||||||
|
*
|
||||||
|
* retrun WOLFSSL_EVP_CIPHER
|
||||||
|
*/
|
||||||
|
const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_get_cipherbynid(int id)
|
||||||
|
{
|
||||||
|
WOLFSSL_ENTER("EVP_get_cipherbynid");
|
||||||
|
|
||||||
|
switch(id) {
|
||||||
|
|
||||||
|
#if defined(OPENSSL_EXTRA)
|
||||||
|
#ifndef NO_AES
|
||||||
|
case NID_aes_128_cbc:
|
||||||
|
return wolfSSL_EVP_aes_128_cbc();
|
||||||
|
case NID_aes_192_cbc:
|
||||||
|
return wolfSSL_EVP_aes_192_cbc();
|
||||||
|
case NID_aes_256_cbc:
|
||||||
|
return wolfSSL_EVP_aes_256_cbc();
|
||||||
|
case NID_aes_128_ctr:
|
||||||
|
return wolfSSL_EVP_aes_128_ctr();
|
||||||
|
case NID_aes_192_ctr:
|
||||||
|
return wolfSSL_EVP_aes_192_ctr();
|
||||||
|
case NID_aes_256_ctr:
|
||||||
|
return wolfSSL_EVP_aes_256_ctr();
|
||||||
|
case NID_aes_128_ecb:
|
||||||
|
return wolfSSL_EVP_aes_128_ecb();
|
||||||
|
case NID_aes_192_ecb:
|
||||||
|
return wolfSSL_EVP_aes_192_ecb();
|
||||||
|
case NID_aes_256_ecb:
|
||||||
|
return wolfSSL_EVP_aes_256_ecb();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
|
case NID_des_cbc:
|
||||||
|
return wolfSSL_EVP_des_cbc();
|
||||||
|
#ifdef WOLFSSL_DES_ECB
|
||||||
|
case NID_des_ecb:
|
||||||
|
return wolfSSL_EVP_des_ecb();
|
||||||
|
#endif
|
||||||
|
case NID_des_ede3_cbc:
|
||||||
|
return wolfSSL_EVP_des_ede3_cbc();
|
||||||
|
#ifdef WOLFSSL_DES_ECB
|
||||||
|
case NID_des_ede3_ecb:
|
||||||
|
return wolfSSL_EVP_des_ede3_ecb();
|
||||||
|
#endif
|
||||||
|
#endif /*NO_DES3*/
|
||||||
|
|
||||||
|
#ifdef HAVE_IDEA
|
||||||
|
case NID_idea_cbc:
|
||||||
|
return wolfSSL_EVP_idea_cbc();
|
||||||
|
#endif
|
||||||
|
#endif /*OPENSSL_EXTRA*/
|
||||||
|
|
||||||
|
default:
|
||||||
|
WOLFSSL_MSG("Bad cipher id value");
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef NO_AES
|
#ifndef NO_AES
|
||||||
static char *EVP_AES_128_CBC;
|
static char *EVP_AES_128_CBC;
|
||||||
|
@ -17826,7 +17888,6 @@ int wolfSSL_BN_sub(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* SSL_SUCCESS on ok */
|
/* SSL_SUCCESS on ok */
|
||||||
int wolfSSL_BN_mod(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a,
|
int wolfSSL_BN_mod(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a,
|
||||||
const WOLFSSL_BIGNUM* b, const WOLFSSL_BN_CTX* c)
|
const WOLFSSL_BIGNUM* b, const WOLFSSL_BN_CTX* c)
|
||||||
|
|
51
tests/api.c
51
tests/api.c
|
@ -703,6 +703,50 @@ static int test_wolfSSL_SetMinVersion(void)
|
||||||
|
|
||||||
} /* END test_wolfSSL_SetMinVersion */
|
} /* END test_wolfSSL_SetMinVersion */
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*
|
||||||
|
| EVP
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Test function for wolfSSL_EVP_get_cipherbynid.
|
||||||
|
*
|
||||||
|
* POST: return 1 on success.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# if defined(OPENSSL_EXTRA)
|
||||||
|
static void test_wolfSSL_EVP_get_cipherbynid(void)
|
||||||
|
{
|
||||||
|
#ifndef NO_AES
|
||||||
|
AssertNotNull(strcmp("EVP_AES_128_CBC", wolfSSL_EVP_get_cipherbynid(419)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_192_CBC", wolfSSL_EVP_get_cipherbynid(423)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_256_CBC", wolfSSL_EVP_get_cipherbynid(427)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_128_CTR", wolfSSL_EVP_get_cipherbynid(904)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_192_CTR", wolfSSL_EVP_get_cipherbynid(905)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_256_CTR", wolfSSL_EVP_get_cipherbynid(906)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_128_ECB", wolfSSL_EVP_get_cipherbynid(418)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_192_ECB", wolfSSL_EVP_get_cipherbynid(422)));
|
||||||
|
AssertNotNull(strcmp("EVP_AES_256_ECB", wolfSSL_EVP_get_cipherbynid(426)));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NO_DES3
|
||||||
|
AssertNotNull(strcmp("EVP_DES_CBC", wolfSSL_EVP_get_cipherbynid(31)));
|
||||||
|
#ifdef WOLFSSL_DES_ECB
|
||||||
|
AssertNotNull(strcmp("EVP_DES_ECB", wolfSSL_EVP_get_cipherbynid(29)));
|
||||||
|
#endif
|
||||||
|
AssertNotNull(strcmp("EVP_DES_EDE3_CBC", wolfSSL_EVP_get_cipherbynid(44)));
|
||||||
|
#ifdef WOLFSSL_DES_ECB
|
||||||
|
AssertNotNull(strcmp("EVP_DES_EDE3_ECB", wolfSSL_EVP_get_cipherbynid(33)));
|
||||||
|
#endif
|
||||||
|
#endif /*NO_DES3*/
|
||||||
|
|
||||||
|
#ifdef HAVE_IDEA
|
||||||
|
AssertNotNull(strcmp("EVP_IDEA_CBC", wolfSSL_EVP_get_cipherbynid(34)));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* test for nid is out of range */
|
||||||
|
AssertNull(wolfSSL_EVP_get_cipherbynid(1));
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*
|
/*----------------------------------------------------------------------------*
|
||||||
| IO
|
| IO
|
||||||
|
@ -10948,9 +10992,16 @@ void ApiTest(void)
|
||||||
AssertIntEQ(test_wc_MakeDsaKey(), 0);
|
AssertIntEQ(test_wc_MakeDsaKey(), 0);
|
||||||
AssertIntEQ(test_wc_DsaKeyToDer(), 0);
|
AssertIntEQ(test_wc_DsaKeyToDer(), 0);
|
||||||
|
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
|
/*wolfSSS_EVP_get_cipherbynid test*/
|
||||||
|
test_wolfSSL_EVP_get_cipherbynid();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_HASHDRBG
|
#ifdef HAVE_HASHDRBG
|
||||||
AssertIntEQ(test_wc_RNG_GenerateBlock(), 0);
|
AssertIntEQ(test_wc_RNG_GenerateBlock(), 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf(" End API Tests\n");
|
printf(" End API Tests\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,23 @@ enum {
|
||||||
EVP_PKEY_HMAC = NID_hmac
|
EVP_PKEY_HMAC = NID_hmac
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NID_aes_128_cbc = 419,
|
||||||
|
NID_aes_192_cbc = 423,
|
||||||
|
NID_aes_256_cbc = 427,
|
||||||
|
NID_aes_128_ctr = 904,
|
||||||
|
NID_aes_192_ctr = 905,
|
||||||
|
NID_aes_256_ctr = 906,
|
||||||
|
NID_aes_128_ecb = 418,
|
||||||
|
NID_aes_192_ecb = 422,
|
||||||
|
NID_aes_256_ecb = 426,
|
||||||
|
NID_des_cbc = 31,
|
||||||
|
NID_des_ecb = 29,
|
||||||
|
NID_des_ede3_cbc= 44,
|
||||||
|
NID_des_ede3_ecb= 33,
|
||||||
|
NID_idea_cbc = 34,
|
||||||
|
};
|
||||||
|
|
||||||
#define WOLFSSL_EVP_BUF_SIZE 16
|
#define WOLFSSL_EVP_BUF_SIZE 16
|
||||||
typedef struct WOLFSSL_EVP_CIPHER_CTX {
|
typedef struct WOLFSSL_EVP_CIPHER_CTX {
|
||||||
int keyLen; /* user may set for variable */
|
int keyLen; /* user may set for variable */
|
||||||
|
@ -299,6 +316,7 @@ WOLFSSL_API int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||||
unsigned char* dst, unsigned char* src,
|
unsigned char* dst, unsigned char* src,
|
||||||
unsigned int len);
|
unsigned int len);
|
||||||
|
|
||||||
|
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_get_cipherbynid(int);
|
||||||
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
|
WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
|
||||||
|
|
||||||
WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
|
WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
|
||||||
|
@ -441,6 +459,7 @@ typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
|
||||||
#define EVP_CIPHER_CTX_free wolfSSL_EVP_CIPHER_CTX_free
|
#define EVP_CIPHER_CTX_free wolfSSL_EVP_CIPHER_CTX_free
|
||||||
#define EVP_CIPHER_CTX_new wolfSSL_EVP_CIPHER_CTX_new
|
#define EVP_CIPHER_CTX_new wolfSSL_EVP_CIPHER_CTX_new
|
||||||
|
|
||||||
|
#define EVP_get_cipherbynid wolfSSL_EVP_get_cipherbynid
|
||||||
#define EVP_get_digestbynid wolfSSL_EVP_get_digestbynid
|
#define EVP_get_digestbynid wolfSSL_EVP_get_digestbynid
|
||||||
#define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
|
#define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
|
||||||
#define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
|
#define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
|
||||||
|
|
Loading…
Reference in New Issue