Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.RecipientInformationStore


        CMSEnvelopedData ed = edGen.generate(new CMSProcessableByteArray(resp),CMSEnvelopedDataGenerator.DES_EDE3_CBC,"BC");
        resp = ed.getEncoded();
      }
      if ((serviceReq.getMode() & CmsCAServiceRequest.MODE_DECRYPT) != 0) {
        CMSEnvelopedData ed = new CMSEnvelopedData(resp);
        RecipientInformationStore  recipients = ed.getRecipientInfos();
        RecipientId id = new RecipientId();
        id.setIssuer(getCMSCertificate().getIssuerX500Principal());
        id.setSerialNumber(getCMSCertificate().getSerialNumber());
        RecipientInformation recipient = recipients.get(id);
        if (recipient != null) {
          resp = recipient.getContent(this.privKey, "BC");
        }
      }
      returnval = new CmsCAServiceResponse(resp);
View Full Code Here


            log.error(errorText);
            return;
        }

        CMSEnvelopedData ed = new CMSEnvelopedData(envEncData);
        RecipientInformationStore recipients = ed.getRecipientInfos();
        Collection c = recipients.getRecipients();
        Iterator it = c.iterator();
        byte[] decBytes = null;

        while (it.hasNext()) {
            RecipientInformation recipient = (RecipientInformation) it.next();
View Full Code Here

  public static byte[] decryptData(PrivateKey decKey, byte[] encData) {
    byte[] retdata = null;
    try{
      CMSEnvelopedData ed = new CMSEnvelopedData(encData);          
     
      RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator    it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();     
      retdata = recipient.getContent(decKey, provider);
    } catch(Exception e){
      log.error("Error decypting data : ", e);
    }
View Full Code Here

              // First we extract the encrypted data from the CMS enveloped data contained
              // within the CMS signed data
              final CMSProcessable sp = s.getSignedContent();
              final byte content[] = (byte[])sp.getContent();
              final CMSEnvelopedData ed = new CMSEnvelopedData(content);
              final RecipientInformationStore recipients = ed.getRecipientInfos();
              final RecipientInformation recipient;
              {
                final Collection<?> c = recipients.getRecipients();
                if ( c.size() != 1 ) {
                  StressTest.this.performanceTest.getLog().error("recipients should be 1: "+c.size());
                  return false;
                }
                final Iterator<?> it = c.iterator();
View Full Code Here

            // contained
            // within the CMS signed data
            final CMSProcessable sp = s.getSignedContent();
            final byte[] content = (byte[]) sp.getContent();
            final CMSEnvelopedData ed = new CMSEnvelopedData(content);
            final RecipientInformationStore recipients = ed.getRecipientInfos();
            CertStore certstore;
            {
                Collection<RecipientInformation> c = recipients.getRecipients();
                assertEquals(c.size(), 1);
                Iterator<RecipientInformation> it = c.iterator();
                byte[] decBytes = null;
                RecipientInformation recipient = it.next();
                decBytes = recipient.getContent(key1.getPrivate(), "BC");
View Full Code Here

            // First we extract the encrypted data from the CMS enveloped data contained
            // within the CMS signed data
            CMSProcessable sp = s.getSignedContent();
            byte[] content = (byte[])sp.getContent();
            CMSEnvelopedData ed = new CMSEnvelopedData(content);
            RecipientInformationStore recipients = ed.getRecipientInfos();
            Collection c = recipients.getRecipients();
            assertEquals(c.size(), 1);
            Iterator it = c.iterator();
            byte[] decBytes = null;
            RecipientInformation recipient = (RecipientInformation) it.next();
            decBytes = recipient.getContent(keys.getPrivate(), "BC");
View Full Code Here

    }
   
    public KeyPair decryptKeys(byte[] data) throws Exception {
      CMSEnvelopedData ed = new CMSEnvelopedData(data);          
          
    RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();
      ObjectInputStream ois = null;
      byte[] recdata = recipient.getContent(getCAToken().getPrivateKey(SecConst.CAKEYPURPOSE_KEYENCRYPT),getCAToken().getJCEProvider());
      ois = new ObjectInputStream(new ByteArrayInputStream(recdata));
                 
View Full Code Here

      return (KeyPair) ois.readObject()
    }

  public byte[] decryptData(byte[] data, int cAKeyPurpose) throws Exception {
      CMSEnvelopedData ed = new CMSEnvelopedData(data);
    RecipientInformationStore  recipients = ed.getRecipientInfos();            
      Iterator it =  recipients.getRecipients().iterator();
      RecipientInformation   recipient = (RecipientInformation) it.next();
      byte[] recdata = recipient.getContent(getCAToken().getPrivateKey(cAKeyPurpose),getCAToken().getProvider());     
                 
      return recdata; 
  }
View Full Code Here

    validate(pkcsPkiEnvelope);

    LOGGER.debug(
        "Decrypting pkcsPkiEnvelope using key belonging to [issuer={}; serial={}]",
        recipient.getIssuerDN(), recipient.getSerialNumber());
    final RecipientInformationStore recipientInfos = pkcsPkiEnvelope
        .getRecipientInfos();
    RecipientInformation info = recipientInfos
        .get(new JceKeyTransRecipientId(recipient));

    if (info == null) {
      throw new MessageDecodingException(
          "Missing expected key transfer recipient");
View Full Code Here

      {
         MimeBodyPart encryptedBodyPart = body;
         SMIMEEnveloped m = new SMIMEEnveloped(encryptedBodyPart);
         JceKeyTransRecipientId recId = new JceKeyTransRecipientId(cert);

         RecipientInformationStore recipients = m.getRecipientInfos();
         RecipientInformation recipient = recipients.get(recId);

         decrypted = SMIMEUtil.toMimeBodyPart(recipient.getContent(pKey, "BC"));
      }
      catch (Exception e1)
      {
View Full Code Here

TOP

Related Classes of org.bouncycastle.cms.RecipientInformationStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.