Skip to content

Commit 84c9909

Browse files
Gabor MihalyGabor Mihaly
authored andcommitted
Update AuthenticatorAssertionResponse.cs
AssertionResponse: UserPresent flag is must have unless we are in conformance testing
1 parent 9775832 commit 84c9909

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Src/Fido2/AuthenticatorAssertionResponse.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,18 @@ public async Task<VerifyAssertionResult> VerifyAsync(
122122
var rpid = Raw.Extensions?.AppID ?? false ? options.Extensions?.GetAppID() : options.RpId;
123123
byte[] hashedRpId = CryptoUtils.HashData(HashAlgorithmName.SHA256, Encoding.UTF8.GetBytes(rpid ?? string.Empty));
124124
byte[] hash = CryptoUtils.HashData(HashAlgorithmName.SHA256, Raw.Response.ClientDataJson);
125+
bool conformanceTesting = metadataService != null && metadataService.ConformanceTesting();
125126

126127
if (!authData.RpIdHash.SequenceEqual(hashedRpId))
127128
throw new Fido2VerificationException(Fido2ErrorCode.InvalidRpidHash, Fido2ErrorMessages.InvalidRpidHash);
128129

129-
if (options.UserVerification is UserVerificationRequirement.Required)
130-
{
131-
// 14. Verify that the UP bit of the flags in authData is set.
132-
if (!authData.UserPresent)
133-
throw new Fido2VerificationException(Fido2ErrorCode.UserPresentFlagNotSet, Fido2ErrorMessages.UserPresentFlagNotSet);
130+
// 14. Verify that the UP bit of the flags in authData is set.
131+
if (!authData.UserPresent && (!conformanceTesting || options.UserVerification is UserVerificationRequirement.Required))
132+
throw new Fido2VerificationException(Fido2ErrorCode.UserPresentFlagNotSet, Fido2ErrorMessages.UserPresentFlagNotSet);
134133

135-
// 15. If the Relying Party requires user verification for this assertion, verify that the UV bit of the flags in authData is set.
136-
if (!authData.UserVerified)
137-
throw new Fido2VerificationException(Fido2ErrorCode.UserVerificationRequirementNotMet, Fido2ErrorMessages.UserVerificationRequirementNotMet);
138-
}
134+
// 15. If the Relying Party requires user verification for this assertion, verify that the UV bit of the flags in authData is set.
135+
if (options.UserVerification is UserVerificationRequirement.Required && !authData.UserVerified)
136+
throw new Fido2VerificationException(Fido2ErrorCode.UserVerificationRequirementNotMet, Fido2ErrorMessages.UserVerificationRequirementNotMet);
139137

140138
// 16. If the credential backup state is used as part of Relying Party business logic or policy, let currentBe and currentBs be the values of the BE and BS bits, respectively, of the flags in authData.
141139
// Compare currentBe and currentBs with credentialRecord.BE and credentialRecord.BS and apply Relying Party policy, if any.

0 commit comments

Comments
 (0)