Functions
The following functions are available globally.
-
Undocumented
Declaration
Swift
func ^ (lhs: Data, rhs: Data) -> Data?
-
Undocumented
Declaration
Swift
func + (lhs: Data, rhs: Data) -> Data
-
Creates the salted verification key based on a user’s username and password. Only the salt and verification key need to be stored on the server, there’s no need to keep the plain-text password.
Keep the verification key private, as it can be used to brute-force the password from.
Declaration
Swift
public func createSaltedVerificationKey<H: HashFunction>( using hashFunction: H.Type, group: Group = .N2048, username: String, password: String, salt: Data? = nil) -> (salt: Data, verificationKey: Data)
Parameters
using
hash function to use
username
user’s username
password
user’s password
salt
(optional) custom salt value; if providing a salt, make sure to provide a good random salt of at least 16 bytes. Default is to generate a salt of 16 bytes.
group
Group
parameters; default is 2048-bits group.algorithm
which
Digest.Algorithm
to use; default is SHA1.Return Value
salt (s) and verification key (v)
-
Creates the salted verification key based on a precomputed SRP x value. Only the salt and verification key need to be stored on the server, there’s no need to keep the plain-text password.
Keep the verification key private, as it can be used to brute-force the password from.
Declaration
Swift
public func createSaltedVerificationKey( from x: Data, salt: Data? = nil, group: Group = .N2048) -> (salt: Data, verificationKey: Data)
Parameters
x
precomputed SRP x
salt
(optional) custom salt value; if providing a salt, make sure to provide a good random salt of at least 16 bytes. Default is to generate a salt of 16 bytes.
group
Group
parameters; default is 2048-bits group.Return Value
salt (s) and verification key (v)
-
Undocumented
Declaration
Swift
func pad(_ data: Data, to size: Int) -> Data
-
Undocumented
Declaration
Swift
func randomBytes(_ count: Int) -> Data