From ef7861180220c64aef79fbdda44b02e584445813 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Fri, 17 Feb 2023 22:17:02 +0100 Subject: rfc compliant client proof --- srp/src/utils.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'srp/src/utils.rs') diff --git a/srp/src/utils.rs b/srp/src/utils.rs index a9372bd..6eeb3a3 100644 --- a/srp/src/utils.rs +++ b/srp/src/utils.rs @@ -25,10 +25,25 @@ pub fn compute_k(params: &SrpGroup) -> BigUint { BigUint::from_bytes_be(d.finalize().as_slice()) } -// M1 = H(A, B, K) this doesn't follow the spec but apparently no one does for M1 -// M1 should equal = H(H(N) XOR H(g) | H(U) | s | A | B | K) according to the spec -pub fn compute_m1(a_pub: &[u8], b_pub: &[u8], key: &[u8]) -> Output { +// M1 = H(H(N) XOR H(g) | H(U) | s | A | B | K) +pub fn compute_m1( + params: &SrpGroup, + a_pub: &[u8], + b_pub: &[u8], + key: &[u8], +) -> Output { + let mut d_n = D::new(); + d_n.update(params.n.to_bytes_be()); + let h_n = d_n.finalize(); + + let mut d_g = D::new(); + d_g.update(params.g.to_bytes_be()); + let h_g = d_g.finalize(); + + let ng_xor: Vec = h_n.iter().zip(h_g.iter()).map(|(n, g)| n ^ g).collect(); + let mut d = D::new(); + d.update(ng_xor); d.update(a_pub); d.update(b_pub); d.update(key); -- cgit v1.2.3