Skip to content

Commit

Permalink
Renamed parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Oct 29, 2024
1 parent 9369b01 commit cd494c3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/SRP/client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public struct SRPClient<H: HashFunction> {
public func calculateServerProof(clientPublicKey: SRPKey, clientProof: [UInt8], sharedSecret: SRPKey) -> [UInt8] {
let hashSharedSecret = [UInt8](H.hash(data: sharedSecret.bytes(padding: configuration.sizeN)))
// get out version of server proof
return SRP<H>.calculateServerVerification(clientPublicKey: clientPublicKey, clientProof: clientProof, sharedSecret: hashSharedSecret, padding: configuration.sizeN)
return SRP<H>.calculateServerVerification(clientPublicKey: clientPublicKey, clientProof: clientProof, hashSharedSecret: hashSharedSecret, padding: configuration.sizeN)
}

/// If the server returns that the client verification code was valid it will also return a server
Expand Down
2 changes: 1 addition & 1 deletion Sources/SRP/server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ public struct SRPServer<H: HashFunction> {
padding: configuration.sizeN
)
guard clientProof == proof else { throw SRPServerError.invalidClientProof }
return SRP<H>.calculateServerVerification(clientPublicKey: clientPublicKey, clientProof: clientProof, sharedSecret: hashSharedSecret, padding: configuration.sizeN)
return SRP<H>.calculateServerVerification(clientPublicKey: clientPublicKey, clientProof: clientProof, hashSharedSecret: hashSharedSecret, padding: configuration.sizeN)
}
}
4 changes: 2 additions & 2 deletions Sources/SRP/srp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public struct SRP<H: HashFunction> {
}

/// Calculate server verification code H(A | M1 | K)
static func calculateServerVerification(clientPublicKey: SRPKey, clientProof: [UInt8], sharedSecret: [UInt8], padding: Int) -> [UInt8] {
let HAMK = H.hash(data: clientPublicKey.bytes(padding: padding) + clientProof + sharedSecret)
static func calculateServerVerification(clientPublicKey: SRPKey, clientProof: [UInt8], hashSharedSecret: [UInt8], padding: Int) -> [UInt8] {
let HAMK = H.hash(data: clientPublicKey.bytes(padding: padding) + clientProof + hashSharedSecret)
return [UInt8](HAMK)
}
}
2 changes: 1 addition & 1 deletion Tests/SRPTests/SRPTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final class SRPTests: XCTestCase {
let secret = "d89740e18a9fb597aef8f2ecc0e66f4b31c2ae08".bytes(using: .hexadecimal)!
let clientProof = "e1a8629a723039a61be91a173ab6260fc582192f".bytes(using: .hexadecimal)!

let serverProof = SRP<Insecure.SHA1>.calculateServerVerification(clientPublicKey: SRPKey(A), clientProof: clientProof, sharedSecret: secret, padding: 0)
let serverProof = SRP<Insecure.SHA1>.calculateServerVerification(clientPublicKey: SRPKey(A), clientProof: clientProof, hashSharedSecret: secret, padding: 0)

XCTAssertEqual(serverProof.hexdigest(), "8342bd06bdf4d263de2df9a56da8e581fb38c769")
}
Expand Down

0 comments on commit cd494c3

Please sign in to comment.