Examples of extractPrivateKey()


Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

                    for (String keyUserId : keyUserIds) {
                        if (keyUserId.contains(userIdPart)) {
                            for (Iterator<PGPSecretKey> iterKey = keyring.getSecretKeys(); iterKey.hasNext();) {
                                PGPSecretKey secKey = iterKey.next();
                                if (isSigningKey(secKey)) {
                                    PGPPrivateKey privateKey = secKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider(
                                            provider).build(sigKeyUserId2Password.get(userIdPart).toCharArray()));
                                    if (privateKey != null) {
                                        result.add(new PGPSecretKeyAndPrivateKeyAndUserId(secKey, privateKey, keyUserId));
                                        LOG.debug("Private key with key user ID {} and key ID {} found for specified user ID part {}",
                                                new Object[] {keyUserId, Long.toString(privateKey.getKeyID()), userIdPart });
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        }
    }

    private void createSignature(OutputStream out) throws Exception {
        PGPSecretKey pgpSec = readSecretKey();
        PGPPrivateKey pgpPrivKey = pgpSec.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider(getProvider()).build(
                "sdude".toCharArray()));
        PGPSignatureGenerator sGen = new PGPSignatureGenerator(new JcaPGPContentSignerBuilder(pgpSec.getPublicKey().getAlgorithm(),
                PGPUtil.SHA1).setProvider(getProvider()));

        sGen.init(PGPSignature.BINARY_DOCUMENT, pgpPrivKey);
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        PGPPrivateKey privateKey = null;
        PGPPublicKeyEncryptedData encryptedData;
        while (privateKey == null && encryptedDataObjects.hasNext()) {
            encryptedData = (PGPPublicKeyEncryptedData) encryptedDataObjects.next();
            PGPSecretKey pgpSecKey = pgpSec.getSecretKey(encryptedData.getKeyID());
            privateKey = pgpSecKey.extractPrivateKey(passphrase.toCharArray(), "BC");
        }
        return privateKey;
    }

    public static byte[] compress(byte[] clearData, String fileName, int algorithm) throws IOException {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        {
            return null;
        }
        else
        {
            return pgpSecKey.extractPrivateKey(pass.toCharArray(), "BC");
        }
    }
}
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        PGPSecretKey sigSecretKey = PGPDataFormatUtil.findSecretKey(exchange.getContext(), sigKeyFileName, sigKeyPassword);
        if (sigSecretKey == null) {
            throw new IllegalArgumentException("Signature secret key is null, cannot proceed");
        }

        PGPPrivateKey sigPrivateKey = sigSecretKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(sigKeyPassword.toCharArray()));
        if (sigPrivateKey == null) {
            throw new IllegalArgumentException("Signature private key is null, cannot proceed");
        }

        PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        PGPPrivateKey privateKey = null;
        PGPPublicKeyEncryptedData encryptedData;
        while (privateKey == null && encryptedDataObjects.hasNext()) {
            encryptedData = (PGPPublicKeyEncryptedData) encryptedDataObjects.next();
            PGPSecretKey pgpSecKey = pgpSec.getSecretKey(encryptedData.getKeyID());
            privateKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
        }
        return privateKey;
    }

    public static PGPSecretKey findSecretKey(CamelContext context, String keychainFilename, String passphrase)
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        for (Iterator<?> i = pgpSec.getKeyRings(); i.hasNext() && pgpSecKey == null;) {
            Object data = i.next();
            if (data instanceof PGPSecretKeyRing) {
                PGPSecretKeyRing keyring = (PGPSecretKeyRing) data;
                PGPSecretKey secKey = keyring.getSecretKey();
                PGPPrivateKey privateKey = secKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
                if (privateKey != null) {
                    pgpSecKey = secKey;
                }
            }
        }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        {
            digest = PGPUtil.SHA1;
        }
       
        PGPSecretKey                    pgpSecKey = readSecretKey(keyIn);
        PGPPrivateKey                   pgpPrivKey = pgpSecKey.extractPrivateKey(pass, "BC");       
        PGPSignatureGenerator           sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC");
        PGPSignatureSubpacketGenerator  spGen = new PGPSignatureSubpacketGenerator();
       
        sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey);
       
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

        PGPPrivateKey privateKey = null;
        PGPPublicKeyEncryptedData encryptedData;
        while (privateKey == null && encryptedDataObjects.hasNext()) {
            encryptedData = (PGPPublicKeyEncryptedData) encryptedDataObjects.next();
            PGPSecretKey pgpSecKey = pgpSec.getSecretKey(encryptedData.getKeyID());
            privateKey = pgpSecKey.extractPrivateKey(passphrase.toCharArray(), "BC");
        }
        return privateKey;
    }

    public static byte[] compress(byte[] clearData, String fileName, int algorithm) throws IOException {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPSecretKey.extractPrivateKey()

            while (keyIter.hasNext()) {
                PGPSecretKey key = keyIter.next();
                for (Iterator<String> iterator = key.getUserIDs(); iterator.hasNext();) {
                    String userId = iterator.next();
                    if (key.isSigningKey() && userId.contains(userid)) {
                        return key.extractPrivateKey(passphrase.toCharArray(), "BC");
                    }
                }
            }
        }
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.