Examples of PGPKeyRingGenerator


Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        }

        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date());
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date());
       
        PGPKeyRingGenerator    keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, dsaKeyPair,
                 identity, PGPEncryptedData.AES_256, passPhrase, true, null, null, new SecureRandom(), "BC");
       
        keyRingGen.addSubKey(elgKeyPair);
       
        keyRingGen.generateSecretKeyRing().encode(secretOut);
       
        secretOut.close();
       
        if (armor)
        {
            publicOut = new ArmoredOutputStream(publicOut);
        }
       
        keyRingGen.generatePublicKeyRing().encode(publicOut);
       
        publicOut.close();
    }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        //
        KeyPair                    elgKp = elgKpg.generateKeyPair();
        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date());
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date());
   
        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 BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider()).build(passPhrase));
       
        PGPPublicKeyRing        pubRing = keyRingGen.generatePublicKeyRing();
       
        PGPPublicKey            vKey = null;
        PGPPublicKey            sKey = null;
       
        Iterator                    it = pubRing.getPublicKeys();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        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());

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

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        //
        KeyPair                    elgKp = elgKpg.generateKeyPair();
        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date());
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date());
   
        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 BcPBESecretKeyDecryptorBuilder(new BcPGPDigestCalculatorProvider()).build(passPhrase));
       
        PGPPublicKeyRing        pubRing = keyRingGen.generatePublicKeyRing();
       
        PGPPublicKey            vKey = null;
        PGPPublicKey            sKey = null;
       
        Iterator                    it = pubRing.getPublicKeys();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

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

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        svg.setPreferredCompressionAlgorithms(true, comprAlgs);
        svg.setFeature(true, Features.FEATURE_MODIFICATION_DETECTION);
        svg.setKeyFlags(true, KeyFlags.CERTIFY_OTHER + KeyFlags.SIGN_DATA);
        PGPSignatureSubpacketVector hashedPcks = svg.generate();

        PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION,
            sgnKeyPair, identity, PGPEncryptedData.AES_256, passPhrase,
            true, hashedPcks, unhashedPcks, new SecureRandom(), "BC");

        svg = new PGPSignatureSubpacketGenerator();
        svg.setKeyExpirationTime(true, 86400L * 366 * 2);
        svg.setKeyFlags(true, KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE);
        svg.setPrimaryUserID(true, false);
        svg.setFeature(true, Features.FEATURE_MODIFICATION_DETECTION);
        hashedPcks = svg.generate();

        keyRingGen.addSubKey(encKeyPair, hashedPcks, unhashedPcks);

        byte[] encodedKeyRing = keyRingGen.generatePublicKeyRing().getEncoded();

        PGPPublicKeyRing keyRing = new PGPPublicKeyRing(encodedKeyRing, new BcKeyFingerprintCalculator());

        for (Iterator it = keyRing.getPublicKeys(); it.hasNext();)
        {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        //
        KeyPair                    elgKp = elgKpg.generateKeyPair();
        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date());
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date());
   
        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;
       
        Iterator                    it = pubRing.getPublicKeys();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        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());

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

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        //
        KeyPair                    elgKp = elgKpg.generateKeyPair();
        PGPKeyPair        dsaKeyPair = new PGPKeyPair(PGPPublicKey.DSA, dsaKp, new Date());
        PGPKeyPair        elgKeyPair = new PGPKeyPair(PGPPublicKey.ELGAMAL_ENCRYPT, elgKp, new Date());
   
        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();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPKeyRingGenerator

        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();)
        {
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.