mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-26 00:11:52 -05:00
Due to compatiblity switch from SHA512 to SHA256
This commit is contained in:
parent
c026dac8fc
commit
d172058150
@ -71,7 +71,7 @@ public final class Constants {
|
|||||||
public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl";
|
public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl";
|
||||||
public static final String LANGUAGE = "language";
|
public static final String LANGUAGE = "language";
|
||||||
public static final String KEY_SERVERS = "keyServers";
|
public static final String KEY_SERVERS = "keyServers";
|
||||||
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion";
|
public static final String PREF_DEFAULT_VERSION = "keyServersDefaultVersion";
|
||||||
public static final String WRITE_VERSION_HEADER = "writeVersionHeader";
|
public static final String WRITE_VERSION_HEADER = "writeVersionHeader";
|
||||||
public static final String FIRST_TIME = "firstTime";
|
public static final String FIRST_TIME = "firstTime";
|
||||||
public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs";
|
public static final String SHOW_ADVANCED_TABS = "showAdvancedTabs";
|
||||||
@ -83,7 +83,7 @@ public final class Constants {
|
|||||||
|
|
||||||
public static final class Defaults {
|
public static final class Defaults {
|
||||||
public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, hkps://pgp.mit.edu";
|
public static final String KEY_SERVERS = "hkps://hkps.pool.sks-keyservers.net, hkps://pgp.mit.edu";
|
||||||
public static final int KEY_SERVERS_VERSION = 3;
|
public static final int PREF_VERSION = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class DrawerItems {
|
public static final class DrawerItems {
|
||||||
|
@ -29,7 +29,6 @@ import org.sufficientlysecure.keychain.Constants.Pref;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ public class Preferences {
|
|||||||
|
|
||||||
public int getDefaultHashAlgorithm() {
|
public int getDefaultHashAlgorithm() {
|
||||||
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_HASH_ALGORITHM,
|
return mSharedPreferences.getInt(Constants.Pref.DEFAULT_HASH_ALGORITHM,
|
||||||
HashAlgorithmTags.SHA512);
|
HashAlgorithmTags.SHA256);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultHashAlgorithm(int value) {
|
public void setDefaultHashAlgorithm(int value) {
|
||||||
@ -237,9 +236,15 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePreferences() {
|
public void updatePreferences() {
|
||||||
|
if (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0) !=
|
||||||
|
Constants.Defaults.PREF_VERSION) {
|
||||||
|
switch (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0)) {
|
||||||
|
case 1:
|
||||||
|
// fall through
|
||||||
|
case 2:
|
||||||
|
// fall through
|
||||||
|
case 3: {
|
||||||
// migrate keyserver to hkps
|
// migrate keyserver to hkps
|
||||||
if (mSharedPreferences.getInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, 0) !=
|
|
||||||
Constants.Defaults.KEY_SERVERS_VERSION) {
|
|
||||||
String[] serversArray = getKeyServers();
|
String[] serversArray = getKeyServers();
|
||||||
ArrayList<String> servers = new ArrayList<String>(Arrays.asList(serversArray));
|
ArrayList<String> servers = new ArrayList<String>(Arrays.asList(serversArray));
|
||||||
ListIterator<String> it = servers.listIterator();
|
ListIterator<String> it = servers.listIterator();
|
||||||
@ -261,19 +266,33 @@ public class Preferences {
|
|||||||
|
|
||||||
}
|
}
|
||||||
setKeyServers(servers.toArray(new String[servers.size()]));
|
setKeyServers(servers.toArray(new String[servers.size()]));
|
||||||
mSharedPreferences.edit()
|
|
||||||
.putInt(Constants.Pref.KEY_SERVERS_DEFAULT_VERSION, Constants.Defaults.KEY_SERVERS_VERSION)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// migrate old uncompressed constant to new one
|
// migrate old uncompressed constant to new one
|
||||||
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_FILE_COMPRESSION, 0) == 0x21070001) {
|
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_FILE_COMPRESSION, 0)
|
||||||
|
== 0x21070001) {
|
||||||
setDefaultFileCompression(CompressionAlgorithmTags.UNCOMPRESSED);
|
setDefaultFileCompression(CompressionAlgorithmTags.UNCOMPRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// migrate away from MD5
|
// migrate away from MD5
|
||||||
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_HASH_ALGORITHM, 0) == HashAlgorithmTags.MD5) {
|
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_HASH_ALGORITHM, 0)
|
||||||
setDefaultHashAlgorithm(HashAlgorithmTags.SHA512);
|
== HashAlgorithmTags.MD5) {
|
||||||
|
setDefaultHashAlgorithm(HashAlgorithmTags.SHA256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
|
case 4: {
|
||||||
|
// for compatibility: change from SHA512 to SHA256
|
||||||
|
if (mSharedPreferences.getInt(Constants.Pref.DEFAULT_HASH_ALGORITHM, 0)
|
||||||
|
== HashAlgorithmTags.SHA512) {
|
||||||
|
setDefaultHashAlgorithm(HashAlgorithmTags.SHA256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// write new preference version
|
||||||
|
mSharedPreferences.edit()
|
||||||
|
.putInt(Constants.Pref.PREF_DEFAULT_VERSION, Constants.Defaults.PREF_VERSION)
|
||||||
|
.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public class PgpKeyOperation {
|
|||||||
* http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
* http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
||||||
*/
|
*/
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 0x60;
|
private static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 0x60;
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA512;
|
private static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA256;
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
private static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
||||||
|
|
||||||
public PgpKeyOperation(Progressable progress) {
|
public PgpKeyOperation(Progressable progress) {
|
||||||
|
@ -39,7 +39,7 @@ public class AccountSettings {
|
|||||||
|
|
||||||
// defaults:
|
// defaults:
|
||||||
this.mEncryptionAlgorithm = PGPEncryptedData.AES_256;
|
this.mEncryptionAlgorithm = PGPEncryptedData.AES_256;
|
||||||
this.mHashAlgorithm = HashAlgorithmTags.SHA512;
|
this.mHashAlgorithm = HashAlgorithmTags.SHA256;
|
||||||
this.mCompression = CompressionAlgorithmTags.ZLIB;
|
this.mCompression = CompressionAlgorithmTags.ZLIB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user