aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-05-22 13:05:02 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-05-22 13:05:02 +0200
commitcd0aba9d43403877df2130a54bde8ab51c8030d7 (patch)
tree10ca3f32b323d50ecc5d6f5252bcf32d4bffab60 /OpenKeychain/src/main/java
parent952bb99a2467bb5c1c2988d33451df0249e04a42 (diff)
downloadopen-keychain-cd0aba9d43403877df2130a54bde8ab51c8030d7.tar.gz
open-keychain-cd0aba9d43403877df2130a54bde8ab51c8030d7.tar.bz2
open-keychain-cd0aba9d43403877df2130a54bde8ab51c8030d7.zip
wrapped-key-ring: encapsulate key flags
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedSecretKey.java7
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java35
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java3
3 files changed, 27 insertions, 18 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedSecretKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedSecretKey.java
index 82224c6cf..0e14a7fd3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedSecretKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedSecretKey.java
@@ -1,5 +1,6 @@
package org.sufficientlysecure.keychain.pgp;
+import org.spongycastle.bcpg.sig.KeyFlags;
import org.spongycastle.openpgp.PGPSecretKey;
import java.io.IOException;
@@ -7,6 +8,12 @@ import java.io.OutputStream;
public class UncachedSecretKey extends UncachedPublicKey {
+ public static final int CERTIFY_OTHER = KeyFlags.CERTIFY_OTHER;
+ public static final int SIGN_DATA = KeyFlags.SIGN_DATA;
+ public static final int ENCRYPT_COMMS = KeyFlags.ENCRYPT_COMMS;
+ public static final int ENCRYPT_STORAGE = KeyFlags.ENCRYPT_STORAGE;
+ public static final int AUTHENTICATION = KeyFlags.AUTHENTICATION;
+
final PGPSecretKey mSecretKey;
public UncachedSecretKey(PGPSecretKey secretKey) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java
index e1a603787..40fe7665c 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java
@@ -38,7 +38,6 @@ import android.widget.TextView;
import com.beardedhen.androidbootstrap.BootstrapButton;
-import org.spongycastle.bcpg.sig.KeyFlags;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.pgp.UncachedSecretKey;
@@ -244,11 +243,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
mIsNewKey = isNewKey;
if (isNewKey) {
mUsage = usage;
- mChkCertify.setChecked((usage & KeyFlags.CERTIFY_OTHER) == KeyFlags.CERTIFY_OTHER);
- mChkSign.setChecked((usage & KeyFlags.SIGN_DATA) == KeyFlags.SIGN_DATA);
- mChkEncrypt.setChecked(((usage & KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS) ||
- ((usage & KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE));
- mChkAuthenticate.setChecked((usage & KeyFlags.AUTHENTICATION) == KeyFlags.AUTHENTICATION);
+ mChkCertify.setChecked(
+ (usage & UncachedSecretKey.CERTIFY_OTHER) == UncachedSecretKey.CERTIFY_OTHER);
+ mChkSign.setChecked(
+ (usage & UncachedSecretKey.SIGN_DATA) == UncachedSecretKey.SIGN_DATA);
+ mChkEncrypt.setChecked(
+ ((usage & UncachedSecretKey.ENCRYPT_COMMS) == UncachedSecretKey.ENCRYPT_COMMS) ||
+ ((usage & UncachedSecretKey.ENCRYPT_STORAGE) == UncachedSecretKey.ENCRYPT_STORAGE));
+ mChkAuthenticate.setChecked(
+ (usage & UncachedSecretKey.AUTHENTICATION) == UncachedSecretKey.AUTHENTICATION);
} else {
mUsage = key.getKeyUsage();
mOriginalUsage = mUsage;
@@ -319,16 +322,16 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
}
public int getUsage() {
- mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) |
- (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0);
- mUsage = (mUsage & ~KeyFlags.SIGN_DATA) |
- (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0);
- mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) |
- (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0);
- mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) |
- (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0);
- mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) |
- (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0);
+ mUsage = (mUsage & ~UncachedSecretKey.CERTIFY_OTHER) |
+ (mChkCertify.isChecked() ? UncachedSecretKey.CERTIFY_OTHER : 0);
+ mUsage = (mUsage & ~UncachedSecretKey.SIGN_DATA) |
+ (mChkSign.isChecked() ? UncachedSecretKey.SIGN_DATA : 0);
+ mUsage = (mUsage & ~UncachedSecretKey.ENCRYPT_COMMS) |
+ (mChkEncrypt.isChecked() ? UncachedSecretKey.ENCRYPT_COMMS : 0);
+ mUsage = (mUsage & ~UncachedSecretKey.ENCRYPT_STORAGE) |
+ (mChkEncrypt.isChecked() ? UncachedSecretKey.ENCRYPT_STORAGE : 0);
+ mUsage = (mUsage & ~UncachedSecretKey.AUTHENTICATION) |
+ (mChkAuthenticate.isChecked() ? UncachedSecretKey.AUTHENTICATION : 0);
return mUsage;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
index 35ebfcd58..3e8e18ce5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java
@@ -35,7 +35,6 @@ import android.widget.TextView;
import com.beardedhen.androidbootstrap.BootstrapButton;
-import org.spongycastle.openpgp.PGPKeyFlags;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
import org.sufficientlysecure.keychain.pgp.UncachedSecretKey;
@@ -420,7 +419,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
view.setEditorListener(SectionView.this);
int usage = 0;
if (mEditors.getChildCount() == 0) {
- usage = PGPKeyFlags.CAN_CERTIFY;
+ usage = UncachedSecretKey.CERTIFY_OTHER;
}
view.setValue(newKey, newKey.isMasterKey(), usage, true);
mEditors.addView(view);