Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] New function suggestion in RSACryptoServiceProvider #409

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ codeunit 1445 RSACryptoServiceProvider
end;
#endif

/// <summary>
/// Creates an instance of RSACryptoServiceProvider from the specified encrypted PKCS#8 private key.
/// </summary>
/// <param name="EncryptedKeyInStream">The input stream containig ecrypted PKCS#8 private key.</param>
/// <param name="Password">Password to decrypt the private key.</param>
[NonDebuggable]
procedure ImportEncryptedPkcs8PrivateKey(EncryptedKeyInStream: InStream; Password: Text)
begin
RSACryptoServiceProviderImpl.ImportEncryptedPkcs8PrivateKey(EncryptedKeyInStream, Password);
end;

/// <summary>
/// Creates and returns an XML string containing the key of the current RSA object.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@
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);

Check failure on line 189 in src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Clean) / System Application (Clean)

AL0196 The call is ambiguous between the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)' and the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Char>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)'.

Check failure on line 189 in src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Translated) / System Application (Translated)

AL0196 The call is ambiguous between the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)' and the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Char>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)'.

Check failure on line 189 in src/System Application/App/Cryptography Management/src/RSACryptoServiceProviderImpl.Codeunit.al

View workflow job for this annotation

GitHub Actions / Build System Application (Default) / System Application (Default)

AL0196 The call is ambiguous between the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)' and the method 'ImportEncryptedPkcs8PrivateKey(DotNet "System.ReadOnlySpan<System.Char>", DotNet "System.ReadOnlySpan<System.Byte>", DotNet "System.Int32&")' defined in DotNet 'System.Security.Cryptography.RSACryptoServiceProvider' by the extension 'System Application by Microsoft (25.0.2147483647.0)'.
end;
#endregion

local procedure RSACryptoServiceProvider()
begin
DotNetRSACryptoServiceProvider := DotNetRSACryptoServiceProvider.RSACryptoServiceProvider();
Expand Down
4 changes: 4 additions & 0 deletions src/System Application/App/DotNet Aliases/src/dotnet.al
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,10 @@ dotnet
{
}

type("System.ReadOnlySpan`1"; "ReadOnlySpan1")
{
}

type("System.Collections.ArrayList"; "ArrayList")
{
}
Expand Down
Loading