Package org.bouncycastle.operator

Examples of org.bouncycastle.operator.DigestCalculatorProvider


        CMSSignedDataGenerator generator = new CMSSignedDataGenerator();

        ContentSigner signer = new JcaContentSignerBuilder(this.algorithm).build(privateKey);

        DigestCalculatorProvider digest = new JcaDigestCalculatorProviderBuilder().build();
        SignerInfoGenerator signerInfo = new SignerInfoGeneratorBuilder(digest).build(signer, new byte[]{0});

        generator.addSignerInfoGenerator(signerInfo);

        byte[] dataBytes = new byte[this.data.readableBytes()];
View Full Code Here


    ioe.initCause(e);

    throw ioe;
      }
      generator.addCertificates(store);
      DigestCalculatorProvider digestProvider = new JcaDigestCalculatorProviderBuilder()
        .build();
      SignerInfoGeneratorBuilder infoGenBuilder = new SignerInfoGeneratorBuilder(
        digestProvider);
      X509CertificateHolder certHolder = new X509CertificateHolder(
        getRecipient().getEncoded());
View Full Code Here

      verifierProvider = new JcaContentVerifierProviderBuilder()
        .build(signer);
  } catch (OperatorCreationException e) {
      throw new RuntimeException(e);
  }
  DigestCalculatorProvider digestProvider;
  try {
      digestProvider = new JcaDigestCalculatorProviderBuilder().build();
  } catch (OperatorCreationException e1) {
      throw new RuntimeException(e1);
  }
View Full Code Here

        ContentSigner contentSigner = contentSignerBuilder.build(privateKey);

        JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
        digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
        DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();

        JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder(digestCalculatorProvider);

        if (this.parameters.isDataDigested()) {
          Attribute attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(data)));
View Full Code Here

    return verified;
  }

  private boolean verifyDetached(final byte[] data, final byte[] signature) throws CMSException, IOException, OperatorCreationException {
    InputStream inputStream = new ByteArrayInputStream(data);
    DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();
    CMSSignedDataParser signedDataParser = new CMSSignedDataParser(digestCalculatorProvider, new CMSTypedStream(inputStream), signature);
    CMSTypedStream signedContent = signedDataParser.getSignedContent();

    signedContent.drain();
View Full Code Here

          ContentVerifierProvider contentVerifierProvider = jcaContentVerifierProviderBuilder.build((X509Certificate) cert);

          JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
          digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
          DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();

          SignatureAlgorithmIdentifierFinder signatureAlgorithmIdentifierFinder = new DefaultSignatureAlgorithmIdentifierFinder();
          CMSSignatureAlgorithmNameGenerator signatureAlgorithmNameGenerator = new DefaultCMSSignatureAlgorithmNameGenerator();

          signerInformationVerifier = new SignerInformationVerifier(signatureAlgorithmNameGenerator, signatureAlgorithmIdentifierFinder, contentVerifierProvider, digestCalculatorProvider);
View Full Code Here

    }
  }

  protected OCSPReq buildRequest(final X509Certificate certificate, final X509Certificate issuer) throws CertificateEncodingException, IOException, OperatorCreationException, OCSPException {
    OCSPReqBuilder builder = new OCSPReqBuilder();
    DigestCalculatorProvider provider = new BcDigestCalculatorProvider();
    X509CertificateHolder holder = new X509CertificateHolder(issuer.getEncoded());
    CertificateID certificateID = new CertificateID(provider.get(CertificateID.HASH_SHA1), holder, certificate.getSerialNumber());
    BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());

    builder.addRequest(certificateID);
    ExtensionsGenerator extensionsGenerator = new ExtensionsGenerator();
    extensionsGenerator.addExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(nonce.toByteArray()));
View Full Code Here

      ContentSigner contentSigner = contentSignerBuilder.build(privateKey);

      JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
      digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
      DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();

      JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder(digestCalculatorProvider);

      SignerInfoGenerator signerInfoGenerator = signerInfoGeneratorBuilder.build(contentSigner, (X509Certificate) certificate);

      DigestCalculator digestCalculator = digestCalculatorProvider.get(signerInfoGenerator.getDigestAlgorithm());

      this.timeStampTokenGenerator = new TimeStampTokenGenerator(digestCalculator, signerInfoGenerator, new ASN1ObjectIdentifier(BouncyCastleTimeStampServer.TSA_POLICY_ID));

      JcaCertStore certStore = new JcaCertStore(Arrays.asList(chain));
      this.timeStampTokenGenerator.addCertificates(certStore);
View Full Code Here

    }
  }

  protected OCSPReq buildRequest(final X509Certificate certificate, final X509Certificate issuer) throws CertificateEncodingException, IOException, OperatorCreationException, OCSPException {
    OCSPReqBuilder builder = new OCSPReqBuilder();
    DigestCalculatorProvider provider = new BcDigestCalculatorProvider();
    X509CertificateHolder holder = new X509CertificateHolder(issuer.getEncoded());
    CertificateID certificateID = new CertificateID(provider.get(CertificateID.HASH_SHA1), holder, certificate.getSerialNumber());
    BigInteger nonce = BigInteger.valueOf(System.currentTimeMillis());

    builder.addRequest(certificateID);
    ExtensionsGenerator extensionsGenerator = new ExtensionsGenerator();
    extensionsGenerator.addExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(nonce.toByteArray()));
View Full Code Here

        ContentSigner contentSigner = contentSignerBuilder.build(privateKey);

        JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
        digestCalculatorProviderBuilder.setProvider(BouncyCastleProviderHelper.PROVIDER_NAME);
        DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();

        JcaSignerInfoGeneratorBuilder signerInfoGeneratorBuilder = new JcaSignerInfoGeneratorBuilder(digestCalculatorProvider);

        if (this.parameters.isDataDigested()) {
          Attribute attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(data)));
View Full Code Here

TOP

Related Classes of org.bouncycastle.operator.DigestCalculatorProvider

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.