Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.CMSProcessableByteArray


        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();                                    
      CMSEnvelopedData ed;
    try {
      edGen.addKeyTransRecipient( this.getCAToken().getPublicKey(keyPurpose), this.keyId);
      ed = edGen.generate(
          new CMSProcessableByteArray(data), CMSEnvelopedDataGenerator.AES256_CBC,"BC");
    } catch (Exception e) {
            log.error("-encryptKeys: ", e);
            throw new IOException(e.getMessage());       
    }       
   
View Full Code Here


    private byte[] wrap(byte[] envBytes, String messageType, String transactionId) throws IOException, NoSuchAlgorithmException, NoSuchProviderException, CMSException, InvalidAlgorithmParameterException, CertStoreException {

        //
        // Create inner enveloped data
        //
        CMSEnvelopedData ed = envelope(new CMSProcessableByteArray(envBytes));
        log.debug("Enveloped data is " + ed.getEncoded().length + " bytes long");
        CMSProcessable msg = new CMSProcessableByteArray(ed.getEncoded());
        //
        // Create the outer signed data
        //
        CMSSignedData s = sign(msg, messageType, transactionId);
       
View Full Code Here

      }
    }
    if (hasMessageData) {
      try {
        CMSEnvelopedData ed = encodeMessage(message);
        signable = new CMSProcessableByteArray(ed.getEncoded());
      } catch (IOException e) {
        throw new MessageEncodingException(e);
      }
    } else {
      signable = new CMSAbsentContent();
View Full Code Here

   */
  public CMSEnvelopedData encode(byte[] messageData)
      throws MessageEncodingException {
    LOGGER.debug("Encoding pkcsPkiEnvelope");
    CMSEnvelopedDataGenerator edGenerator = new CMSEnvelopedDataGenerator();
    CMSTypedData envelopable = new CMSProcessableByteArray(messageData);
    RecipientInfoGenerator recipientGenerator;
    try {
      recipientGenerator = new JceKeyTransRecipientInfoGenerator(
          recipient);
    } catch (CertificateEncodingException e) {
View Full Code Here

        if ((this.parameters.isMergeSignatures()) && (this.isSigned(data))) {
          CMSSignedData signedData = new CMSSignedData(data);
          signedDataGenerator.addSigners(signedData.getSignerInfos());
          content = signedData.getSignedContent();
        } else {
          content = new CMSProcessableByteArray(data);
        }

        if (PKCS7SignatureMode.DETACHED.equals(mode)) {
          encapsulate = false;
        }
View Full Code Here

      throw new SignerException(e);
    }
  }

  private boolean verifyAttached(final byte[] data, final byte[] signature) throws CMSException, IOException, OperatorCreationException {
    CMSSignedData signedData = new CMSSignedData(new CMSProcessableByteArray(data), signature);

    CollectionStore certificatesStore = (CollectionStore) signedData.getCertificates();

    SignerInformationStore signerInformationStore = signedData.getSignerInfos();
    boolean verified = true;
View Full Code Here

            je = new JarEntry(numKeys == 1 ?
                              (String.format(CERT_SIG_NAME, keyType)) :
                              (String.format(CERT_SIG_MULTI_NAME, k, keyType)));
            je.setTime(timestamp);
            outputJar.putNextEntry(je);
            writeSignatureBlock(new CMSProcessableByteArray(signedData),
                                publicKey[k], privateKey[k], outputJar);
        }
    }
View Full Code Here

            byte[] signedData = baos.toByteArray();
            mOutputJar.write(signedData);

            // CERT.*
            mOutputJar.putNextEntry(new JarEntry("META-INF/CERT." + mKey.getAlgorithm()));
            writeSignatureBlock(new CMSProcessableByteArray(signedData), mCertificate, mKey);
        }

        mOutputJar.close();
        mOutputJar = null;
    }
View Full Code Here

      bodyHeaders.add("Content-Type",  out.getMediaType().toString());
      writer.writeTo(out.getEntity(), out.getType(), out.getGenericType(), null, out.getMediaType(), bodyHeaders, bodyOs);
      CMSSignedDataGenerator signGen = new CMSSignedDataGenerator();
      signGen.addSigner(out.getPrivateKey(), (X509Certificate)out.getCertificate(), CMSSignedDataGenerator.DIGEST_SHA1);
      //signGen.addCertificatesAndCRLs(certs);
      CMSProcessable content = new CMSProcessableByteArray(bodyOs.toByteArray());

      CMSSignedData signedData = signGen.generate(content, true, "BC");
      return signedData.getEncoded();
   }
View Full Code Here

   private static byte[] p7s(PrivateKey priv, X509Certificate storecert, CertStore certs, byte[] contentbytes) throws CertStoreException, CMSException, NoSuchAlgorithmException, NoSuchProviderException, IOException
   {
      CMSSignedDataGenerator signGen = new CMSSignedDataGenerator();
      signGen.addSigner(priv, (X509Certificate)storecert, CMSSignedDataGenerator.DIGEST_SHA512);
      //signGen.addCertificatesAndCRLs(certs);
      CMSProcessable content = new CMSProcessableByteArray(contentbytes);

      CMSSignedData signedData = signGen.generate(content, true, "BC");
      return signedData.getEncoded();
   }
View Full Code Here

TOP

Related Classes of org.bouncycastle.cms.CMSProcessableByteArray

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.