diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-01 18:53:19 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-02-01 18:53:19 +0100 |
commit | 7e634a9930a61bed0f41713ec876c6d31b6d2264 (patch) | |
tree | 769c0507f1e80c244ff9c93cff1f54f7bc2ab337 /libraries | |
parent | a891ff2f7c078631900d15a181c209a289cb9c23 (diff) | |
parent | 1e565ef8724453e2ab3c5f661b270f7ead78cce3 (diff) | |
download | open-keychain-7e634a9930a61bed0f41713ec876c6d31b6d2264.tar.gz open-keychain-7e634a9930a61bed0f41713ec876c6d31b6d2264.tar.bz2 open-keychain-7e634a9930a61bed0f41713ec876c6d31b6d2264.zip |
Merge branch 'master' of github.com:openpgp-keychain/openpgp-keychain
Diffstat (limited to 'libraries')
3 files changed, 29 insertions, 1 deletions
diff --git a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPObjectFactory.java b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPObjectFactory.java index 11fb3a53c..73b11b9a1 100644 --- a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPObjectFactory.java +++ b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPObjectFactory.java @@ -103,6 +103,15 @@ public class PGPObjectFactory { throw new IOException("can't create secret key object: " + e); } + case PacketTags.SECRET_SUBKEY: + try + { + return PGPSecretKeyRing.readSubkey(in, fingerPrintCalculator); + } + catch (PGPException e) + { + throw new IOException("processing error: " + e.getMessage()); + } case PacketTags.PUBLIC_KEY: return new PGPPublicKeyRing(in, fingerPrintCalculator); case PacketTags.PUBLIC_SUBKEY: diff --git a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKey.java b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKey.java index d705e5ce6..c0f7dfa3b 100644 --- a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKey.java +++ b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKey.java @@ -64,7 +64,7 @@ public class PGPSecretKey this(privKey, pubKey, checksumCalculator, false, keyEncryptor); } - PGPSecretKey( + public PGPSecretKey( PGPPrivateKey privKey, PGPPublicKey pubKey, PGPDigestCalculator checksumCalculator, diff --git a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKeyRing.java b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKeyRing.java index c182a1f1e..6df4c0c91 100644 --- a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKeyRing.java +++ b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/PGPSecretKeyRing.java @@ -477,4 +477,23 @@ public class PGPSecretKeyRing return new PGPSecretKeyRing(keys, secRing.extraPubKeys); } + + public static PGPSecretKey readSubkey(BCPGInputStream in, KeyFingerPrintCalculator fingerPrintCalculator) + throws IOException, PGPException + { + SecretSubkeyPacket sub = (SecretSubkeyPacket)in.readPacket(); + + // + // ignore GPG comment packets if found. + // + while (in.nextPacketTag() == PacketTags.EXPERIMENTAL_2) + { + in.readPacket(); + } + + TrustPacket subTrust = readOptionalTrustPacket(in); + List sigList = readSignaturesAndTrust(in); + + return new PGPSecretKey(sub, new PGPPublicKey(sub.getPublicKeyPacket(), subTrust, sigList, fingerPrintCalculator)); + } } |