Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ struct ParsedAuthenticatorAssertionResponse: Sendable {
relyingPartyOrigin: relyingPartyOrigin
)

guard let expectedRelyingPartyIDData = relyingPartyID.data(using: .utf8) else {
throw WebAuthnError.invalidRelyingPartyID
}
let expectedRelyingPartyIDData = Data(relyingPartyID.utf8)
let expectedRelyingPartyIDHash = SHA256.hash(data: expectedRelyingPartyIDData)
guard expectedRelyingPartyIDHash == authenticatorData.relyingPartyIDHash else {
throw WebAuthnError.relyingPartyIDHashDoesNotMatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct AttestationObject: Sendable {
supportedPublicKeyAlgorithms: [PublicKeyCredentialParameters],
pemRootCertificatesByFormat: [AttestationFormat: [Data]] = [:]
) async throws -> AttestedCredentialData {
let relyingPartyIDHash = SHA256.hash(data: relyingPartyID.data(using: .utf8)!)
let relyingPartyIDHash = SHA256.hash(data: Data(relyingPartyID.utf8))

guard relyingPartyIDHash == authenticatorData.relyingPartyIDHash else {
throw WebAuthnError.relyingPartyIDHashDoesNotMatch
Expand Down
2 changes: 0 additions & 2 deletions Sources/WebAuthn/WebAuthnError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public struct WebAuthnError: Error, Hashable, Sendable {
case invalidUserID
case unsupportedCredentialPublicKeyAlgorithm
case credentialIDAlreadyExists
case invalidRelyingPartyID
case userVerifiedFlagNotSet
case potentialReplayAttack
case invalidAssertionCredentialType
Expand Down Expand Up @@ -90,7 +89,6 @@ public struct WebAuthnError: Error, Hashable, Sendable {
public static let invalidUserID = Self(reason: .invalidUserID)
public static let unsupportedCredentialPublicKeyAlgorithm = Self(reason: .unsupportedCredentialPublicKeyAlgorithm)
public static let credentialIDAlreadyExists = Self(reason: .credentialIDAlreadyExists)
public static let invalidRelyingPartyID = Self(reason: .invalidRelyingPartyID)
public static let userVerifiedFlagNotSet = Self(reason: .userVerifiedFlagNotSet)
public static let potentialReplayAttack = Self(reason: .potentialReplayAttack)
public static let invalidAssertionCredentialType = Self(reason: .invalidAssertionCredentialType)
Expand Down
2 changes: 1 addition & 1 deletion Tests/WebAuthnTests/Utils/TestModels/TestAuthData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct TestAuthDataBuilder {
}

func relyingPartyIDHash(fromRelyingPartyID relyingPartyID: String) -> Self {
let relyingPartyIDData = relyingPartyID.data(using: .utf8)!
let relyingPartyIDData = Data(relyingPartyID.utf8)
let relyingPartyIDHash = SHA256.hash(data: relyingPartyIDData)
var temp = self
temp.wrapped.relyingPartyIDHash = [UInt8](relyingPartyIDHash)
Expand Down
Loading