From 0bed677e5e1d7153546acfab26a0ce6f5feec755 Mon Sep 17 00:00:00 2001 From: joegoldman674 <147369450+joegoldman2@users.noreply.github.com> Date: Mon, 9 Oct 2023 06:33:57 +0000 Subject: [PATCH 1/3] Move CredentialMakeResult to Fido2NetLib.Objects namespace --- .../Objects/CredentialMakeResult.cs | 26 +++++++++++++++++++ Src/Fido2/Fido2.cs | 17 ------------ Src/Fido2/IFido2.cs | 2 +- Test/Attestation/None.cs | 2 +- Test/Attestation/Packed.cs | 2 +- Test/Fido2Tests.cs | 2 +- 6 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 Src/Fido2.Models/Objects/CredentialMakeResult.cs diff --git a/Src/Fido2.Models/Objects/CredentialMakeResult.cs b/Src/Fido2.Models/Objects/CredentialMakeResult.cs new file mode 100644 index 00000000..dca6f8d2 --- /dev/null +++ b/Src/Fido2.Models/Objects/CredentialMakeResult.cs @@ -0,0 +1,26 @@ +#nullable enable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Fido2NetLib.Objects; + +/// +/// Result of parsing and verifying attestation. Used to transport Public Key back to RP +/// +public sealed class CredentialMakeResult : Fido2ResponseBase +{ + public CredentialMakeResult(string status, string errorMessage, RegisteredPublicKeyCredential? result) + { + Status = status; + ErrorMessage = errorMessage; + Result = result; + } + + public RegisteredPublicKeyCredential? Result { get; } + + // todo: add debuginfo? +} diff --git a/Src/Fido2/Fido2.cs b/Src/Fido2/Fido2.cs index c8e1585b..829acc3d 100644 --- a/Src/Fido2/Fido2.cs +++ b/Src/Fido2/Fido2.cs @@ -119,23 +119,6 @@ public async Task MakeAssertionAsync( return result; } - - /// - /// Result of parsing and verifying attestation. Used to transport Public Key back to RP - /// - public sealed class CredentialMakeResult : Fido2ResponseBase - { - public CredentialMakeResult(string status, string errorMessage, RegisteredPublicKeyCredential? result) - { - Status = status; - ErrorMessage = errorMessage; - Result = result; - } - - public RegisteredPublicKeyCredential? Result { get; } - - // todo: add debuginfo? - } } /// diff --git a/Src/Fido2/IFido2.cs b/Src/Fido2/IFido2.cs index d49233cb..d4cb51f4 100644 --- a/Src/Fido2/IFido2.cs +++ b/Src/Fido2/IFido2.cs @@ -22,7 +22,7 @@ Task MakeAssertionAsync( IsUserHandleOwnerOfCredentialIdAsync isUserHandleOwnerOfCredentialIdCallback, CancellationToken cancellationToken = default); - Task MakeNewCredentialAsync( + Task MakeNewCredentialAsync( AuthenticatorAttestationRawResponse attestationResponse, CredentialCreateOptions origChallenge, IsCredentialIdUniqueToUserAsyncDelegate isCredentialIdUniqueToUser, diff --git a/Test/Attestation/None.cs b/Test/Attestation/None.cs index d8e509ca..7f74aaad 100644 --- a/Test/Attestation/None.cs +++ b/Test/Attestation/None.cs @@ -25,7 +25,7 @@ public async Task TestNone() _attestationObject.Add("attStmt", new CborMap()); _credentialPublicKey = Fido2Tests.MakeCredentialPublicKey((keyType, alg, crv)); - Fido2.CredentialMakeResult res; + CredentialMakeResult res; res = await MakeAttestationResponseAsync(); diff --git a/Test/Attestation/Packed.cs b/Test/Attestation/Packed.cs index 28195bc4..c987881a 100644 --- a/Test/Attestation/Packed.cs +++ b/Test/Attestation/Packed.cs @@ -202,7 +202,7 @@ public async Task TestFull() DateTimeOffset notAfter = notBefore.AddDays(2); var attDN = new X500DistinguishedName("CN=Testing, OU=Authenticator Attestation, O=FIDO2-NET-LIB, C=US"); - Fido2.CredentialMakeResult res = null; + CredentialMakeResult res = null; switch (type) { diff --git a/Test/Fido2Tests.cs b/Test/Fido2Tests.cs index 3bc5ed99..d1652b81 100644 --- a/Test/Fido2Tests.cs +++ b/Test/Fido2Tests.cs @@ -150,7 +150,7 @@ public Attestation() idFidoGenCeAaGuidExt = new X509Extension(oidIdFidoGenCeAaGuid, _asnEncodedAaguid, false); } - public async Task MakeAttestationResponseAsync() + public async Task MakeAttestationResponseAsync() { _attestationObject.Set("authData", new CborByteString(_authData.ToByteArray())); From 175eb3314ff65ed4224cf837cb4f4b17ae9b8b1a Mon Sep 17 00:00:00 2001 From: joegoldman674 <147369450+joegoldman2@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:53:09 +0000 Subject: [PATCH 2/3] Rename CredentialMakeResult to MakeNewCredentialResult --- Demo/Controller.cs | 2 +- .../{CredentialMakeResult.cs => MakeNewCredentialResult.cs} | 4 ++-- Src/Fido2/Fido2.cs | 4 ++-- Src/Fido2/IFido2.cs | 2 +- Test/Attestation/None.cs | 2 +- Test/Attestation/Packed.cs | 2 +- Test/Fido2Tests.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename Src/Fido2.Models/Objects/{CredentialMakeResult.cs => MakeNewCredentialResult.cs} (73%) diff --git a/Demo/Controller.cs b/Demo/Controller.cs index 103f50f9..f4ee83ca 100644 --- a/Demo/Controller.cs +++ b/Demo/Controller.cs @@ -140,7 +140,7 @@ public async Task MakeCredential([FromBody] AuthenticatorAttestation } catch (Exception e) { - return Json(new CredentialMakeResult(status: "error", errorMessage: FormatException(e), result: null)); + return Json(new MakeNewCredentialResult(status: "error", errorMessage: FormatException(e), result: null)); } } diff --git a/Src/Fido2.Models/Objects/CredentialMakeResult.cs b/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs similarity index 73% rename from Src/Fido2.Models/Objects/CredentialMakeResult.cs rename to Src/Fido2.Models/Objects/MakeNewCredentialResult.cs index dca6f8d2..ea9a6f55 100644 --- a/Src/Fido2.Models/Objects/CredentialMakeResult.cs +++ b/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs @@ -11,9 +11,9 @@ namespace Fido2NetLib.Objects; /// /// Result of parsing and verifying attestation. Used to transport Public Key back to RP /// -public sealed class CredentialMakeResult : Fido2ResponseBase +public sealed class MakeNewCredentialResult : Fido2ResponseBase { - public CredentialMakeResult(string status, string errorMessage, RegisteredPublicKeyCredential? result) + public MakeNewCredentialResult(string status, string errorMessage, RegisteredPublicKeyCredential? result) { Status = status; ErrorMessage = errorMessage; diff --git a/Src/Fido2/Fido2.cs b/Src/Fido2/Fido2.cs index 829acc3d..11e76d0a 100644 --- a/Src/Fido2/Fido2.cs +++ b/Src/Fido2/Fido2.cs @@ -62,7 +62,7 @@ public CredentialCreateOptions RequestNewCredential( /// /// /// - public async Task MakeNewCredentialAsync( + public async Task MakeNewCredentialAsync( AuthenticatorAttestationRawResponse attestationResponse, CredentialCreateOptions origChallenge, IsCredentialIdUniqueToUserAsyncDelegate isCredentialIdUniqueToUser, @@ -72,7 +72,7 @@ public async Task MakeNewCredentialAsync( var success = await parsedResponse.VerifyAsync(origChallenge, _config, isCredentialIdUniqueToUser, _metadataService, cancellationToken); // todo: Set Errormessage etc. - return new CredentialMakeResult( + return new MakeNewCredentialResult( status: "ok", errorMessage: string.Empty, result: success diff --git a/Src/Fido2/IFido2.cs b/Src/Fido2/IFido2.cs index d4cb51f4..585dc12a 100644 --- a/Src/Fido2/IFido2.cs +++ b/Src/Fido2/IFido2.cs @@ -22,7 +22,7 @@ Task MakeAssertionAsync( IsUserHandleOwnerOfCredentialIdAsync isUserHandleOwnerOfCredentialIdCallback, CancellationToken cancellationToken = default); - Task MakeNewCredentialAsync( + Task MakeNewCredentialAsync( AuthenticatorAttestationRawResponse attestationResponse, CredentialCreateOptions origChallenge, IsCredentialIdUniqueToUserAsyncDelegate isCredentialIdUniqueToUser, diff --git a/Test/Attestation/None.cs b/Test/Attestation/None.cs index 7f74aaad..9ee39ea9 100644 --- a/Test/Attestation/None.cs +++ b/Test/Attestation/None.cs @@ -25,7 +25,7 @@ public async Task TestNone() _attestationObject.Add("attStmt", new CborMap()); _credentialPublicKey = Fido2Tests.MakeCredentialPublicKey((keyType, alg, crv)); - CredentialMakeResult res; + MakeNewCredentialResult res; res = await MakeAttestationResponseAsync(); diff --git a/Test/Attestation/Packed.cs b/Test/Attestation/Packed.cs index c987881a..e48d62fb 100644 --- a/Test/Attestation/Packed.cs +++ b/Test/Attestation/Packed.cs @@ -202,7 +202,7 @@ public async Task TestFull() DateTimeOffset notAfter = notBefore.AddDays(2); var attDN = new X500DistinguishedName("CN=Testing, OU=Authenticator Attestation, O=FIDO2-NET-LIB, C=US"); - CredentialMakeResult res = null; + MakeNewCredentialResult res = null; switch (type) { diff --git a/Test/Fido2Tests.cs b/Test/Fido2Tests.cs index d1652b81..b7bfc7a0 100644 --- a/Test/Fido2Tests.cs +++ b/Test/Fido2Tests.cs @@ -150,7 +150,7 @@ public Attestation() idFidoGenCeAaGuidExt = new X509Extension(oidIdFidoGenCeAaGuid, _asnEncodedAaguid, false); } - public async Task MakeAttestationResponseAsync() + public async Task MakeAttestationResponseAsync() { _attestationObject.Set("authData", new CborByteString(_authData.ToByteArray())); From ad4765107fa85b41cbb3b5a7d7a02a0d16dbcfdd Mon Sep 17 00:00:00 2001 From: joegoldman674 <147369450+joegoldman2@users.noreply.github.com> Date: Mon, 23 Oct 2023 07:21:13 -0700 Subject: [PATCH 3/3] Remove unnecessary usings --- Src/Fido2.Models/Objects/MakeNewCredentialResult.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs b/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs index ea9a6f55..0fbf3c21 100644 --- a/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs +++ b/Src/Fido2.Models/Objects/MakeNewCredentialResult.cs @@ -1,11 +1,5 @@ #nullable enable -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Fido2NetLib.Objects; ///