Skip to content

Commit 0daf48a

Browse files
committed
f pce split rather than slice
1 parent 6cecdeb commit 0daf48a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lightning/src/ln/peer_channel_encryptor.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,9 @@ impl PeerChannelEncryptor {
202202
let mut nonce = [0; 12];
203203
nonce[4..].copy_from_slice(&n.to_le_bytes()[..]);
204204

205-
let mut chacha = ChaCha20Poly1305RFC::new(key, &nonce, h);
206-
let hmac = &cyphertext[cyphertext.len() - 16..];
205+
let (data, hmac) = cyphertext.split_at(cyphertext.len() - 16);
207206
let mac_check =
208-
chacha.variable_time_decrypt(&cyphertext[0..cyphertext.len() - 16], res, hmac);
207+
ChaCha20Poly1305RFC::new(key, &nonce, h).variable_time_decrypt(&data, res, hmac);
209208
mac_check.map_err(|()| LightningError {
210209
err: "Bad MAC".to_owned(),
211210
action: msgs::ErrorAction::DisconnectPeer { msg: None },

0 commit comments

Comments
 (0)