Skip to content

Commit c565374

Browse files
committed
Update to the latest hpke rev
1 parent cebeec9 commit c565374

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ed25519-dalek = { version = "3.0.0-pre.2", default-features = false, features =
5959
getrandom = "0.3.4"
6060
hkdf = "0.13.0-rc.3"
6161
hmac = "0.13.0-rc.3"
62-
hpke = { git = "https://github.com/poljar/rust-hpke", rev = "f1022438", features = ["alloc", "x25519"] }
62+
hpke = { git = "https://github.com/poljar/rust-hpke", rev = "3520bd55", features = ["alloc", "x25519"] }
6363
matrix-pickle = { version = "0.2.2" }
6464
prost = "0.14.1"
6565
rand = "0.10.0-rc.5"

src/hpke/mod.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mod messages;
5454
use error::*;
5555
use hpke::{
5656
Deserializable as _, OpModeS, Serializable,
57-
aead::{AeadCtxR, AeadCtxS, AeadResponseCtxR, AeadResponseCtxS, ChaCha20Poly1305},
57+
aead::{AeadCtxR, AeadCtxS, ChaCha20Poly1305},
5858
kdf::HkdfSha384,
5959
kem::X25519HkdfSha256,
6060
};
@@ -71,8 +71,6 @@ type Kdf = HkdfSha384;
7171

7272
type SenderContext = AeadCtxS<Aead, Kdf, Kem>;
7373
type RecipientContext = AeadCtxR<Aead, Kdf, Kem>;
74-
type SenderResponseContext = AeadResponseCtxS<Aead, Kem>;
75-
type RecipientResponseContext = AeadResponseCtxR<Aead, Kem>;
7674

7775
/// A check code that can be used to confirm that two [`EstablishedHpkeChannel`]
7876
/// objects share the same secret. This is supposed to be shared out-of-band to
@@ -143,8 +141,8 @@ pub struct SenderCreationResult {
143141
/// device is initiating the channel or receiving/responding as the other side
144142
/// of the initiation.
145143
enum Role {
146-
Sender { context: SenderContext, response_context: SenderResponseContext },
147-
Recipient { context: RecipientContext, response_context: RecipientResponseContext },
144+
Sender { context: SenderContext },
145+
Recipient { context: RecipientContext },
148146
}
149147

150148
impl std::fmt::Debug for Role {
@@ -273,7 +271,6 @@ impl HpkeSenderChannel {
273271
let ciphertext = context
274272
.seal(initial_plaintext, &[])
275273
.expect("We should be able to seal the initial plaintext");
276-
let response_context = context.response_context();
277274

278275
let encapsulated_key = encapsulated_key.to_bytes();
279276
#[allow(clippy::expect_used)]
@@ -283,7 +280,7 @@ impl HpkeSenderChannel {
283280

284281
let our_public_key = encapsulated_key;
285282

286-
let role = Role::Sender { context, response_context };
283+
let role = Role::Sender { context };
287284
let check_code =
288285
role.check_code(&application_info_prefix, our_public_key, their_public_key);
289286

@@ -353,9 +350,8 @@ impl HpkeRecipientChannel {
353350
.map_err(|_| Error::Decryption)?;
354351

355352
let message = context.open(&message.ciphertext, &[]).map_err(|_| Error::Decryption)?;
356-
let response_context = context.response_context();
357353

358-
let role = Role::Recipient { context, response_context };
354+
let role = Role::Recipient { context };
359355

360356
let check_code =
361357
role.check_code(&application_info_prefix, our_public_key, their_public_key);
@@ -431,7 +427,7 @@ impl EstablishedHpkeChannel {
431427
pub fn seal(&mut self, plaintext: &[u8]) -> Message {
432428
let ret = match &mut self.role {
433429
Role::Sender { context, .. } => context.seal(plaintext, &[]),
434-
Role::Recipient { response_context, .. } => response_context.seal(plaintext, &[]),
430+
Role::Recipient { context, .. } => context.response_context().seal(plaintext, &[]),
435431
};
436432

437433
#[allow(clippy::expect_used)]
@@ -444,8 +440,8 @@ impl EstablishedHpkeChannel {
444440

445441
pub fn open(&mut self, message: &Message) -> Result<Vec<u8>, Error> {
446442
let ret = match &mut self.role {
447-
Role::Sender { response_context, .. } => {
448-
response_context.open(&message.ciphertext, &[])
443+
Role::Sender { context, .. } => {
444+
context.response_context().open(&message.ciphertext, &[])
449445
}
450446
Role::Recipient { context, .. } => context.open(&message.ciphertext, &[]),
451447
};

0 commit comments

Comments
 (0)