HMAC
public struct HMAC<H> : MACAlgorithm where H : HashFunction
Performs HMAC - Keyed-Hashing for Message Authentication Reference: https://tools.ietf.org/html/rfc2104
-
Undocumented
Declaration
Swift
public typealias Key = SymmetricKey -
Undocumented
Declaration
Swift
public typealias MAC = HashedAuthenticationCode<H> -
Verifies a tag of a Message Authentication Code. The comparison is done in constant-time.
Declaration
Swift
public static func isValidAuthenticationCode(_ mac: MAC, authenticating bufferPointer: UnsafeRawBufferPointer, using key: SymmetricKey) -> BoolParameters
keyThe key used to authenticate the data
dataThe data to authenticate
macThe MAC to verify
Return Value
Returns true if the MAC is valid. False otherwise.
-
Initializes an incremental HMAC
Declaration
Swift
public init(key: SymmetricKey)Parameters
keyThe key to use for HMAC.
-
Computes a Message Authentication Code.
Declaration
Swift
public static func authenticationCode<D>(for data: D, using key: SymmetricKey) -> MAC where D : DataProtocolParameters
keyThe key used to authenticate the data
dataThe data to authenticate
Return Value
A Message Authentication Code
-
Verifies a Message Authentication Code. The comparison is done in constant-time.
Declaration
Swift
public static func isValidAuthenticationCode<D>(_ authenticationCode: MAC, authenticating authenticatedData: D, using key: SymmetricKey) -> Bool where D : DataProtocolParameters
authenticationCodeThe authentication code
authenticatedDataAuthenticated Data
keyThe key to authenticate the data with
Return Value
Returns true if the MAC is valid. False otherwise.
-
Verifies a Message Authentication Code. The comparison is done in constant-time.
Declaration
Swift
public static func isValidAuthenticationCode<C: ContiguousBytes, D: DataProtocol>(_ authenticationCode: C, authenticating authenticatedData: D, using key: SymmetricKey) -> BoolParameters
authenticationCodeThe authentication code
authenticatedDataAuthenticated Data
keyThe key to authenticate the data with
Return Value
Returns true if the MAC is valid. False otherwise.
-
Updates the MAC with data.
Declaration
Swift
public mutating func update<D>(data: D) where D : DataProtocolParameters
dataThe data to update the MAC
-
Returns the Message Authentication Code (MAC) from the data inputted into the MAC.
Throws
Throws if the MAC has already been finalizedDeclaration
Swift
public func finalize() -> MACReturn Value
The Message Authentication Code
View on GitHub
Install in Dash
HMAC Structure Reference