Examples of PGPSignature


Examples of org.bouncycastle.openpgp.PGPSignature

        }
        else {
            p3 = (PGPSignatureList) obj;
        }

        final PGPSignature pgpSignature = p3.get(0);
        Validate.notNull(pgpSignature,
                "Unable to retrieve signature from stream");

        final PgpKeyId keyIdInHex = new PgpKeyId(pgpSignature);
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

            while (userIdIterator.hasNext()) {
                final String userId = userIdIterator.next();
                final Iterator<PGPSignature> signatureIterator = key
                        .getSignaturesForID(userId);
                while (signatureIterator.hasNext()) {
                    final PGPSignature signature = signatureIterator.next();
                    final PgpKeyId signatureKeyId = new PgpKeyId(signature);
                    discoveredKeyIds.add(signatureKeyId);
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

                    final String userId = userIdIterator.next();
                    appendLine(sb, "     User ID: " + userId);
                    final Iterator<PGPSignature> signatureIterator = pgpKey
                            .getSignaturesForID(userId);
                    while (signatureIterator.hasNext()) {
                        final PGPSignature signature = signatureIterator.next();
                        appendLine(sb, "          Signed By: "
                                + getKeySummaryIfPossible(new PgpKeyId(
                                        signature)));
                    }
                }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

    }

    public boolean isResourceSignedBySignature(final InputStream resource,
            InputStream signature) {
        PGPPublicKey publicKey = null;
        PGPSignature pgpSignature = null;

        try {
            if (!(signature instanceof ArmoredInputStream)) {
                signature = new ArmoredInputStream(signature);
            }

            pgpSignature = isSignatureAcceptable(signature).getPgpSignature();
            final PGPPublicKeyRing keyRing = getPublicKey(new PgpKeyId(
                    pgpSignature));
            rememberKey(keyRing);
            publicKey = keyRing.getPublicKey();

            Validate.notNull(publicKey,
                    "Could not obtain public key for signer key ID '%s'",
                    pgpSignature);

            pgpSignature.initVerify(publicKey, "BC");

            // Now verify the signed content
            final byte[] buff = new byte[BUFFER_SIZE];
            int chunk;
            do {
                chunk = resource.read(buff);
                if (chunk > 0) {
                    pgpSignature.update(buff, 0, chunk);
                }
            } while (chunk >= 0);

            return pgpSignature.verify();
        }
        catch (final Exception e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

                {
                    int             count = 0;
                    Iterator        sIt = k.getSignaturesOfType(PGPSignature.SUBKEY_REVOCATION);
                    while (sIt.hasNext())
                    {
                        PGPSignature sig = (PGPSignature)sIt.next();
                        count++;
                    }
                   
                    if (count != 1)
                    {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

                masterKey = k;
                continue;
            }
           
            int             count = 0;
            PGPSignature    sig = null;
            Iterator        sIt = k.getSignaturesOfType(PGPSignature.SUBKEY_REVOCATION);

            while (sIt.hasNext())
            {
                sig = (PGPSignature)sIt.next();
                count++;
            }
               
            if (count != 1)
            {
                fail("wrong number of revocations in test7.");
            }

            sig.initVerify(masterKey, "BC");
                                                                           
            if (!sig.verifyCertification(k))
            {
                fail("failed to verify revocation certification");
            }
        }
    }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

        }
       
        Iterator    sIt = sKey.getSignatures();
        while (sIt.hasNext())
        {
            PGPSignature    sig = (PGPSignature)sIt.next();
           
            if (sig.getKeyID() == vKey.getKeyID()
                && sig.getSignatureType() == PGPSignature.SUBKEY_BINDING)
            {
                sig.initVerify(vKey, "BC");

                if (!sig.verifyCertification(vKey, sKey))
                {
                    fail("failed to verify sub-key signature.");
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

        }
       
        Iterator    sIt = sKey.getSignatures();
        while (sIt.hasNext())
        {
            PGPSignature    sig = (PGPSignature)sIt.next();
           
            if (sig.getKeyID() == vKey.getKeyID()
                && sig.getSignatureType() == PGPSignature.SUBKEY_BINDING)
            {
                sig.initVerify(vKey, "BC");
   
                if (!sig.verifyCertification(vKey, sKey))
                {
                    fail("failed to verify sub-key signature.");
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

            Iterator sIt = key.getSignatures();

            if (sIt.hasNext())
            {
                PGPSignature sig = (PGPSignature)sIt.next();
                if (sig.getKeyAlgorithm() != 100)
                {
                    fail("experimental signature not found");
                }
                if (!areEqual(sig.getSignature(), Hex.decode("000101")))
                {
                    fail("experimental encoding check failed");
                }
            }
            else
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSignature

           
            // iterate through all direct key signautures and look for NotationData subpackets
            Iterator iter = key.getSignaturesOfType(PGPSignature.DIRECT_KEY);
            while(iter.hasNext())
            {
                PGPSignature    sig = (PGPSignature)iter.next();
               
                System.out.println("Signature date is: " + sig.getHashedSubPackets().getSignatureCreationTime());

                NotationData[] data = sig.getHashedSubPackets().getNotationDataOccurences();//.getSubpacket(SignatureSubpacketTags.NOTATION_DATA);
               
                for (int i = 0; i < data.length; i++)
                {
                    System.out.println("Found Notaion named '"+data[i].getNotationName()+"' with content '"+data[i].getNotationValue()+"'.");
                }
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.