Support GnuPG AEAD password entries

This commit is contained in:
Hermes Agent
2026-08-10 08:57:57 +00:00
parent d66d9b0f08
commit 977eb236da
10 changed files with 319 additions and 13 deletions

View File

@@ -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() {