<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CryptoKit",
  "identifier" : "/documentation/CryptoKit/HMAC/isValidAuthenticationCode(_:authenticating:using:)-8ezmw",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Apple CryptoKit"
    ],
    "preciseIdentifier" : "s:9CryptoKit4HMACV25isValidAuthenticationCode_14authenticating5usingSbAA06HashedfG0VyxG_qd__AA12SymmetricKeyVt10Foundation12DataProtocolRd__lFZ"
  },
  "title" : "isValidAuthenticationCode(_:authenticating:using:)"
}
-->

# isValidAuthenticationCode(_:authenticating:using:)

Returns a Boolean value indicating whether the given message
authentication code is valid for a block of data.

```
static func isValidAuthenticationCode<D>(_ authenticationCode: HMAC<H>.MAC, authenticating authenticatedData: D, using key: SymmetricKey) -> Bool where D : DataProtocol
```

## Parameters

`authenticationCode`

The authentication code to compare.

`authenticatedData`

The block of data to compare.

`key`

The symmetric key for the authentication code.

## Return Value

A Boolean value that’s `true` if the message authentication
code is valid for the specified block of data.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)