From 803a1e9481b3725d84ddc9cd3402d7a29bb11c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 18 Jan 2014 20:03:40 +0100 Subject: [PATCH] sign key without passphrase fixed --- .../keychain/pgp/PgpKeyOperation.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 225167fce..3ec6fd2a8 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -165,7 +165,8 @@ public class PgpKeyOperation { } default: { - throw new PgpGeneralException(mContext.getString(R.string.error_unknown_algorithm_choice)); + throw new PgpGeneralException( + mContext.getString(R.string.error_unknown_algorithm_choice)); } } @@ -289,7 +290,7 @@ public class PgpKeyOperation { updateProgress(R.string.progress_certifying_master_key, 20, 100); - //TODO: if we are editing a key, keep old certs, don't remake certs we don't have to. + // TODO: if we are editing a key, keep old certs, don't remake certs we don't have to. for (String userId : userIds) { PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( @@ -374,15 +375,16 @@ public class PgpKeyOperation { usageId = keysUsages.get(i); canSign = (usageId == Id.choice.usage.sign_only || usageId == Id.choice.usage.sign_and_encrypt); canEncrypt = (usageId == Id.choice.usage.encrypt_only || usageId == Id.choice.usage.sign_and_encrypt); - if (canSign) { //TODO: ensure signing times are the same, like gpg + if (canSign) { // TODO: ensure signing times are the same, like gpg keyFlags |= KeyFlags.SIGN_DATA; - //cross-certify signing keys + // cross-certify signing keys PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( - subPublicKey.getAlgorithm(), PGPUtil.SHA1) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + subPublicKey.getAlgorithm(), PGPUtil.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); sGen.init(PGPSignature.PRIMARYKEY_BINDING, subPrivateKey); - PGPSignature certification = sGen.generateCertification(masterPublicKey, subPublicKey); + PGPSignature certification = sGen.generateCertification(masterPublicKey, + subPublicKey); unhashedPacketsGen.setEmbeddedSignature(false, certification); } if (canEncrypt) { @@ -420,7 +422,7 @@ public class PgpKeyOperation { public PGPPublicKeyRing signKey(long masterKeyId, long pubKeyId, String passphrase) throws PgpGeneralException, NoSuchAlgorithmException, NoSuchProviderException, PGPException, SignatureException { - if (passphrase == null || passphrase.length() <= 0) { + if (passphrase == null) { throw new PgpGeneralException("Unable to obtain passphrase"); } else { PGPPublicKeyRing pubring = ProviderHelper