-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
132 changed files
with
13,876 additions
and
11,774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,4 +331,5 @@ ASALocalRun/ | |
/results | ||
/Test/coverage.netcoreapp3.1.cobertura.xml | ||
|
||
.DS_Store | ||
/testEnvironments.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
<Project> | ||
<!-- Package Metadata --> | ||
<PropertyGroup> | ||
<VersionPrefix>2.0.2</VersionPrefix> | ||
<VersionPrefix>3.0.0</VersionPrefix> | ||
<VersionSuffix> | ||
</VersionSuffix> | ||
<Description>FIDO2 .NET library (WebAuthn)</Description> | ||
<RepositoryUrl>https://github.com/abergs/fido2-net-lib</RepositoryUrl> | ||
<RepositoryUrl>https://github.com/passwordless-lib/fido2-net-lib</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageTags>fido2 webauthn</PackageTags> | ||
<PackageReleaseNotes>Initial release</PackageReleaseNotes> | ||
<PackageProjectUrl>https://github.com/abergs/fido2-net-lib</PackageProjectUrl> | ||
<PackageProjectUrl>https://github.com/passwordless-lib/fido2-net-lib</PackageProjectUrl> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
</PropertyGroup> | ||
|
||
<!-- Global Variables --> | ||
<PropertyGroup> | ||
<SupportedTargetFrameworks>net6.0</SupportedTargetFrameworks> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<!-- Language + Compiler Settings--> | ||
<PropertyGroup> | ||
<LangVersion>10</LangVersion> | ||
</PropertyGroup> | ||
|
||
<!--MISC--> | ||
<PropertyGroup> | ||
<!-- Avoid annoying build warnings when packing using the solution file --> | ||
<IsPackable>false</IsPackable> | ||
<!-- Avoid annoying build warnings when packing using the solution file --> | ||
<IsTestProject>false</IsTestProject> | ||
</PropertyGroup> | ||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Fido2NetLib.Cbor; | ||
using Fido2NetLib.Objects; | ||
|
||
namespace Fido2NetLib.Ctap2; | ||
|
||
internal sealed class CborHelper | ||
{ | ||
public static PublicKeyCredentialDescriptor DecodePublicKeyCredentialDescriptor(CborMap map) | ||
{ | ||
var result = new PublicKeyCredentialDescriptor(); | ||
|
||
foreach (var (key, value) in map) | ||
{ | ||
switch ((string)key) | ||
{ | ||
case "id": | ||
result.Id = (byte[])value; | ||
break; | ||
case "type" when (value is CborTextString { Value: "public-key" }): | ||
result.Type = PublicKeyCredentialType.PublicKey; | ||
break; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static PublicKeyCredentialUserEntity DecodePublicKeyCredentialUserEntity(CborMap map) | ||
{ | ||
var result = new PublicKeyCredentialUserEntity(); | ||
|
||
foreach (var (key, value) in map) | ||
{ | ||
switch ((string)key) | ||
{ | ||
case "id": | ||
result.Id = (byte[])value; | ||
break; | ||
case "name": | ||
result.Name = (string)value; | ||
break; | ||
case "displayName": | ||
result.DisplayName = (string)value; | ||
break; | ||
case "icon": | ||
result.Icon = (string)value; | ||
break; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static string[] ToStringArray(CborObject cborObject) | ||
{ | ||
var cborArray = (CborArray)cborObject; | ||
|
||
var result = new string[cborArray.Length]; | ||
|
||
for (int i = 0; i < cborArray.Length; i++) | ||
{ | ||
result[i] = (string)cborArray[i]; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static int[] ToInt32Array(CborObject cborObject) | ||
{ | ||
var cborArray = (CborArray)cborObject; | ||
|
||
var result = new int[cborArray.Length]; | ||
|
||
for (int i = 0; i < cborArray.Length; i++) | ||
{ | ||
result[i] = (int)cborArray[i]; | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Fido2NetLib.Ctap2; | ||
|
||
public sealed class CborMember : Attribute | ||
{ | ||
public object _key; | ||
|
||
public CborMember(byte key) | ||
{ | ||
_key = key; | ||
} | ||
|
||
public CborMember(string key) | ||
{ | ||
_key = key; | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
Src/Fido2.Ctap2/Commands/AuthenticatorClientPinCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using Fido2NetLib.Cbor; | ||
using Fido2NetLib.Objects; | ||
|
||
namespace Fido2NetLib.Ctap2; | ||
|
||
public sealed class AuthenticatorClientPinCommand : CtapCommand | ||
{ | ||
public AuthenticatorClientPinCommand( | ||
uint pinProtocol, | ||
AuthenticatorClientPinSubCommand subCommand, | ||
CredentialPublicKey? keyAgreement = null, | ||
byte[]? pinAuth = null, | ||
byte[]? newPinEnc = null, | ||
byte[]? pinHashEnc = null) | ||
{ | ||
|
||
PinProtocol = pinProtocol; | ||
SubCommand = subCommand; | ||
KeyAgreement = keyAgreement; | ||
PinAuth = pinAuth; | ||
NewPinEnc = newPinEnc; | ||
PinHashEnc = pinHashEnc; | ||
} | ||
|
||
/// <summary> | ||
/// Required PIN protocol version chosen by the client | ||
/// </summary> | ||
[CborMember(0x01)] | ||
public uint PinProtocol { get; } | ||
|
||
/// <summary> | ||
/// The authenticator Client PIN sub command currently being requested. | ||
/// </summary> | ||
[CborMember(0x02)] | ||
public AuthenticatorClientPinSubCommand SubCommand { get; } | ||
|
||
/// <summary> | ||
/// Public key of platformKeyAgreementKey. | ||
/// The COSE_Key-encoded public key MUST contain the optional "alg" parameter and MUST NOT contain any other optional parameters. | ||
/// The "alg" parameter MUST contain a COSEAlgorithmIdentifier value. | ||
/// </summary> | ||
[CborMember(0x03)] | ||
public CredentialPublicKey? KeyAgreement { get; } | ||
|
||
/// <summary> | ||
/// First 16 bytes of HMAC-SHA-256 of encrypted contents using sharedSecret. | ||
/// </summary> | ||
[CborMember(0x04)] | ||
public byte[]? PinAuth { get; } | ||
|
||
/// <summary> | ||
/// Encrypted new PIN using sharedSecret. | ||
/// </summary> | ||
[CborMember(0x05)] | ||
public byte[]? NewPinEnc { get; } | ||
|
||
/// <summary> | ||
/// Encrypted first 16 bytes of SHA-256 of PIN using sharedSecret. | ||
/// </summary> | ||
[CborMember(0x06)] | ||
public byte[]? PinHashEnc { get; } | ||
|
||
public override CtapCommandType Type => CtapCommandType.AuthenticatorClientPin; | ||
|
||
protected override CborObject? GetParameters() | ||
{ | ||
var cbor = new CborMap | ||
{ | ||
{ 0x01, PinProtocol }, | ||
{ 0x02, (int)SubCommand } | ||
}; | ||
|
||
if (KeyAgreement != null) | ||
{ | ||
cbor.Add(0x03, KeyAgreement.GetCborObject()); | ||
} | ||
|
||
if (PinAuth != null) | ||
{ | ||
cbor.Add(0x04, PinAuth); | ||
} | ||
|
||
if (NewPinEnc != null) | ||
{ | ||
cbor.Add(0x05, NewPinEnc); | ||
} | ||
|
||
if (PinHashEnc != null) | ||
{ | ||
cbor.Add(0x06, PinHashEnc); | ||
} | ||
|
||
return cbor; | ||
} | ||
} | ||
|
||
public enum AuthenticatorClientPinSubCommand | ||
{ | ||
GetRetries = 0x01, | ||
GetKeyAgreement = 0x02, | ||
SetPin = 0x03, | ||
ChangePin = 0x04, | ||
GetPinToken = 0x05, | ||
} |
Oops, something went wrong.