Skip to content

Commit d29ad47

Browse files
committed
add features and preferred algorithms to the public key
1 parent 17fe4c7 commit d29ad47

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

src/key.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ use base64::Engine as _;
99
use deltachat_contact_tools::EmailAddress;
1010
use pgp::composed::Deserializable;
1111
pub use pgp::composed::{SignedPublicKey, SignedSecretKey};
12-
use pgp::packet::PacketTrait as _;
13-
use pgp::packet::{Notation, SignatureConfig, SignatureType, Subpacket, SubpacketData};
12+
use pgp::crypto::aead::AeadAlgorithm;
13+
use pgp::crypto::hash::HashAlgorithm;
14+
use pgp::crypto::sym::SymmetricKeyAlgorithm;
15+
use pgp::packet::{
16+
Features, KeyFlags, Notation, PacketTrait as _, SignatureConfig, SignatureType, Subpacket,
17+
SubpacketData,
18+
};
1419
use pgp::ser::Serialize;
15-
use pgp::types::{KeyDetails, KeyVersion};
20+
use pgp::types::{CompressionAlgorithm, KeyDetails, KeyVersion};
1621
use rand_old::thread_rng;
1722
use tokio::runtime::Handle;
1823

@@ -149,17 +154,38 @@ pub(crate) async fn secret_key_to_public_key(
149154
name: "relays@chatmail.at".into(),
150155
value: all_addrs.into(),
151156
};
157+
let mut keyflags = KeyFlags::default();
158+
keyflags.set_certify(true);
159+
keyflags.set_sign(true);
160+
let mut features = Features::default();
161+
features.set_seipd_v1(true);
162+
features.set_seipd_v2(true);
152163
signature_config.hashed_subpackets = vec![
153164
Subpacket::regular(SubpacketData::SignatureCreationTime(now))?,
154165
Subpacket::regular(SubpacketData::IssuerFingerprint(
155166
signed_secret_key.fingerprint(),
156167
))?,
157-
//Subpacket::regular(SubpacketData::KeyFlags(TODO))
158-
//Subpacket::regular(SubpacketData::Features(TODO))
159-
//Subpacket::regular(SubpacketData::PreferredSymmetricALgorithms(TODO)
160-
//Subpacket::regular(SubpacketData::PreferredHashAlgorithms(TODO)
161-
//Subpacket::regular(SubpacketData::PreferredCompressionAlgorithms(TODO)
162-
//Subpacket::regular(SubpacketData::PreferredAeadAlgorithms(TODO)
168+
Subpacket::regular(SubpacketData::KeyFlags(keyflags))?,
169+
Subpacket::regular(SubpacketData::Features(features))?,
170+
Subpacket::regular(SubpacketData::PreferredSymmetricAlgorithms(smallvec![
171+
SymmetricKeyAlgorithm::AES256,
172+
SymmetricKeyAlgorithm::AES192,
173+
SymmetricKeyAlgorithm::AES128
174+
]))?,
175+
Subpacket::regular(SubpacketData::PreferredHashAlgorithms(smallvec![
176+
HashAlgorithm::Sha256,
177+
HashAlgorithm::Sha384,
178+
HashAlgorithm::Sha512,
179+
HashAlgorithm::Sha224,
180+
]))?,
181+
Subpacket::regular(SubpacketData::PreferredCompressionAlgorithms(smallvec![
182+
CompressionAlgorithm::ZLIB,
183+
CompressionAlgorithm::ZIP,
184+
]))?,
185+
Subpacket::regular(SubpacketData::PreferredAeadAlgorithms(smallvec![(
186+
SymmetricKeyAlgorithm::AES256,
187+
AeadAlgorithm::Ocb
188+
)]))?,
163189
Subpacket::regular(SubpacketData::IsPrimary(true))?,
164190
Subpacket::regular(SubpacketData::Notation(notation))?,
165191
];

0 commit comments

Comments
 (0)