Unable to encrypt using a 4096 RSA public key

I have been given a public key generated with the following parameters:

  • Encryption Type: oaep
  • Hash Function: sha512
  • Key Length: kl4096
  • Format: Base64
  • Unicode: Yes

when I try to encrypt the call never returns.

e.g. Try using the following function

function Encrypt(text: string): string;
const
KEY = 'MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAr3LdvmGdOnIZcNJr9LBN' +
'05aFTek8qrrtL7Jm23KmGHPHFeAZcVtfPb7g5aO/hWOKMw69mjyg3rB8OtEzy8qf' +
'wQlhRRHnz0qyxiwAzoX+8AfYjMWaxHoqdUbZAbNef5Snt4k4WDlmDCfpsCf862M6' +
'gmwkijq/SCE0MSf0xA7o+W8HAYGtNab6lXkFaMNQw4xgqjXCMdKpdSQekLOHIREI' +
'x4E/Hw1NagbdIxoQcD6s9qO1FZcf7NX40WnKXbquAMoz+XR2hmN7G5ao7Lwx7tbB' +
'T5SVUcry878JZ6mPU+zcfTcGk7Kn22Z8ifxYw36WVJCV0h7AH5HkruAcNd1QKAom' +
'61eSlXaYxndWkRj7pj7vtlaBp1uhkJ0zGV9UIkGE0tlLUuAA3iuERGjEPO+ccHR0' +
'lL8GQlTK8DzjOVVveMuYGipwx0vQ2v+fBUBRxLuRFswmsk6DoG6ocBeuNmS8t+Oo' +
'SqGYf2MsIKCzXjN+qwNNFEA5vrrQf46utbzkPkpwNcYWtxRZOwxPq/6DUFDsl1/l' +
'h38YKGl5D3cLFLqlGQHqnwSRXDJqZBj9/EJVH33PHDvaes3PZ0KThxgPcT2/m8PF' +
'fb+wdO0Uieiack9zry/3ebZquh4iVbT1GWoK/3qIHi7J7+Cd3XBZNL0FiEfaZlWg' +
'M2mQuZiLMugpMsH60mNh8s8CAwEAAQ==';
begin
crpRSA.FromPublicKey(KEY);
Result := crpRSA.Encrypt(text);
end;

Please note: you will need to add the function to a form that has a TRSAEncSign component on it with the name crpRSA and the following settings:

object crpRSA: TRSAEncSign
Version = '4.3.3.0'
keyLength = kl4096
hashFunction = sha512
outputFormat = base64
pssSaltLen = 0
Left = 304
Top = 120
end:

RSA 4096 causes problems because of a buffer overflow in a modular multiplication.I have fixed it but not released the fix as the library is being ported to Pascal.

If you only need the Pascal version (not the C++ one), I can send you a limited TMS CP library with RSA, AES, SHA2 and SHA3.

Yes, I need the Pascal (Delphi) version. (11.3 and 12 if versions are important). It is fairly urgent, so I would appreciate getting a limited CP library.

can you send me your email address at bernard@tmssoftware.com?

I tried sending an email message to that address. I get the following error:

Original-Recipient: rfc822; bernard@tmssofware.com
Final-Recipient: rfc822; bernard@tmssofware.com
Status: 512
Action: failed
Last-Attempt-Date: 18 Jan 2024 13:41:16 GMT
Diagnostic-Code: 5.4.4 DNS error:NXDOMAIN. Domain not found :tmssofware.com
Remote-MTA: dns; tmssofware.com

Please email me at vannersp@yahoo.com.au

Has this been resolved yet? I am also experiencing that the software freezes when trying to use the RSA 4096 key length (in the demo application).

It is true that RSA 4096 freezes in some cases. That is fixed in 5.0.0 (buffer overflow in the C code that has been fixed, then ported to Delphi).

Where can I find the 5.0.0 version? It does not show up in the subscription manager or on the download page (4.3.3.0 seems to be the latest there).

It's coming up in a few weeks. Working of fixing a few bugs left in XAdES detached.