Simplified algorithms names

This commit is contained in:
M66B 2021-09-08 08:12:17 +02:00
parent 718274ecc7
commit 35436c8ee7
4 changed files with 22 additions and 23 deletions

View File

@ -516,6 +516,9 @@ public class ApplicationEx extends Application
if (!prefs.contains("landscape3"))
editor.putBoolean("landscape3", false);
}
} else if (version < 17150) {
editor.remove("sign_algo_smime");
editor.remove("encrypt_algo_smime");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)

View File

@ -3434,12 +3434,7 @@ public class FragmentCompose extends FragmentBase {
CMSSignedDataGenerator cmsGenerator = new CMSSignedDataGenerator();
cmsGenerator.addCertificates(store);
String signAlgorithm = prefs.getString("sign_algo_smime", "SHA256");
// https://datatracker.ietf.org/doc/html/rfc5751#page-29
String micalg = signAlgorithm.toLowerCase(Locale.ROOT);
if (micalg.startsWith("sha"))
micalg = micalg.substring(0, 3) + "-" + micalg.substring(3);
String signAlgorithm = prefs.getString("sign_algo_smime", "SHA-256");
String algorithm = privkey.getAlgorithm();
if (TextUtils.isEmpty(algorithm) || "RSA".equals(algorithm))
@ -3477,7 +3472,7 @@ public class FragmentCompose extends FragmentBase {
// Build signature
if (EntityMessage.SMIME_SIGNONLY.equals(type)) {
ContentType ct = new ContentType("application/pkcs7-signature");
ct.setParameter("micalg", micalg);
ct.setParameter("micalg", signAlgorithm.toLowerCase(Locale.ROOT));
EntityAttachment sattachment = new EntityAttachment();
sattachment.message = draft.id;
@ -3550,7 +3545,7 @@ public class FragmentCompose extends FragmentBase {
// Build message
ContentType ct = new ContentType("multipart/signed");
ct.setParameter("micalg", micalg);
ct.setParameter("micalg", signAlgorithm.toLowerCase(Locale.ROOT));
ct.setParameter("protocol", "application/pkcs7-signature");
ct.setParameter("smime-type", "signed-data");
String ctx = ct.toString();
@ -3587,17 +3582,16 @@ public class FragmentCompose extends FragmentBase {
}
CMSTypedData msg = new CMSProcessableFile(einput);
// https://datatracker.ietf.org/doc/html/rfc5751#section-2.7
ASN1ObjectIdentifier encryptionOID;
String encryptAlgorithm = prefs.getString("encrypt_algo_smime", "AES128");
String encryptAlgorithm = prefs.getString("encrypt_algo_smime", "AES-128");
switch (encryptAlgorithm) {
case "AES128":
case "AES-128":
encryptionOID = CMSAlgorithm.AES128_CBC;
break;
case "AES192":
case "AES-192":
encryptionOID = CMSAlgorithm.AES192_CBC;
break;
case "AES256":
case "AES-256":
encryptionOID = CMSAlgorithm.AES256_CBC;
break;
default:

View File

@ -471,7 +471,7 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
swAutocryptMutual.setEnabled(swAutocrypt.isChecked());
swEncryptSubject.setChecked(prefs.getBoolean("encrypt_subject", false));
String signAlgorithm = prefs.getString("sign_algo_smime", "SHA256");
String signAlgorithm = prefs.getString("sign_algo_smime", "SHA-256");
String[] smimeSignAlgo = getResources().getStringArray(R.array.smimeSignAlgo);
for (int pos = 0; pos < smimeSignAlgo.length; pos++)
if (smimeSignAlgo[pos].equals(signAlgorithm)) {
@ -479,7 +479,7 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
break;
}
String encryptAlgorithm = prefs.getString("encrypt_algo_smime", "AES128");
String encryptAlgorithm = prefs.getString("encrypt_algo_smime", "AES-128");
String[] smimeEncryptAlgo = getResources().getStringArray(R.array.smimeEncryptAlgo);
for (int pos = 0; pos < smimeEncryptAlgo.length; pos++)
if (smimeEncryptAlgo[pos].equals(encryptAlgorithm)) {

View File

@ -2023,19 +2023,21 @@
</string-array>
<!-- https://www.bouncycastle.org/specifications.html -->
<!-- https://datatracker.ietf.org/doc/html/rfc5751#page-29 -->
<string-array name="smimeSignAlgo" translatable="false">
<item>MD5</item>
<item>SHA1</item>
<item>SHA224</item>
<item>SHA256</item>
<item>SHA384</item>
<item>SHA512</item>
<item>SHA-1</item>
<item>SHA-224</item>
<item>SHA-256</item>
<item>SHA-384</item>
<item>SHA-512</item>
</string-array>
<!-- https://datatracker.ietf.org/doc/html/rfc5751#section-2.7 -->
<string-array name="smimeEncryptAlgo" translatable="false">
<item>AES128</item>
<item>AES192</item>
<item>AES256</item>
<item>AES-128</item>
<item>AES-192</item>
<item>AES-256</item>
</string-array>
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>