AuthenticationCode

public class AuthenticationCode : KeyMaterial

This class represents a message authentication code to verify the integrity of encrypted messages.

  • The size of the authentication code in bytes.

    Declaration

    Swift

    public static let SizeInBytes: UInt32
  • Restore a authentication code from a byte array. Authentication codes are generated when encrypting a message. This initializer is for restoring an authentication code if it was persisted. The byte array is copied to a secure location and overwritten with zeroes to avoid the authentication code being compromised in memory. The authentication code itself is not a secret value, but access in other contexts is not necessary.

    Declaration

    Swift

    public override init?(bytes: inout Bytes)

    Parameters

    bytes

    The message authentication code.

  • Compares two message authentication codes in constant time.

    Declaration

    Swift

    public static func == (lhs: SecretBox.AuthenticationCode, rhs: SecretBox.AuthenticationCode) -> Bool

    Parameters

    lhs

    A message authentication code.

    rhs

    Another message authentication code.

    Return Value

    true if both message authentication codes are equal.