tananaev / passport-reader

e-Passport NFC Reader Android app
326 stars 126 forks source link

insertProviderAt(SC, 1) breaks other crypto ops #12

Open mvayngrib opened 5 years ago

mvayngrib commented 5 years ago

Q: is there a way to only use the Spongy/BouncyCastleProvider for the particular operations needed for chip reading/auth? Mutating the global list of providers breaks other crypto I'm doing. Thanks!

edit: i tried addProvider() instead, but then it doesn't scan the chip

tananaev commented 5 years ago

Why does it break other crypto? Does it replace some provider that you need?

mvayngrib commented 5 years ago

@tananaev yep, see the code here https://github.com/tradle/react-native-ecc/blob/master/android/src/main/java/com/rn/ecc/ECCModule.java

sign doesn't work, the SC provider seems to get in the way. I printed the providers:

with passport-reader:

SC
AndroidKeyStoreBCWorkaround
AndroidOpenSSL
BC
Crypto
HarmonyJSSE
AndroidKeyStore

without passport reader:

AndroidKeyStoreBCWorkaround
AndroidOpenSSL
BC
Crypto
HarmonyJSSE
AndroidKeyStore
tananaev commented 5 years ago

Not sure how to solve the issue. Maybe there is a way to specify provider explicitly?

mvayngrib commented 5 years ago

i've googled a fair bit. One way is to insertProviderAt before the relevant code in this module, and then remove it after. However, as it's executing in the background, it will probably affect anything that happens to be using crypto at the same time.

some libraries allow you to setProvider explicitly, e.g. here, but i'm not really familiar with the libraries being used here. Maybe you can check if u know where to look?

tananaev commented 5 years ago

Unfortunately I don't have much time to dedicate to this project.