From b20419fbf3dd6d9da412c95f1c7af8c651e40612 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 29 Apr 2010 11:50:25 +0000 Subject: [PATCH] recognize RSA_SIGN and RSA_ENCRYPT keys correctly, which fixes the hushmail problems --- src/org/thialfihar/android/apg/Apg.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index af4cbf1ed..01464dd33 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -647,7 +647,7 @@ public class Apg { ProgressDialogUpdater progress) throws GeneralException, FileNotFoundException, PGPException, IOException { Bundle returnData = new Bundle(); - PGPObjectFactory objectFactors = null; + PGPObjectFactory objectFactory = null; if (type == Id.type.secret_key) { progress.setProgress("importing secret keys...", 0, 100); @@ -661,13 +661,13 @@ public class Apg { FileInputStream fileIn = new FileInputStream(filename); InputStream in = PGPUtil.getDecoderStream(fileIn); - objectFactors = new PGPObjectFactory(in); + objectFactory = new PGPObjectFactory(in); Vector objects = new Vector(); - Object obj = objectFactors.nextObject(); + Object obj = objectFactory.nextObject(); while (obj != null) { objects.add(obj); - obj = objectFactors.nextObject(); + obj = objectFactory.nextObject(); } int newKeys = 0; @@ -1009,11 +1009,15 @@ public class Apg { return key.isEncryptionKey(); } - // special case, this algorithm, no need to look further + // special cases if (key.getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT) { return true; } + if (key.getAlgorithm() == PGPPublicKey.RSA_ENCRYPT) { + return true; + } + for (PGPSignature sig : new IterableIterator(key.getSignatures())) { if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) { PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); @@ -1036,6 +1040,11 @@ public class Apg { return true; } + // special case + if (key.getAlgorithm() == PGPPublicKey.RSA_SIGN) { + return true; + } + for (PGPSignature sig : new IterableIterator(key.getSignatures())) { if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) { PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();