amitaymolko / react-native-rsa-native

A native implementation of RSA key generation and encryption/decryption.
MIT License
233 stars 113 forks source link

Inconsistent parameter order #155

Open raphaelheinz opened 1 year ago

raphaelheinz commented 1 year ago

Be careful when using verify64WithAlgorithm! Order of signature and message parameters is inconsistent between Android and iOS. This results in a rejected signature.

A quick solution is to check the platform, but this should be fixed in the next version....

if (Platform.OS === 'android') {
    isValid = await RSA.verify64WithAlgorithm(signature, message, this.key.public, this.algorithm);
} else if (Platform.OS === 'ios') {
    isValid = await RSA.verify64WithAlgorithm(message, signature, this.key.public, this.algorithm);
}

Environment: react@18.2.0 react-native@0.71.8 react-native-rsa-native@2.0.5