Fix sign via API
This commit is contained in:
@@ -34,6 +34,7 @@ import org.sufficientlysecure.keychain.nfc.NfcActivity;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||||
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||||
@@ -246,7 +247,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
// carefully: only set if timestamp exists
|
// carefully: only set if timestamp exists
|
||||||
Date nfcCreationDate = null;
|
Date nfcCreationDate = null;
|
||||||
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
||||||
if (nfcCreationTimestamp > 0) {
|
if (nfcCreationTimestamp != 0) {
|
||||||
nfcCreationDate = new Date(nfcCreationTimestamp);
|
nfcCreationDate = new Date(nfcCreationTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +258,11 @@ public class OpenPgpService extends RemoteService {
|
|||||||
long inputLength = is.available();
|
long inputLength = is.available();
|
||||||
InputData inputData = new InputData(is, inputLength);
|
InputData inputData = new InputData(is, inputLength);
|
||||||
|
|
||||||
|
// Find the appropriate subkey to sign with
|
||||||
|
CachedPublicKeyRing signingRing =
|
||||||
|
new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
|
||||||
|
long sigSubKeyId = signingRing.getSignId();
|
||||||
|
|
||||||
// sign-only
|
// sign-only
|
||||||
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
|
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
|
||||||
new ProviderHelper(getContext()),
|
new ProviderHelper(getContext()),
|
||||||
@@ -276,6 +282,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||||
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
||||||
.setSignatureMasterKeyId(accSettings.getKeyId())
|
.setSignatureMasterKeyId(accSettings.getKeyId())
|
||||||
|
.setSignatureSubKeyId(sigSubKeyId)
|
||||||
.setSignaturePassphrase(passphrase)
|
.setSignaturePassphrase(passphrase)
|
||||||
.setNfcState(nfcSignedHash, nfcCreationDate);
|
.setNfcState(nfcSignedHash, nfcCreationDate);
|
||||||
|
|
||||||
@@ -398,13 +405,19 @@ public class OpenPgpService extends RemoteService {
|
|||||||
// carefully: only set if timestamp exists
|
// carefully: only set if timestamp exists
|
||||||
Date nfcCreationDate = null;
|
Date nfcCreationDate = null;
|
||||||
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0);
|
||||||
if (nfcCreationTimestamp > 0) {
|
if (nfcCreationTimestamp != 0) {
|
||||||
nfcCreationDate = new Date(nfcCreationTimestamp);
|
nfcCreationDate = new Date(nfcCreationTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find the appropriate subkey to sign with
|
||||||
|
CachedPublicKeyRing signingRing =
|
||||||
|
new ProviderHelper(this).getCachedPublicKeyRing(accSettings.getKeyId());
|
||||||
|
long sigSubKeyId = signingRing.getSignId();
|
||||||
|
|
||||||
// sign and encrypt
|
// sign and encrypt
|
||||||
builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
||||||
.setSignatureMasterKeyId(accSettings.getKeyId())
|
.setSignatureMasterKeyId(accSettings.getKeyId())
|
||||||
|
.setSignatureSubKeyId(sigSubKeyId)
|
||||||
.setSignaturePassphrase(passphrase)
|
.setSignaturePassphrase(passphrase)
|
||||||
.setNfcState(nfcSignedHash, nfcCreationDate);
|
.setNfcState(nfcSignedHash, nfcCreationDate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ public class KeyFormattingUtils {
|
|||||||
public static final int STATE_UNAVAILABLE = 4;
|
public static final int STATE_UNAVAILABLE = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if status has been set, if false no status!
|
* Sets status image based on constant
|
||||||
*/
|
*/
|
||||||
public static void setStatusImage(Context context, ImageView statusView, int state) {
|
public static void setStatusImage(Context context, ImageView statusView, int state) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user