diff --git a/samples/KristofferStrube.Blazor.WebAuthentication.WasmExample/Pages/Index.razor.cs b/samples/KristofferStrube.Blazor.WebAuthentication.WasmExample/Pages/Index.razor.cs index f1e462e..8c33c4e 100644 --- a/samples/KristofferStrube.Blazor.WebAuthentication.WasmExample/Pages/Index.razor.cs +++ b/samples/KristofferStrube.Blazor.WebAuthentication.WasmExample/Pages/Index.razor.cs @@ -53,7 +53,7 @@ private async Task CreateCredential() new PublicKeyCredentialParameters() { Type = PublicKeyCredentialType.PublicKey, - Alg = COSEAlgorithm.RS256 + Alg = COSEAlgorithm.SHA_256 } ], Timeout = 360000, diff --git a/src/KristofferStrube.Blazor.WebAuthentication/COSEAlgorithms.cs b/src/KristofferStrube.Blazor.WebAuthentication/COSEAlgorithms.cs index a81678f..eddce87 100644 --- a/src/KristofferStrube.Blazor.WebAuthentication/COSEAlgorithms.cs +++ b/src/KristofferStrube.Blazor.WebAuthentication/COSEAlgorithms.cs @@ -1,640 +1,643 @@ namespace KristofferStrube.Blazor.WebAuthentication; +/// +/// A COSEAlgorithmIdentifier's value is a number identifying a cryptographic algorithm. +/// public enum COSEAlgorithm : long { /// - /// RSASSA-PKCS1-v1_5 using SHA-1 + /// RSASSA-PKCS1-v1_5 using SHA-1
/// This is not recommended to use. ///
/// - /// See the reference for RFC8812. - /// See the reference for RFC9053. + /// See the reference for RFC8812.
+ /// See the reference for RFC9053.
///
RS1 = -65535, /// - /// AES-CTR w/ 128-bit key + /// AES-CTR w/ 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A128CTR = -65534, /// - /// AES-CTR w/ 192-bit key + /// AES-CTR w/ 192-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A192CTR = -65533, /// - /// AES-CTR w/ 256-bit key + /// AES-CTR w/ 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A256CTR = -65532, /// - /// AES-CBC w/ 128-bit key + /// AES-CBC w/ 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A128CBC = -65531, /// - /// AES-CBC w/ 192-bit key + /// AES-CBC w/ 192-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A192CBC = -65530, /// - /// AES-CBC w/ 256-bit key + /// AES-CBC w/ 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for RFC9459. + /// See the reference for RFC9459.
///
A256CBC = -65529, /// - /// WalnutDSA signature + /// WalnutDSA signature
/// This is not recommended to use. ///
/// - /// See the reference for RFC9021. - /// See the reference for RFC9053. + /// See the reference for RFC9021.
+ /// See the reference for RFC9053.
///
WalnutDSA = -260, /// - /// RSASSA-PKCS1-v1_5 using SHA-512 + /// RSASSA-PKCS1-v1_5 using SHA-512
/// This is not recommended to use. ///
/// - /// See the reference for RFC8812. - /// See the reference for RFC9053. + /// See the reference for RFC8812.
+ /// See the reference for RFC9053.
///
RS512 = -259, /// - /// RSASSA-PKCS1-v1_5 using SHA-384 + /// RSASSA-PKCS1-v1_5 using SHA-384
/// This is not recommended to use. ///
/// - /// See the reference for RFC8812. - /// See the reference for RFC9053. + /// See the reference for RFC8812.
+ /// See the reference for RFC9053.
///
RS384 = -258, /// - /// RSASSA-PKCS1-v1_5 using SHA-256 + /// RSASSA-PKCS1-v1_5 using SHA-256
/// This is not recommended to use. ///
/// - /// See the reference for RFC8812. - /// See the reference for RFC9053. + /// See the reference for RFC8812.
+ /// See the reference for RFC9053.
///
RS256 = -257, /// - /// ECDSA using secp256k1 curve and SHA-256 + /// ECDSA using secp256k1 curve and SHA-256
/// This is not recommended to use. ///
/// - /// See the reference for RFC8812. - /// See the reference for RFC9053. + /// See the reference for RFC8812.
+ /// See the reference for RFC9053.
///
ES256K = -47, /// - /// HSS/LMS hash-based digital signature + /// HSS/LMS hash-based digital signature
/// This is recommended to use. ///
/// - /// See the reference for RFC8778. - /// See the reference for RFC9053. + /// See the reference for RFC8778.
+ /// See the reference for RFC9053.
///
HSS_LMS = -46, /// - /// SHAKE-256 512-bit Hash Value + /// SHAKE-256 512-bit Hash Value
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHAKE256 = -45, /// - /// SHA-2 512-bit Hash + /// SHA-2 512-bit Hash
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_512 = -44, /// - /// SHA-2 384-bit Hash + /// SHA-2 384-bit Hash
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_384 = -43, /// - /// RSAES-OAEP w/ SHA-512 + /// RSAES-OAEP w/ SHA-512
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
RSAES_OAEP_SHA_512 = -42, /// - /// RSAES-OAEP w/ SHA-256 + /// RSAES-OAEP w/ SHA-256
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
RSAES_OAEP_SHA_256 = -41, /// - /// RSAES-OAEP w/ SHA-1 + /// RSAES-OAEP w/ SHA-1
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
RSAES_OAEP_RFC_8017_default_parameters = -40, /// - /// RSASSA-PSS w/ SHA-512 + /// RSASSA-PSS w/ SHA-512
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
PS512 = -39, /// - /// RSASSA-PSS w/ SHA-384 + /// RSASSA-PSS w/ SHA-384
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
PS384 = -38, /// - /// RSASSA-PSS w/ SHA-256 + /// RSASSA-PSS w/ SHA-256
/// This is recommended to use. ///
/// - /// See the reference for RFC8230. - /// See the reference for RFC9053. + /// See the reference for RFC8230.
+ /// See the reference for RFC9053.
///
PS256 = -37, /// - /// ECDSA w/ SHA-512 + /// ECDSA w/ SHA-512
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ES512 = -36, /// - /// ECDSA w/ SHA-384 + /// ECDSA w/ SHA-384
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ES384 = -35, /// - /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 256-bit key + /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 256-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_SS_and_A256KW = -34, /// - /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 192-bit key + /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 192-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_SS_and_A192KW = -33, /// - /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 128-bit key + /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 128-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_SS_and_A128KW = -32, /// - /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 256-bit key + /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 256-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_ES_and_A256KW = -31, /// - /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 192-bit key + /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 192-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_ES_and_A192KW = -30, /// - /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 128-bit key + /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 128-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_ES_and_A128KW = -29, /// - /// ECDH SS w/ HKDF - generate key directly + /// ECDH SS w/ HKDF - generate key directly
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_SS_and_HKDF_512 = -28, /// - /// ECDH SS w/ HKDF - generate key directly + /// ECDH SS w/ HKDF - generate key directly
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_SS_and_HKDF_256 = -27, /// - /// ECDH ES w/ HKDF - generate key directly + /// ECDH ES w/ HKDF - generate key directly
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_ES_and_HKDF_512 = -26, /// - /// ECDH ES w/ HKDF - generate key directly + /// ECDH ES w/ HKDF - generate key directly
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ECDH_ES_and_HKDF_256 = -25, /// - /// SHAKE-128 256-bit Hash Value + /// SHAKE-128 256-bit Hash Value
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHAKE128 = -18, /// - /// SHA-2 512-bit Hash truncated to 256-bits + /// SHA-2 512-bit Hash truncated to 256-bits
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_512_truncated_to_256 = -17, /// - /// SHA-2 256-bit Hash + /// SHA-2 256-bit Hash
/// This is recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_256 = -16, /// - /// SHA-2 256-bit Hash truncated to 64-bits + /// SHA-2 256-bit Hash truncated to 64-bits
/// This is not recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_256_truncated_to_64 = -15, /// - /// SHA-1 Hash + /// SHA-1 Hash
/// This is not recommended to use. ///
/// - /// See the reference for RFC9054. - /// See the reference for RFC9053. + /// See the reference for RFC9054.
+ /// See the reference for RFC9053.
///
SHA_1 = -14, /// - /// Shared secret w/ AES-MAC 256-bit key + /// Shared secret w/ AES-MAC 256-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
directandHKDF_AES_256 = -13, /// - /// Shared secret w/ AES-MAC 128-bit key + /// Shared secret w/ AES-MAC 128-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
directandHKDF_AES_128 = -12, /// - /// Shared secret w/ HKDF and SHA-512 + /// Shared secret w/ HKDF and SHA-512
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
directandHKDF_SHA_512 = -11, /// - /// Shared secret w/ HKDF and SHA-256 + /// Shared secret w/ HKDF and SHA-256
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
directandHKDF_SHA_256 = -10, /// - /// EdDSA + /// EdDSA
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
EdDSA = -8, /// - /// ECDSA w/ SHA-256 + /// ECDSA w/ SHA-256
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
ES256 = -7, /// - /// Direct use of CEK + /// Direct use of CEK
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
direct = -6, /// - /// AES Key Wrap w/ 256-bit key + /// AES Key Wrap w/ 256-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
A256KW = -5, /// - /// AES Key Wrap w/ 192-bit key + /// AES Key Wrap w/ 192-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
A192KW = -4, /// - /// AES Key Wrap w/ 128-bit key + /// AES Key Wrap w/ 128-bit key
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
A128KW = -3, /// - /// + ///
/// This is not recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
Reserved = 0, /// - /// "AES-GCM mode w/ 128-bit key + /// "AES-GCM mode w/ 128-bit key
/// This is not recommended to use. ///
A128GCM = 1, /// - /// "AES-GCM mode w/ 192-bit key + /// "AES-GCM mode w/ 192-bit key
/// This is not recommended to use. ///
A192GCM = 2, /// - /// "AES-GCM mode w/ 256-bit key + /// "AES-GCM mode w/ 256-bit key
/// This is not recommended to use. ///
A256GCM = 3, /// - /// HMAC w/ SHA-256 truncated to 64 bits + /// HMAC w/ SHA-256 truncated to 64 bits
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
HMAC_256_truncated_to_64 = 4, /// - /// HMAC w/ SHA-256 + /// HMAC w/ SHA-256
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
HMAC_256_truncated_to_256 = 5, /// - /// HMAC w/ SHA-384 + /// HMAC w/ SHA-384
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
HMAC_384_truncated_to_384 = 6, /// - /// HMAC w/ SHA-512 + /// HMAC w/ SHA-512
/// This is recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
HMAC_512_truncated_to_512 = 7, /// - /// "AES-CCM mode 128-bit key + /// "AES-CCM mode 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_16_64_128 = 10, /// - /// "AES-CCM mode 256-bit key + /// "AES-CCM mode 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_16_64_256 = 11, /// - /// "AES-CCM mode 128-bit key + /// "AES-CCM mode 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_64_64_128 = 12, /// - /// "AES-CCM mode 256-bit key + /// "AES-CCM mode 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_64_64_256 = 13, /// - /// "AES-MAC 128-bit key + /// "AES-MAC 128-bit key
/// This is not recommended to use. ///
AES_MAC_128_truncated_to_64 = 14, /// - /// "AES-MAC 256-bit key + /// "AES-MAC 256-bit key
/// This is not recommended to use. ///
AES_MAC_256_truncated_to_64 = 15, /// - /// "ChaCha20/Poly1305 w/ 256-bit key + /// "ChaCha20/Poly1305 w/ 256-bit key
/// This is not recommended to use. ///
ChaCha20_truncated_to_Poly1305 = 24, /// - /// "AES-MAC 128-bit key + /// "AES-MAC 128-bit key
/// This is not recommended to use. ///
AES_MAC_128_truncated_to_128 = 25, /// - /// "AES-MAC 256-bit key + /// "AES-MAC 256-bit key
/// This is not recommended to use. ///
AES_MAC_256_truncated_to_128 = 26, /// - /// "AES-CCM mode 128-bit key + /// "AES-CCM mode 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_16_128_128 = 30, /// - /// "AES-CCM mode 256-bit key + /// "AES-CCM mode 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_16_128_256 = 31, /// - /// "AES-CCM mode 128-bit key + /// "AES-CCM mode 128-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_64_128_128 = 32, /// - /// "AES-CCM mode 256-bit key + /// "AES-CCM mode 256-bit key
/// This is not recommended to use. ///
/// - /// See the reference for kty. + /// See the reference for kty.
///
AES_CCM_64_128_256 = 33, /// - /// For doing IV generation for symmetric algorithms. + /// For doing IV generation for symmetric algorithms.
/// This is not recommended to use. ///
/// - /// See the reference for RFC9053. + /// See the reference for RFC9053.
///
IV_GENERATION = 34, diff --git a/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialParameters.cs b/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialParameters.cs index 050cf1e..d039f34 100644 --- a/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialParameters.cs +++ b/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialParameters.cs @@ -14,5 +14,5 @@ public class PublicKeyCredentialParameters /// This member specifies the cryptographic signature algorithm with which the newly generated credential will be used, and thus also the type of asymmetric key pair to be generated, e.g., RSA or Elliptic Curve. /// [JsonPropertyName("alg")] - public required COSEAlgorithm Algorithm { get; set; } + public required COSEAlgorithm Alg { get; set; } } diff --git a/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialType.cs b/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialType.cs index e2b2321..9f8e279 100644 --- a/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialType.cs +++ b/src/KristofferStrube.Blazor.WebAuthentication/Options/PublicKeyCredentialType.cs @@ -3,6 +3,13 @@ namespace KristofferStrube.Blazor.WebAuthentication; +/// +/// This enumeration defines the valid credential types. +/// It is an extension point; values can be added to it in the future, as more credential types are defined. +/// The values of this enumeration are used for versioning the Authentication Assertion and attestation structures according to the type of the authenticator.
+/// Currently one credential type is defined, namely . +///
+/// See the API definition here. [JsonConverter(typeof(PublicKeyCredentialTypeConverter))] public enum PublicKeyCredentialType { diff --git a/src/KristofferStrube.Blazor.WebAuthentication/PublicKeyCredential.cs b/src/KristofferStrube.Blazor.WebAuthentication/PublicKeyCredential.cs index 2203033..7060fc7 100644 --- a/src/KristofferStrube.Blazor.WebAuthentication/PublicKeyCredential.cs +++ b/src/KristofferStrube.Blazor.WebAuthentication/PublicKeyCredential.cs @@ -3,7 +3,10 @@ using Microsoft.JSInterop; namespace KristofferStrube.Blazor.WebAuthentication; - +/// +/// The PublicKeyCredential interface inherits from , and contains the attributes that are returned to the caller when a new credential is created, or a new assertion is requested. +/// +/// See the API definition here. public class PublicKeyCredential : Credential { protected readonly Lazy> webAuthenticationHelperTask; @@ -15,6 +18,9 @@ protected internal PublicKeyCredential(IJSRuntime jSRuntime, IJSObjectReference public PublicKeyCredential(Credential credential) : this(credential.JSRuntime, credential.JSReference) { } + /// + /// This attribute returns the ArrayBuffer for this credential. + /// public async Task GetRawIdAsync() { IJSObjectReference helper = await webAuthenticationHelperTask.Value; diff --git a/tools/KristofferStrube.Blazor.COSEGenerator/Program.cs b/tools/KristofferStrube.Blazor.COSEGenerator/Program.cs index 0019350..60f13d0 100644 --- a/tools/KristofferStrube.Blazor.COSEGenerator/Program.cs +++ b/tools/KristofferStrube.Blazor.COSEGenerator/Program.cs @@ -24,6 +24,9 @@ writer.WriteLine($"namespace {args[2]};"); writer.WriteLine(); +writer.WriteLine("/// "); +writer.WriteLine("/// A COSEAlgorithmIdentifier's value is a number identifying a cryptographic algorithm."); +writer.WriteLine("/// "); writer.WriteLine("public enum COSEAlgorithm : long"); writer.WriteLine("{"); writer.Indent++; @@ -42,7 +45,7 @@ string referenceList = lineSegments[5]; string recommended = lineSegments[6]; writer.WriteLine("/// "); - writer.WriteLine($"/// {description}"); + writer.WriteLine($"/// {description}
"); writer.WriteLine($"/// {(recommended == "Yes" ? "This is recommended to use." : "This is not recommended to use.")}"); writer.WriteLine("///
"); if (referenceList.Length >= 3) @@ -51,7 +54,7 @@ string[] references = referenceList[1..^1].Split("]["); foreach(string reference in references) { - writer.WriteLine($"/// See the reference for {reference}."); + writer.WriteLine($"/// See the reference for {reference}.
"); } writer.WriteLine("/// "); }