Skip to content

Commit de4b814

Browse files
committed
ohttp: change nonce array length from 16 to 32
Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
1 parent a118d36 commit de4b814

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

ohttp/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const INFO_REQUEST: &[u8] = b"message/bhttp request";
6262
const LABEL_RESPONSE: &[u8] = b"message/bhttp response";
6363
const INFO_KEY: &[u8] = b"key";
6464
const INFO_NONCE: &[u8] = b"nonce";
65+
const MAX_ENTROPY_LEN: usize = 32;
6566

6667
/// The type of a key identifier.
6768
pub type KeyId = u8;

ohttp/src/stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
entropy,
1818
err::Res,
1919
export_secret, make_aead, random, Aead, Error, HpkeConfig, HpkeR, HpkeS, KeyConfig, KeyId,
20-
Mode, PublicKey, SymKey, REQUEST_HEADER_LEN,
20+
Mode, PublicKey, SymKey, MAX_ENTROPY_LEN, REQUEST_HEADER_LEN,
2121
};
2222

2323
/// The info string for a chunked request.
@@ -241,7 +241,7 @@ impl<D> ClientRequest<D> {
241241
state: ClientResponseState::Header {
242242
enc,
243243
secret,
244-
nonce: [0; 16],
244+
nonce: Default::default(),
245245
read: 0,
246246
},
247247
})
@@ -265,7 +265,7 @@ impl<D> ClientRequest<D> {
265265
state: ClientResponseState::Header {
266266
enc,
267267
secret,
268-
nonce: [0; 16],
268+
nonce: Default::default(),
269269
read: 0,
270270
},
271271
})
@@ -809,7 +809,7 @@ enum ClientResponseState {
809809
Header {
810810
enc: Vec<u8>,
811811
secret: SymKey,
812-
nonce: [u8; 16],
812+
nonce: [u8; MAX_ENTROPY_LEN],
813813
read: usize,
814814
},
815815
Body {

0 commit comments

Comments
 (0)