extern crate rand; extern crate sarkara; use rand::{ Rng, RngCore, FromEntropy, ChaChaRng }; use sarkara::aead::AeadCipher; use sarkara::kex::KeyExchange; use sarkara::sealedbox::SealedBox; use sarkara::kex::kyber::Kyber; use sarkara::aead::norx6441::Norx6441; fn test_sealedbox() { let mut rng = ChaChaRng::from_entropy(); let (bob_priv, bob_pub) = KEX::keypair(&mut rng); let (alice_msg, alice_enc) = SealedBox::::send(&mut rng, &bob_pub); let bob_dec = SealedBox::::recv(&bob_priv, &alice_msg); let mut nonce = vec![0u8; AE::NONCE_LENGTH]; let mut aad = vec![0u8; rng.gen_range(0, 34)]; let mut pt = vec![0u8; 32]; let mut ct = vec![0u8; pt.len() + AE::TAG_LENGTH]; let mut ot = vec![0u8; pt.len()]; rng.fill_bytes(&mut nonce); rng.fill_bytes(&mut aad); rng.fill_bytes(&mut pt); alice_enc.seal(&nonce, &aad, &pt, &mut ct).unwrap(); bob_dec.open(&nonce, &aad, &ct, &mut ot).unwrap(); assert_eq!(pt, ot); } #[test] fn test_kyber_norx() { test_sealedbox::(); }