Fixing examples to use Sha512 with Ristretto instead of Sha256 (#122)

This commit is contained in:
Kevin Lewi
2021-01-26 13:17:15 -08:00
committed by GitHub
parent 6eeeb0db28
commit d6ace87c21
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -46,7 +46,7 @@ struct Default;
impl CipherSuite for Default { impl CipherSuite for Default {
type Group = curve25519_dalek::ristretto::RistrettoPoint; type Group = curve25519_dalek::ristretto::RistrettoPoint;
type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH;
type Hash = sha2::Sha256; type Hash = sha2::Sha512;
type SlowHash = opaque_ke::slow_hash::NoOpHash; type SlowHash = opaque_ke::slow_hash::NoOpHash;
} }
@@ -57,7 +57,7 @@ struct Locker {
// Given a key and plaintext, produce an AEAD ciphertext along with a nonce // Given a key and plaintext, produce an AEAD ciphertext along with a nonce
fn encrypt(key: &[u8], plaintext: &[u8]) -> Vec<u8> { fn encrypt(key: &[u8], plaintext: &[u8]) -> Vec<u8> {
let cipher = ChaCha20Poly1305::new(Key::from_slice(&key)); let cipher = ChaCha20Poly1305::new(Key::from_slice(&key[..32]));
let mut rng = OsRng; let mut rng = OsRng;
let mut nonce_bytes = [0u8; 12]; let mut nonce_bytes = [0u8; 12];
@@ -70,7 +70,7 @@ fn encrypt(key: &[u8], plaintext: &[u8]) -> Vec<u8> {
// Decrypt using a key and a ciphertext (nonce included) to recover the original plaintext // Decrypt using a key and a ciphertext (nonce included) to recover the original plaintext
fn decrypt(key: &[u8], ciphertext: &[u8]) -> Vec<u8> { fn decrypt(key: &[u8], ciphertext: &[u8]) -> Vec<u8> {
let cipher = ChaCha20Poly1305::new(Key::from_slice(&key)); let cipher = ChaCha20Poly1305::new(Key::from_slice(&key[..32]));
cipher cipher
.decrypt( .decrypt(
Nonce::from_slice(&ciphertext[..12]), Nonce::from_slice(&ciphertext[..12]),
+1 -1
View File
@@ -41,7 +41,7 @@ struct Default;
impl CipherSuite for Default { impl CipherSuite for Default {
type Group = curve25519_dalek::ristretto::RistrettoPoint; type Group = curve25519_dalek::ristretto::RistrettoPoint;
type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH;
type Hash = sha2::Sha256; type Hash = sha2::Sha512;
type SlowHash = opaque_ke::slow_hash::NoOpHash; type SlowHash = opaque_ke::slow_hash::NoOpHash;
} }