Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.CMSProcessableByteArray


    public void testCertOrdering2()
        throws Exception
    {
        List                  certList = new ArrayList();
        CMSProcessable        msg = new CMSProcessableByteArray("Hello World!".getBytes());

        certList.add(_signCert);
        certList.add(_signDsaCert);
        certList.add(_origCert);
View Full Code Here


    public void testSignerStoreReplacement()
        throws Exception
    {
        List                  certList = new ArrayList();
        CMSProcessable        msg = new CMSProcessableByteArray("Hello World!".getBytes());

        certList.add(_origCert);
        certList.add(_signCert);

        CertStore           certs = CertStore.getInstance("Collection",
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);
            } catch (Exception e) {
                throw new SigningException(e);
            }
        }

View Full Code Here

    public void testSHA1WithRSAEncapsulated()
        throws Exception
    {
        List certList = new ArrayList();
        CMSProcessable msg = new CMSProcessableByteArray(TEST_MESSAGE.getBytes());

        certList.add(keyCert);

        CertStore certsAndCrls = CertStore.getInstance("Collection",
                        new CollectionCertStoreParameters(certList));
View Full Code Here

        CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();

        edGen.addKeyTransRecipient(keyCert);

        CMSEnvelopedData ed = edGen.generate(
                                new CMSProcessableByteArray(data),
                                algorithm, null);

        RecipientInformationStore recipients = ed.getRecipientInfos();

View Full Code Here

  public String sign(byte[] theBytes) throws SignatureFailureException {
    try {
      Security.addProvider(new BouncyCastleProvider());

      List<X509Certificate> certList = new ArrayList<X509Certificate>();
      CMSTypedData msg = new CMSProcessableByteArray(theBytes);

      X509Certificate signCert = (X509Certificate) myKeyStore.getCertificate(myKeyAlias);
      certList.add(signCert);

      Store certs = new JcaCertStore(certList);
View Full Code Here

        throw new SignatureVerificationException("No algorithm found in signature block: " + theSignature);
      }

      theSignature = theSignature.substring(spaceIndex + 1);

      CMSProcessable content = new CMSProcessableByteArray(theBytes);
      CMSSignedData s = new CMSSignedData(content, Base64.decodeBase64(theSignature));

      ourLog.debug("Verifying message against public key with alias[{}]", myKeyAlias);

      SignerInformationVerifier vib = new JcaSimpleSignerInfoVerifierBuilder().build(pubKey);
View Full Code Here

        cmsSignedDataGenerator.addSignerInfoGenerator(signerInfoGenerator);
        cmsSignedDataGenerator.addCertificates(this.getCertificateStore(chain));
      }

      CMSTypedData content = new CMSProcessableByteArray(data);

      CMSSignedData signedData = cmsSignedDataGenerator.generate(content, true);

      if (timeStampClient != null) {
        SignerInformationStore signerInformationStore = signedData.getSignerInfos();
View Full Code Here

        if ((this.parameters.isMergeSignatures()) && (this.isSigned(data))) {
          CMSSignedData signedData = new CMSSignedData(data);
          signedDataGenerator.addSigners(signedData.getSignerInfos());
          content = (CMSTypedData) 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, GeneralSecurityException {
    CMSSignedData signedData = new CMSSignedData(new CMSProcessableByteArray(data), signature);

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

    SignerInformationStore signerInformationStore = signedData.getSignerInfos();
    boolean verified = true;
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.