Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPPublicKeyRing


        PGPPublicKeyRingCollection  pubRings = new PGPPublicKeyRingCollection(pub6);
        Iterator                    rIt = pubRings.getKeyRings();

        while (rIt.hasNext())
        {
            PGPPublicKeyRing    pgpPub = (PGPPublicKeyRing)rIt.next();
            Iterator            it = pgpPub.getPublicKeys();
            while (it.hasNext())
            {
                PGPPublicKey    k = (PGPPublicKey)it.next();

                if (k.getKeyID() == 0x5ce086b5b5a18ff4L)
View Full Code Here


    }

    public void test7()
        throws Exception
    {
        PGPPublicKeyRing    pgpPub = new PGPPublicKeyRing(pub7);
        Iterator            it = pgpPub.getPublicKeys();
        PGPPublicKey        masterKey = null;

        while (it.hasNext())
        {
            PGPPublicKey    k = (PGPPublicKey)it.next();
View Full Code Here

       
        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing          pgpPub = (PGPPublicKeyRing)rIt.next();
           
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpPub.getEncoded();
           
            pgpPub = new PGPPublicKeyRing(bytes);
           
            Iterator    it = pgpPub.getPublicKeys();
            while (it.hasNext())
            {
                keyCount++;

                it.next();
View Full Code Here

            {
                fail("seconds wrong on secret key ring");
            }
        }
       
        PGPPublicKeyRing    publicRing = new PGPPublicKeyRing(pub10);
        Iterator            publicKeys = publicRing.getPublicKeys();
       
        while (publicKeys.hasNext())
        {
            PGPPublicKey pubKey = (PGPPublicKey)publicKeys.next();
View Full Code Here

   
        PGPSecretKeyRing       keyRing = keyRingGen.generateSecretKeyRing();
       
        keyRing.getSecretKey().extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passPhrase));
       
        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())
            {
View Full Code Here

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

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

    }
   
    private void test11()
        throws Exception
    {
        PGPPublicKeyRing pubRing = new PGPPublicKeyRing(subKeyBindingKey);
        Iterator         it = pubRing.getPublicKeys();
       
        while (it.hasNext())
        {
            PGPPublicKey key = (PGPPublicKey)it.next();
           
View Full Code Here

    private void testPublicKeyRingWithX509()
        throws Exception
    {
        checkPublicKeyRingWithX509(pubWithX509);

        PGPPublicKeyRing pubRing = new PGPPublicKeyRing(pubWithX509);

        checkPublicKeyRingWithX509(pubRing.getEncoded());
    }
View Full Code Here

    }

    private void testUmlaut()
        throws Exception
    {
        PGPPublicKeyRing pubRing = new PGPPublicKeyRing(umlautKeySig);

        PGPPublicKey pub = pubRing.getPublicKey();
        String       userID = (String)pub.getUserIDs().next();

        for (Iterator it = pub.getSignatures(); it.hasNext();)
        {
            PGPSignature sig = (PGPSignature)it.next();

            if (sig.getSignatureType() == PGPSignature.POSITIVE_CERTIFICATION)
            {
                sig.initVerify(pub, "BC");

                if (!sig.verifyCertification(userID, pub))
                {
                    fail("failed UTF8 userID test");
                }
            }
        }

        //
        // this is quicker because we are using pregenerated parameters.
        //
        KeyPairGenerator  rsaKpg = KeyPairGenerator.getInstance("RSA", "BC");
        KeyPair           rsaKp = rsaKpg.generateKeyPair();
        PGPKeyPair        rsaKeyPair1 = new PGPKeyPair(PGPPublicKey.RSA_GENERAL, rsaKp, new Date());
                          rsaKp = rsaKpg.generateKeyPair();
        PGPKeyPair        rsaKeyPair2 = new PGPKeyPair(PGPPublicKey.RSA_GENERAL, rsaKp, new Date());
        char[]            passPhrase = "passwd".toCharArray();

        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, rsaKeyPair1,
                userID, PGPEncryptedData.AES_256, passPhrase, null, null, new SecureRandom(), "BC");

        PGPPublicKeyRing       pubRing1 = keyRingGen.generatePublicKeyRing();

        pub = pubRing1.getPublicKey();

        for (Iterator it = pub.getSignatures(); it.hasNext();)
        {
            PGPSignature sig = (PGPSignature)it.next();
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.PGPPublicKeyRing

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.