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.
sachy-crypto/README.md
sachy-crypto/README.md
This file has not been changed.
+12
-13
sachy-crypto/src/lib.rs
+12
-13
sachy-crypto/src/lib.rs
···
307
307
let (ciphertext, server) = ServerHandshake::receive(ek.serialize().as_bytes())?;
308
308
309
309
// Pretend to send ciphertext across the webz: server -> client
310
-
let client_transport = client.finish(&ciphertext, &psk)?;
311
-
let server_transport = server.finish(&psk)?;
310
+
let alice = client.finish(&ciphertext, &psk)?;
311
+
let bob = server.finish(&psk)?;
312
312
313
313
let nonce = aead::Nonce::<ChaCha20Poly1305>::generate();
314
314
315
315
let mut buffer1 = vec![0u8; 64];
316
316
let mut buffer2 = vec![0u8; 64];
317
317
318
-
// Using the same nonce to check that the internal states match. Normally, client/server
318
+
// Using the same nonce to check that the internal AEAD states match. Normally, client/server
319
319
// would work with randomised nonces, because nonce reuse is BAD
320
-
client_transport
320
+
alice
321
321
.aead
322
322
.encrypt_in_place(&nonce, &[], &mut buffer1)?;
323
-
server_transport
323
+
bob
324
324
.aead
325
325
.encrypt_in_place(&nonce, &[], &mut buffer2)?;
326
326
···
328
328
// so the outputs should match each other
329
329
assert_eq!(&buffer1, &buffer2);
330
330
331
+
// Both Transports have derived base nonces for each client/server context.
332
+
// Client nonces will not match Server nonces.
333
+
assert_eq!(alice.client, bob.client);
334
+
assert_eq!(alice.server, bob.server);
335
+
assert_ne!(alice.client, alice.server);
336
+
assert_ne!(bob.client, bob.server);
337
+
331
338
Ok(())
332
339
}
333
340
···
350
357
let (mut alice_send, mut alice_recv) = alice.split();
351
358
let (mut bob_send, mut bob_recv) = bob.split();
352
359
353
-
// Have to be synchronised on both ends, so the counter state matches between the two
354
-
// and thus messages can be encrypted/decrypted statefully. But the actual number is
355
-
// "random", making it harder to guess the position state.
356
-
assert_eq!(alice.client, bob.client);
357
-
assert_eq!(alice.server, bob.server);
358
-
assert_ne!(alice.client, alice.server);
359
-
assert_ne!(bob.client, bob.server);
360
-
361
360
let orig = b"Test Message, Please ignore.";
362
361
363
362
let mut msg = orig.to_vec();
History
18 rounds
0 comments
1 commit
expand
collapse
Sachy's crypto scheme lmao
2/2 success
expand
collapse
expand 0 comments
pull request successfully merged
1 commit
expand
collapse
Sachy's crypto scheme lmao
1/2 failed, 1/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
1/2 failed, 1/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
2/2 success
expand
collapse
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