2using System.Threading.Tasks;
20 private readonly
int nrDigits;
21 private readonly
byte[] secret;
24 private readonly
string endpoint;
121 long Counter,
int PassCode)
124 RemoteEndPoint, Counter, PassCode, this.auditor);
141 RemoteEndPoint, Counter, PassCode,
Auditor);
156 string OtpEndpoint,
string RemoteEndPoint,
long Counter,
int PassCode,
183 if (Counter <= LastCounter)
193 if (EarliestOpportunity.HasValue)
197 bool Ok = Expected == PassCode;
Static class managing persistent counters.
static Task< long > IncrementCounter(CaseInsensitiveString Key)
Increments a counter.
static async Task< long > GetCount(CaseInsensitiveString Key)
Gets the current count of a counter.
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Static class of application-wide semaphores that can be used to order access to editable objects.
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
Class that monitors login events, and help applications determine malicious intent....
async Task< DateTime?> GetEarliestLoginOpportunity(string RemoteEndPoint, string Protocol)
Checks when a remote endpoint can login.
static async void Success(string Message, string UserName, string RemoteEndPoint, string Protocol, params KeyValuePair< string, object >[] Tags)
Handles a successful login attempt.
static void Fail(string Message, string UserName, string RemoteEndPoint, string Protocol)
Handles a failed login attempt.
Contains OTP secret information for an OTP endpoint.
byte[] Secret
Endpoint secret.
HashFunction? HashFunction
Hash function used for the endpoint.
int NrDigits
Number of digits.
Implements the HOTP calculator algorithm, as defined in RFC 4226: https://datatracker....
int Compute(long Counter)
Calculates the expected one-time-password for the given counter value.
const int DefaultNrDigits
Default number of digits (6).
const HashFunction DefaultHashFunction
Default Hash Function (SHA-1)
Implements the HOTP validator algorithm, as defined in RFC 4226: https://datatracker....
HashFunction HashFunction
Hash function to use in computation.
static Task< ValidationResult > Validate(int NrDigits, byte[] Secret, string OtpEndpoint, string RemoteEndPoint, long Counter, int PassCode, LoginAuditor Auditor)
Calculates the expected one-time-password for the given counter value.
HotpValidator(byte[] Secret, string OtpEndpoint, LoginAuditor Auditor)
Implements the HOTP validator algorithm, as defined in RFC 4226: https://datatracker....
Task< ValidationResult > Validate(string OtpEndpoint, string RemoteEndPoint, long Counter, int PassCode)
Calculates the expected one-time-password for the given counter value.
string OtpEndpoint
OTP Endpoint
int NrDigits
Number of digits to present.
static Task< ValidationResult > Validate(byte[] Secret, string OtpEndpoint, string RemoteEndPoint, long Counter, int PassCode, LoginAuditor Auditor)
Calculates the expected one-time-password for the given counter value.
const string ProtocolName
Protocol name (HOTP).
LoginAuditor Auditor
Login auditor.
static async Task< HotpValidator > TryCreate(string OtpEndpoint, LoginAuditor Auditor)
Tries to create an HOTP calculator for the given endpoint.
HotpValidator(int NrDigits, byte[] Secret, string OtpEndpoint, LoginAuditor Auditor)
Implements the HOTP validator algorithm, as defined in RFC 4226: https://datatracker....
HotpValidator(int NrDigits, byte[] Secret, HashFunction HashFunction, string OtpEndpoint, LoginAuditor Auditor)
Implements the HOTP validator algorithm, as defined in RFC 4226: https://datatracker....
static async Task< ValidationResult > Validate(int NrDigits, byte[] Secret, HashFunction HashFunction, string OtpEndpoint, string RemoteEndPoint, long Counter, int PassCode, LoginAuditor Auditor)
Calculates the expected one-time-password for the given counter value.
Contains information of a HOTP or TOTP validation attempt.
CredentialAlgorithm
Specifies the type of external credential algorithm to use.
HashFunction
Hash method enumeration.