Manually embedding of RSA digital signature into CMS structure
Hi David,
Do you know if its possible to manually embed a previously calculated 1024 bits RSA digital signature into a CMS. With bouncycastle, the way I saw to sign data and generate a CMSSignedData structure is done with 'generate' method of CMSSignedDataGenerator.
This method requires as Input the private key that will be used for signing. In my case I can't do that as I'm calculating the digital signature of a SHA-1 hash using a smartcard, at the APDU level. After performing the digital signature (with a previous authentication in order to gain access to the private key that never leaves the card), the card returns a 128 bytes answer (the pure 1024 bits signature).
I'm requested to return this signature as a CMSSignedData object, that includes the hash to be signed (SHA1, 20 bytes), the signed hash (this 128 bytes), and the public key certificate associated with the private key that has been used to sign.
I've all the things separated: the hash, the signed hash and the X509 Public Key Certificate, but I don't know how to manually construct a valid CMSSignedData struct with all these.
Do you know how this can be done with BouncyCastle? or any other way to achieve it?
Thank you in advance!
Best Regards,
Lautaro.
|