From 7d3113ca15cc7bb3f3ea3c10755c3f3fe0fce8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 6 Sep 2013 19:06:17 +0200 Subject: [PATCH] Preparation for other app settings --- .../keychain/helper/PgpMain.java | 1 + .../keychain/provider/ProviderHelper.java | 41 +++++++++---------- .../keychain/remote_api/AppSettings.java | 8 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java index e1bd415be..65e50599d 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java @@ -788,6 +788,7 @@ public class PgpMain { } updateProgress(progress, R.string.progress_preparingStreams, 5, 100); + Log.d(Constants.TAG, "as"+symmetricEncryptionAlgorithm); // encrypt and compress input file content JcePGPDataEncryptorBuilder encryptorBuilder = new JcePGPDataEncryptorBuilder( symmetricEncryptionAlgorithm).setProvider(BOUNCY_CASTLE_PROVIDER_NAME) diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 90674b03d..13f4e085c 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -741,27 +741,26 @@ public class ProviderHelper { return packageNames; } - private static void contentValueForApiApps() { - - } - - public static void insertApiApp(Context context, AppSettings appSettings) { + private static ContentValues contentValueForApiApps(AppSettings appSettings) { ContentValues values = new ContentValues(); values.put(ApiApps.PACKAGE_NAME, appSettings.getPackageName()); values.put(ApiApps.KEY_ID, appSettings.getKeyId()); values.put(ApiApps.ASCII_ARMOR, appSettings.isAsciiArmor()); - // TODO: other parameters - context.getContentResolver().insert(ApiApps.CONTENT_URI, values); + values.put(ApiApps.COMPRESSION, appSettings.getCompression()); + values.put(ApiApps.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); + values.put(ApiApps.HASH_ALORITHM, appSettings.getHashAlgorithm()); + + return values; + } + + public static void insertApiApp(Context context, AppSettings appSettings) { + context.getContentResolver().insert(ApiApps.CONTENT_URI, + contentValueForApiApps(appSettings)); } public static void updateApiApp(Context context, AppSettings appSettings, Uri uri) { - final ContentValues cv = new ContentValues(); - cv.put(KeychainContract.ApiApps.KEY_ID, appSettings.getKeyId()); - - cv.put(KeychainContract.ApiApps.ASCII_ARMOR, appSettings.isAsciiArmor()); - // TODO: other parameters - - if (context.getContentResolver().update(uri, cv, null, null) <= 0) { + if (context.getContentResolver().update(uri, contentValueForApiApps(appSettings), null, + null) <= 0) { throw new RuntimeException(); } } @@ -775,17 +774,15 @@ public class ProviderHelper { if (cur.moveToFirst()) { settings.setPackageName(cur.getString(cur .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); - settings.setKeyId(cur.getLong(cur.getColumnIndex(KeychainContract.ApiApps.KEY_ID))); - settings.setAsciiArmor(cur.getInt(cur .getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1); - - settings.setPackageName(cur.getString(cur - .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); - - settings.setPackageName(cur.getString(cur - .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + settings.setCompression(cur.getInt(cur + .getColumnIndexOrThrow(KeychainContract.ApiApps.COMPRESSION))); + settings.setHashAlgorithm(cur.getInt(cur + .getColumnIndexOrThrow(KeychainContract.ApiApps.HASH_ALORITHM))); + settings.setEncryptionAlgorithm(cur.getInt(cur + .getColumnIndexOrThrow(KeychainContract.ApiApps.ENCRYPTION_ALGORITHM))); } return settings; diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettings.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettings.java index e0d63d461..98f48ff59 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettings.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettings.java @@ -17,6 +17,8 @@ package org.sufficientlysecure.keychain.remote_api; +import org.spongycastle.bcpg.HashAlgorithmTags; +import org.spongycastle.openpgp.PGPEncryptedData; import org.sufficientlysecure.keychain.Id; public class AppSettings { @@ -36,9 +38,9 @@ public class AppSettings { this.packageName = packageName; // defaults: this.asciiArmor = true; - this.encryptionAlgorithm = 7; // AES-128 - this.hashAlgorithm = 10; // SHA-512 - this.compression = 2; // zlib + this.encryptionAlgorithm = PGPEncryptedData.AES_128; // AES-128 + this.hashAlgorithm = HashAlgorithmTags.SHA512; // SHA-512 + this.compression = Id.choice.compression.zlib; // zlib } public String getPackageName() {