[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] Constructing a signed S/Mime with signature and without private key


I'm working with smartcards, the SC stores the private key. I can get only the signature and not the private key. I try to create an S/MIME message. 

I have the SMimeSigned object created:

FileInputStream isCert = new FileInputStream ("certificate.cer");
X509Certificate cert = new X509Certificate (isCert);

X509Certificate[] certificates = new X509Certificate [1];
certificates [0] = cert;

FileInputStream isMsg = new FileInputStream ("msg.txt");

SMimeSigned signedData = new SMimeSigned (isMsg, SignedDataStream.IMPLICIT);
signedData.setCertificates (certificates);

IssuerAndSerialNumber issuer = new IssuerAndSerialNumber (cert);
SignerInfo signerInfo = new SignerInfo (issuer, AlgorithmID.sha1, null);

FileInputStream isSign = new FileInputStream ("signature.sig");
byte [] bufSign = new byte [isSign.available()];
isSign.read (bufSign);
signerInfo.setEncryptedDigest (bufSign);

signedData.addSignerInfo (signerInfo);

FileOutputStream osP7 = new FileOutputStream ("test.msg");
signedData.writeTo (osP7, 2048);

What is the next step? I don't see the connection to SignedContent or MimeMessage object.

With kind regards,

Istvan Parti
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-jce