diff options
| author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-09-18 13:19:57 +0200 | 
|---|---|---|
| committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-09-18 13:19:57 +0200 | 
| commit | 91e97d03a1a436b8a13e423f34643586bb343e4a (patch) | |
| tree | aabe34d3e1444af250c622b7ec9643630e8f32fe /OpenKeychain/src/main/java/org/sufficientlysecure | |
| parent | 9586d6b9b8193d3b7d990578eb97fab35c3e11eb (diff) | |
| download | open-keychain-91e97d03a1a436b8a13e423f34643586bb343e4a.tar.gz open-keychain-91e97d03a1a436b8a13e423f34643586bb343e4a.tar.bz2 open-keychain-91e97d03a1a436b8a13e423f34643586bb343e4a.zip | |
Fix sign via API
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
| -rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java | 17 | ||||
| -rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java | 2 | 
2 files changed, 16 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 a8751bac0..b23662a6e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -34,6 +34,7 @@ import org.sufficientlysecure.keychain.nfc.NfcActivity;  import org.sufficientlysecure.keychain.Constants;  import org.sufficientlysecure.keychain.pgp.PassphraseCacheInterface;  import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; +import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;  import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;  import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;  import org.sufficientlysecure.keychain.pgp.PgpHelper; @@ -246,7 +247,7 @@ public class OpenPgpService extends RemoteService {              // carefully: only set if timestamp exists              Date nfcCreationDate = null;              long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0); -            if (nfcCreationTimestamp > 0) { +            if (nfcCreationTimestamp != 0) {                  nfcCreationDate = new Date(nfcCreationTimestamp);              } @@ -257,6 +258,11 @@ public class OpenPgpService extends RemoteService {                  long inputLength = is.available();                  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                  PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(                          new ProviderHelper(getContext()), @@ -276,6 +282,7 @@ public class OpenPgpService extends RemoteService {                          .setVersionHeader(PgpHelper.getVersionForHeader(this))                          .setSignatureHashAlgorithm(accSettings.getHashAlgorithm())                          .setSignatureMasterKeyId(accSettings.getKeyId()) +                        .setSignatureSubKeyId(sigSubKeyId)                          .setSignaturePassphrase(passphrase)                          .setNfcState(nfcSignedHash, nfcCreationDate); @@ -398,13 +405,19 @@ public class OpenPgpService extends RemoteService {                      // carefully: only set if timestamp exists                      Date nfcCreationDate = null;                      long nfcCreationTimestamp = data.getLongExtra(OpenPgpApi.EXTRA_NFC_SIG_CREATION_TIMESTAMP, 0); -                    if (nfcCreationTimestamp > 0) { +                    if (nfcCreationTimestamp != 0) {                          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                      builder.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())                              .setSignatureMasterKeyId(accSettings.getKeyId()) +                            .setSignatureSubKeyId(sigSubKeyId)                              .setSignaturePassphrase(passphrase)                              .setNfcState(nfcSignedHash, nfcCreationDate);                  } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java index dad1f19a8..fc206aaf5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java @@ -340,7 +340,7 @@ public class KeyFormattingUtils {      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) {          switch (state) { | 
