SodiumKeyDerivation
struct SodiumKeyDerivation
A wrapper for key derivation.
-
The size of the master key in bytes.
Declaration
Swift
let masterKeySizeInBytes: Int
-
The size of a sub key context in bytes.
Declaration
Swift
let contextSizeInBytes: Int
-
The minimum size of a derived key in bytes.
Declaration
Swift
let minimumSubKeySizeInBytes: Int
-
The maximum size of a derived key in bytes.
Declaration
Swift
let maximumSubKeySizeInBytes: Int
-
Generate a master key.
Declaration
Swift
func keygen(_ pointer: UnsafeMutablePointer<UInt8>)
Parameters
pointer
The memory region where the key will be stored.
-
Derive a sub key from a given master key.
Precondition
precondition:
minimumSubKeySizeInBytes
≤subKeySizeInBytes
≤maximumSubKeySizeInBytes
context.count
=contextSizeInBytes
- size of
masterKey
=masterKeySizeInBytes
Declaration
Swift
func derive(subKey: UnsafeMutablePointer<UInt8>, subKeySizeInBytes: Int, subKeyId: UInt64, context: Bytes, masterKey: UnsafePointer<UInt8>)
Parameters
subKey
The memory region where the sub key should be stored.
subKeySizeInBytes
The size of
subKey
in bytes.subKeyId
The ID of the sub key.
context
A context.
masterKey
The master key.