@@ -54,7 +54,7 @@ mod messages;
5454use error:: * ;
5555use 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
7272type SenderContext = AeadCtxS < Aead , Kdf , Kem > ;
7373type 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.
145143enum 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
150148impl 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