Fix signature timestamp in API

This commit is contained in:
Dominik Schürmann 2014-09-08 00:17:13 +02:00
parent 83af19de20
commit 7ccd30b78e

View File

@ -240,7 +240,12 @@ public class OpenPgpService extends RemoteService {
} }
byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH); 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 // Get Input- and OutputStream from ParcelFileDescriptor
InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input);
@ -258,7 +263,7 @@ public class OpenPgpService extends RemoteService {
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm()) .setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
.setSignatureMasterKeyId(accSettings.getKeyId()) .setSignatureMasterKeyId(accSettings.getKeyId())
.setSignaturePassphrase(passphrase) .setSignaturePassphrase(passphrase)
.setNfcState(nfcSignedHash, nfcCreationTimestamp); .setNfcState(nfcSignedHash, nfcCreationDate);
// TODO: currently always assume cleartext input, no sign-only of binary currently! // TODO: currently always assume cleartext input, no sign-only of binary currently!
builder.setCleartextInput(true); builder.setCleartextInput(true);
@ -358,10 +363,19 @@ public class OpenPgpService extends RemoteService {
return getPassphraseIntent(data, accSettings.getKeyId()); 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 // sign and encrypt
builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm()) builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
.setSignatureMasterKeyId(accSettings.getKeyId()) .setSignatureMasterKeyId(accSettings.getKeyId())
.setSignaturePassphrase(passphrase); .setSignaturePassphrase(passphrase)
.setNfcState(nfcSignedHash, nfcCreationDate);
} }
try { try {