From 9468111ec05b2beceecb4726fdd5006907173319 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Wed, 30 Oct 2024 14:48:20 +0000 Subject: [PATCH] Use pad(to:) when padding `g` --- Sources/SRP/srp.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/SRP/srp.swift b/Sources/SRP/srp.swift index 44ef4a9..e6d7999 100644 --- a/Sources/SRP/srp.swift +++ b/Sources/SRP/srp.swift @@ -19,8 +19,7 @@ public struct SRP { hashSharedSecret: [UInt8] ) -> [UInt8] { // M = H(H(N)^ H(g)) | H(username) | salt | client key | server key | H(shared secret)) - let g = SRPKey(configuration.g, padding: configuration.sizeN) - let N_xor_g = [UInt8](H.hash(data: configuration.N.bytes)) ^ [UInt8](H.hash(data: g.bytes)) + let N_xor_g = [UInt8](H.hash(data: configuration.N.bytes)) ^ [UInt8](H.hash(data: configuration.g.bytes.pad(to: configuration.sizeN))) let hashUser = H.hash(data: [UInt8](username.utf8)) let M1 = [UInt8](N_xor_g) + hashUser + salt let M2 = clientPublicKey.bytes + serverPublicKey.bytes + hashSharedSecret