aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2016-02-10 17:08:00 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2016-02-10 17:08:00 +0100
commit01b165ea88a032f31b8c2ff07351d3f893f6413d (patch)
treea0d1b003fcadc6a8d8b3ce5c1e486125ff29bdb0 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
parent3bf6a00250684a48db00d2437615d014bbbca5b4 (diff)
downloadopen-keychain-01b165ea88a032f31b8c2ff07351d3f893f6413d.tar.gz
open-keychain-01b165ea88a032f31b8c2ff07351d3f893f6413d.tar.bz2
open-keychain-01b165ea88a032f31b8c2ff07351d3f893f6413d.zip
performance: add license headers and some documentation
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
index 95a0d41cc..012a7e4e6 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CanonicalizedSecretKey.java
@@ -38,6 +38,7 @@ import org.spongycastle.openpgp.operator.jcajce.SessionKeySecretKeyDecryptorBuil
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
+import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase;
@@ -120,8 +121,13 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
}
- // This method can potentially take a LONG time (i.e. seconds), so it should only
- // ever be called by ProviderHelper to be cached in the database.
+ /** This method returns the SecretKeyType for this secret key, testing for an empty
+ * passphrase in the process.
+ *
+ * This method can potentially take a LONG time (i.e. seconds), so it should only
+ * ever be called by {@link ProviderHelper} for the purpose of caching its output
+ * in the database.
+ */
public SecretKeyType getSecretKeyTypeSuperExpensive() {
S2K s2k = mSecretKey.getS2K();
if (s2k != null && s2k.getType() == S2K.GNU_DUMMY_S2K) {
@@ -175,13 +181,13 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
}
byte[] sessionKey;
- sessionKey = passphrase.getCachedSessionKeyForAlgorithm(keyEncryptionAlgorithm, s2k);
+ sessionKey = passphrase.getCachedSessionKeyForParameters(keyEncryptionAlgorithm, s2k);
if (sessionKey == null) {
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.getCharArray());
// this operation is EXPENSIVE, so we cache its result in the passed Passphrase object!
sessionKey = keyDecryptor.makeKeyFromPassPhrase(keyEncryptionAlgorithm, s2k);
- passphrase.addCachedSessionKey(keyEncryptionAlgorithm, s2k, sessionKey);
+ passphrase.addCachedSessionKeyForParameters(keyEncryptionAlgorithm, s2k, sessionKey);
}
PBESecretKeyDecryptor keyDecryptor = new SessionKeySecretKeyDecryptorBuilder()