From 4bdc765c57c77a0d6dd65d78e72bb8e3d4b5fd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 9 May 2024 10:35:01 +0200 Subject: [PATCH] fixup! fixup! feat: Add an Elliptic Curve Encryption Scheme --- src/ecies/mod.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ecies/mod.rs b/src/ecies/mod.rs index 7ef27d90..dbf1647b 100644 --- a/src/ecies/mod.rs +++ b/src/ecies/mod.rs @@ -91,7 +91,7 @@ use crate::Curve25519PublicKey; mod messages; -const MATRIX_INFO_PREFIX: &str = "MATRIX_QR_CODE_LOGIN"; +const MATRIX_QR_LOGIN_INFO_PREFIX: &str = "MATRIX_QR_CODE_LOGIN"; type ApplicationInfo = String; @@ -99,11 +99,11 @@ fn get_check_code_info(info: &str) -> String { format!("{info}_CHECKCODE") } -fn get_encrytpion_key_g_info(info: &str) -> String { +fn get_encryption_key_g_info(info: &str) -> String { format!("{info}_ENCKEY_G") } -fn get_encrytpion_key_s_info(info: &str) -> String { +fn get_encryption_key_s_info(info: &str) -> String { format!("{info}_ENCKEY_S") } @@ -229,11 +229,11 @@ impl Ecies { /// Create a new, random, unestablished ECIES session. /// /// This method will use the `MATRIX_QR_CODE_LOGIN` info. If you are using - /// this for a different purpose consider using the [`Ecies::with_info()`] + /// this for a different purpose, consider using the [`Ecies::with_info()`] /// method. #[allow(clippy::new_without_default)] pub fn new() -> Self { - Self::with_info(MATRIX_INFO_PREFIX) + Self::with_info(MATRIX_QR_LOGIN_INFO_PREFIX) } /// Create a new, random, unestablished ECIES session with the given @@ -432,10 +432,10 @@ impl EstablishedEcies { ) -> Box<[u8; 32]> { let info = if initiator { // we are Device G - get_encrytpion_key_g_info(info) + get_encryption_key_g_info(info) } else { // we are Device S - get_encrytpion_key_s_info(info) + get_encryption_key_s_info(info) }; Self::create_key(&info, shared_secret, our_public_key, their_public_key, initiator) @@ -450,10 +450,10 @@ impl EstablishedEcies { ) -> Box<[u8; 32]> { let info = if initiator { // we are Device G, they are Device S - get_encrytpion_key_s_info(info) + get_encryption_key_s_info(info) } else { // we are Device S, they are Device G - get_encrytpion_key_g_info(info) + get_encryption_key_g_info(info) }; Self::create_key(&info, shared_secret, our_public_key, their_public_key, initiator) @@ -463,7 +463,7 @@ impl EstablishedEcies { shared_secret: &SharedSecret, our_public_key: Curve25519PublicKey, their_public_key: Curve25519PublicKey, - infos: ApplicationInfo, + info: ApplicationInfo, initiator: bool, ) -> Self { let (encryption_nonce, decryption_nonce) = (EciesNonce::new(), EciesNonce::new()); @@ -472,21 +472,21 @@ impl EstablishedEcies { shared_secret, our_public_key, their_public_key, - &infos, + &info, initiator, ); let decryption_key = Self::create_decryption_key( shared_secret, our_public_key, their_public_key, - &infos, + &info, initiator, ); let check_code = Self::create_check_code( shared_secret, our_public_key, their_public_key, - &infos, + &info, initiator, ); @@ -664,13 +664,13 @@ mod test { #[test] fn info_expansion() { - let info = get_check_code_info(MATRIX_INFO_PREFIX); + let info = get_check_code_info(MATRIX_QR_LOGIN_INFO_PREFIX); assert_eq!(info, "MATRIX_QR_CODE_LOGIN_CHECKCODE"); - let info = get_encrytpion_key_g_info(MATRIX_INFO_PREFIX); + let info = get_encryption_key_g_info(MATRIX_QR_LOGIN_INFO_PREFIX); assert_eq!(info, "MATRIX_QR_CODE_LOGIN_ENCKEY_G"); - let info = get_encrytpion_key_s_info(MATRIX_INFO_PREFIX); + let info = get_encryption_key_s_info(MATRIX_QR_LOGIN_INFO_PREFIX); assert_eq!(info, "MATRIX_QR_CODE_LOGIN_ENCKEY_S"); }