Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedicated AAGUID Type #58

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

dimitribouniol
Copy link
Collaborator

As I was implementing the client, I found it useful to have a type for Authenticator Attestation Globally Unique IDs (AAGUIDs) since AAGUIDs are defined as 16-byte IDs, which prevents passing in the wrong-sized values. Internally, I have this wrapping a UUID since they are conceptually similar. Some questions before we consider merging this though:

  • The name: AuthenticatorAttestationGloballyUniqueID is clearly more descriptive, though AAGUID is defined as a type alias. Similarly, the property names are now spelled out, but I kept aaguid for things like local variables.
  • Codable for this type falls back to the UUID representation (hex string with dashes), but I can see base64-urlencoded or straight hex as equally good alternatives. This is Codable because AttestedCredentialData (and by extension AuthenticatorData) are, but not sure they need to be since authenticator data is represented in a binary form.

As a follow-up, would love to extend this to other bag-of-byte types like CredentialID.

@dimitribouniol dimitribouniol force-pushed the dimitri/aaguid branch 6 times, most recently from 4549f3d to a98ef3a Compare March 29, 2024 12:59
@@ -14,7 +14,7 @@

// Contains the new public key created by the authenticator.
struct AttestedCredentialData: Equatable {
let aaguid: [UInt8]
let authenticatorAttestationGloballyUniqueID: AAGUID
Copy link
Member

Choose a reason for hiding this comment

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

I would say GUID is a well enough understood term that we can use it here without causing confusion - wdyt?

Suggested change
let authenticatorAttestationGloballyUniqueID: AAGUID
let authenticatorAttestationGUID: AAGUID

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

///
/// The Relying Party MAY use the AAGUID to infer certain properties of the authenticator, such as certification level and strength of key protection, using information from other sources. The Relying Party MAY use the AAGUID to attempt to identify the maker of the authenticator without requesting and verifying attestation, but the AAGUID is not provably authentic without attestation.
/// - SeeAlso: [WebAuthn Leven 3 Editor's Draft §6. WebAuthn Authenticator Model](https://w3c.github.io/webauthn/#aaguid)
public struct AuthenticatorAttestationGloballyUniqueID: Hashable {
Copy link
Member

Choose a reason for hiding this comment

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

Given #64

Suggested change
public struct AuthenticatorAttestationGloballyUniqueID: Hashable {
public struct AuthenticatorAttestationGloballyUniqueID: Hashable, Sendable {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Sources/WebAuthn/Helpers/ByteCasting.swift Show resolved Hide resolved
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

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

One nit then LGTM

public var bytes: [UInt8] { withUnsafeBytes(of: id) { Array($0) } }

/// The identifier of an anonymized authenticator, set to a byte sequence of 16 zeros.
public static let anonymous = AuthenticatorAttestationGloballyUniqueID(bytes: Array(repeating: 0, count: 16))!
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
public static let anonymous = AuthenticatorAttestationGloballyUniqueID(bytes: Array(repeating: 0, count: 16))!
public static let anonymous = AuthenticatorAttestationGloballyUniqueID(bytes: Array(repeating: 0, count: Self.size))!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, fixed!

@dimitribouniol dimitribouniol merged commit a706351 into swift-server:main Sep 10, 2024
4 checks passed
@dimitribouniol dimitribouniol deleted the dimitri/aaguid branch September 10, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants