Skip to content

Commit

Permalink
Create function to get the XML structure via the private key
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiLE committed Oct 28, 2024
1 parent bf5a847 commit 1b0db60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Up @@ -186,6 +186,14 @@ codeunit 1476 "RSA Impl." implements "Signature Algorithm v2"
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

View workflow job for this annotation

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

View workflow job for this annotation

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

View workflow job for this annotation

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));
Expand Down

0 comments on commit 1b0db60

Please sign in to comment.