aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-03-18 13:45:16 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2015-03-18 14:06:59 +0100
commit4499caef1e64d2e1afec37d360958f516da4dd40 (patch)
tree61b7d6e1926a14bf85832ea6e58b455b3da2f3e2 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input
parent53d7c1f5330a6b5e83d27196ae4145e364af2cd3 (diff)
downloadopen-keychain-4499caef1e64d2e1afec37d360958f516da4dd40.tar.gz
open-keychain-4499caef1e64d2e1afec37d360958f516da4dd40.tar.bz2
open-keychain-4499caef1e64d2e1afec37d360958f516da4dd40.zip
introduce CryptoOperationParcel for nfc data
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/CryptoOperationParcel.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/CryptoOperationParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/CryptoOperationParcel.java
new file mode 100644
index 000000000..2101755ad
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/CryptoOperationParcel.java
@@ -0,0 +1,52 @@
+package org.sufficientlysecure.keychain.service.input;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+import java.util.HashMap;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+
+/** This is a base class for the input of crypto operations.
+ *
+ */
+public abstract class CryptoOperationParcel implements Parcelable {
+
+ Date mOperationTime;
+
+ // this map contains both decrypted session keys and signed hashes to be
+ // used in the crypto operation described by this parcel.
+ HashMap<ByteBuffer,byte[]> mCryptoData;
+
+ protected CryptoOperationParcel(Date operationTime) {
+ mOperationTime = operationTime;
+ }
+
+ protected CryptoOperationParcel(Parcel source) {
+ mOperationTime = new Date(source.readLong());
+
+ {
+ int count = source.readInt();
+ mCryptoData = new HashMap<>(count);
+ for (int i = 0; i < count; i++) {
+ byte[] key = source.createByteArray();
+ byte[] value = source.createByteArray();
+ mCryptoData.put(ByteBuffer.wrap(key), value);
+ }
+ }
+
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeLong(mOperationTime.getTime());
+
+ dest.writeInt(mCryptoData.size());
+ for (HashMap.Entry<ByteBuffer,byte[]> entry : mCryptoData.entrySet()) {
+ dest.writeByteArray(entry.getKey().array());
+ dest.writeByteArray(entry.getValue());
+ }
+ }
+
+}