diff --git a/src/System Application/App/Cryptography Management/src/RSACryptoServiceProvider.Codeunit.al b/src/System Application/App/Cryptography Management/src/RSACryptoServiceProvider.Codeunit.al index dcccaa820c..cfe3cb582a 100644 --- a/src/System Application/App/Cryptography Management/src/RSACryptoServiceProvider.Codeunit.al +++ b/src/System Application/App/Cryptography Management/src/RSACryptoServiceProvider.Codeunit.al @@ -97,6 +97,17 @@ codeunit 1445 RSACryptoServiceProvider end; #endif + /// + /// Creates an instance of RSACryptoServiceProvider from the specified encrypted PKCS#8 private key. + /// + /// The input stream containig ecrypted PKCS#8 private key. + /// Password to decrypt the private key. + [NonDebuggable] + procedure ImportEncryptedPkcs8PrivateKey(EncryptedKeyInStream: InStream; Password: Text) + begin + RSACryptoServiceProviderImpl.ImportEncryptedPkcs8PrivateKey(EncryptedKeyInStream, Password); + end; + /// /// Creates and returns an XML string containing the key of the current RSA object. /// diff --git a/src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al b/src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al index b0a27c7b80..d8714d6349 100644 --- a/src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al +++ b/src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al @@ -172,6 +172,24 @@ codeunit 1446 "RSACryptoServiceProvider Impl." implements "Signature Algorithm v end; #endregion + #region Pkcs8 + [NonDebuggable] + procedure ImportEncryptedPkcs8PrivateKey(EncryptedKeyInStream: InStream; Password: Text) + var + EncryptedKeyBytes: DotNet Array; + PasswordChars: DotNet Array; + DotNetString: DotNet String; + ReadOnlySpan: DotNet ReadOnlySpan1; + BytesRead: Integer; + begin + InStreamToArray(EncryptedKeyInStream, EncryptedKeyBytes); + DotNetString := Password; + PasswordChars := DotNetString.ToCharArray(); + RSACryptoServiceProvider(); + DotNetRSACryptoServiceProvider.ImportEncryptedPkcs8PrivateKey(ReadOnlySpan.ReadOnlySpan(PasswordChars), ReadOnlySpan.ReadOnlySpan(EncryptedKeyBytes), BytesRead); + end; + #endregion + local procedure RSACryptoServiceProvider() begin DotNetRSACryptoServiceProvider := DotNetRSACryptoServiceProvider.RSACryptoServiceProvider(); diff --git a/src/System Application/App/DotNet Aliases/src/dotnet.al b/src/System Application/App/DotNet Aliases/src/dotnet.al index 9d84294f6d..fbd4ef9d1a 100644 --- a/src/System Application/App/DotNet Aliases/src/dotnet.al +++ b/src/System Application/App/DotNet Aliases/src/dotnet.al @@ -1403,6 +1403,10 @@ dotnet { } + type("System.ReadOnlySpan`1"; "ReadOnlySpan1") + { + } + type("System.Collections.ArrayList"; "ArrayList") { }