Skip to content

Conversation

@Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Aug 4, 2025

Motivation

AES CMAC is a standardised albeit somewhat uncommon MAC built on top of the AES block cipher. CMAC pops up in a few places, mostly where it is convenient to assume that you have access to AES, but not to a hash function. For example, AES-SIV is built on CMAC.

Modifications

Add CMAC support
Add tests and test vectors

Result

CMAC is supported

Motivation

AES CMAC is a standardised albeit somewhat uncommon MAC
built on top of the AES block cipher. CMAC pops up in a
few places, mostly where it is convenient to assume that
you have access to AES, but not to a hash function. For
example, AES-SIV is built on CMAC.

Modifications

Add CMAC support
Add tests and test vectors

Result

CMAC is supported
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Aug 4, 2025
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two tiny things but LGTM otherwise


@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
extension AES {
public struct CMAC: @unchecked Sendable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a "why @unchecked is okay here" comment?

Comment on lines 57 to 58
/// - data: The data to be authenticated.
public mutating func update(bufferPointer: UnsafeRawBufferPointer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels don't line up here

@Lukasa Lukasa enabled auto-merge (squash) August 5, 2025 10:09
@Lukasa Lukasa merged commit 334e682 into apple:main Aug 5, 2025
43 checks passed
@Lukasa Lukasa deleted the cb-cmac branch August 5, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants