Skip to content

Commit 987db3b

Browse files
committed
refactor: manually unroll loop
1 parent e4c8a6e commit 987db3b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/crypto/openssl/aead.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,12 @@ impl CipherSuite {
190190
let mut signer = openssl::sign::Signer::new(openssl::hash::MessageDigest::sha256(), &key)?;
191191

192192
// for current platforms there is no issue casting from usize to u64
193-
let aad_len = &(aad.len() as u64).to_be_bytes();
194-
let ct_len = &(encrypted.len() as u64).to_be_bytes();
195-
let tag_len = &(self.auth_tag_len as u64).to_be_bytes();
196-
197-
for buf in [aad_len, ct_len, tag_len, nonce, aad, encrypted] {
198-
signer.update(buf)?;
199-
}
193+
signer.update(&(aad.len() as u64).to_be_bytes())?;
194+
signer.update(&(encrypted.len() as u64).to_be_bytes())?;
195+
signer.update(&(self.auth_tag_len as u64).to_be_bytes())?;
196+
signer.update(nonce)?;
197+
signer.update(aad)?;
198+
signer.update(encrypted)?;
200199

201200
let mut tag = signer.sign_to_vec()?;
202201
tag.resize(self.auth_tag_len, 0);

0 commit comments

Comments
 (0)