Decrypting RSA signature using public key fails

From: Andrus Moor (nospam_at_no.no)
Date: 12/22/04


Date: Wed, 22 Dec 2004 23:14:31 +0200

I have a RSA signature S (128 byte integer ) and modulus n (also 128 byte
integer)

I need to calculate

( S**3 ) MOD n

All I need is to perform exponent ( S**3 ) and MOD operation on
128 byte integers using Windows Crypto API

I created a PUBLICKEYBLOB structure :

06020000 00240000 prefix
RSA1 words
modulus len (1024 bitts)
exponent (3)
modulus E3BF ...

result is:

06020000 00240000 52534131 00040000 03000000
E3BFA04FB29DE84F614B4F4482BE5586F0DA8366DF492E25FA820B519CA020DB41B1DD360243
A26203B19FE6BAD7BAFCE6D6EABF91D22C94CC9BA591F4E1C45851035F1648504C4DB32954DC
3719791201C80D59C23284F1EF9A916E2CF000B3A97ABE2194E85598BE02E05A8A8D98DAD01A
D1D6F464F4E7543A47B4F1B87F49

I pass this structure to a CryptImportkey() and receive a key handle without
error.

I have a PKCS#1 v1.5 signature (128 bytes, created manually)

D0A6E9D79BAB3E89118FED6ABD93EA3A2803D41B4F2A990FFE3DDC9FB711BCEA88291A1BBB71
1902C71B105700680FD3C8E1E08CF99E304595122EEB1CD7896AC0DABAF1EF8CCA405F2EDF96
BD715F90381E8624CCF60C5A67205A7BF0AAE06BF981669B42E82CC74C72DF8ECE481158BA46
D98E57CF536359ADB62438DDA253

I pass the key handle and this signature to a cryptdecrypt using parameters

CryptDecrypt( pihKeyHandle, 0, -1,0, picData, lcDataLen)

but got an error code 3

Any idea why CryptDecrypt() fails ?

Andrus