mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg,sm: Error out on compliance mismatch while decrypting.
* g10/pubkey-enc.c (get_session_key): Bail out if the algo is not allowed in the current compliance mode. * sm/decrypt.c (gpgsm_decrypt): Ditto. -- The idea here is that the owner of the key created a non-compliant key and later receives a mail encrypted to that key. The sender should have checked this key too but we can't guarantee that. By hard failing here the owner of the key will notice that he had created a non-compliant key and thus has a chance to generate a new compliant key. In case the compliant criteria changes and the owner wants to decrypt an old message he can still switch gpg to another compliant mode. Fixes-commit: a0d0cbee7654ad7582400efaa92d493cd8e669e9 GnuPG-bug-id: 3308 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
a21ca77988
commit
4e117f206b
@ -90,15 +90,18 @@ get_session_key (ctrl_t ctrl, PKT_pubkey_enc * k, DEK * dek)
|
|||||||
sk->pubkey_algo = k->pubkey_algo; /* We want a pubkey with this algo. */
|
sk->pubkey_algo = k->pubkey_algo; /* We want a pubkey with this algo. */
|
||||||
if (!(rc = get_seckey (ctrl, sk, k->keyid)))
|
if (!(rc = get_seckey (ctrl, sk, k->keyid)))
|
||||||
{
|
{
|
||||||
/* Print compliance warning. */
|
/* Check compliance. */
|
||||||
if (!gnupg_pk_is_compliant (opt.compliance,
|
if (! gnupg_pk_is_allowed (opt.compliance, PK_USE_DECRYPTION,
|
||||||
sk->pubkey_algo,
|
sk->pubkey_algo,
|
||||||
sk->pkey, nbits_from_pk (sk), NULL))
|
sk->pkey, nbits_from_pk (sk), NULL))
|
||||||
log_info (_("Note: key %s is not suitable for encryption"
|
{
|
||||||
|
log_info (_("key %s is not suitable for decryption"
|
||||||
" in %s mode\n"),
|
" in %s mode\n"),
|
||||||
keystr_from_pk (sk),
|
keystr_from_pk (sk),
|
||||||
gnupg_compliance_option_string (opt.compliance));
|
gnupg_compliance_option_string (opt.compliance));
|
||||||
|
rc = gpg_error (GPG_ERR_PUBKEY_ALGO);
|
||||||
|
}
|
||||||
|
else
|
||||||
rc = get_it (ctrl, k, dek, sk, k->keyid);
|
rc = get_it (ctrl, k, dek, sk, k->keyid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,14 +131,17 @@ get_session_key (ctrl_t ctrl, PKT_pubkey_enc * k, DEK * dek)
|
|||||||
log_info (_("anonymous recipient; trying secret key %s ...\n"),
|
log_info (_("anonymous recipient; trying secret key %s ...\n"),
|
||||||
keystr (keyid));
|
keystr (keyid));
|
||||||
|
|
||||||
/* Print compliance warning. */
|
/* Check compliance. */
|
||||||
if (!gnupg_pk_is_compliant (opt.compliance,
|
if (! gnupg_pk_is_allowed (opt.compliance, PK_USE_DECRYPTION,
|
||||||
sk->pubkey_algo,
|
sk->pubkey_algo,
|
||||||
sk->pkey, nbits_from_pk (sk), NULL))
|
sk->pkey, nbits_from_pk (sk), NULL))
|
||||||
log_info (_("Note: key %s is not suitable for encryption"
|
{
|
||||||
|
log_info (_("key %s is not suitable for decryption"
|
||||||
" in %s mode\n"),
|
" in %s mode\n"),
|
||||||
keystr_from_pk (sk),
|
keystr_from_pk (sk),
|
||||||
gnupg_compliance_option_string (opt.compliance));
|
gnupg_compliance_option_string (opt.compliance));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
rc = get_it (ctrl, k, dek, sk, keyid);
|
rc = get_it (ctrl, k, dek, sk, keyid);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
|
11
sm/decrypt.c
11
sm/decrypt.c
@ -480,8 +480,9 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
|
|||||||
unsigned int nbits;
|
unsigned int nbits;
|
||||||
int pk_algo = gpgsm_get_key_algo_info (cert, &nbits);
|
int pk_algo = gpgsm_get_key_algo_info (cert, &nbits);
|
||||||
|
|
||||||
/* Print compliance warning. */
|
/* Check compliance. */
|
||||||
if (! gnupg_pk_is_compliant (opt.compliance,
|
if (!gnupg_pk_is_allowed (opt.compliance,
|
||||||
|
PK_USE_DECRYPTION,
|
||||||
pk_algo, NULL, nbits, NULL))
|
pk_algo, NULL, nbits, NULL))
|
||||||
{
|
{
|
||||||
char kidstr[10+1];
|
char kidstr[10+1];
|
||||||
@ -489,10 +490,12 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
|
|||||||
snprintf (kidstr, sizeof kidstr, "0x%08lX",
|
snprintf (kidstr, sizeof kidstr, "0x%08lX",
|
||||||
gpgsm_get_short_fingerprint (cert, NULL));
|
gpgsm_get_short_fingerprint (cert, NULL));
|
||||||
log_info
|
log_info
|
||||||
(_("Note: key %s is not suitable for encryption"
|
(_("key %s is not suitable for decryption"
|
||||||
" in %s mode\n"),
|
" in %s mode\n"),
|
||||||
kidstr,
|
kidstr,
|
||||||
gnupg_compliance_option_string (opt.compliance));
|
gnupg_compliance_option_string (opt.compliance));
|
||||||
|
rc = gpg_error (GPG_ERR_PUBKEY_ALGO);
|
||||||
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that all certs are compliant with CO_DE_VS. */
|
/* Check that all certs are compliant with CO_DE_VS. */
|
||||||
@ -504,9 +507,11 @@ gpgsm_decrypt (ctrl_t ctrl, int in_fd, estream_t out_fp)
|
|||||||
|
|
||||||
oops:
|
oops:
|
||||||
if (rc)
|
if (rc)
|
||||||
|
{
|
||||||
/* We cannot check compliance of certs that we
|
/* We cannot check compliance of certs that we
|
||||||
* don't have. */
|
* don't have. */
|
||||||
is_de_vs = 0;
|
is_de_vs = 0;
|
||||||
|
}
|
||||||
xfree (issuer);
|
xfree (issuer);
|
||||||
xfree (serial);
|
xfree (serial);
|
||||||
ksba_cert_release (cert);
|
ksba_cert_release (cert);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user