SodiumKeyDerivation
struct SodiumKeyDerivation
A wrapper for key derivation.
-
The initializer is disabled.
Declaration
Swift
fileprivate init() -
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
pointerThe memory region where the key will be stored.
-
Derive a sub key from a given master key.
Precondition
precondition:
minimumSubKeySizeInBytes≤subKeySizeInBytes≤maximumSubKeySizeInBytescontext.count=contextSizeInBytes- size of
masterKey=masterKeySizeInBytes
Declaration
Swift
func derive(subKey: UnsafeMutablePointer<UInt8>, subKeySizeInBytes: Int, subKeyId: UInt64, context: Bytes, masterKey: UnsafePointer<UInt8>)Parameters
subKeyThe memory region where the sub key should be stored.
subKeySizeInBytesThe size of
subKeyin bytes.subKeyIdThe ID of the sub key.
contextA context.
masterKeyThe master key.
View on GitHub
SodiumKeyDerivation Structure Reference