✨ Add subtle.deriveKey support
What feature or enhancement are you suggesting?
I think it would be great to have support for the subtle.deriveKey function in QuickCrypto.
What Platforms whould this feature/enhancement affect?
iOS, Android
Alternatives/Workarounds
I thinking about moving a full web application built with classic html/css/js to a React Native app (and support multiple plateforms). My app uses encryption a lot and QuickCrypto seems an excellent starting point to translate my current implementation. However, I do need an alternative to crypto.subtle.deriveKey and it is not available (yet ^^) in QuickCrypto.
Additional information
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar feature requests in this repository and found none.
👍 for this, it'll be amazing to do:
crypto.subtle.deriveKey(...args);
would love this feature.
It's good to have it in react-native-quick-crypto but in the meantime, you can use deriveBits and importKey instead of deriveKey.
Based on deriveBits MDN:
This method is very similar to SubtleCrypto.deriveKey(), except that deriveKey() returns a CryptoKey object rather than an ArrayBuffer. Essentially deriveKey() is composed of deriveBits() followed by importKey().
Here is a sample code:
const derivedKey = await window.crypto.subtle.deriveKey(
{ name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' },
baseKey,
{ name: 'AES-GCM', length: 256 },
true,
['encrypt', 'decrypt']
);
can be replaced with:
const derivedBits = await quickCrypto.subtle.deriveBits(
{ name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' },
baseKey,
256
);
const derivedKey = await quickCrypto.subtle.importKey(
'raw',
derivedBits,
{ name: 'AES-GCM', length: 256 },
true,
['encrypt', 'decrypt']
);
#840, #848