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

Remove OpenPGP::new_context.

  - This is a nop now that we only use SOP.
parent b1788274
......@@ -125,7 +125,6 @@ impl<'de> serde::Deserialize<'de> for Data {
/// interface.
pub trait OpenPGP: std::fmt::Debug {
fn sop(&self) -> &Sop;
fn new_context(&self) -> Result<Box<dyn OpenPGP>>;
fn version(&self) -> Result<Version>;
fn encrypt(&self, recipient: &[u8], plaintext: &[u8]) -> Result<Data>;
fn decrypt(&self, recipient: &[u8], ciphertext: &[u8]) -> Result<Data>;
......
......@@ -434,11 +434,6 @@ impl crate::OpenPGP for Sop {
self
}
fn new_context(&self) -> Result<Box<dyn crate::OpenPGP>> {
Self::new(&self.sop, &self.env)
.map(|i| -> Box<dyn crate::OpenPGP> { Box::new(i) })
}
fn version(&self) -> Result<crate::Version> {
Sop::version(self)
}
......
......@@ -544,8 +544,7 @@ impl ConsumerTest for PrimaryKeyFlags {
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
let ciphertext = pgp.encrypt(&super::extract_cert(artifact)?, b"Hello World!")?;
pgp.new_context()?
.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
pgp.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
}
}
......
......@@ -307,8 +307,7 @@ impl ConsumerTest for DetachedPrimary {
-> Result<Data> {
let sig = pgp.sign_detached(artifact, self.message())
.context("Signing failed")?;
pgp.new_context()?
.verify_detached(&self.cert, self.message(), &sig)
pgp.verify_detached(&self.cert, self.message(), &sig)
.context("Verification failed")
}
}
......@@ -330,8 +330,7 @@ impl ConsumerTest for CertExpiration {
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
let ciphertext = pgp.encrypt(artifact, self.message())?;
pgp.new_context()?
.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
pgp.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
}
fn check_consumer(&self, _i: usize, artifact: &[u8])
......
......@@ -103,8 +103,7 @@ impl ConsumerTest for ImMyOwnGrandpa {
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
let ciphertext = pgp.encrypt(artifact, self.message())?;
pgp.new_context()?
.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
pgp.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
}
fn check_consumer(&self, _i: usize, artifact: &[u8])
......
......@@ -134,8 +134,7 @@ impl ConsumerTest for MockMcEliece {
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
let ciphertext = pgp.encrypt(artifact, self.message())?;
pgp.new_context()?
.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
pgp.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
}
fn check_consumer(&self, _i: usize, artifact: &[u8])
......
......@@ -201,8 +201,7 @@ impl ConsumerTest for PerturbedCerts {
fn consume(&self, _i: usize, pgp: &dyn OpenPGP, artifact: &[u8])
-> Result<Data> {
let ciphertext = pgp.encrypt(artifact, self.message())?;
pgp.new_context()?
.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
pgp.decrypt(data::certificate("bob-secret.pgp"), &ciphertext)
}
fn check_consumer(&self, _i: usize, artifact: &[u8])
......
......@@ -60,8 +60,7 @@ pub trait ConsumerTest : Test {
let artifact = Artifact::ok(description, data);
let mut results = Vec::new();
for consumer in implementations.iter() {
let c = consumer.new_context()?;
for c in implementations.iter() {
let plaintext = self.consume(i, c.as_ref(), &artifact.data);
let mut a = match plaintext {
Ok(p) =>
......@@ -117,9 +116,8 @@ pub trait ProducerConsumerTest : Test {
{
let mut test_results = Vec::new();
for producer in implementations.iter() {
for p in implementations.iter() {
let expectation = self.expectation();
let p = producer.new_context()?;
let mut artifact = match self.produce(p.as_ref()) {
Ok(d) => Artifact::ok(p.version()?.to_string(), d),
Err(e) => Artifact::err(p.version()?.to_string(),
......@@ -133,9 +131,7 @@ pub trait ProducerConsumerTest : Test {
let mut results = Vec::new();
if artifact.error.len() == 0 {
for consumer in implementations.iter() {
let p = producer.new_context()?;
let c = consumer.new_context()?;
for c in implementations.iter() {
let plaintext =
self.consume(p.as_ref(), c.as_ref(),
&artifact.data);
......
Markdown is supported
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