react-native-quick-crypto
react-native-quick-crypto copied to clipboard
pbkdf2 is undefined
In version 0.7.0rc6 pbkdf2 is seen as undefined. I get this error whenever I try to call it from my app.
With further analysis I noticed that the issue wasn't from the app but from the latest version of the package. The code snippet below is enough to reproduce:
import qc from 'react-native-quick-crypto'
const salt = toUtf8Bytes("abcd", UnicodeNormalizationForm.NFKD)
qc.pbkdf2Sync(toUtf8Bytes("abcd", UnicodeNormalizationForm.NFKD), salt, 2048, 64, "SHA-512")
Not sure what changed from v0.6.1 but I'm happy to provide more information if you're unable to reproduce
perhaps the partial subtle implementation is implicated here. it might be good to give users fine grained control over whether they want to adopt subtle or not.
perhaps the partial subtle implementation is implicated here. it might be good to give users fine grained control over whether they want to adopt subtle or not.
Why subtle here? He's using the crypto method, not crypto.subtle. Granted, subtle is what has changed recently, but I haven't found anything in the commits that is a smoking gun (yet). Changes around algo name "SHA-512" should still result in sha512 being sent into C++.
I've added a test in a branch, and it passes: https://github.com/boorad/react-native-quick-crypto/commit/6dc72cfe0c16a934e25971c9dcfee60010256880
Does this pass for everyone else, in the example app?
15 failed and the rest passed. No undefined though, just mismatched expected values. Can I take this as a sign that the undefined issue will be resolved in the new RC release?
Sorry, this was unclear unless you're working in the codebase all the time...
Look at the last line in the log. It should say "pass: fns should not be undefined, #322" or similar. This shows that the new test passes, and that pbkdf2 is not undefined and that the call to pbkdf2Sync() gives the proper result. So something is wrong with your app, because the Example App can run your code just fine.
Hmm, maybe is it because I'm substituting crypto with it and assigning pbkdf2Sync to crypto's pbkdf2? But it's still weird that it works for v0.6.1 but breaks on the latest RC. I'll try again later in the week as it's not an urgent thing right now, it's just halted our Expo 51 update.
Any update here? Maybe look at our crypto polyfill code and use that or duplicate it?
Upgrading to the latest version fixes this. Thanks. Sorry for the late response