Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPSecretKeyRingCollection


        throws Exception
    {
        SecureRandom rand = new SecureRandom();

        // Read the secret key rings
        PGPSecretKeyRingCollection privRings = new PGPSecretKeyRingCollection(
                                                         new ByteArrayInputStream(rewrapKey));

        Iterator rIt = privRings.getKeyRings();

        if (rIt.hasNext())
        {
            PGPSecretKeyRing pgpPriv = (PGPSecretKeyRing)rIt.next();
View Full Code Here


            // find the secret key
            //
            Iterator                    it = enc.getEncryptedDataObjects();
            PGPPrivateKey               sKey = null;
            PGPPublicKeyEncryptedData   pbe = null;
            PGPSecretKeyRingCollection  pgpSec = new PGPSecretKeyRingCollection(
                PGPUtil.getDecoderStream(keyIn));                                                                
           
            while (sKey == null && it.hasNext())
            {
                pbe = (PGPPublicKeyEncryptedData)it.next();
View Full Code Here

     */
    private static PGPSecretKey readSecretKey(
        InputStream    in)
        throws IOException, PGPException
    {   
        PGPSecretKeyRingCollection        pgpSec = new PGPSecretKeyRingCollection(in);

        //
        // we just loop through the collection till we find a key suitable for encryption, in the real
        // world you would probably want to be a bit smarter about this.
        //
        PGPSecretKey    key = null;
       
        //
        // iterate through the key rings.
        //
        Iterator rIt = pgpSec.getKeyRings();
       
        while (key == null && rIt.hasNext())
        {
            PGPSecretKeyRing    kRing = (PGPSecretKeyRing)rIt.next();   
            Iterator                        kIt = kRing.getSecretKeys();
View Full Code Here

        InputStream    in)
        throws IOException, PGPException
    {
        in = PGPUtil.getDecoderStream(in);
       
        PGPSecretKeyRingCollection        pgpSec = new PGPSecretKeyRingCollection(in);

        //
        // we just loop through the collection till we find a key suitable for encryption, in the real
        // world you would probably want to be a bit smarter about this.
        //
        PGPSecretKey    key = null;
       
        //
        // iterate through the key rings.
        //
        Iterator rIt = pgpSec.getKeyRings();
       
        while (key == null && rIt.hasNext())
        {
            PGPSecretKeyRing    kRing = (PGPSecretKeyRing)rIt.next();   
            Iterator                        kIt = kRing.getSecretKeys();
View Full Code Here

        InputStream    in)
        throws IOException, PGPException
    {
        in = PGPUtil.getDecoderStream(in);
       
        PGPSecretKeyRingCollection        pgpSec = new PGPSecretKeyRingCollection(in);

        //
        // we just loop through the collection till we find a key suitable for encryption, in the real
        // world you would probably want to be a bit smarter about this.
        //
        PGPSecretKey    key = null;
       
        //
        // iterate through the key rings.
        //
        Iterator rIt = pgpSec.getKeyRings();
       
        while (key == null && rIt.hasNext())
        {
            PGPSecretKeyRing    kRing = (PGPSecretKeyRing)rIt.next();   
            Iterator            kIt = kRing.getSecretKeys();
View Full Code Here

        // find the secret key
        //
        Iterator it = enc.getEncryptedDataObjects();
        PGPPrivateKey sKey = null;
        PGPPublicKeyEncryptedData pbe = null;
        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(
                PGPUtil.getDecoderStream(keyIn));

        while (sKey == null && it.hasNext()) {
            pbe = (PGPPublicKeyEncryptedData) it.next();
View Full Code Here

   
    public static PGPSecretKey readSecretKey(InputStream in, long keyId) throws IOException, PGPException {
        InputStream decoderStream = null;
        try {
            decoderStream = PGPUtil.getDecoderStream(in);
            PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(decoderStream);
            PGPSecretKey key = null;
            Iterator rIt = pgpSec.getKeyRings();
            while (key == null && rIt.hasNext()) {
                PGPSecretKeyRing kRing = (PGPSecretKeyRing) rIt.next();
                Iterator kIt = kRing.getSecretKeys();
                while (key == null && kIt.hasNext()) {
                    PGPSecretKey k = (PGPSecretKey) kIt.next();
View Full Code Here

    public long[] findDecryptionKeyIds(InputStream in) throws IOException, CryptoException {
        InputStream decoderStream = null;
        try {
            List<Long> keyIDs = new ArrayList<Long>();
            decoderStream = PGPUtil.getDecoderStream(in);
            PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(decoderStream);
            Iterator rIt = pgpSec.getKeyRings();
            while (rIt.hasNext()) {
                PGPSecretKeyRing kRing = (PGPSecretKeyRing) rIt.next();
                Iterator kIt = kRing.getSecretKeys();
                while (kIt.hasNext()) {
                    PGPSecretKey k = (PGPSecretKey) kIt.next();
View Full Code Here

                                    throws PGPException, NoSuchProviderException, IOException {
            InputStream in = null;
            try {
                in = decryptionKey.getKeyData();
                Iterator it = encryptedDataList.getEncryptedDataObjects();
                PGPSecretKeyRingCollection keyRings = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(in));
                while (secretKey == null && it.hasNext()) {
                    encryptedData = (PGPPublicKeyEncryptedData) it.next();
                    secretKey = findSecretKey(keyRings, encryptedData.getKeyID(), password);
                }
                if (secretKey == null) {
View Full Code Here

        }
    }

    private PGPSecretKey readSecretKey(InputStream in) throws IOException, PGPException {
        in = PGPUtil.getDecoderStream(in);
        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(in);

        PGPSecretKey key = null;
        for (Iterator it = pgpSec.getKeyRings(); key == null && it.hasNext(); ) {
            PGPSecretKeyRing kRing = (PGPSecretKeyRing) it.next();  
           
            for (Iterator it2 = kRing.getSecretKeys(); key == null && it2.hasNext(); ) {
                PGPSecretKey k = (PGPSecretKey) it2.next();
                if ((keyId == null) && k.isSigningKey()) {
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.PGPSecretKeyRingCollection

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.