Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differently formatted keys on android and iOS #157

Open
acc-amilojkovic opened this issue Aug 1, 2023 · 3 comments
Open

Differently formatted keys on android and iOS #157

acc-amilojkovic opened this issue Aug 1, 2023 · 3 comments

Comments

@acc-amilojkovic
Copy link

acc-amilojkovic commented Aug 1, 2023

While using the RSA.generateKeys() method I've noticed that it generates differently formatted keys depending on the OS. I've noticed that the Android one is very differently generated than the iOS one since the headers are different and on android you have a lot more new lines.

Here is the example code And here are the the generated keys for Android and iOS
Android.txt
iOS.txt

it's causing us problems because our backend needs to verify the JWT that's signed by the device's private key, but when our backend gets the public key from the Android device it says its not in SPKI. The backend uses Jose to verify the SPKI public key.

Jose.txt - this is the output we get from JOSE

I've looked at the native modules for it and noticed there are differences between the java and swift code. Is it maybe a problem with the native modules how they generate the keys on Android or with Jose?

Thank you in advance.

@vinithreddy3
Copy link

vinithreddy3 commented Aug 16, 2023

@aleksa-milojkovic-accordia
Seems there is a fn -> RSAKeychain.getPublicKeyRSA for iOS only to get public key in pksc1 format similar to android. I used this function on iOS & the response is now formatted similar to android.

You can give a try with RSAKeychain instead of RSA. Check this older thread as well #110

@TereshchenkoVlad
Copy link

Have the same problem.
RSA.generateKeys(2048) - this method returns diff public length for Android and IOS.
On IOS it's longer.
There is no fix for it.

@acc-amilojkovic
Copy link
Author

Since there was no fix I used this: https://github.com/jerson/react-native-fast-rsa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants