Support GnuPG AEAD password entries
This commit is contained in:
@@ -11,8 +11,9 @@ use std::{
|
||||
use cap_std::{ambient_authority, fs::Dir};
|
||||
use pgp::{
|
||||
composed::{
|
||||
ArmorOptions, Deserializable, DetachedSignature, Esk, Message, MessageBuilder,
|
||||
PublicOrSecret, SignedPublicKey, SignedPublicSubKey, SignedSecretKey, SubpacketConfig,
|
||||
ArmorOptions, DecryptionOptions, Deserializable, DetachedSignature, Esk, Message,
|
||||
MessageBuilder, PublicOrSecret, SignedPublicKey, SignedPublicSubKey, SignedSecretKey,
|
||||
SubpacketConfig, TheRing,
|
||||
},
|
||||
crypto::{hash::HashAlgorithm, sym::SymmetricKeyAlgorithm},
|
||||
packet::{SignatureType, Subpacket, SubpacketData},
|
||||
@@ -460,7 +461,13 @@ impl KeyStore {
|
||||
let password = Password::from(supplied.expose());
|
||||
let message = Message::from_bytes(Cursor::new(ciphertext.as_bytes()))
|
||||
.map_err(|_| CryptoError::CorruptMessage)?;
|
||||
if let Ok(mut decrypted) = message.decrypt(&password, secret)
|
||||
let ring = TheRing {
|
||||
secret_keys: vec![secret],
|
||||
key_passwords: vec![&password],
|
||||
decrypt_options: DecryptionOptions::new().enable_gnupg_aead(),
|
||||
..Default::default()
|
||||
};
|
||||
if let Ok((mut decrypted, _)) = message.decrypt_the_ring(ring, true)
|
||||
&& let Ok(plaintext) = decrypted.as_data_vec()
|
||||
{
|
||||
if let Some(info) = key.as_ref() {
|
||||
|
||||
Reference in New Issue
Block a user