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

Update RSA.Codeunit.al #2255

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Create function to get the XML structure via the private key
MattiLE committed Oct 28, 2024
commit 1b0db6088adfa2ad74ec369a3353b7a5eee7d68c
Original file line number Diff line number Diff line change
@@ -27,13 +27,14 @@ codeunit 1475 "RSA"
end;

/// <summary>
/// Initializes a new instance of RSA with the specified key size and a pem private Key.
/// Creates a RSA object with private key and returns the XML string.
/// </summary>
/// <param name="KeySize">The size of the key in bits.</param>
/// <param name="PrivateKey">The private key as text.</param>
procedure InitializeRSA(KeySize: Integer; PrivateKey: Text)
/// <param name="PrivateKey">private key as text</param>
/// <param name="IncludePrivateParameters">true to include a public and private RSA key; false to include only the public key.</param>
/// <returns>An XML string containing the key of the current RSA object.</returns>
procedure ToSecretXmlString(PrivateKey: SecretText; IncludePrivateParameters: Boolean): SecretText
begin
RSAImpl.InitializeRSA(KeySize, PrivateKey);
exit(RSAImpl.ToSecretXmlString(PrivateKey, IncludePrivateParameters));
end;

/// <summary>
@@ -96,4 +97,4 @@ codeunit 1475 "RSA"
begin
RSAImpl.Decrypt(XmlString, EncryptedTextInStream, OaepPadding, DecryptedTextOutStream);
end;
}
}
Original file line number Diff line number Diff line change
@@ -186,6 +186,14 @@
DotNetRSA.FromXmlString(XmlString);
end;
#endif

procedure ToSecretXmlString(PrivateKey: SecretText; IncludePrivateParameters: Boolean): SecretText
begin
DotNetRSA := DotNetRSA.Create(2048);
DotNetRSA.ImportFromPem(PrivateKey);

Check failure on line 193 in src/System Application/App/Cryptography Management/src/RSAImpl.Codeunit.al

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

AL0133 Argument 1: cannot convert from 'SecretText' to 'DotNet "System.ReadOnlySpan<System.Char>"'

Check failure on line 193 in src/System Application/App/Cryptography Management/src/RSAImpl.Codeunit.al

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

AL0133 Argument 1: cannot convert from 'SecretText' to 'DotNet "System.ReadOnlySpan<System.Char>"'

Check failure on line 193 in src/System Application/App/Cryptography Management/src/RSAImpl.Codeunit.al

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

AL0133 Argument 1: cannot convert from 'SecretText' to 'DotNet "System.ReadOnlySpan<System.Char>"'
exit(ToSecretXmlString(IncludePrivateParameters));
end;

procedure ToSecretXmlString(IncludePrivateParameters: Boolean): SecretText
begin
exit(DotNetRSA.ToXmlString(IncludePrivateParameters));