Skip to content

Commit

Permalink
Add some missing comments on public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
joegoldman2 committed Nov 3, 2023
1 parent bfc2f5b commit 8366d34
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 35 deletions.
9 changes: 4 additions & 5 deletions Src/Fido2.AspNet/DateTimeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ internal static class DateTimeUtilities
/// <returns></returns>
public static DateTimeOffset GetNextIncrement(this DateTimeOffset startTime, TimeSpan increment)
{
//Find next increment
// Find next increment
var nextIncrementTicks = (long)(Math.Ceiling((decimal)startTime.Ticks / (decimal)increment.Ticks) * (decimal)increment.Ticks);

//Find the difference between the start time and the target time
// Find the difference between the start time and the target time
var timeSpanDiff = TimeSpan.FromTicks(nextIncrementTicks).Subtract(TimeSpan.FromTicks(startTime.Ticks));

//If the calculated difference is 0 then make it the increment value
// If the calculated difference is 0 then make it the increment value
if (timeSpanDiff.Ticks == 0)
timeSpanDiff = TimeSpan.FromTicks(increment.Ticks);

//Add the difference to the normalised time
// Add the difference to the normalized time
return startTime.Add(timeSpanDiff);
}

}
2 changes: 1 addition & 1 deletion Src/Fido2.AspNet/DistributedCacheMetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected virtual string GetBlobCacheKey(IMetadataRepository repository)
if (!string.IsNullOrWhiteSpace(blob?.NextUpdate)
&& DateTimeOffset.TryParseExact(
blob.NextUpdate,
new[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "o" }, //Sould be ISO8601 date but allow for other ISO-like formats too
new[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "o" }, // Should be ISO8601 date but allow for other ISO-like formats too
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal,
out var parsedDate))
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.Ctap2/Commands/AuthenticatorClientPinCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public sealed class AuthenticatorClientPinCommand : CtapCommand
}

/// <summary>
/// Required PIN protocol version chosen by the client
/// Required PIN protocol version chosen by the client.
/// </summary>
[CborMember(0x01)]
public uint PinProtocol { get; }
Expand Down
8 changes: 4 additions & 4 deletions Src/Fido2.Ctap2/Commands/AuthenticatorGetAssertionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public sealed class AuthenticatorGetAssertionCommand : CtapCommand
}

/// <summary>
/// Relying party identifier
/// Relying party identifier.
/// </summary>
[CborMember(0x01)]
public string RpId { get; }

/// <summary>
/// Hash of the serialized client data collected by the host
/// Hash of the serialized client data collected by the host.
/// </summary>
[CborMember(0x02)]
public byte[] ClientDataHash { get; }
Expand All @@ -46,13 +46,13 @@ public sealed class AuthenticatorGetAssertionCommand : CtapCommand
public PublicKeyCredentialDescriptor[] AllowList { get; }

/// <summary>
/// CBOR map of extension identifier → authenticator extension input values
/// CBOR map of extension identifier → authenticator extension input values.
/// </summary>
[CborMember(0x04)]
public CborMap? Extensions { get; }

/// <summary>
/// Map of authenticator options
/// Map of authenticator options.
/// </summary>
[CborMember(0x05)]
public AuthenticatorGetAssertionOptions? Options { get; }
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2.Models/Objects/MakeNewCredentialResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Fido2NetLib.Objects;

/// <summary>
/// Result of parsing and verifying attestation. Used to transport Public Key back to RP
/// Result of parsing and verifying attestation. Used to transport Public Key back to RP.
/// </summary>
public sealed class MakeNewCredentialResult : Fido2ResponseBase
{
Expand Down
13 changes: 5 additions & 8 deletions Src/Fido2/AuthenticatorAssertionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ public static AuthenticatorAssertionResponse Parse(AuthenticatorAssertionRawResp
}

/// <summary>
/// Implements algorithm from https://www.w3.org/TR/webauthn/#verifying-assertion
/// Implements algorithm from https://www.w3.org/TR/webauthn/#verifying-assertion.
/// </summary>
/// <param name="options">The assertionoptions that was sent to the client</param>
/// <param name="fullyQualifiedExpectedOrigins">
/// The expected fully qualified server origins, used to verify that the signature is sent to the expected server
/// </param>
/// <param name="storedPublicKey">The stored public key for this CredentialId</param>
/// <param name="options">The original assertion options that was sent to the client.</param>
/// <param name="storedPublicKey">The stored public key for this CredentialId.</param>
/// <param name="storedSignatureCounter">The stored counter value for this CredentialId</param>
/// <param name="isUserHandleOwnerOfCredId">A function that returns <see langword="true"/> if user handle is owned by the credential ID</param>
/// <param name="cancellationToken"></param>
/// <param name="isUserHandleOwnerOfCredId">A function that returns <see langword="true"/> if user handle is owned by the credential ID.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
public async Task<VerifyAssertionResult> VerifyAsync(
AssertionOptions options,
Fido2Configuration config,
Expand Down
35 changes: 22 additions & 13 deletions Src/Fido2/Fido2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public class Fido2 : IFido2
}

/// <summary>
/// Returns CredentialCreateOptions including a challenge to be sent to the browser/authr to create new credentials
/// Returns CredentialCreateOptions including a challenge to be sent to the browser/authenticator to create new credentials.
/// </summary>
/// <returns></returns>
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator.The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator. The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
public CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
Expand All @@ -37,11 +37,11 @@ public class Fido2 : IFido2
}

/// <summary>
/// Returns CredentialCreateOptions including a challenge to be sent to the browser/authr to create new credentials
/// Returns CredentialCreateOptions including a challenge to be sent to the browser/authenticator to create new credentials.
/// </summary>
/// <returns></returns>
/// <param name="attestationPreference">This member is intended for use by Relying Parties that wish to express their preference for attestation conveyance. The default is none.</param>
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator.The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator. The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
public CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
Expand All @@ -55,12 +55,12 @@ public class Fido2 : IFido2
}

/// <summary>
/// Verifies the response from the browser/authr after creating new credentials
/// Verifies the response from the browser/authenticator after creating new credentials.
/// </summary>
/// <param name="attestationResponse"></param>
/// <param name="origChallenge"></param>
/// <param name="isCredentialIdUniqueToUser"></param>
/// <param name="cancellationToken"></param>
/// <param name="attestationResponse">The attestation response from the authenticator.</param>
/// <param name="origChallenge">The original options that was sent to the client.</param>
/// <param name="isCredentialIdUniqueToUser">The delegate used to validate that the CredentialID is unique to this user.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns></returns>
public async Task<MakeNewCredentialResult> MakeNewCredentialAsync(
AuthenticatorAttestationRawResponse attestationResponse,
Expand All @@ -80,7 +80,7 @@ public class Fido2 : IFido2
}

/// <summary>
/// Returns AssertionOptions including a challenge to the browser/authr to assert existing credentials and authenticate a user.
/// Returns AssertionOptions including a challenge to the browser/authenticator to assert existing credentials and authenticate a user.
/// </summary>
/// <returns></returns>
public AssertionOptions GetAssertionOptions(
Expand All @@ -94,8 +94,15 @@ public class Fido2 : IFido2
}

/// <summary>
/// Verifies the assertion response from the browser/authr to assert existing credentials and authenticate a user.
/// Verifies the assertion response from the browser/authenticator to assert existing credentials and authenticate a user.
/// </summary>
/// <param name="assertionResponse">The assertion response from the authenticator.</param>
/// <param name="originalOptions">The original options that was sent to the client.</param>
/// <param name="storedPublicKey">The stored credential public key.</param>
/// <param name="storedDevicePublicKeys">The stored device public keys.</param>
/// <param name="storedSignatureCounter">The stored value of the signature counter.</param>
/// <param name="isUserHandleOwnerOfCredentialIdCallback">The delegate used to validate that the user handle is indeed owned of the CredentialId.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns></returns>
public async Task<VerifyAssertionResult> MakeAssertionAsync(
AuthenticatorAssertionRawResponse assertionResponse,
Expand All @@ -122,15 +129,17 @@ public class Fido2 : IFido2
}

/// <summary>
/// Callback function used to validate that the CredentialID is unique to this User
/// Callback function used to validate that the CredentialID is unique to this user.
/// </summary>
/// <param name="credentialIdUserParams"></param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns></returns>
public delegate Task<bool> IsCredentialIdUniqueToUserAsyncDelegate(IsCredentialIdUniqueToUserParams credentialIdUserParams, CancellationToken cancellationToken);

/// <summary>
/// Callback function used to validate that the user handle is indeed owned of the CredentialId
/// Callback function used to validate that the user handle is indeed owned of the CredentialId.
/// </summary>
/// <param name="credentialIdUserHandleParams"></param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns></returns>
public delegate Task<bool> IsUserHandleOwnerOfCredentialIdAsync(IsUserHandleOwnerOfCredentialIdParams credentialIdUserHandleParams, CancellationToken cancellationToken);
2 changes: 1 addition & 1 deletion Src/Fido2/IMetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Fido2NetLib;
public interface IMetadataService
{
/// <summary>
/// Gets the metadata payload entry by a guid asynchronously
/// Gets the metadata payload entry by a guid asynchronously.
/// </summary>
/// <param name="aaguid">The Authenticator Attestation GUID.</param>
/// <returns>Returns the entry; Otherwise <c>null</c>.</returns>
Expand Down
2 changes: 1 addition & 1 deletion Src/Fido2/Objects/AttestedCredentialData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Fido2NetLib.Objects;
public sealed class AttestedCredentialData
{
/// <summary>
/// Minimum length of the attested credential data structure. AAGUID + credentialID length + credential ID + credential public key.
/// Minimum length of the attested credential data structure. AAGUID + credentialID length + credential ID + credential public key.
/// <see cref="https://www.w3.org/TR/webauthn/#attested-credential-data"/>
/// </summary>
private const int _minLength = 20; // Marshal.SizeOf(typeof(Guid)) + sizeof(ushort) + sizeof(byte) + sizeof(byte)
Expand Down

0 comments on commit 8366d34

Please sign in to comment.