EncryptedContentInfo ::= SEQUENCE { contentType ContentType, contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier, encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL }
295296297298299300301302303304305306307
private void parseEnveloped(byte[] data) throws IOException { Asn1InputStream aIn = new Asn1InputStream(data); ContentInfoParser cP = new ContentInfoParser((Asn1Sequence)aIn.readObject()); EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE)); eP.getRecipientInfos(); EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
182183184185186187188189190191192193194195196197
// // reading back // Asn1InputStream aIn = new Asn1InputStream(bOut.toByteArray()); ContentInfoParser cp = new ContentInfoParser((Asn1Sequence)aIn.readObject()); CompressedDataParser comData = new CompressedDataParser((Asn1Sequence)cp.getContent(BerTag.SEQUENCE)); ContentInfoParser content = comData.getEncapContentInfo(); Asn1OctetString bytes = (Asn1OctetString)content.getContent(BerTag.OCTET_STRING); InputStream in = bytes.getOctetStream(); int count = 0; while (in.read() >= 0)
301302303304305306307308309310311312313
EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE)); eP.getRecipientInfos(); EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo(); Asn1OctetString content = (Asn1OctetString)ecP.getEncryptedContent(BerTag.OCTET_STRING); InputStream in = content.getOctetStream(); while (in.read() >= 0) {
297298299300301302303304305306307308309310311
{ Asn1InputStream aIn = new Asn1InputStream(data); ContentInfoParser cP = new ContentInfoParser((Asn1Sequence)aIn.readObject()); EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE)); eP.getRecipientInfos(); EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo(); Asn1OctetString content = (Asn1OctetString)ecP.getEncryptedContent(BerTag.OCTET_STRING); InputStream in = content.getOctetStream();