Skip to content

EncryptionAlgorithmsProvider Class

Provides access to the collections of JWE algorithms supported by the JWT infrastructure. Projects both sets - key-management algorithms (the JWE alg, e.g. "RSA-OAEP-256") and content-encryption algorithms (the JWE enc, e.g. "A256GCM") - from the live keyed IKeyManagementAlgorithm<TJsonWebKey> and Abblix.Jwt.Encryption.IContentEncryptionAlgorithm registrations, so discovery always reflects exactly the encryptors the host currently has registered - including algorithms the host added or replaced - with no registration-time bookkeeping to keep in sync.

C#
public sealed class EncryptionAlgorithmsProvider

Inheritance System.Object → EncryptionAlgorithmsProvider

Remarks

The enumerated key types mirror the dispatch by key type that encryption and decryption make: an encryptor registered for any other JsonWebKey subtype is unreachable at run time, so it is deliberately not advertised. The enumeration order (RSA, EC, octet) is the order these algorithms appear in the discovery document, which consumers read verbatim.

Constructors

EncryptionAlgorithmsProvider(IServiceProvider) Constructor

Provides access to the collections of JWE algorithms supported by the JWT infrastructure. Projects both sets - key-management algorithms (the JWE alg, e.g. "RSA-OAEP-256") and content-encryption algorithms (the JWE enc, e.g. "A256GCM") - from the live keyed IKeyManagementAlgorithm<TJsonWebKey> and Abblix.Jwt.Encryption.IContentEncryptionAlgorithm registrations, so discovery always reflects exactly the encryptors the host currently has registered - including algorithms the host added or replaced - with no registration-time bookkeeping to keep in sync.

C#
public EncryptionAlgorithmsProvider(System.IServiceProvider serviceProvider);

Parameters

serviceProvider System.IServiceProvider

Remarks

The enumerated key types mirror the dispatch by key type that encryption and decryption make: an encryptor registered for any other JsonWebKey subtype is unreachable at run time, so it is deliberately not advertised. The enumeration order (RSA, EC, octet) is the order these algorithms appear in the discovery document, which consumers read verbatim.

Properties

EncryptionAlgorithmsProvider.ContentEncryptionAlgorithms Property

Gets the supported JWE content-encryption algorithms (the enc values, e.g. "A256GCM").

C#
public System.Collections.Generic.IEnumerable<string> ContentEncryptionAlgorithms { get; }

Property Value

System.Collections.Generic.IEnumerable<System.String>

EncryptionAlgorithmsProvider.KeyManagementAlgorithms Property

Gets the supported JWE key-management algorithms (the alg values, e.g. "RSA-OAEP-256").

C#
public System.Collections.Generic.IEnumerable<string> KeyManagementAlgorithms { get; }

Property Value

System.Collections.Generic.IEnumerable<System.String>

Methods

EncryptionAlgorithmsProvider.CanEncrypt(JsonWebKey, string) Method

Whether key may encrypt and decrypt a JWE with the key management algorithm keyManagementAlgorithm: it declares that algorithm or none, an algorithm of that name is registered for the key's type, and that algorithm accepts the key's material. The registry answering this is the one KeyManagementAlgorithms lists and encryption and decryption dispatch to, so an algorithm a host registers is advertised, matched to its keys and carried out by one and the same registration.

C#
public bool CanEncrypt(Abblix.Jwt.JsonWebKey key, string keyManagementAlgorithm);

Parameters

key JsonWebKey

The key asked about.

keyManagementAlgorithm System.String

The JWE alg it would be used with.

Returns

System.Boolean

Remarks

RFC 8725 section 3.1: "each key MUST be used with exactly one algorithm, and this MUST be checked when the cryptographic operation is performed", so a key declaring another algorithm is refused; RFC 7517 section 4.4 makes alg optional, so a key declaring none is judged by its type and material.