recognize RSA_SIGN and RSA_ENCRYPT keys correctly, which fixes the hushmail problems

This commit is contained in:
Thialfihar 2010-04-29 11:50:25 +00:00
parent a6fe3364d1
commit b20419fbf3

View File

@ -647,7 +647,7 @@ public class Apg {
ProgressDialogUpdater progress) ProgressDialogUpdater progress)
throws GeneralException, FileNotFoundException, PGPException, IOException { throws GeneralException, FileNotFoundException, PGPException, IOException {
Bundle returnData = new Bundle(); Bundle returnData = new Bundle();
PGPObjectFactory objectFactors = null; PGPObjectFactory objectFactory = null;
if (type == Id.type.secret_key) { if (type == Id.type.secret_key) {
progress.setProgress("importing secret keys...", 0, 100); progress.setProgress("importing secret keys...", 0, 100);
@ -661,13 +661,13 @@ public class Apg {
FileInputStream fileIn = new FileInputStream(filename); FileInputStream fileIn = new FileInputStream(filename);
InputStream in = PGPUtil.getDecoderStream(fileIn); InputStream in = PGPUtil.getDecoderStream(fileIn);
objectFactors = new PGPObjectFactory(in); objectFactory = new PGPObjectFactory(in);
Vector<Object> objects = new Vector<Object>(); Vector<Object> objects = new Vector<Object>();
Object obj = objectFactors.nextObject(); Object obj = objectFactory.nextObject();
while (obj != null) { while (obj != null) {
objects.add(obj); objects.add(obj);
obj = objectFactors.nextObject(); obj = objectFactory.nextObject();
} }
int newKeys = 0; int newKeys = 0;
@ -1009,11 +1009,15 @@ public class Apg {
return key.isEncryptionKey(); return key.isEncryptionKey();
} }
// special case, this algorithm, no need to look further // special cases
if (key.getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT) { if (key.getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT) {
return true; return true;
} }
if (key.getAlgorithm() == PGPPublicKey.RSA_ENCRYPT) {
return true;
}
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) { for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) {
if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) { if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) {
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
@ -1036,6 +1040,11 @@ public class Apg {
return true; return true;
} }
// special case
if (key.getAlgorithm() == PGPPublicKey.RSA_SIGN) {
return true;
}
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) { for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) {
if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) { if (!key.isMasterKey() || sig.getKeyID() == key.getKeyID()) {
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();