SodiumKeyExchange
struct SodiumKeyExchange
A wrapper for key exchange.
-
The initializer is disabled.
Declaration
Swift
fileprivate init()
-
The size of the secret key in bytes.
Declaration
Swift
let secretKeySizeInBytes: Int
-
The size of the session key in bytes.
Declaration
Swift
let sessionKeySizeInBytes: Int
-
The size of the public key in bytes.
Declaration
Swift
let publicKeySizeInBytes: Int
-
Generate a keypair that can be used for exchanging keys.
Declaration
Swift
func keypair(publicKeyPtr: UnsafeMutablePointer<UInt8>, secretKeyPtr: UnsafeMutablePointer<UInt8>)
Parameters
publicKeyPtr
The pointer to where the public key will be stored.
secretKeyPtr
The pointer to where the secret key will be stored.
-
Calculate session keys for the client side.
Declaration
Swift
func client_session_keys( rxPtr: UnsafeMutablePointer<UInt8>, txPtr: UnsafeMutablePointer<UInt8>, clientPk: UnsafePointer<UInt8>, clientSk: UnsafePointer<UInt8>, serverPk: UnsafePointer<UInt8> ) -> Int32
Parameters
rxPtr
A pointer to where the session key, that is used to receive data from the server, should be stored.
txPtr
A pointer to where the session key, that is used to send data to the server, should be stored.
clientPk
A pointer to the client’s public key.
clientSk
A pointer to the client’s secret key.
serverPk
A pointer to the server’s public key.
Return Value
0
on success and-1
ifserverPk
is not acceptible. -
Calculate session keys for the server side.
Declaration
Swift
func server_session_keys( rxPtr: UnsafeMutablePointer<UInt8>, txPtr: UnsafeMutablePointer<UInt8>, serverPk: UnsafePointer<UInt8>, serverSk: UnsafePointer<UInt8>, clientPk: UnsafePointer<UInt8> ) -> Int32
Parameters
rxPtr
A pointer to where the session key, that is used to receive data from the client, should be stored.
txPtr
A pointer to where the session key, that is used to sen data to the client, should be stored.
serverPk
A pointer to the server’s public key.
serverSk
A pointer to the server’s secret key.
clientPk
A pointer to the client’s public key.
Return Value
0
on success and-1
ifclientPk
is not acceptible.