Skip to content

Commit 4f42780

Browse files
committed
dev: Drop dead code in ChaCha20Poly1305RFC module
1 parent 2adf45a commit 4f42780

1 file changed

Lines changed: 0 additions & 56 deletions

File tree

lightning/src/crypto/chacha20poly1305rfc.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ impl ChaCha20Poly1305RFC {
5151
ChaCha20Poly1305RFC { cipher, mac, finished: false, data_len: 0, aad_len: aad.len() as u64 }
5252
}
5353

54-
pub fn encrypt(&mut self, input: &[u8], output: &mut [u8], out_tag: &mut [u8]) {
55-
assert!(input.len() == output.len());
56-
assert!(!self.finished);
57-
self.cipher.process(input, output);
58-
self.data_len += input.len();
59-
self.mac.input(output);
60-
ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
61-
self.finished = true;
62-
self.mac.input(&self.aad_len.to_le_bytes());
63-
self.mac.input(&(self.data_len as u64).to_le_bytes());
64-
out_tag.copy_from_slice(&self.mac.result());
65-
}
66-
67-
pub fn encrypt_full_message_in_place(&mut self, input_output: &mut [u8], out_tag: &mut [u8]) {
68-
self.encrypt_in_place(input_output);
69-
self.finish_and_get_tag(out_tag);
70-
}
71-
7254
// Encrypt `input_output` in-place. To finish and calculate the tag, use `finish_and_get_tag`
7355
// below.
7456
pub(in super::super) fn encrypt_in_place(&mut self, input_output: &mut [u8]) {
@@ -89,44 +71,6 @@ impl ChaCha20Poly1305RFC {
8971
out_tag.copy_from_slice(&self.mac.result());
9072
}
9173

92-
/// Decrypt the `input`, checking the given `tag` prior to writing the decrypted contents
93-
/// into `output`. Note that, because `output` is not touched until the `tag` is checked,
94-
/// this decryption is *variable time*.
95-
pub fn variable_time_decrypt(
96-
&mut self, input: &[u8], output: &mut [u8], tag: &[u8],
97-
) -> Result<(), ()> {
98-
assert!(input.len() == output.len());
99-
assert!(!self.finished);
100-
101-
self.finished = true;
102-
103-
self.mac.input(input);
104-
105-
self.data_len += input.len();
106-
ChaCha20Poly1305RFC::pad_mac_16(&mut self.mac, self.data_len);
107-
self.mac.input(&self.aad_len.to_le_bytes());
108-
self.mac.input(&(self.data_len as u64).to_le_bytes());
109-
110-
let calc_tag = self.mac.result();
111-
if fixed_time_eq(&calc_tag, tag) {
112-
self.cipher.process(input, output);
113-
Ok(())
114-
} else {
115-
Err(())
116-
}
117-
}
118-
119-
pub fn check_decrypt_in_place(
120-
&mut self, input_output: &mut [u8], tag: &[u8],
121-
) -> Result<(), ()> {
122-
self.decrypt_in_place(input_output);
123-
if self.finish_and_check_tag(tag) {
124-
Ok(())
125-
} else {
126-
Err(())
127-
}
128-
}
129-
13074
/// Decrypt in place, without checking the tag. Use `finish_and_check_tag` to check it
13175
/// later when decryption finishes.
13276
///

0 commit comments

Comments
 (0)