Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPSecretKeyRing


    private UnlockedKeySet unlockedKeySet;

    @Before
    public void setup() throws Exception {
      final FileInputStream keyRingFile = new FileInputStream("src/test/resources/secret-keyring.gpg");
      final PGPSecretKeyRing keyRing = new PGPSecretKeyRing(keyRingFile);
      keyRingFile.close();

      this.keySet = KeySet.load(keyRing);
      this.unlockedKeySet = keySet.unlock("test".toCharArray());
    }
View Full Code Here


    private KeySignature signature;
   
    @Before
    public void setup() throws Exception {
      final FileInputStream keyRingFile = new FileInputStream("src/test/resources/secret-keyring.gpg");
      final PGPSecretKeyRing keyRing = new PGPSecretKeyRing(keyRingFile);
      keyRingFile.close();
     
      this.key = keyRing.getSecretKey(0x8C7035EF8838238CL);
      final Iterator<?> sigs = key.getPublicKey().getSignatures();
      this.signature = new KeySignature((PGPSignature) sigs.next());
    }
View Full Code Here

    private MasterKey key;
   
    @Before
    public void setup() throws Exception {
      final FileInputStream keyRingFile = new FileInputStream("src/test/resources/secret-keyring.gpg");
      final PGPSecretKeyRing keyRing = new PGPSecretKeyRing(keyRingFile);
      keyRingFile.close();
     
      this.key = MasterKey.load(keyRing.getSecretKey(0x8C7035EF8838238CL));
    }
View Full Code Here

    private PGPSecretKeyRing keyRing;

    @Before
    public void setup() throws Exception {
      final FileInputStream keyRingFile = new FileInputStream("src/test/resources/secret-keyring.gpg");
      this.keyRing = new PGPSecretKeyRing(keyRingFile);
      keyRingFile.close();
    }
View Full Code Here

    private MasterKey key;
   
    @Before
    public void setup() throws Exception {
      final FileInputStream keyRingFile = new FileInputStream("src/test/resources/secret-keyring.gpg");
      final PGPSecretKeyRing keyRing = new PGPSecretKeyRing(keyRingFile);
      keyRingFile.close();
     
      this.key = MasterKey.load(keyRing.getSecretKey(0x8C7035EF8838238CL));
    }
View Full Code Here

        new DateTime().toDate()
      );

      generator.addSubKey(subPGPKeyPair, generateSubKeySettings(), null);

      final PGPSecretKeyRing keyRing = generator.generateSecretKeyRing();
      return KeySet.load(keyRing);
     
    } catch (GeneralSecurityException e) {
      throw new CryptographicException(e);
    } catch (PGPException e) {
View Full Code Here

  /**
   * Loads a {@link KeySet} from an {@link InputStream}.
   */
  public static KeySet load(InputStream input) throws CryptographicException {
    try {
      final PGPSecretKeyRing keyRing = new PGPSecretKeyRing(input);
      input.close();
      return load(keyRing);
    } catch (IOException e) {
      throw new CryptographicException(e);
    } catch (PGPException e) {
View Full Code Here

        PGPSecretKey pgpSecKey = null;
        PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyringInput));
        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(passphrase.toCharArray(), "BC");
                if (privateKey != null) {
                    pgpSecKey = secKey;
                }
            }
View Full Code Here

       
        secretRings = new PGPSecretKeyRingCollection(encRing);
       
        while (rIt.hasNext())
        {
            PGPSecretKeyRing                    pgpSec = (PGPSecretKeyRing)rIt.next();
   
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpSec.getEncoded();
           
            pgpSec = new PGPSecretKeyRing(bytes);
           
            Iterator    it = pgpSec.getSecretKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();
View Full Code Here

       
        secretRings = new PGPSecretKeyRingCollection(encRing);
       
        while (rIt.hasNext())
        {
            PGPSecretKeyRing                    pgpSec = (PGPSecretKeyRing)rIt.next();
   
            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpSec.getEncoded();
           
            pgpSec = new PGPSecretKeyRing(bytes);
           
            Iterator    it = pgpSec.getSecretKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPSecretKey    k = (PGPSecretKey)it.next();
View Full Code Here

TOP

Related Classes of org.bouncycastle.openpgp.PGPSecretKeyRing

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.