question

CatalinJuganaru-3997 avatar image
0 Votes"
CatalinJuganaru-3997 asked CatalinJuganaru-3997 commented

How to import 1024 bits RSA private key

Hi,

Please help me to import 1024 bits RSA Private Key with BCryptImportKey.
I need to make some encryption and decryption for tls authentications.
I spent some time on this issue, but with the existing documentation I can not solve it.
I generated keys, hashes, but I can't manage to import this 128-byte private key under any circumstances.
Please help me with a complete documentation of the necessary parameters or with an example.

Thank you very much.
Catalin

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

XiaopoYang-MSFT avatar image
0 Votes"
XiaopoYang-MSFT answered CatalinJuganaru-3997 commented

Perhaps you should use BCryptImportKeyPair with BCRYPT_RSAPRIVATE_BLOB. A quick search for a sample.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I managed to import a RSA private key with 2048 bits. Thank you very much.

I further sign a 32 byte hash and send it along with other data as a TLS1.3 packet.
If I sign with

BCRYPT_PKCS1_PADDING_INFO paddingInfo = {};
paddingInfo.pszAlgId = BCRYPT_SHA256_ALGORITHM;

I get what is in the picture: "last octet invalid : rsa_pss.c:94", etc, etc

199869-tls-error.png


0 Votes 0 ·
tls-error.png (49.7 KiB)
XiaopoYang-MSFT avatar image XiaopoYang-MSFT CatalinJuganaru-3997 ·

Hello @CatalinJuganaru-3997 , Could you please show a minimal, reproducible sample without private information?

0 Votes 0 ·