forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
339 stars 384 forks source link

Use SHA-256 for MFG during push notification decryption #2542

Closed wmathurin closed 2 months ago

wmathurin commented 2 months ago

OAEP uses a separate hash invocation for MGF (mask generation function) and for the hashing of the label.

Most libraries use the same hash algorithm for MGF and the hashing of the label. But Java uses a different hash algorithm: it defaults to SHA-1 when using the cipher RSA/ECB/OAEPWithSHA-256AndMGF1Padding. iOS uses SHA-256 when using the cipher kSecKeyAlgorithmRSAEncryptionOAEPSHA256.

Java provides a way to override the default and specify SHA-256 as the hash for MGF (and conversely iOS does not provide a way to specify a different hash function) ==> we need to make sure to explicitly set SHA-256 has the hash function for MGF on both the server and Android.