/** @deprecated use open(OutputStream, ASN1ObjectIdentifier, ContentCompressor) */ public OutputStream open(OutputStream out, String contentOID, String compressionOID) throws IOException { BERSequenceGenerator sGen = new BERSequenceGenerator(out); sGen.addObject(CMSObjectIdentifiers.compressedData); // // Compressed Data // BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true); cGen.addObject(new DERInteger(0)); // // AlgorithmIdentifier // DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream()); algGen.addObject(new DERObjectIdentifier(ZLIB)); algGen.close(); // // Encapsulated ContentInfo // BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream()); eiGen.addObject(new DERObjectIdentifier(contentOID)); OutputStream octetStream = CMSUtils.createBEROctetOutputStream(eiGen.getRawOutputStream(), 0, true, _bufferSize); return new CmsCompressedOutputStream(new DeflaterOutputStream(octetStream), sGen, cGen, eiGen); }
/** * Open a compressing output stream. * * @param contentOID * @param out * @param compressor * @return * @throws IOException */ public OutputStream open( ASN1ObjectIdentifier contentOID, OutputStream out, OutputCompressor compressor) throws IOException { BERSequenceGenerator sGen = new BERSequenceGenerator(out); sGen.addObject(CMSObjectIdentifiers.compressedData); // // Compressed Data // BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true); cGen.addObject(new DERInteger(0)); // // AlgorithmIdentifier // cGen.addObject(compressor.getAlgorithmIdentifier()); // // Encapsulated ContentInfo // BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream()); eiGen.addObject(contentOID); OutputStream octetStream = CMSUtils.createBEROctetOutputStream(eiGen.getRawOutputStream(), 0, true, _bufferSize); return new CmsCompressedOutputStream( compressor.getOutputStream(octetStream), sGen, cGen, eiGen); }
/** * Add a recipient based on the passed in certificate's public key and its issuer and serial * number. * * @param recipientCert recipient's certificate * @return the current instance. * @throws CertificateEncodingException if the necessary data cannot be extracted from the * certificate. */ public JceKeyAgreeRecipientInfoGenerator addRecipient(X509Certificate recipientCert) throws CertificateEncodingException { recipientIDs.add( new KeyAgreeRecipientIdentifier(CMSUtils.getIssuerAndSerialNumber(recipientCert))); recipientKeys.add(recipientCert.getPublicKey()); return this; }
AlgorithmIdentifier getAlgorithmIdentifier( ASN1ObjectIdentifier encryptionOID, AlgorithmParameters params) throws CMSException { ASN1Encodable asn1Params; if (params != null) { asn1Params = CMSUtils.extractParameters(params); } else { asn1Params = DERNull.INSTANCE; } return new AlgorithmIdentifier(encryptionOID, asn1Params); }
protected Key extractSecretKey( AlgorithmIdentifier keyEncryptionAlgorithm, AlgorithmIdentifier encryptedKeyAlgorithm, byte[] encryptedEncryptionKey) throws CMSException { AsymmetricKeyUnwrapper unwrapper = helper.createAsymmetricUnwrapper(keyEncryptionAlgorithm, recipientKey); try { return CMSUtils.getJceKey( unwrapper.generateUnwrappedKey(encryptedKeyAlgorithm, encryptedEncryptionKey)); } catch (OperatorException e) { throw new CMSException("exception unwrapping key: " + e.getMessage(), e); } }
public CMSDigestedData(InputStream compressedData) throws CMSException { this(CMSUtils.readContentInfo(compressedData)); }
public CMSAuthEnvelopedData(InputStream authEnvData) throws CMSException { this(CMSUtils.readContentInfo(authEnvData)); }
/** * decrypt the content and return an input stream. * * @deprecated use getContentStream(Recipient) */ public CMSTypedStream getContentStream(Key key, String prov) throws CMSException, NoSuchProviderException { return getContentStream(key, CMSUtils.getProvider(prov)); }
/** * return an AlgorithmParameters object representing the parameters to the key derivation * algorithm to the recipient. * * @return AlgorithmParameters object, null if there aren't any. */ public AlgorithmParameters getKeyDerivationAlgParameters(String provider) throws NoSuchProviderException { return getKeyDerivationAlgParameters(CMSUtils.getProvider(provider)); }
/** * verify that the given certificate successfully handles and confirms the signature associated * with this signer and, if a signingTime attribute is available, that the certificate was valid * at the time the signature was generated. * * @deprecated use verify(ContentVerifierProvider) */ public boolean verify(X509Certificate cert, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CertificateExpiredException, CertificateNotYetValidException, CMSException { return verify(cert, CMSUtils.getProvider(sigProvider)); }
/** * verify that the given public key successfully handles and confirms the signature associated * with this signer. * * @deprecated use verify(ContentVerifierProvider) */ public boolean verify(PublicKey key, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException { return verify(key, CMSUtils.getProvider(sigProvider)); }