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) -> SymmetricKey
Parameters
inputKeyMaterial
Input key material.
salt
A non-secret random value.
info
Context and application specific information.
outputByteCount
The 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) -> SymmetricKey
Parameters
inputKeyMaterial
Input key material.
info
Context and application specific information.
outputByteCount
The 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) -> SymmetricKey
Parameters
inputKeyMaterial
Input key material.
salt
A non-secret random value.
outputByteCount
The 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) -> SymmetricKey
Parameters
inputKeyMaterial
Input key material.
outputByteCount
The 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 : DataProtocol
Parameters
inputKeyMaterial
Input key material.
salt
A 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 : DataProtocol
Parameters
pseudoRandomKey
The 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.
info
Context and application specific information.
outputByteCount
The desired number of output bytes.
Return Value
The expanded key bytes.