blob: 2101755ad150ff22296a1c55891d10179baeedc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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());
}
}
}
|