DerivedKey

public class DerivedKey : KeyMaterial

A key that is derived from a Password.

A derived key contains additional information, i.e., the parameters used to derive the key. In order to derive the same key from the password, the same parameters have to be used.

  • Minimum size of the derived key in bytes.

    Declaration

    Swift

    public static let MinimumSizeInBytes: UInt32
  • Maximum size of the derived key in bytes.

    Declaration

    Swift

    public static let MaximumSizeInBytes: UInt32
  • Size of the public parameters, serialized to a byte array.

    Declaration

    Swift

    public static let SizeOfPublicParametersInBytes: UInt32
  • The salt used for deriving the key.

    Declaration

    Swift

    let salt: Salt
  • The complexity limit used for deriving the key.

    Declaration

    Swift

    let complexityLimit: ComplexityLimit
  • The memory limit used for deriving the key.

    Declaration

    Swift

    let memoryLimit: MemoryLimit
  • A byte array containing all the parameters required to derive the same key for the given password.

    Declaration

    Swift

    public var publicParameters: Bytes { get }
  • Extract the public parameters from a byte array. The size of the byte array has to be at least SizeOfPublicParametersInBytes. The public parameters are extracted from the beginning of the byte array.

    Declaration

    Swift

    public static func extractPublicParameters(bytes: Bytes) -> (Salt, ComplexityLimit, MemoryLimit)?

    Parameters

    bytes

    An array containing serialized public parameters at the beginning.

    Return Value

    A tuple consisting of the salt, the complexity limit, and the memory limit used for deriving the key. nil is returned if the byte sequence cannot be deserialized.

  • Construct a derived key with an expected size. The actual key is not initialized, but the public parameters are stored already.

    This is used if the parameters are known, but the key has not been derived, yet.

    Declaration

    Swift

    fileprivate init?(sizeInBytes: UInt32, salt: Salt, complexityLimit: ComplexityLimit, memoryLimit: MemoryLimit)

    Parameters

    sizeInBytes

    The size of the derived key in bytes.

    salt

    The salt that will be used for deriving the key.

    complexityLimit

    The complexity limit that will be used for deriving the key.

    memoryLimit

    The memory limit that will be used for deriving the key.

    Return Value

    nil if the size of the key is invalid.