Skip to content

Commit 0f302e2

Browse files
authored
Update to .NET 8 (#503)
* Update to .NET 8 * Remove GuidHelper
1 parent 57b8652 commit 0f302e2

File tree

8 files changed

+16
-55
lines changed

8 files changed

+16
-55
lines changed

Directory.Build.props

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Description>FIDO2 .NET library (WebAuthn)</Description>
88
<RepositoryUrl>https://github.com/passwordless-lib/fido2-net-lib</RepositoryUrl>
99
<RepositoryType>git</RepositoryType>
10+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1011
<PackageTags>fido2 webauthn</PackageTags>
1112
<PackageReleaseNotes>Initial release</PackageReleaseNotes>
1213
<PackageProjectUrl>https://github.com/passwordless-lib/fido2-net-lib</PackageProjectUrl>
@@ -15,7 +16,7 @@
1516

1617
<!-- Global Variables -->
1718
<PropertyGroup>
18-
<SupportedTargetFrameworks>net6.0</SupportedTargetFrameworks>
19+
<SupportedTargetFrameworks>net8.0</SupportedTargetFrameworks>
1920
<ImplicitUsings>enable</ImplicitUsings>
2021
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2122
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Src/Directory.Build.props

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
<Project>
33
<Import Project="..\Directory.Build.props"/>
44

5-
<!-- SourceLink Support-->
65
<PropertyGroup Condition="$(IS_DOCKER) == ''">
6+
<!-- Include PDB in the NuGet package -->
77
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
8-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
98
</PropertyGroup>
10-
<ItemGroup Condition="$(IS_DOCKER) == ''">
11-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
12-
</ItemGroup>
9+
1310
</Project>

Src/Fido2.BlazorWebAssembly/Fido2.BlazorWebAssembly.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
4+
<TargetFrameworks>$(SupportedTargetFrameworks)</TargetFrameworks>
55
<RootNamespace>Fido2NetLib</RootNamespace>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<Nullable>enable</Nullable>

Src/Fido2.Models/Metadata/AuthenticatorStatus.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Fido2NetLib;
88
/// <remarks>
99
/// <see href="https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-metadata-service-v2.0-rd-20180702.html#authenticatorstatus-enum"/>
1010
/// </remarks>
11-
[JsonConverter(typeof(JsonStringEnumConverter))]
11+
[JsonConverter(typeof(JsonStringEnumConverter<AuthenticatorStatus>))]
1212
public enum AuthenticatorStatus
1313
{
1414
/// <summary>

Src/Fido2/AttestationFormat/Packed.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
7474
else
7575
{
7676
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAttestation, "Malformed x5c cert found in packed attestation statement");
77-
}
77+
}
7878
}
7979

8080
// The attestation certificate attestnCert MUST be the first element in the array.
@@ -109,15 +109,15 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
109109
// 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
110110
if (aaguid != null)
111111
{
112-
if (GuidHelper.FromBigEndian(aaguid).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0)
112+
if (new Guid(aaguid, bigEndian: true).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0)
113113
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAttestation, "aaguid present in packed attestation cert exts but does not match aaguid from authData");
114114
}
115115

116116
// id-fido-u2f-ce-transports
117-
byte u2fTransports = U2FTransportsFromAttnCert(attestnCert.Extensions);
118-
119-
// 2d. Optionally, inspect x5c and consult externally provided knowledge to determine whether attStmt conveys a Basic or AttCA attestation
120-
117+
byte u2fTransports = U2FTransportsFromAttnCert(attestnCert.Extensions);
118+
119+
// 2d. Optionally, inspect x5c and consult externally provided knowledge to determine whether attStmt conveys a Basic or AttCA attestation
120+
121121
return new(new VerifyAttestationResult(AttestationType.AttCa, trustPath));
122122
}
123123

Src/Fido2/AttestationFormat/Tpm.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ public override ValueTask<VerifyAttestationResult> VerifyAsync(VerifyAttestation
198198
// 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
199199
if (AaguidFromAttnCertExts(aikCert.Extensions) is byte[] aaguid &&
200200
(!aaguid.AsSpan().SequenceEqual(Guid.Empty.ToByteArray())) &&
201-
(GuidHelper.FromBigEndian(aaguid).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0))
201+
(new Guid(aaguid, bigEndian: true).CompareTo(request.AuthData.AttestedCredentialData!.AaGuid) != 0))
202202
{
203-
throw new Fido2VerificationException($"aaguid malformed, expected {request.AuthData.AttestedCredentialData.AaGuid}, got {new Guid(aaguid)}");
203+
throw new Fido2VerificationException($"aaguid malformed, expected {request.AuthData.AttestedCredentialData.AaGuid}, got {new Guid(aaguid, bigEndian: true)}");
204204
}
205205

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

Src/Fido2/Extensions/GuidHelper.cs

-34
This file was deleted.

Src/Fido2/Objects/AttestedCredentialData.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ internal static AttestedCredentialData Parse(ReadOnlyMemory<byte> data, out int
9999

100100
position += 16;
101101

102-
#if NET8_0_OR_GREATER
103-
Guid aaGuid = new Guid(aaGuidBytes, isBigEndian: true);
104-
#else
105-
Guid aaGuid = GuidHelper.FromBigEndian(aaGuidBytes.ToArray());
106-
#endif
102+
var aaGuid = new Guid(aaGuidBytes.Span, bigEndian: true);
103+
107104
// Byte length of Credential ID, 16-bit unsigned big-endian integer.
108105
var credentialIDLen = BinaryPrimitives.ReadUInt16BigEndian(data.Slice(position, 2).Span);
109106
if (credentialIDLen > _maxCredentialIdLength)

0 commit comments

Comments
 (0)