Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to .NET 8 #503

Merged
merged 2 commits into from
Feb 28, 2024
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
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>
</PropertyGroup>
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
Loading