Package org.bouncycastle.operator

Examples of org.bouncycastle.operator.ContentSigner


    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1withRSA");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    BcRSAContentSignerBuilder sigBuild = new BcRSAContentSignerBuilder(sigAlgId, digAlgId);
    ContentSigner signer;
    try {
      signer = sigBuild.build(BouncyCastleHelpers.toAsymmetricKeyParameter(keyPair.getPrivate()));
    } catch (OperatorCreationException e) {
      throw new IllegalArgumentException("Error building content signer", e);
    }
View Full Code Here


      // certificateBuilder.addExtension(X509Extensions.SubjectKeyIdentifier, isCritical,
      // csr.getSubjectPublicKeyInfo());
      // }

      AsymmetricKeyParameter caPrivateKeyParameters = PrivateKeyFactory.createKey(signerPrivateKey.getEncoded());
      ContentSigner contentSigner = new BcRSAContentSignerBuilder(sigAlgId, digestAlgId)
          .build(caPrivateKeyParameters);

      X509CertificateHolder certificateHolder = certificateBuilder.build(contentSigner);
      Certificate certificate = certificateHolder.toASN1Structure();
View Full Code Here

      builder.addRDN(BCStyle.L, localityName);
      builder.addRDN(BCStyle.ST, state);
      builder.addRDN(BCStyle.E, emailAddress);
      builder.addRDN(BCStyle.CN, commonName);

      final ContentSigner sigGen = new JcaContentSignerBuilder(sa.name())
          .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(
              kp.getPrivate());
      // JcaX509v3CertificateBuilder parameters:
      // issuer X500Name representing the issuer of this certificate.
      // serial the serial number for the certificate.
View Full Code Here

            throw new Exception("Key is invalid private key: " + object);
        }

        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);
View Full Code Here

            System.out.println("Content read sucessfully");

            X509Certificate cert = (X509Certificate) readCert(args[2]);
            System.out.println("Certificate read sucessfully");

            ContentSigner sha256Signer = new JcaContentSignerBuilder("SHA256withRSA").setProvider("BC").build(key);

            Store certs = certToStore(cert);

            generator.addCertificates(certs);
            generator.addSignerInfoGenerator(
View Full Code Here

            AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WITHRSAENCRYPTION");
            AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
            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);
View Full Code Here

           
            AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WITHRSAENCRYPTION");
            AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
            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);
View Full Code Here

    /**
     * Inizializzo il generatore impostando l'algoritmo di
     * hashing desiderato ed aggiungendo un firmatario
     */
    CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
    ContentSigner sigGen =
       new JcaContentSignerBuilder("SHA256withRSA").setProvider(
       pkcs11Provider.getName()).build(privateKey);

    /**
     * -- CADES --
View Full Code Here

  BigInteger serial = BigInteger.ONE;
  IssuerAndSerialNumber iasn = new IssuerAndSerialNumber(issuer, serial);
  PKCS10CertificationRequest csr = getCsr(new X500Principal("CN=Client"),
    pair.getPublic(), pair.getPrivate(), "password".toCharArray());
  CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
  ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA")
    .build(pair.getPrivate());
  X509Certificate cert = X509Certificates.createEphemeral(
    new X500Principal("CN=client"), pair);
  Store certs = new JcaCertStore(Collections.singleton(cert));
  gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(
View Full Code Here

  SubjectPublicKeyInfo pkInfo = SubjectPublicKeyInfo.getInstance(pubKey
    .getEncoded());

  JcaContentSignerBuilder signerBuilder = new JcaContentSignerBuilder(
    "SHA1withRSA");
  ContentSigner signer;
  try {
      signer = signerBuilder.build(priKey);
  } catch (OperatorCreationException e) {
      IOException ioe = new IOException();
      ioe.initCause(e);
View Full Code Here

TOP

Related Classes of org.bouncycastle.operator.ContentSigner

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.