HKDF
public struct HKDF<H> where H : HashFunction
The HMAC-based Extract-and-Expand Key Derivation Function (IETF RFC 5869) https://tools.ietf.org/html/rfc5869
-
Derives a symmetric key using the HKDF algorithm.
Declaration
Swift
public static func deriveKey<Salt: DataProtocol, Info: DataProtocol>(inputKeyMaterial: SymmetricKey, salt: Salt, info: Info, outputByteCount: Int) -> SymmetricKeyParameters
inputKeyMaterialInput key material.
saltA non-secret random value.
infoContext and application specific information.
outputByteCountThe desired number of output bytes.
Return Value
The derived key
-
Derives a symmetric key using the HKDF algorithm.
Declaration
Swift
public static func deriveKey<Info: DataProtocol>(inputKeyMaterial: SymmetricKey, info: Info, outputByteCount: Int) -> SymmetricKeyParameters
inputKeyMaterialInput key material.
infoContext and application specific information.
outputByteCountThe desired number of output bytes.
Return Value
The derived key
-
Derives a symmetric key using the HKDF algorithm.
Declaration
Swift
public static func deriveKey<Salt: DataProtocol>(inputKeyMaterial: SymmetricKey, salt: Salt, outputByteCount: Int) -> SymmetricKeyParameters
inputKeyMaterialInput key material.
saltA non-secret random value.
outputByteCountThe desired number of output bytes.
Return Value
The derived key
-
Derives a symmetric key using the HKDF algorithm.
Declaration
Swift
public static func deriveKey(inputKeyMaterial: SymmetricKey, outputByteCount: Int) -> SymmetricKeyParameters
inputKeyMaterialInput key material.
outputByteCountThe desired number of output bytes.
Return Value
The derived key
-
The extract function as defined by specification. The goal of the extract function is to “concentrate” the possibly dispersed entropy of the input keying material into a short, but cryptographically strong, pseudorandom key. Unless required by a specification, it is recommended to use the one-shot “deriveKey” API instead that performs both extraction and expansion.
Declaration
Swift
public static func extract<Salt>(inputKeyMaterial: SymmetricKey, salt: Salt?) -> HashedAuthenticationCode<H> where Salt : DataProtocolParameters
inputKeyMaterialInput key material.
saltA non-secret random value.
Return Value
The resulting secret
-
The expand function as defined by the specification. The goal of the expand function is to expand the pseudorandom key to the desired length. Unless required by a specification, it is recommended to use the one-shot “deriveKey” API instead that performs both extraction and expansion.
Declaration
Swift
public static func expand<PRK, Info>(pseudoRandomKey prk: PRK, info: Info?, outputByteCount: Int) -> SymmetricKey where PRK : ContiguousBytes, Info : DataProtocolParameters
pseudoRandomKeyThe extracted pseudorandom key. This value is expected to be a high-entropy secret. In the HKDF specification it is obtained from the input key material and the salt using the extract method.
infoContext and application specific information.
outputByteCountThe desired number of output bytes.
Return Value
The expanded key bytes.
View on GitHub
Install in Dash
HKDF Structure Reference