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

Move to generated keys in RSA tests #826

Merged
merged 2 commits into from
Mar 26, 2024
Merged
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 @@ -155,4 +155,17 @@ codeunit 1445 RSACryptoServiceProvider
begin
RSACryptoServiceProviderImpl.Decrypt(XmlString, EncryptedTextInStream, OaepPadding, DecryptedTextOutStream);
end;

/// <summary>
/// The CreateRSAKeyPair procedure is a function that generates a public and private RSA key pair.
/// </summary>
/// <param name="PublicKeyInXml">This is an output parameter that returns the public key in XML format.</param>
/// <param name="PrivateKeyInXml">This is an output parameter that returns the private key in XML format. This is a sensitive information hence marked as SecretText.</param>
/// <returns>
/// This function does not return a value. The output is via the two parameters PublicKeyInXml and PrivateKeyInXml.
/// </returns>
procedure CreateRSAKeyPair(var PublicKeyInXml: Text; var PrivateKeyInXml: SecretText)
begin
RSACryptoServiceProviderImpl.CreateRSAKeyPair(PublicKeyInXml, PrivateKeyInXml);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ codeunit 1446 "RSACryptoServiceProvider Impl." implements "Signature Algorithm v
DotNetAsymmetricAlgorithm := DotNetRSACryptoServiceProvider;
end;

[NonDebuggable]
procedure CreateRSAKeyPair(var PublicKeyInXml: Text; var PrivateKeyInXml: SecretText)
var
DotnetRSA: DotNet RSA;
begin
RSACryptoServiceProvider();
DotnetRSA := DotNetRSACryptoServiceProvider.Create();
PublicKeyInXml := DotnetRSA.ToXmlString(false);
PrivateKeyInXml := DotnetRSA.ToXmlString(true);
end;

#region SignData
procedure SignData(XmlString: SecretText; DataInStream: InStream; HashAlgorithm: Enum "Hash Algorithm"; SignatureOutStream: OutStream)
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ codeunit 132613 RSACryptoServiceProviderTests
begin
if IsInitialized then
exit;
PrivateKeyXmlStringSecret := Base64Convert.FromBase64('PFJTQUtleVZhbHVlPjxNb2R1bHVzPmNKMHBpL2ZBcXJTRy9TZTUrZGdzcksyNjNwSUkvQjhieGZyWDBoMm1aN0VZUWhURXhYa2d6Z0xwS3dFRWFmdUs0MFVqUjEzNlNLQ3I5S240aHpPek1zam5hMXJJRXJCUnMzcU5IS1NxS3JzdkhaUTljRFo3RElVekh2cVh0Q01KMFo0clFBZlZLcWl2bGZqd3RJR1ZPSXRKK0RMT1E4S2tZNjJiOTI2YzhMTEtGUG5SU1ZxQnQrL3lGbEJ3M1NlQWdNYzBtaXRKRUhvYW5LdExXc3RLVzlDTW55OWc1R1V2cnZaY0wwUjR4NkpabFlGTVMwQnBmdFJNbmFrbnI3VXpxMGdvWnY4OHhmb1IrTW1ud1ZUOWdTU0ZRRW1rOVRHaVdjdUV1bnFNUmZ4b3htQW0zVGt3RTRMSDVDNHVNMWRlUGVnWDM0bmoyZmphOWhpUWtReHVqdz09PC9Nb2R1bHVzPjxFeHBvbmVudD5BUUFCPC9FeHBvbmVudD48UD5zSW5SbG0wSGRWeTMrUlo0NDhLNTZaSVNDdkNQNlVMZGZJMk10RU96MlZ2cUN2Z0Vham1BckJkYmYzaUVFNUlXRWhNbEtRRGJCVktZdVMvcW1hanROc202cVhUMXFiRldIdGRQcGNmQ3BMeVFHT2Y0dStFb2xnK2FIWFlIYytNejdSdjBIOSt2NUlxejVWMzZ0ck11N0Q4clF5QVNMeHR2L3BYZ1ZDVzRpUk09PC9QPjxRPm8wMXpmb0UxazBzdmdhRGNzUHEzNWxPaTlsV25LVWUvNzA2eDdjeDNES1drQmR4aUhOSDJFVjhsTVhnS2hra2s2YmNocWo3dXNaQi9OdVBZaER0TWRsYnd3REdkTmFmZ09qKy94Q2loUEFRaF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HlDbnZnN2gyRUdzRnh4N1RRbVdneWxoT3YweTdaQXp5Q0Rmc3JEUy90Mk8rcHNoWm9PYkpWZGVlVlNlaVF4QVZLYTNFTzdJRHFLNm5pSHV2azhOMVgyejBBYWFWaVlJUDdJZ0JXMmdZNXJwcTlRa25HZHhxb2I2VHFvQlV4aFBSM2VVblAvbWhnOWlXejZiNW42RnhsR2tSVkxSMndjaVQ1Z25TMzFjaEJ3cXVRPT08L0Q+PC9SU0FLZXlWYWx1ZT4=');
PublicKeyXmlString := Base64Convert.FromBase64('PFJTQUtleVZhbHVlPjxNb2R1bHVzPmNKMHBpL2ZBcXJTRy9TZTUrZGdzcksyNjNwSUkvQjhieGZyWDBoMm1aN0VZUWhURXhYa2d6Z0xwS3dFRWFmdUs0MFVqUjEzNlNLQ3I5S240aHpPek1zam5hMXJJRXJCUnMzcU5IS1NxS3JzdkhaUTljRFo3RElVekh2cVh0Q01KMFo0clFBZlZLcWl2bGZqd3RJR1ZPSXRKK0RMT1E4S2tZNjJiOTI2YzhMTEtGUG5SU1ZxQnQrL3lGbEJ3M1NlQWdNYzBtaXRKRUhvYW5LdExXc3RLVzlDTW55OWc1R1V2cnZaY0wwUjR4NkpabFlGTVMwQnBmdFJNbmFrbnI3VXpxMGdvWnY4OHhmb1IrTW1ud1ZUOWdTU0ZRRW1rOVRHaVdjdUV1bnFNUmZ4b3htQW0zVGt3RTRMSDVDNHVNMWRlUGVnWDM0bmoyZmphOWhpUWtReHVqdz09PC9Nb2R1bHVzPjxFeHBvbmVudD5BUUFCPC9FeHBvbmVudD48L1JTQUtleVZhbHVlPg==');
RSACryptoServiceProvider.CreateRSAKeyPair(PublicKeyXmlString, PrivateKeyXmlStringSecret);
IsInitialized := true;
end;

Expand Down
Loading