Skip to content

Commit

Permalink
Update to .NET 8 (#503)
Browse files Browse the repository at this point in the history
* Update to .NET 8

* Remove GuidHelper
  • Loading branch information
joegoldman2 authored Feb 28, 2024
1 parent 57b8652 commit 0f302e2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 55 deletions.
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Description>FIDO2 .NET library (WebAuthn)</Description>
<RepositoryUrl>https://github.com/passwordless-lib/fido2-net-lib</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<PackageTags>fido2 webauthn</PackageTags>
<PackageReleaseNotes>Initial release</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/passwordless-lib/fido2-net-lib</PackageProjectUrl>
Expand All @@ -15,7 +16,7 @@

<!-- Global Variables -->
<PropertyGroup>
<SupportedTargetFrameworks>net6.0</SupportedTargetFrameworks>
<SupportedTargetFrameworks>net8.0</SupportedTargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
7 changes: 2 additions & 5 deletions Src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
<Project>
<Import Project="..\Directory.Build.props"/>

<!-- SourceLink Support-->
<PropertyGroup Condition="$(IS_DOCKER) == ''">
<!-- Include PDB in the NuGet package -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
<ItemGroup Condition="$(IS_DOCKER) == ''">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Src/Fido2.BlazorWebAssembly/Fido2.BlazorWebAssembly.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<TargetFrameworks>$(SupportedTargetFrameworks)</TargetFrameworks>
<RootNamespace>Fido2NetLib</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.Models/Metadata/AuthenticatorStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Fido2NetLib;
/// <remarks>
/// <see href="https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-metadata-service-v2.0-rd-20180702.html#authenticatorstatus-enum"/>
/// </remarks>
[JsonConverter(typeof(JsonStringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter<AuthenticatorStatus>))]
public enum AuthenticatorStatus
{
/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions Src/Fido2/AttestationFormat/Packed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
else
{
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAttestation, "Malformed x5c cert found in packed attestation statement");
}
}
}

// The attestation certificate attestnCert MUST be the first element in the array.
Expand Down Expand Up @@ -109,15 +109,15 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
// 2c. If attestnCert contains an extension with OID 1.3.6.1.4.1.45724.1.1.4 (id-fido-gen-ce-aaguid) verify that the value of this extension matches the aaguid in authenticatorData
if (aaguid != null)
{
if (GuidHelper.FromBigEndian(aaguid).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0)
if (new Guid(aaguid, bigEndian: true).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0)
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAttestation, "aaguid present in packed attestation cert exts but does not match aaguid from authData");
}

// id-fido-u2f-ce-transports
byte u2fTransports = U2FTransportsFromAttnCert(attestnCert.Extensions);

// 2d. Optionally, inspect x5c and consult externally provided knowledge to determine whether attStmt conveys a Basic or AttCA attestation

byte u2fTransports = U2FTransportsFromAttnCert(attestnCert.Extensions);

// 2d. Optionally, inspect x5c and consult externally provided knowledge to determine whether attStmt conveys a Basic or AttCA attestation

return new(new VerifyAttestationResult(AttestationType.AttCa, trustPath));
}

Expand Down
4 changes: 2 additions & 2 deletions Src/Fido2/AttestationFormat/Tpm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
// 5c. If aikCert contains an extension with OID 1.3.6.1.4.1.45724.1.1.4 (id-fido-gen-ce-aaguid) verify that the value of this extension matches the aaguid in authenticatorData
if (AaguidFromAttnCertExts(aikCert.Extensions) is byte[] aaguid &&
(!aaguid.AsSpan().SequenceEqual(Guid.Empty.ToByteArray())) &&
(GuidHelper.FromBigEndian(aaguid).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0))
(new Guid(aaguid, bigEndian: true).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0))
{
throw new Fido2VerificationException($"aaguid malformed, expected {request.AuthData.AttestedCredentialData.AaGuid}, got {new Guid(aaguid)}");
throw new Fido2VerificationException($"aaguid malformed, expected {request.AuthData.AttestedCredentialData.AaGuid}, got {new Guid(aaguid, bigEndian: true)}");
}

return new(new VerifyAttestationResult(AttestationType.AttCa, trustPath));
Expand Down
34 changes: 0 additions & 34 deletions Src/Fido2/Extensions/GuidHelper.cs

This file was deleted.

7 changes: 2 additions & 5 deletions Src/Fido2/Objects/AttestedCredentialData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ internal static AttestedCredentialData Parse(ReadOnlyMemory<byte> data, out int

position += 16;

#if NET8_0_OR_GREATER
Guid aaGuid = new Guid(aaGuidBytes, isBigEndian: true);
#else
Guid aaGuid = GuidHelper.FromBigEndian(aaGuidBytes.ToArray());
#endif
var aaGuid = new Guid(aaGuidBytes.Span, bigEndian: true);

// Byte length of Credential ID, 16-bit unsigned big-endian integer.
var credentialIDLen = BinaryPrimitives.ReadUInt16BigEndian(data.Slice(position, 2).Span);
if (credentialIDLen > _maxCredentialIdLength)
Expand Down

0 comments on commit 0f302e2

Please sign in to comment.