aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.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/ComparableS2K.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/ComparableS2K.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.java40
1 files changed, 35 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.java
index 5c92008e5..31faa233c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/ComparableS2K.java
@@ -1,3 +1,20 @@
+/*
+ * Copyright (C) 2016 Vincent Breitmoser <look@my.amazin.horse>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package org.sufficientlysecure.keychain.pgp;
@@ -9,13 +26,26 @@ import android.os.Parcelable;
import org.spongycastle.bcpg.S2K;
+/** This is an immutable and parcelable class which stores the full s2k parametrization
+ * of an encrypted secret key, i.e. all fields of the {@link S2K} class (type, hash algo,
+ * iteration count, iv) plus the encryptionAlgorithm. This class is intended to be used
+ * as key in a HashMap for session key caching purposes, and overrides the
+ * {@link #hashCode} and {@link #equals} methods in a suitable way.
+ *
+ * Note that although it is a rather unlikely scenario that secret keys of the same key
+ * are encrypted with different ciphers, the encryption algorithm still determines the
+ * length of the specific session key and thus needs to be considered for purposes of
+ * session key caching.
+ *
+ * @see org.spongycastle.bcpg.S2K
+ */
public class ComparableS2K implements Parcelable {
- int encryptionAlgorithm;
- int s2kType;
- int s2kHashAlgo;
- long s2kItCount;
- byte[] s2kIV;
+ private final int encryptionAlgorithm;
+ private final int s2kType;
+ private final int s2kHashAlgo;
+ private final long s2kItCount;
+ private final byte[] s2kIV;
Integer cachedHashCode;