I am using a smart card device used to sign pdf document. I already know how to sign the pdf using itext.
I have a 20 byte sha-1 hash, 256 byte signature (rsa encrypted by smart card private key) and a public key (.cer certificate)
Is there a way to create a pkcs#7 binary object in C, using a free library such as cryptlib?
You seem to want to generate a PKCS#7 / CMS (cryptographic message syntax) signature using a pre-calculated signature.
This is - to my surprise - possible but for a very big IF. That IF is that the CMS message doesn't contain any additional meta data that needs to be signed. In the badly phrased words of the CMS RFC:
You can exclude the
signedAtrrsin for instance OpenSSL using the-noattrcommand line option. Unfortunately I did not find a direct way to include the signature value itself, but this is very likely to be possible using the C API of OpenSSL - and as OpenSSL is Open Source, it would of course be possible to amend this problem if it isn't.Notes: