Skip to content

Commit

Permalink
Fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
timokoessler committed Sep 7, 2024
1 parent eea77b7 commit e5ab795
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Guard.Core/Security/WebAuthn/WebAuthnInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static extern int WebAuthNAuthenticatorMakeCredential(
[In] RawUserInfo rawUserInfo,
[In] RawCoseCredentialParameters rawCoseCredParams,
[In] RawClientData rawClientData,
[In, Optional] RawAuthenticatorMakeCredentialOptions rawMakeCredentialOptions,
[In, Optional] RawAuthenticatorMakeCredentialOptions? rawMakeCredentialOptions,
[Out] out IntPtr rawCredentialAttestation
);

Expand Down Expand Up @@ -123,7 +123,7 @@ private static extern WebAuthnHResult WebAuthNAuthenticatorGetAssertion(
[In] IntPtr hWnd,
[In, Optional] string rpId,
[In] RawClientData rawClientData,
[In, Optional] RawAuthenticatorGetAssertionOptions rawGetAssertionOptions,
[In, Optional] RawAuthenticatorGetAssertionOptions? rawGetAssertionOptions,
[Out] out IntPtr rawAssertionPtr
);

Expand Down
33 changes: 23 additions & 10 deletions Guard.Core/Security/WebAuthn/entities/Assertion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down Expand Up @@ -82,15 +83,27 @@ public Assertion MarshalToPublic()
if (HmacSecret != IntPtr.Zero)
{
var rawSecret = Marshal.PtrToStructure<RawHmacSecretSalt>(HmacSecret);
hmacSecret = new HmacSecret()
if (rawSecret != null)
{
First = new byte[rawSecret.FirstSize],
Second = new byte[rawSecret.SecondSize]
};
if (rawSecret.FirstSize > 0 && rawSecret.First != IntPtr.Zero)
Marshal.Copy(rawSecret.First, hmacSecret.First, 0, rawSecret.FirstSize);
if (rawSecret.SecondSize > 0 && rawSecret.Second != IntPtr.Zero)
Marshal.Copy(rawSecret.Second, hmacSecret.Second, 0, rawSecret.SecondSize);
hmacSecret = new HmacSecret()
{
First = new byte[rawSecret.FirstSize],
Second = new byte[rawSecret.SecondSize]
};
if (rawSecret.FirstSize > 0 && rawSecret.First != IntPtr.Zero)
{
Marshal.Copy(rawSecret.First, hmacSecret.First, 0, rawSecret.FirstSize);
}
if (rawSecret.SecondSize > 0 && rawSecret.Second != IntPtr.Zero)
{
Marshal.Copy(
rawSecret.Second,
hmacSecret.Second,
0,
rawSecret.SecondSize
);
}
}
}
}

Expand Down Expand Up @@ -135,6 +148,6 @@ internal class Assertion

public LargeBlobStatus LargeBlobStatus;
public byte[] LargeBlob;
public HmacSecret? HmacSecret;
public HmacSecret HmacSecret;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
5 changes: 3 additions & 2 deletions Guard.Core/Security/WebAuthn/entities/ClientData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand All @@ -18,7 +19,7 @@ internal class RawClientData
public IntPtr ClientDataJSON;

// Hash algorithm ID used to hash the pbClientDataJSON field.
public string? HashAlgId;
public string HashAlgId;

public RawClientData() { }

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/CommonAttestation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License
Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/CredProtect.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/Credentials.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/CredentialsEx.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/Enumerations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
#nullable disable
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/HmacSecret.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/HmacSecretSalt.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
#nullable disable
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License

Expand Down
3 changes: 2 additions & 1 deletion Guard.Core/Security/WebAuthn/entities/WebAuthnExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
#nullable disable
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Based on https://github.com/dbeinder/Yoq.WindowsWebAuthn - Copyright (c) 2019 David Beinder - MIT License
Expand Down

0 comments on commit e5ab795

Please sign in to comment.