title: How to extract PKCS#1 signature from PKCS#7
body: <p>I know that <code>PKCS#7 = Certificate + Optional raw data + Signature in PKCS#1 format</code> I need to extract PKCS#1 from a PKCS#7 signature how can I do this in C#. Can I use the bouncy castle to do this, Here is my implementation 
  ie. to convert PKCS#7 to ASN.1 and to take the last sequence as it is PKCS#1</p>
  
  <pre><code>Asn1InputStream asn1 = new Asn1InputStream(pkcs7Stream);
  Asn1Sequence sequence = (Asn1Sequence)asn1.ReadObject().ToAsn1Object();
  var sequenceString = sequence.ToString();
  var lastCommaIndex = sequenceString.LastIndexOf(",");
  var pkcs1HexStr = sequenceString.Substring(lastCommaIndex + 3).Replace("]", string.Empty);
  </code></pre>
  
  <p>Is there any other eligant way to obtain PKCS#1</p>