Comments (5)
@kevlened Besides, the version you mention seems to support concurrent calls. I'm currently using isomorphic-webcrypto in a React Native project and I started to refactor a crypto dependent third party library to remove problematic Promise.all.
Yet, unless concurrent calls are forbidden (which would drastically limit user interactions) it is a lost cause.
I'll try to integrate https://github.com/microsoft/MSR-JavaScript-Crypto and test the result. If I can help, do not hesitate.
from isomorphic-webcrypto.
Cryptography is CPU-bound, so long operations will lock the thread. To get around the problem in the browser, the MSR library uses WebWorkers. React-native doesn’t support WebWorkers by default, but you may be able to patch it with a native module. Unfortunately, I don’t know any WebWorker libraries that work out-of-the-box with Expo yet.
An alternative to all this may be using an Expo WebView and proxying calls to that. That would give massively improved performance, not lock the main thread, and automatically get any Safari security updates.
from isomorphic-webcrypto.
I agree with your analysis. But I'm not concerned by the performance gain that could be achieved by externalising the computations for the main thread (yet). I'm rather interested in the 1.5 version change mentioned in https://github.com/microsoft/MSR-JavaScript-Crypto#changes-with-version-15. There, we can read:
Now allow concurrent crypto calls of the same type at the same time. Before, concurrent
crypto operations that shared code would possibly return incorrect results.
Now, for example, you could perform multiple encryptions at the same time with streaming.
As a matter of fact, currently, you might encountered issues if you try to import keys or decrypt objects concurrently. Typically, if you execute something like:
Promise.all([crypto.subtle.importKey(format, key_1, ...),... , crypto.subtle.importKey(format, key_N, ...)])
This is the kind of concurrent calls I was mentioning and how it would be a bad idea to design the application in such a way to avoid occurence of these concurrencies (the Promise.all being a simple way to produce them).
=======
That being said, your advice related to the WebView is very interesting!
I was aware of this mechanism as a way to relax the main thread charge but now, I'm thinking that a WebView could embed the whole crypto library I'm working with... but that is not the subject of the issue :-) Thanks anyway !
from isomorphic-webcrypto.
Ah. I assumed you were using Promise.all
to try to speed up the crypto operations, but you're just trying to avoid unexpected side effects if someone calls crypto methods concurrently. Let me know if you attempt a migration, I'd love to see it.
If you attempt a WebView-based polyfill, there are two caveats:
- A WebView needs to be in the root of the App component
Crypto.getRandomValues
can’t be synchronous
from isomorphic-webcrypto.
@kevlened Is there any chance you will update this library with the latest version of the MSR crypto library? I'm tryting to derive a key with the ECDH algorithm but it says: 'unsupported algorithm' whilst in the latest version, it should be supported.
Thanks in advance!
from isomorphic-webcrypto.
Related Issues (20)
- webcrypto-liner not react-native compatible HOT 1
- Unsupported algorithm error HOT 1
- Is `node-webcrypto-ossl` a dependency still? HOT 5
- `WebCrypto` is a namespace import in index.mjs; `WebCrypto.Crypto` is the constructor to be instantiated HOT 4
- RSA generatekey, unsupported algorithm HOT 20
- TypeError: global.document.addEventListener is not a function. React Native version 0.63.2 HOT 10
- Warning with react-native dependencies HOT 6
- Large react-native library being pulled in from indirect dependencies HOT 4
- React Native TypeError: Cannot convert null value to object
- Non-functional RSA-OEAP Support
- Huge dependency tree
- importKey does not support the PBKDF2 algorithm
- Update react-native-securerandom to 0.2.0
- Migrate to Expo-Modules HOT 2
- Migrate to Expo-Modules for Expo SDK 43 and newer HOT 8
- An export assignment cannot be used in a module with other exported elements. HOT 1
- React native bare app crashes because of expo-random import
- Adding standalone AES-KW support for React Native
- doesn't actually detect native modules for ios or android anymore HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isomorphic-webcrypto.