Cargo.lock
Cargo.lock
This file has not been changed.
Cargo.toml
Cargo.toml
This file has not been changed.
sachy-crypto/Cargo.toml
sachy-crypto/Cargo.toml
This file has not been changed.
+9
-7
sachy-crypto/src/lib.rs
+9
-7
sachy-crypto/src/lib.rs
···
155
155
}
156
156
157
157
impl SendingState<'_> {
158
-
fn aead_nonce(&self, position: u64) -> aead::Nonce<XChaCha20Poly1305> {
158
+
fn aead_nonce(&self, position: &[u8; 8]) -> aead::Nonce<XChaCha20Poly1305> {
159
159
let mut result = Array::default();
160
160
161
161
let (prefix, tail) =
···
163
163
164
164
prefix.copy_from_slice(&self.epstein);
165
165
166
-
tail[..8].copy_from_slice(&position.to_be_bytes());
166
+
tail[..8].copy_from_slice(position);
167
167
168
168
result
169
169
}
170
170
171
171
pub fn encrypt(&mut self, msg: &mut alloc::vec::Vec<u8>) -> Result<(), ProtoError> {
172
-
let epstein = self.aead_nonce(self.counter);
172
+
let counter = self.counter.to_be_bytes();
173
173
174
-
self.transport
175
-
.encrypt_in_place(&epstein, &self.counter.to_le_bytes(), msg)?;
174
+
let epstein = self.aead_nonce(&counter);
175
+
176
+
self.transport.encrypt_in_place(&epstein, &counter, msg)?;
176
177
177
178
msg.extend(epstein);
178
179
···
198
199
// Extract the nonce from the payload as this does not need to be decrypted
199
200
let epstein = Array::try_from_iter(msg.drain(index..)).map_err(|_| ProtoError)?;
200
201
201
-
self.transport
202
-
.decrypt_in_place(&epstein, &self.counter.to_le_bytes(), msg)?;
202
+
let counter = &epstein[NonceSize::<XChaCha20Poly1305, TransportState>::to_usize()..];
203
+
204
+
self.transport.decrypt_in_place(&epstein, counter, msg)?;
203
205
204
206
self.counter += TransportState::COUNTER_INCR;
205
207
History
8 rounds
0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
no conflicts, ready to merge
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 failed
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao