Examples of BcDigestCalculatorProvider


Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

            RSAPrivateKey privateRSAKey = (RSAPrivateKey)privKey;
            RSAKeyParameters keyParams = new RSAKeyParameters(true, privateRSAKey.getModulus(), privateRSAKey.getPrivateExponent());
            ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParams);
            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            gen.addSignerInfoGenerator(
                    new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                        .build(sigGen, new X509CertificateHolder(certificate)));
            CMSProcessableInputStream processable = new CMSProcessableInputStream(content);
            CMSSignedData signedData = gen.generate(processable, false);
            return signedData.getEncoded();
        }
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

            RSAPrivateKey privateRSAKey = (RSAPrivateKey)privateKey;
            RSAKeyParameters keyParams = new RSAKeyParameters(true, privateRSAKey.getModulus(), privateRSAKey.getPrivateExponent());
            ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(keyParams);

            gen.addSignerInfoGenerator(
                    new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider())
                        .build(sigGen, new X509CertificateHolder(certificate)));
            CMSProcessableInputStream processable = new CMSProcessableInputStream(content);
            CMSSignedData signedData = gen.generate(processable, false);
            if (tsaClient != null)
            {
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

      if (!signCert.getSerialNumber().equals(resp[i].getCertID().getSerialNumber())) {
        continue;
      }
      // check if the issuer matches
      try {
        if (!resp[i].getCertID().matchesIssuer(new X509CertificateHolder(issuerCert.getEncoded()), new BcDigestCalculatorProvider())) {
          LOGGER.info("OCSP: Issuers doesn't match.");
          continue;
        }
      } catch (OCSPException e) {
        continue;
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

            if (log.isDebugEnabled()) {
                log.debug("Content-type: "+msg.getContentType());
            }
            if (msg.isMimeType("multipart/signed")) { // $NON-NLS-1$
                MimeMultipart multipart = (MimeMultipart) msg.getContent();
                s = new SMIMESignedParser(new BcDigestCalculatorProvider(), multipart);
            } else if (msg.isMimeType("application/pkcs7-mime") // $NON-NLS-1$
                    || msg.isMimeType("application/x-pkcs7-mime")) { // $NON-NLS-1$
                s = new SMIMESignedParser(new BcDigestCalculatorProvider(), msg);
            }

            if (null != s) {
                log.debug("Found signature");
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

     * -- END CADES --
     */
    AttributeTable at = new AttributeTable(v);
    CMSAttributeTableGenerator attrGen = new DefaultSignedAttributeTableGenerator(at);
    SignerInfoGeneratorBuilder genBuild =
       new SignerInfoGeneratorBuilder(new BcDigestCalculatorProvider());
    genBuild.setSignedAttributeGenerator(attrGen);
    SignerInfoGenerator sifGen =
       genBuild.build(sigGen, new X509CertificateHolder(userCertificate.getEncoded()));

    gen.addSignerInfoGenerator(sifGen);
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

        continue;
      }
      // check if the issuer matches
      try {
        if (issuerCert == null) issuerCert = signCert;
        if (!resp[i].getCertID().matchesIssuer(new X509CertificateHolder(issuerCert.getEncoded()), new BcDigestCalculatorProvider())) {
          LOGGER.info("OCSP: Issuers doesn't match.");
          continue;
        }
      } catch (OCSPException e) {
        continue;
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

    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

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

    }
  }

  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

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

        // verify TSP signer signature
        X509CertificateHolder holder = new X509CertificateHolder(tspCertificateChain.get(0).getEncoded());
        DefaultCMSSignatureAlgorithmNameGenerator nameGen = new DefaultCMSSignatureAlgorithmNameGenerator();
        DefaultSignatureAlgorithmIdentifierFinder sigAlgoFinder = new DefaultSignatureAlgorithmIdentifierFinder();
        DefaultDigestAlgorithmIdentifierFinder hashAlgoFinder = new DefaultDigestAlgorithmIdentifierFinder();
        BcDigestCalculatorProvider calculator = new BcDigestCalculatorProvider();
        BcRSASignerInfoVerifierBuilder verifierBuilder = new BcRSASignerInfoVerifierBuilder(nameGen, sigAlgoFinder, hashAlgoFinder, calculator);
        SignerInformationVerifier verifier = verifierBuilder.build(holder);
       
        timeStampToken.validate(verifier);
View Full Code Here

Examples of org.bouncycastle.operator.bc.BcDigestCalculatorProvider

    }
  }

  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
TOP
Copyright © 2018 www.massapi.com. 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.