mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 11:14:36 +00:00
Add support in the default provider for 192/128 bit AES ECB
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8700)
This commit is contained in:
parent
861b8f8747
commit
f4a129bb8d
@ -140,6 +140,8 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
if (tmpcipher->prov == NULL) {
|
||||
switch(tmpcipher->nid) {
|
||||
case NID_aes_256_ecb:
|
||||
case NID_aes_192_ecb:
|
||||
case NID_aes_128_ecb:
|
||||
break;
|
||||
default:
|
||||
goto legacy;
|
||||
|
@ -146,6 +146,28 @@ static void *aes_256_ecb_newctx(void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void *aes_192_ecb_newctx(void)
|
||||
{
|
||||
PROV_AES_KEY *ctx = OPENSSL_zalloc(sizeof(*ctx));
|
||||
|
||||
ctx->pad = 1;
|
||||
ctx->keylen = 192 / 8;
|
||||
ctx->ciph = PROV_AES_CIPHER_ecb();
|
||||
ctx->mode = EVP_CIPH_ECB_MODE;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void *aes_128_ecb_newctx(void)
|
||||
{
|
||||
PROV_AES_KEY *ctx = OPENSSL_zalloc(sizeof(*ctx));
|
||||
|
||||
ctx->pad = 1;
|
||||
ctx->keylen = 128 / 8;
|
||||
ctx->ciph = PROV_AES_CIPHER_ecb();
|
||||
ctx->mode = EVP_CIPH_ECB_MODE;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void aes_freectx(void *vctx)
|
||||
{
|
||||
PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx;
|
||||
@ -168,6 +190,16 @@ static size_t key_length_256(void)
|
||||
return 256 / 8;
|
||||
}
|
||||
|
||||
static size_t key_length_192(void)
|
||||
{
|
||||
return 192 / 8;
|
||||
}
|
||||
|
||||
static size_t key_length_128(void)
|
||||
{
|
||||
return 128 / 8;
|
||||
}
|
||||
|
||||
static int aes_get_params(void *vctx, const OSSL_PARAM params[])
|
||||
{
|
||||
PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx;
|
||||
@ -209,3 +241,35 @@ const OSSL_DISPATCH aes256ecb_functions[] = {
|
||||
{ OSSL_FUNC_CIPHER_SET_PARAMS, (void (*)(void))aes_set_params },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const OSSL_DISPATCH aes192ecb_functions[] = {
|
||||
{ OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_192_ecb_newctx },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_einit },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_UPDATE, (void (*)(void))aes_update },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_FINAL, (void (*)(void))aes_efinal },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_dinit },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_UPDATE, (void (*)(void))aes_update },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_FINAL, (void (*)(void))aes_dfinal },
|
||||
{ OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_freectx },
|
||||
{ OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_dupctx },
|
||||
{ OSSL_FUNC_CIPHER_KEY_LENGTH, (void (*)(void))key_length_192 },
|
||||
{ OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_get_params },
|
||||
{ OSSL_FUNC_CIPHER_SET_PARAMS, (void (*)(void))aes_set_params },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const OSSL_DISPATCH aes128ecb_functions[] = {
|
||||
{ OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_128_ecb_newctx },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_einit },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_UPDATE, (void (*)(void))aes_update },
|
||||
{ OSSL_FUNC_CIPHER_ENCRYPT_FINAL, (void (*)(void))aes_efinal },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_dinit },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_UPDATE, (void (*)(void))aes_update },
|
||||
{ OSSL_FUNC_CIPHER_DECRYPT_FINAL, (void (*)(void))aes_dfinal },
|
||||
{ OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_freectx },
|
||||
{ OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_dupctx },
|
||||
{ OSSL_FUNC_CIPHER_KEY_LENGTH, (void (*)(void))key_length_128 },
|
||||
{ OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_get_params },
|
||||
{ OSSL_FUNC_CIPHER_SET_PARAMS, (void (*)(void))aes_set_params },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
@ -12,3 +12,5 @@ extern const OSSL_DISPATCH sha256_functions[];
|
||||
|
||||
/* Ciphers */
|
||||
extern const OSSL_DISPATCH aes256ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes192ecb_functions[];
|
||||
extern const OSSL_DISPATCH aes128ecb_functions[];
|
||||
|
@ -57,6 +57,8 @@ static const OSSL_ALGORITHM deflt_digests[] = {
|
||||
|
||||
static const OSSL_ALGORITHM deflt_ciphers[] = {
|
||||
{ "AES-256-ECB", "default=yes", aes256ecb_functions },
|
||||
{ "AES-192-ECB", "default=yes", aes192ecb_functions },
|
||||
{ "AES-128-ECB", "default=yes", aes128ecb_functions },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user