Skip to content

Commit d129f2b

Browse files
authored
Merge pull request #2555 from wmathurin/dev
Using default cipher instantiation (the one with SHA-256 MGF fails on Android 26-33)
2 parents b39adbd + 6db6bc0 commit d129f2b

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

libs/SalesforceAnalytics/src/com/salesforce/androidsdk/analytics/security/Encryptor.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,7 @@ private static byte[] decryptWithPrivateKey(PrivateKey privateKey, String data,
587587

588588

589589
private static void initRSACipher(Cipher cipherInstance, int opmode, Key key, CipherMode cipherMode) throws InvalidKeyException, InvalidAlgorithmParameterException {
590-
if (cipherMode == CipherMode.RSA_OAEP_SHA256) {
591-
// OAEP uses a separate hash invocation for MGF (mask generation function) and for the hashing of the label.
592-
// Most libraries use the same hash algorithm for MGF and the hashing of the label.
593-
// But Java uses a different hash algorithm: it defaults to SHA-1 when using the cipher RSA/ECB/OAEPWithSHA-256AndMGF1Padding.
594-
OAEPParameterSpec paramSpec = new OAEPParameterSpec("SHA-256", "MGF1",
595-
new MGF1ParameterSpec("SHA-256"), PSource.PSpecified.DEFAULT);
596-
cipherInstance.init(opmode, key, paramSpec);
597-
} else {
598-
cipherInstance.init(opmode, key);
599-
}
590+
cipherInstance.init(opmode, key);
600591
}
601592

602593
private static byte[] generateInitVector() {

libs/test/SalesforceSDKTest/src/com/salesforce/androidsdk/security/KeyStoreWrapperTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ private void tryNewOrUpgradedClientAgainstNewOrOldServer(boolean newClient, bool
224224
? Encryptor.CipherMode.RSA_OAEP_SHA256 // new server / cipher mode
225225
: Encryptor.CipherMode.RSA_PKCS1 // old server / cipher mode
226226
);
227+
227228
final String encryptedData = Base64.encodeToString(encryptedBytes, Base64.NO_WRAP | Base64.NO_PADDING);
228229
Assert.assertNotSame("Encrypted data should not match original data", data, encryptedData);
229230
final String decryptedData = new String(Encryptor.decryptWithRSAMultiCipherNodes(privateKey, encryptedData), StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)