aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-09-08 00:17:13 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-09-08 00:17:13 +0200
commit7ccd30b78e75f39f35e02283d2d1c46b7422939e (patch)
treebde1aed93e7868172a6ba2ed0e6711b98f319a8e /OpenKeychain
parent83af19de20cbfa8fe99216f4dcb8af8819570147 (diff)
downloadopen-keychain-7ccd30b78e75f39f35e02283d2d1c46b7422939e.tar.gz
open-keychain-7ccd30b78e75f39f35e02283d2d1c46b7422939e.tar.bz2
open-keychain-7ccd30b78e75f39f35e02283d2d1c46b7422939e.zip
Fix signature timestamp in API
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index 3b4559cf2..f51a3ac14 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -240,7 +240,12 @@ public class OpenPgpService extends RemoteService {
}
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
- Date nfcCreationTimestamp = new Date(data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0));
+ // carefully: only set if timestamp exists
+ Date nfcCreationDate = null;
+ long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
+ if (nfcCreationTimestamp > 0) {
+ nfcCreationDate = new Date(nfcCreationTimestamp);
+ }
// Get Input- and OutputStream from ParcelFileDescriptor
InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input);
@@ -258,7 +263,7 @@ public class OpenPgpService extends RemoteService {
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
.setSignatureMasterKeyId(accSettings.getKeyId())
.setSignaturePassphrase(passphrase)
- .setNfcState(nfcSignedHash, nfcCreationTimestamp);
+ .setNfcState(nfcSignedHash, nfcCreationDate);
// TODO: currently always assume cleartext input, no sign-only of binary currently!
builder.setCleartextInput(true);
@@ -358,10 +363,19 @@ public class OpenPgpService extends RemoteService {
return getPassphraseIntent(data, accSettings.getKeyId());
}
+ byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
+ // carefully: only set if timestamp exists
+ Date nfcCreationDate = null;
+ long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
+ if (nfcCreationTimestamp > 0) {
+ nfcCreationDate = new Date(nfcCreationTimestamp);
+ }
+
// sign and encrypt
builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
.setSignatureMasterKeyId(accSettings.getKeyId())
- .setSignaturePassphrase(passphrase);
+ .setSignaturePassphrase(passphrase)
+ .setNfcState(nfcSignedHash, nfcCreationDate);
}
try {