Client

public class Client<H> where H : HashFunction

SRP Client; the party that initializes the authentication and must proof possession of the correct password.

  • a

    Undocumented

    Declaration

    Swift

    let a: BigUInt
  • A

    Undocumented

    Declaration

    Swift

    let A: BigUInt
  • Undocumented

    Declaration

    Swift

    let group: Group
  • Undocumented

    Declaration

    Swift

    typealias impl = Implementation<H>
  • Undocumented

    Declaration

    Swift

    let username: String
  • Undocumented

    Declaration

    Swift

    var password: String?
  • Undocumented

    Declaration

    Swift

    var precomputedX: BigUInt?
  • Undocumented

    Declaration

    Swift

    var HAMK: Data?
  • K

    Undocumented

    Declaration

    Swift

    var K: Data?
  • Whether the session is authenticated, i.e. the password was verified by the server and proof of a valid session key was provided by the server. If true, sessionKey is also available.

    Declaration

    Swift

    public private(set) var isAuthenticated: Bool { get }
  • Initialize the Client SRP party with a password.

    Declaration

    Swift

    public convenience init(
        username: String,
        password: String,
        group: Group = .N3072,
        privateKey: Data? = nil)

    Parameters

    username

    user’s username.

    password

    user’s password.

    group

    which Group to use, must be the same for the server as well as the pre-stored verificationKey.

    privateKey

    (optional) custom private key (a); if providing the private key of the Client, make sure to provide a good random key of at least 32 bytes. Default is to generate a private key of 128 bytes. You MUST not re-use the private key between sessions.

  • Initialize the Client SRP party with a precomputed x.

    Declaration

    Swift

    public convenience init(
        username: String,
        precomputedX: Data,
        group: Group = .N3072,
        privateKey: Data? = nil)

    Parameters

    username

    user’s username.

    precomputedX

    precomputed SRP x.

    group

    which Group to use, must be the same for the server as well as the pre-stored verificationKey.

    privateKey

    (optional) custom private key (a); if providing the private key of the Client, make sure to provide a good random key of at least 32 bytes. Default is to generate a private key of 128 bytes. You MUST not re-use the private key between sessions.

  • Starts authentication. This method is a no-op.

    Declaration

    Swift

    public func startAuthentication() -> (username: String, publicKey: Data)

    Return Value

    username (I) and publicKey (A)

  • Process the challenge provided by the server. This sets the sessionKey and generates proof that it generated the correct key from the password and the challenge. After the server has also proven the validity of their key, the sessionKey can be used.

    Throws

    AuthenticationFailure.invalidPublicKey if the server’s public key is invalid (i.e. B % N is zero).

    Declaration

    Swift

    public func processChallenge(salt: Data, publicKey serverPublicKey: Data) throws -> (clientVerify: Data, sessionKey: SymmetricKey)

    Parameters

    salt

    user-specific salt (s)

    publicKey

    server’s public key (B)

    Return Value

    key proof (M)

  • After the server has verified that the password is correct, it will send proof of the derived session key. This is verified on our end and finalizes the authentication session. After this step, the sessionKey is available.

    Throws

    Declaration

    Swift

    public func verifySession(keyProof serverKeyProof: Data) throws

    Parameters

    HAMK

    proof of the server that it derived the same session key.

  • The client’s public key (A). For every authentication session a new public key is generated.

    Declaration

    Swift

    public var publicKey: Data { get }
  • The client’s private key (a). For every authentication session a new random private key is generated.

    Declaration

    Swift

    public var privateKey: Data { get }
  • The session key (K) that is exchanged during authentication. This key can be used to encrypt further communication between client and server.

    Declaration

    Swift

    public var sessionKey: Data? { get }