Examples of PGPSecretKeyRing


Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

       
        secretRings = new PGPSecretKeyRingCollection(encRing);
       
        while (rIt.hasNext())
        {
            PGPSecretKeyRing                    pgpSec = (PGPSecretKeyRing)rIt.next();
   
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpSec.getEncoded();
           
            pgpSec = new PGPSecretKeyRing(bytes);
           
            Iterator    it = pgpSec.getSecretKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

       
        secretRings = new PGPSecretKeyRingCollection(encRing);
       
        while (rIt.hasNext())
        {
            PGPSecretKeyRing         pgpSec = (PGPSecretKeyRing)rIt.next();
   
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpSec.getEncoded();
           
            pgpSec = new PGPSecretKeyRing(bytes);
           
            Iterator    it = pgpSec.getSecretKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

       
        secretRings = new PGPSecretKeyRingCollection(encRing);
       
        while (rIt.hasNext())
        {
            PGPSecretKeyRing         pgpSec = (PGPSecretKeyRing)rIt.next();
   
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpSec.getEncoded();
           
            pgpSec = new PGPSecretKeyRing(bytes);
           
            Iterator    it = pgpSec.getSecretKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

    }
   
    public void test10()
        throws Exception
    {
        PGPSecretKeyRing    secretRing = new PGPSecretKeyRing(sec10);
        Iterator            secretKeys = secretRing.getSecretKeys();
       
        while (secretKeys.hasNext())
        {
            PGPPublicKey pubKey = ((PGPSecretKey)secretKeys.next()).getPublicKey();
           
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, dsaKeyPair,
                "test", PGPEncryptedData.AES_256, passPhrase, null, null, new SecureRandom(), "BC");
   
        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

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

                          rsaKp = rsaKpg.generateKeyPair();
        PGPKeyPair        rsaKeyPair2 = new PGPKeyPair(PGPPublicKey.RSA_GENERAL, rsaKp, new Date());

        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, rsaKeyPair1,
                "test", PGPEncryptedData.AES_256, passPhrase, null, null, new SecureRandom(), "BC");
        PGPSecretKeyRing       secRing1 = keyRingGen.generateSecretKeyRing();
        PGPPublicKeyRing       pubRing1 = keyRingGen.generatePublicKeyRing();
        keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, rsaKeyPair2,
                "test", PGPEncryptedData.AES_256, passPhrase, null, null, new SecureRandom(), "BC");
        PGPSecretKeyRing       secRing2 = keyRingGen.generateSecretKeyRing();
        PGPPublicKeyRing       pubRing2 = keyRingGen.generatePublicKeyRing();

        try
        {
            PGPPublicKeyRing.insertPublicKey(pubRing1, pubRing2.getPublicKey());
            fail("adding second master key (public) should throw an IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
            if (!e.getMessage().equals("cannot add a master key to a ring that already has one"))
            {
                fail("wrong message in public test");
            }
        }

        try
        {
            PGPSecretKeyRing.insertSecretKey(secRing1, secRing2.getSecretKey());
            fail("adding second master key (secret) should throw an IllegalArgumentException");
        }
        catch (IllegalArgumentException e)
        {
            if (!e.getMessage().equals("cannot add a master key to a ring that already has one"))
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, dsaKeyPair,
                "test", PGPEncryptedData.AES_256, passPhrase, true, null, null, new SecureRandom(), "BC");
   
        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");
        }

        PGPPublicKeyRing        pubRing = keyRingGen.generatePublicKeyRing();
       
        PGPPublicKey            vKey = null;
        PGPPublicKey            sKey = null;
       
        Iterator                    it = pubRing.getPublicKeys();
        while (it.hasNext())
        {
            PGPPublicKey    pk = (PGPPublicKey)it.next();
            if (pk.isMasterKey())
            {
                vKey = pk;
            }
            else
            {
                sKey = pk;
            }
        }

        // check key id fetch
        if (keyRing.getPublicKey(vKey.getKeyID()).getKeyID() != vKey.getKeyID())
        {
            fail("secret key public key mismatch - vKey");
        }

        if (keyRing.getPublicKey(sKey.getKeyID()).getKeyID() != sKey.getKeyID())
        {
            fail("secret key public key mismatch - sKey");
        }

        Iterator    sIt = sKey.getSignatures();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

        Iterator rIt = privRings.getKeyRings();

        if (rIt.hasNext())
        {
            PGPSecretKeyRing pgpPriv = (PGPSecretKeyRing)rIt.next();

            Iterator it = pgpPriv.getSecretKeys();

            while (it.hasNext())
            {
                PGPSecretKey pgpKey = (PGPSecretKey)it.next();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

        int count = 0;

        for (Iterator rIt = secCol.getKeyRings(); rIt.hasNext();)
        {
            PGPSecretKeyRing ring = (PGPSecretKeyRing)rIt.next();

            for (Iterator it = ring.getExtraPublicKeys(); it.hasNext();)
            {
                it.next();
                count++;
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing

        //

        Iterator keyRingIter = pgpSec.getKeyRings();
        while (keyRingIter.hasNext())
        {
            PGPSecretKeyRing keyRing = (PGPSecretKeyRing)keyRingIter.next();

            Iterator keyIter = keyRing.getSecretKeys();
            while (keyIter.hasNext())
            {
                PGPSecretKey key = (PGPSecretKey)keyIter.next();

                if (key.isSigningKey())
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.