mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
gpg: Make AEAD modes subject to compliance checks.
* g10/decrypt-data.c (decrypt_data): Move aead algo detection up. -- Note that the AEAD modes are not yet approved for --compliance=de-vs Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
ab7a0b0702
commit
37b116db20
@ -221,6 +221,8 @@ int
|
|||||||
decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
|
decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
|
||||||
{
|
{
|
||||||
decode_filter_ctx_t dfx;
|
decode_filter_ctx_t dfx;
|
||||||
|
enum gcry_cipher_modes ciphermode;
|
||||||
|
unsigned int startivlen;
|
||||||
byte *p;
|
byte *p;
|
||||||
int rc=0, c, i;
|
int rc=0, c, i;
|
||||||
byte temp[32];
|
byte temp[32];
|
||||||
@ -242,9 +244,18 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
|
|||||||
dek->algo_info_printed = 1;
|
dek->algo_info_printed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ed->aead_algo)
|
||||||
|
{
|
||||||
|
rc = openpgp_aead_algo_info (ed->aead_algo, &ciphermode, &startivlen);
|
||||||
|
if (rc)
|
||||||
|
goto leave;
|
||||||
|
log_assert (startivlen <= sizeof dfx->startiv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ciphermode = GCRY_CIPHER_MODE_CFB;
|
||||||
|
|
||||||
/* Check compliance. */
|
/* Check compliance. */
|
||||||
if (! gnupg_cipher_is_allowed (opt.compliance, 0, dek->algo,
|
if (!gnupg_cipher_is_allowed (opt.compliance, 0, dek->algo, ciphermode))
|
||||||
GCRY_CIPHER_MODE_CFB))
|
|
||||||
{
|
{
|
||||||
log_error (_("cipher algorithm '%s' may not be used in %s mode\n"),
|
log_error (_("cipher algorithm '%s' may not be used in %s mode\n"),
|
||||||
openpgp_cipher_algo_name (dek->algo),
|
openpgp_cipher_algo_name (dek->algo),
|
||||||
@ -282,20 +293,12 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
|
|||||||
|
|
||||||
if (ed->aead_algo)
|
if (ed->aead_algo)
|
||||||
{
|
{
|
||||||
enum gcry_cipher_modes ciphermode;
|
|
||||||
unsigned int startivlen;
|
|
||||||
|
|
||||||
if (blocksize != 16)
|
if (blocksize != 16)
|
||||||
{
|
{
|
||||||
rc = gpg_error (GPG_ERR_CIPHER_ALGO);
|
rc = gpg_error (GPG_ERR_CIPHER_ALGO);
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = openpgp_aead_algo_info (ed->aead_algo, &ciphermode, &startivlen);
|
|
||||||
if (rc)
|
|
||||||
goto leave;
|
|
||||||
log_assert (startivlen <= sizeof dfx->startiv);
|
|
||||||
|
|
||||||
if (ed->chunkbyte > 56)
|
if (ed->chunkbyte > 56)
|
||||||
{
|
{
|
||||||
log_error ("invalid AEAD chunkbyte %u\n", ed->chunkbyte);
|
log_error ("invalid AEAD chunkbyte %u\n", ed->chunkbyte);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user