public CMSEnvelopedDataParser( InputStream envelopedData) throws CMSException, IOException { super(envelopedData); this.attrNotRead = true; this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE)); // TODO Validate version? //DERInteger version = this._envelopedData.getVersion(); OriginatorInfo info = this.envelopedData.getOriginatorInfo(); if (info != null) { this.originatorInfo = new OriginatorInformation(info); } // // read the recipients // ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive()); // // read the encrypted content info // EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo(); this.encAlg = encInfo.getContentEncryptionAlgorithm(); CMSReadable readable = new CMSProcessableInputStream( ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream()); CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable( this.encAlg, readable); // // build the RecipientInformationStore // this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore( recipientInfos, this.encAlg, secureReadable); }
public CMSEnvelopedDataParser( InputStream envelopedData) throws CMSException, IOException { super(envelopedData); this.attrNotRead = true; this.envelopedData = new EnvelopedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE)); // TODO Validate version? //ASN1Integer version = this._envelopedData.getVersion(); OriginatorInfo info = this.envelopedData.getOriginatorInfo(); if (info != null) { this.originatorInfo = new OriginatorInformation(info); } // // read the recipients // ASN1Set recipientInfos = ASN1Set.getInstance(this.envelopedData.getRecipientInfos().toASN1Primitive()); // // read the encrypted content info // EncryptedContentInfoParser encInfo = this.envelopedData.getEncryptedContentInfo(); this.encAlg = encInfo.getContentEncryptionAlgorithm(); CMSReadable readable = new CMSProcessableInputStream( ((ASN1OctetStringParser)encInfo.getEncryptedContent(BERTags.OCTET_STRING)).getOctetStream()); CMSSecureReadable secureReadable = new CMSEnvelopedHelper.CMSEnvelopedSecureReadable( this.encAlg, readable); // // build the RecipientInformationStore // this.recipientInfoStore = CMSEnvelopedHelper.buildRecipientInformationStore( recipientInfos, this.encAlg, secureReadable); }
private void parseEnveloped(byte[] data) throws IOException { ASN1StreamParser aIn = new ASN1StreamParser(data); ContentInfoParser cP = new ContentInfoParser((ASN1SequenceParser)aIn.readObject()); EnvelopedDataParser eP = new EnvelopedDataParser((ASN1SequenceParser)cP.getContent(BERTags.SEQUENCE)); eP.getRecipientInfos().toASN1Primitive(); // Must drain the parser! EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo(); ASN1OctetStringParser content = (ASN1OctetStringParser)ecP.getEncryptedContent(BERTags.OCTET_STRING); Streams.drain(content.getOctetStream()); }