Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create an pkcs7 block for key exchange only (bouncy castle)
    text
    copied!<p>I am trying to create a file containing a pkcs 7 block. In this container, I need my public key and my signer info (no signed data!!!). I have already tried several alternatives without any luck. This is my code:</p> <p>First the signature info:</p> <pre><code> List&lt;X509Certificate&gt; certs = new List&lt;X509Certificate&gt; { cert }; IX509Store x509Certs = X509StoreFactory.Create( "CERTIFICATE/COLLECTION", new X509CollectionStoreParameters(certs)); var ias = new IssuerAndSerialNumber(cert.IssuerDN, cert.SerialNumber); SignerIdentifier sid = new SignerIdentifier(ias); AlgorithmIdentifier algoDigId = new AlgorithmIdentifierCmsSignedGenerator.DigestSha1); AlgorithmIdentifier algoCryptId = new AlgorithmIdentifier(CmsSignedGenerator.EncryptionRsa); SignerInfo si = new SignerInfo(sid, algoDigId, null, algoCryptId, new DerOctetString(contentSignature), null); </code></pre> <p>the contentSignature byte[] contains a signed digest for some info.</p> <p>Now, when I try to create the SignedData, everything goes down</p> <pre><code> var signedContent = new ContentInfo(CmsObjectIdentifiers.Data, DerNull.Instance); CmsSignedData csd = new CmsSignedData(signedContent); </code></pre> <p>I am not trying to send info, this is only for key exchange and verification purposes. I believe this is a valid scenario but somehow this does not work.</p> <p>Thanks for your help.</p> <p>UPDATE:</p> <p>more context.</p> <p>I am trying to sign a JAR from a .Net executable. I have pretty much done the rest of the process but jarsigner creates a pkcs7 file with:</p> <ul> <li><p>ContentInfo set to type Data and no content. So far, making new ContentInfo( CmsObjectIdentifiers.Data, null) just throws an exception while adding the content info to the CmsData</p></li> <li><p>A SignerInfo is added, this SignerInfo includes a signature previously derived from the JAR's content.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload