Verified Commit cabf7eff authored by Justus Winter's avatar Justus Winter
Browse files

New test exploring ECDH with the recipient's primary fp KDFd in.

parent ee68093b
Pipeline #555081069 passed with stages
in 5 minutes and 22 seconds
-----BEGIN PGP MESSAGE-----
Comment: Produced with a modified version of sequoia-openpgp 1.9.
wV4DR2b2udXyHrYSAQdA9d1Pu/pusvnuSzBJcJnk4q2VNOXPxpPhpras1k9va3Yw
Md7grSoqnOlE9aS/ENhgFezmxsfeK6rNwYDIGYjUf5DsOuJ+DPtl8A7PuRxVzr7S
0j8B6880vxbUclv8tPM/W8doNu2h2awXJSaMuhziVJ13qBxar/tdqlTIeycj7Ea+
c1cXjDbhxfeMpN9/kamW68k=
=A4zF
-----END PGP MESSAGE-----
-----BEGIN PGP MESSAGE-----
Comment: Produced with sequoia-openpgp 1.9.
wV4DR2b2udXyHrYSAQdA5IxdZ8u/DN5ggQiN1ElmKrd+OECI9IJ6etz+Bpv7/Xww
ajvTGqaEbDq7XQirsvkUhuPZ2DZy0MeAWSLVueNnNQYvfQskN5OmeDO/ilvFsdRM
0j8BKcBBTI50xQAv8KEzZvNYcDTDUJiBbUJtvz4g9YCiV4LvHqdtOKdo25YIBvHn
bJrs16FLc+llvnM9oqByHIs=
=5Hk0
-----END PGP MESSAGE-----
......@@ -25,6 +25,7 @@ use crate::{
};
mod ecdh_parameters;
mod ecdh_kdf_fingerprint;
mod unclamped_cv25519;
/// Tests how implementations handle different EdDSA signature
......@@ -117,5 +118,6 @@ pub fn schedule(plan: &mut TestPlan) -> Result<()> {
plan.add(Box::new(EdDSASignatureEncoding::new()?));
plan.add(Box::new(unclamped_cv25519::UnclampedCv25519::new()?));
plan.add(Box::new(ecdh_parameters::ECDHParameters::new()?));
plan.add(Box::new(ecdh_kdf_fingerprint::ECDHKDFFingerprint::new()?));
Ok(())
}
use crate::{
Data,
OpenPGP,
Result,
data,
tests::{
Expectation,
Test,
TestMatrix,
ConsumerTest,
},
};
/// Tests whether implementations are willing to unwrap session keys
/// using the recipient's primary key fingerprint.
pub struct ECDHKDFFingerprint {
}
impl ECDHKDFFingerprint {
pub fn new() -> Result<ECDHKDFFingerprint> {
Ok(ECDHKDFFingerprint {})
}
}
impl Test for ECDHKDFFingerprint {
fn title(&self) -> String {
"ECDH KDF using recipient fingerprint".into()
}
fn description(&self) -> String {
"Tests whether implementations are willing to unwrap session keys \
using the recipient's primary key fingerprint.".into()
}
fn artifacts(&self) -> Vec<(String, Data)> {
vec![
("Key".into(), data::certificate("alice-secret.pgp").into()),
]
}
fn run(&self, implementations: &[crate::Sop])
-> Result<TestMatrix> {
ConsumerTest::run(self, implementations)
}
}
impl ConsumerTest for ECDHKDFFingerprint {
fn produce(&self) -> Result<Vec<(String, Data, Option<Expectation>)>> {
// The test cases are produced with a hacked up version of
// sequoia-openpgp 1.9.
Ok(vec![
("KDF the subkey's fingerprint".into(),
data::message("alice-kdf-subkey.pgp").into(),
Some(Ok("Base case".into()))),
("KDF the primary key's fingerprint".into(),
data::message("alice-kdf-primary.pgp").into(),
None),
])
}
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
Ok(pgp.sop().decrypt()
.key(data::certificate("alice-secret.pgp"))
.ciphertext(artifact)?.1)
}
fn check_consumer(&self, _i: usize, artifact: &[u8])
-> Result<()> {
if artifact == crate::tests::MESSAGE {
Ok(())
} else {
Err(anyhow::anyhow!(format!("Expected {:?}, got {:?}",
crate::tests::MESSAGE,
artifact)))
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment