Skip to content

Conversation

@anblanco
Copy link

This commit adds Windows support for specifying AESGCM algorithms for EncryptingCredentials.

The motivation is described in #2081

Notably #1606 first added support for AESGCM Decryption, but throws a NotSupportedException when attempting to create a new EncryptingCredentials. It also adds a testing class that supports Encryption / Decryption, but I don't have the full context on why encryption was excluded from production code given that decryption works as expected. Alternatively I wouldn't mind overloading CryptoProvider / AuthenticatedEncryptionProvider with the Windows-specific Interop for my use case (.NET Framework), but these types are made internal to the library.

Uses the existing Windows Interop for OS Support of the encryption algorithm.

securityKey = new SymmetricSecurityKey(GenerateAesGcmKeyBytes(256));
else
throw LogHelper.LogExceptionMessage(
new SecurityTokenEncryptionFailedException(LogHelper.FormatInvariant(TokenLogMessages.IDX10617, LogHelper.MarkAsNonPII(SecurityAlgorithms.Aes128CbcHmacSha256), LogHelper.MarkAsNonPII(SecurityAlgorithms.Aes192CbcHmacSha384), LogHelper.MarkAsNonPII(SecurityAlgorithms.Aes256CbcHmacSha512), LogHelper.MarkAsNonPII(encryptingCredentials.Enc))));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if I provide a custom CryptoProviderFactory with my own implementation of AuthenticatedEncryptionProvider, this code still throws and prevents me from creating tokens of type AESGCM

One alternate approach would be to have two separate PRs:

  1. Enable support for AES-GCM with custom CryptoProviderFactory. This would allow consumers of the API to plug-in their own AuthenticatedEncryptionProvider (e.g. Windows Interop / .NET AES GCM)

  2. A separate PR that adds support for AES-GCM Encryption. Later .NET APIs have a cross-platform API to call, but folks on .NET Framework would need to use Windows Interop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant