#### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## 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&lt;TJsonWebKey&gt;](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.Encryption.IKeyManagementAlgorithm_TJsonWebKey_ 'Abblix\.Jwt\.Encryption\.IKeyManagementAlgorithm\<TJsonWebKey\>') and [Abblix\.Jwt\.Encryption\.IContentEncryptionAlgorithm](https://learn.microsoft.com/en-us/dotnet/api/abblix.jwt.encryption.icontentencryptionalgorithm '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\.

```csharp
public sealed class EncryptionAlgorithmsProvider
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object '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](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.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 {#Abblix.Jwt.EncryptionAlgorithmsProvider.EncryptionAlgorithmsProvider(System.IServiceProvider)}

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&lt;TJsonWebKey&gt;](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.Encryption.IKeyManagementAlgorithm_TJsonWebKey_ 'Abblix\.Jwt\.Encryption\.IKeyManagementAlgorithm\<TJsonWebKey\>') and [Abblix\.Jwt\.Encryption\.IContentEncryptionAlgorithm](https://learn.microsoft.com/en-us/dotnet/api/abblix.jwt.encryption.icontentencryptionalgorithm '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\.

```csharp
public EncryptionAlgorithmsProvider(System.IServiceProvider serviceProvider);
```
#### Parameters

###### `serviceProvider` [System\.IServiceProvider](https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider 'System\.IServiceProvider') {#Abblix.Jwt.EncryptionAlgorithmsProvider.EncryptionAlgorithmsProvider(System.IServiceProvider).serviceProvider}

### Remarks
The enumerated key types mirror the dispatch by key type that encryption and decryption make: an
encryptor registered for any other [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.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 {#Abblix.Jwt.EncryptionAlgorithmsProvider.ContentEncryptionAlgorithms}

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

```csharp
public System.Collections.Generic.IEnumerable<string> ContentEncryptionAlgorithms { get; }
```

#### Property Value
[System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')

## EncryptionAlgorithmsProvider\.KeyManagementAlgorithms Property {#Abblix.Jwt.EncryptionAlgorithmsProvider.KeyManagementAlgorithms}

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

```csharp
public System.Collections.Generic.IEnumerable<string> KeyManagementAlgorithms { get; }
```

#### Property Value
[System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
### Methods

## EncryptionAlgorithmsProvider\.CanEncrypt\(JsonWebKey, string\) Method {#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string)}

Whether [key](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.EncryptionAlgorithmsProvider#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string).key 'Abblix\.Jwt\.EncryptionAlgorithmsProvider\.CanEncrypt\(Abblix\.Jwt\.JsonWebKey, string\)\.key') may encrypt and decrypt a JWE with the key management algorithm
[keyManagementAlgorithm](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.EncryptionAlgorithmsProvider#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string).keyManagementAlgorithm 'Abblix\.Jwt\.EncryptionAlgorithmsProvider\.CanEncrypt\(Abblix\.Jwt\.JsonWebKey, string\)\.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](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.EncryptionAlgorithmsProvider#Abblix.Jwt.EncryptionAlgorithmsProvider.KeyManagementAlgorithms 'Abblix\.Jwt\.EncryptionAlgorithmsProvider\.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\.

```csharp
public bool CanEncrypt(Abblix.Jwt.JsonWebKey key, string keyManagementAlgorithm);
```
#### Parameters

###### `key` [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') {#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string).key}

The key asked about\.

###### `keyManagementAlgorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string).keyManagementAlgorithm}

The JWE `alg` it would be used with\.

#### Returns
[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean '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\.
