Package org.bouncycastle.openpgp.operator.jcajce

Examples of org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder


            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();

                k.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(sec8pass));
            }
           
            if (keyCount != 2)
            {
                fail("wrong number of secret keys");
View Full Code Here


            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();

                PGPPrivateKey   pKey = k.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(sec9pass));
                if (keyCount == 1 && pKey != null)
                {
                    fail("primary secret key found, null expected");
                }
            }
View Full Code Here

   
        keyRingGen.addSubKey(elgKeyPair);
   
        PGPSecretKeyRing       keyRing = keyRingGen.generateSecretKeyRing();
       
        keyRing.getSecretKey().extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passPhrase));
       
        PGPPublicKeyRing        pubRing = keyRingGen.generatePublicKeyRing();
       
        PGPPublicKey            vKey = null;
        PGPPublicKey            sKey = null;
View Full Code Here

   
        keyRingGen.addSubKey(elgKeyPair);
   
        PGPSecretKeyRing       keyRing = keyRingGen.generateSecretKeyRing();
       
        keyRing.getSecretKey().extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passPhrase));

        if (!keyRing.getSecretKey().getPublicKey().equals(keyRing.getPublicKey()))
        {
            fail("secret key public key mismatch");
        }
View Full Code Here

                // re-encrypt the key with an empty password
                pgpPriv = PGPSecretKeyRing.removeSecretKey(pgpPriv, pgpKey);
                pgpKey = PGPSecretKey.copyWithNewPassword(
                                    pgpKey,
                                    new JcePBESecretKeyDecryptorBuilder(new JcaPGPDigestCalculatorProviderBuilder().setProvider("BC").build()).setProvider("BC").build(rewrapPass),
                                    null);
                pgpPriv = PGPSecretKeyRing.insertSecretKey(pgpPriv, pgpKey);
           
                // this should succeed
                PGPPrivateKey privTmp = pgpKey.extractPrivateKey(null);
View Full Code Here

        if (armor)
        {
            out = new ArmoredOutputStream(out);
        }

        PGPPrivateKey pgpPrivKey = secretKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(secretKeyPass.toCharArray()));

        PGPSignatureGenerator       sGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(secretKey.getPublicKey().getAlgorithm(), PGPUtil.SHA1).setProvider("BC"));

        sGen.init(PGPSignature.DIRECT_KEY, pgpPrivKey);
View Full Code Here

        {
            digest = PGPUtil.SHA1;
        }
       
        PGPSecretKey                    pgpSecKey = PGPExampleUtil.readSecretKey(keyIn);
        PGPPrivateKey                   pgpPrivKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(pass));
        PGPSignatureGenerator           sGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(pgpSecKey.getPublicKey().getAlgorithm(), digest).setProvider("BC"));
        PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
       
        sGen.init(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
       
View Full Code Here

        {
            out = new ArmoredOutputStream(out);
        }

        PGPSecretKey             pgpSec = PGPExampleUtil.readSecretKey(keyIn);
        PGPPrivateKey            pgpPrivKey = pgpSec.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(pass));
        PGPSignatureGenerator    sGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1).setProvider("BC"));
       
        sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
       
        BCPGOutputStream         bOut = new BCPGOutputStream(out);
View Full Code Here

        {
            out = new ArmoredOutputStream(out);
        }

        PGPSecretKey                pgpSec = PGPExampleUtil.readSecretKey(keyIn);
        PGPPrivateKey               pgpPrivKey = pgpSec.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(pass));
        PGPSignatureGenerator       sGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(pgpSec.getPublicKey().getAlgorithm(), PGPUtil.SHA1).setProvider("BC"));
       
        sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
       
        Iterator    it = pgpSec.getPublicKey().getUserIDs();
View Full Code Here

    private PGPPrivateKey extractPGPPrivateKey(final char[] keyPassPhrase) throws PGPException {
        PGPDigestCalculatorProvider calcProvider = new JcaPGPDigestCalculatorProviderBuilder().
                setProvider(BouncyCastleProvider.PROVIDER_NAME).
                build();
        PBESecretKeyDecryptor decryptor = new JcePBESecretKeyDecryptorBuilder(calcProvider).
                setProvider(BouncyCastleProvider.PROVIDER_NAME).
                build(keyPassPhrase);
        final PGPPrivateKey pgpPrivKey = key.extractPrivateKey(decryptor);
        return pgpPrivKey;
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder

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.