mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-05-17 11:59:42 +00:00
add 'unsupported cipher mode' diagnostics to evp_lib.c and genpkey.c
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6217)
This commit is contained in:
parent
f2950a46a6
commit
49c9c1b3d0
@ -120,6 +120,13 @@ int genpkey_main(int argc, char **argv)
|
|||||||
if (!opt_cipher(opt_unknown(), &cipher)
|
if (!opt_cipher(opt_unknown(), &cipher)
|
||||||
|| do_param == 1)
|
|| do_param == 1)
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
|
if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE ||
|
||||||
|
EVP_CIPHER_mode(cipher) == EVP_CIPH_CCM_MODE ||
|
||||||
|
EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE ||
|
||||||
|
EVP_CIPHER_mode(cipher) == EVP_CIPH_OCB_MODE) {
|
||||||
|
BIO_printf(bio_err, "%s: cipher mode not supported\n", prog);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
argc = opt_num_rest();
|
argc = opt_num_rest();
|
||||||
|
@ -322,6 +322,8 @@ static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
|||||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_TAG), "unknown tag"},
|
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNKNOWN_TAG), "unknown tag"},
|
||||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),
|
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE),
|
||||||
"unsupported any defined by type"},
|
"unsupported any defined by type"},
|
||||||
|
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_CIPHER),
|
||||||
|
"unsupported cipher"},
|
||||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),
|
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE),
|
||||||
"unsupported public key type"},
|
"unsupported public key type"},
|
||||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_TYPE), "unsupported type"},
|
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_UNSUPPORTED_TYPE), "unsupported type"},
|
||||||
|
@ -78,7 +78,7 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
|
|||||||
/* Dummy cipherinit to just setup the IV, and PRF */
|
/* Dummy cipherinit to just setup the IV, and PRF */
|
||||||
if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, iv, 0))
|
if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, iv, 0))
|
||||||
goto err;
|
goto err;
|
||||||
if (EVP_CIPHER_param_to_asn1(ctx, scheme->parameter) < 0) {
|
if (EVP_CIPHER_param_to_asn1(ctx, scheme->parameter) <= 0) {
|
||||||
ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
|
ASN1err(ASN1_F_PKCS5_PBE2_SET_IV, ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,
|
|||||||
/* Dummy cipherinit to just setup the IV */
|
/* Dummy cipherinit to just setup the IV */
|
||||||
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, iv, 0) == 0)
|
if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, iv, 0) == 0)
|
||||||
goto err;
|
goto err;
|
||||||
if (EVP_CIPHER_param_to_asn1(ctx, scheme->parameter) < 0) {
|
if (EVP_CIPHER_param_to_asn1(ctx, scheme->parameter) <= 0) {
|
||||||
ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT,
|
ASN1err(ASN1_F_PKCS5_PBE2_SET_SCRYPT,
|
||||||
ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
|
ASN1_R_ERROR_SETTING_CIPHER_PARAMS);
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -326,7 +326,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
|
|||||||
if (!EVP_CipherInit_ex(kekctx, kekcipher, NULL, NULL, NULL, en_de))
|
if (!EVP_CipherInit_ex(kekctx, kekcipher, NULL, NULL, NULL, en_de))
|
||||||
goto err;
|
goto err;
|
||||||
EVP_CIPHER_CTX_set_padding(kekctx, 0);
|
EVP_CIPHER_CTX_set_padding(kekctx, 0);
|
||||||
if (EVP_CIPHER_asn1_to_param(kekctx, kekalg->parameter) < 0) {
|
if (EVP_CIPHER_asn1_to_param(kekctx, kekalg->parameter) <= 0) {
|
||||||
CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT,
|
CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT,
|
||||||
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
|
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -716,9 +716,11 @@ EVP_F_DES_EDE3_WRAP_CIPHER:171:des_ede3_wrap_cipher
|
|||||||
EVP_F_DO_SIGVER_INIT:161:do_sigver_init
|
EVP_F_DO_SIGVER_INIT:161:do_sigver_init
|
||||||
EVP_F_ENC_NEW:199:enc_new
|
EVP_F_ENC_NEW:199:enc_new
|
||||||
EVP_F_EVP_CIPHERINIT_EX:123:EVP_CipherInit_ex
|
EVP_F_EVP_CIPHERINIT_EX:123:EVP_CipherInit_ex
|
||||||
|
EVP_F_EVP_CIPHER_ASN1_TO_PARAM:202:EVP_CIPHER_asn1_to_param
|
||||||
EVP_F_EVP_CIPHER_CTX_COPY:163:EVP_CIPHER_CTX_copy
|
EVP_F_EVP_CIPHER_CTX_COPY:163:EVP_CIPHER_CTX_copy
|
||||||
EVP_F_EVP_CIPHER_CTX_CTRL:124:EVP_CIPHER_CTX_ctrl
|
EVP_F_EVP_CIPHER_CTX_CTRL:124:EVP_CIPHER_CTX_ctrl
|
||||||
EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH:122:EVP_CIPHER_CTX_set_key_length
|
EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH:122:EVP_CIPHER_CTX_set_key_length
|
||||||
|
EVP_F_EVP_CIPHER_PARAM_TO_ASN1:203:EVP_CIPHER_param_to_asn1
|
||||||
EVP_F_EVP_DECRYPTFINAL_EX:101:EVP_DecryptFinal_ex
|
EVP_F_EVP_DECRYPTFINAL_EX:101:EVP_DecryptFinal_ex
|
||||||
EVP_F_EVP_DECRYPTUPDATE:166:EVP_DecryptUpdate
|
EVP_F_EVP_DECRYPTUPDATE:166:EVP_DecryptUpdate
|
||||||
EVP_F_EVP_DIGESTFINALXOF:174:EVP_DigestFinalXOF
|
EVP_F_EVP_DIGESTFINALXOF:174:EVP_DigestFinalXOF
|
||||||
@ -1831,6 +1833,7 @@ ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE:163:unknown public key type
|
|||||||
ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM:199:unknown signature algorithm
|
ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM:199:unknown signature algorithm
|
||||||
ASN1_R_UNKNOWN_TAG:194:unknown tag
|
ASN1_R_UNKNOWN_TAG:194:unknown tag
|
||||||
ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE:164:unsupported any defined by type
|
ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE:164:unsupported any defined by type
|
||||||
|
ASN1_R_UNSUPPORTED_CIPHER:228:unsupported cipher
|
||||||
ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE:167:unsupported public key type
|
ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE:167:unsupported public key type
|
||||||
ASN1_R_UNSUPPORTED_TYPE:196:unsupported type
|
ASN1_R_UNSUPPORTED_TYPE:196:unsupported type
|
||||||
ASN1_R_WRONG_INTEGER_TYPE:225:wrong integer type
|
ASN1_R_WRONG_INTEGER_TYPE:225:wrong integer type
|
||||||
|
@ -35,12 +35,16 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
|
|||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_DO_SIGVER_INIT, 0), "do_sigver_init"},
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_DO_SIGVER_INIT, 0), "do_sigver_init"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_ENC_NEW, 0), "enc_new"},
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_ENC_NEW, 0), "enc_new"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHERINIT_EX, 0), "EVP_CipherInit_ex"},
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHERINIT_EX, 0), "EVP_CipherInit_ex"},
|
||||||
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_ASN1_TO_PARAM, 0),
|
||||||
|
"EVP_CIPHER_asn1_to_param"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_COPY, 0),
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_COPY, 0),
|
||||||
"EVP_CIPHER_CTX_copy"},
|
"EVP_CIPHER_CTX_copy"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_CTRL, 0),
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_CTRL, 0),
|
||||||
"EVP_CIPHER_CTX_ctrl"},
|
"EVP_CIPHER_CTX_ctrl"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH, 0),
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH, 0),
|
||||||
"EVP_CIPHER_CTX_set_key_length"},
|
"EVP_CIPHER_CTX_set_key_length"},
|
||||||
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_CIPHER_PARAM_TO_ASN1, 0),
|
||||||
|
"EVP_CIPHER_param_to_asn1"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_DECRYPTFINAL_EX, 0),
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_DECRYPTFINAL_EX, 0),
|
||||||
"EVP_DecryptFinal_ex"},
|
"EVP_DecryptFinal_ex"},
|
||||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_DECRYPTUPDATE, 0), "EVP_DecryptUpdate"},
|
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_DECRYPTUPDATE, 0), "EVP_DecryptUpdate"},
|
||||||
|
@ -32,7 +32,7 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
|||||||
case EVP_CIPH_CCM_MODE:
|
case EVP_CIPH_CCM_MODE:
|
||||||
case EVP_CIPH_XTS_MODE:
|
case EVP_CIPH_XTS_MODE:
|
||||||
case EVP_CIPH_OCB_MODE:
|
case EVP_CIPH_OCB_MODE:
|
||||||
ret = -1;
|
ret = -2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -40,6 +40,12 @@ int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
if (ret <= 0)
|
||||||
|
EVPerr(EVP_F_EVP_CIPHER_PARAM_TO_ASN1, ret == -2 ?
|
||||||
|
ASN1_R_UNSUPPORTED_CIPHER :
|
||||||
|
EVP_R_CIPHER_PARAMETER_ERROR);
|
||||||
|
if (ret < -1)
|
||||||
|
ret = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +66,7 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
|||||||
case EVP_CIPH_CCM_MODE:
|
case EVP_CIPH_CCM_MODE:
|
||||||
case EVP_CIPH_XTS_MODE:
|
case EVP_CIPH_XTS_MODE:
|
||||||
case EVP_CIPH_OCB_MODE:
|
case EVP_CIPH_OCB_MODE:
|
||||||
ret = -1;
|
ret = -2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -69,6 +75,12 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
if (ret <= 0)
|
||||||
|
EVPerr(EVP_F_EVP_CIPHER_ASN1_TO_PARAM, ret == -2 ?
|
||||||
|
EVP_R_UNSUPPORTED_CIPHER :
|
||||||
|
EVP_R_CIPHER_PARAMETER_ERROR);
|
||||||
|
if (ret < -1)
|
||||||
|
ret = -1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ OBJECT IDENTIFIER or NID_undef if it has no defined OBJECT IDENTIFIER.
|
|||||||
EVP_CIPHER_CTX_cipher() returns an B<EVP_CIPHER> structure.
|
EVP_CIPHER_CTX_cipher() returns an B<EVP_CIPHER> structure.
|
||||||
|
|
||||||
EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return greater
|
EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() return greater
|
||||||
than zero for success and zero or a negative number.
|
than zero for success and zero or a negative number on failure.
|
||||||
|
|
||||||
EVP_CIPHER_CTX_rand_key() returns 1 for success.
|
EVP_CIPHER_CTX_rand_key() returns 1 for success.
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ the structure and B<cert> its corresponding certificates. B<ca>, if not B<NULL>
|
|||||||
is an optional set of certificates to also include in the structure.
|
is an optional set of certificates to also include in the structure.
|
||||||
|
|
||||||
B<nid_key> and B<nid_cert> are the encryption algorithms that should be used
|
B<nid_key> and B<nid_cert> are the encryption algorithms that should be used
|
||||||
for the key and certificate respectively. B<iter> is the encryption algorithm
|
for the key and certificate respectively. The modes
|
||||||
|
GCM, CCM, XTS, and OCB are unsupported. B<iter> is the encryption algorithm
|
||||||
iteration count to use and B<mac_iter> is the MAC iteration count to use.
|
iteration count to use and B<mac_iter> is the MAC iteration count to use.
|
||||||
B<keytype> is the type of key.
|
B<keytype> is the type of key.
|
||||||
|
|
||||||
|
@ -241,6 +241,7 @@ int ERR_load_ASN1_strings(void);
|
|||||||
# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
|
# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
|
||||||
# define ASN1_R_UNKNOWN_TAG 194
|
# define ASN1_R_UNKNOWN_TAG 194
|
||||||
# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
|
# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
|
||||||
|
# define ASN1_R_UNSUPPORTED_CIPHER 228
|
||||||
# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
|
# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
|
||||||
# define ASN1_R_UNSUPPORTED_TYPE 196
|
# define ASN1_R_UNSUPPORTED_TYPE 196
|
||||||
# define ASN1_R_WRONG_INTEGER_TYPE 225
|
# define ASN1_R_WRONG_INTEGER_TYPE 225
|
||||||
|
@ -38,9 +38,11 @@ int ERR_load_EVP_strings(void);
|
|||||||
# define EVP_F_DO_SIGVER_INIT 161
|
# define EVP_F_DO_SIGVER_INIT 161
|
||||||
# define EVP_F_ENC_NEW 199
|
# define EVP_F_ENC_NEW 199
|
||||||
# define EVP_F_EVP_CIPHERINIT_EX 123
|
# define EVP_F_EVP_CIPHERINIT_EX 123
|
||||||
|
# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 202
|
||||||
# define EVP_F_EVP_CIPHER_CTX_COPY 163
|
# define EVP_F_EVP_CIPHER_CTX_COPY 163
|
||||||
# define EVP_F_EVP_CIPHER_CTX_CTRL 124
|
# define EVP_F_EVP_CIPHER_CTX_CTRL 124
|
||||||
# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
|
# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
|
||||||
|
# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 203
|
||||||
# define EVP_F_EVP_DECRYPTFINAL_EX 101
|
# define EVP_F_EVP_DECRYPTFINAL_EX 101
|
||||||
# define EVP_F_EVP_DECRYPTUPDATE 166
|
# define EVP_F_EVP_DECRYPTUPDATE 166
|
||||||
# define EVP_F_EVP_DIGESTFINALXOF 174
|
# define EVP_F_EVP_DIGESTFINALXOF 174
|
||||||
|
Loading…
x
Reference in New Issue
Block a user