File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -100,22 +100,17 @@ impl Context {
100100 return Ok ( ( ) ) ;
101101 }
102102
103- match self . replay_policy {
104- ReplayAttackPolicy :: Default => {
105- #[ cfg( feature = "aead-cipher-2022" ) ]
106- if method. is_aead_2022 ( ) {
107- return if self . replay_protector . check_nonce_and_set ( method, nonce) {
108- let err = io:: Error :: new ( io:: ErrorKind :: Other , "detected repeated nonce (iv/salt)" ) ;
109- Err ( err)
110- } else {
111- Ok ( ( ) )
112- } ;
113- }
103+ #[ allow( unused_mut) ]
104+ let mut replay_policy = self . replay_policy ;
114105
115- // AEAD, Stream should ignore by default
116- Ok ( ( ) )
117- }
118- ReplayAttackPolicy :: Ignore => Ok ( ( ) ) ,
106+ #[ cfg( feature = "aead-cipher-2022" ) ]
107+ if method. is_aead_2022 ( ) {
108+ // AEAD-2022 can't be ignored.
109+ replay_policy = ReplayAttackPolicy :: Reject ;
110+ }
111+
112+ match replay_policy {
113+ ReplayAttackPolicy :: Default | ReplayAttackPolicy :: Ignore => Ok ( ( ) ) ,
119114 ReplayAttackPolicy :: Detect => {
120115 if self . replay_protector . check_nonce_and_set ( method, nonce) {
121116 warn ! ( "detected repeated nonce (iv/salt) {:?}" , ByteStr :: new( nonce) ) ;
You can’t perform that action at this time.
0 commit comments