-
Notifications
You must be signed in to change notification settings - Fork 55
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
[SDK-3570] Use Web Crypto API for encrypting and decrypting #1299
[SDK-3570] Use Web Crypto API for encrypting and decrypting #1299
Commits on Jun 5, 2023
-
Remove IBufferUtils’s ComparableBuffer generic parameter
Instead, make it so that we can compare any two Bufferlike objects. When I was changing some test code (hence, not TypeScript) that made use of bufferCompare, I found myself having to think more than I would have liked about which type of objects I could pass it.
Configuration menu - View commit details
-
Copy full SHA for cbb98f1 - Browse repository at this point
Copy the full SHA cbb98f1View commit details -
Always use
instanceof
for checking if something is an ArrayBufferGives richer type information to compiler (i.e. whether the object was created with the ArrayBuffer constructor instead of whether it just conforms to the ArrayBuffer interface), which I believe a type guard can't express. I’m doing this because the the compiler seemed to consider a TypedArray to satisfy the ArrayBuffer interface: > const foo: TypedArray = new Uint8Array(); > const bar: ArrayBuffer = foo; // This compiles, weird! The effect of this was that, given an object of TypeScript type `ArrayBuffer | TypedArray`, then, after performing an `is ArrayBuffer` type guard that returned false, the compiler believed the object to be of type `never` (when in fact it could still be a TypedArray).
Configuration menu - View commit details
-
Copy full SHA for 683e88f - Browse repository at this point
Copy the full SHA 683e88fView commit details -
Replace use of TypedArray with ArrayBufferView
This is a more broad definition that means that our web Bufferlike type agrees with the web standards’ list of binary data types [1]. [1] https://www.w3.org/TR/WebIDL-1/#common-BufferSource
Configuration menu - View commit details
-
Copy full SHA for bbdf8b0 - Browse repository at this point
Copy the full SHA bbdf8b0View commit details -
Replace isArrayBufferView with direct call to ArrayBuffer.isView
There’s no need for this indirection.
Configuration menu - View commit details
-
Copy full SHA for 44e4e04 - Browse repository at this point
Copy the full SHA 44e4e04View commit details -
Remove WordArray from web Bufferlike type
Part of #1300 (removing CryptoJS functionality from web’s BufferUtils).
Configuration menu - View commit details
-
Copy full SHA for 5450e80 - Browse repository at this point
Copy the full SHA 5450e80View commit details -
Rename IBufferUtils.bufferCompare to areBuffersEqual
And make it return just a boolean instead of a number — we aren’t making use of the ordering information it provides, which I don’t really understand and don’t want to spend time trying to reproduce when I reimplement the web version of this method.
Configuration menu - View commit details
-
Copy full SHA for 79668b1 - Browse repository at this point
Copy the full SHA 79668b1View commit details -
Don’t use CryptoJS in web implementation of BufferUtils.areBuffersEqual
Now, web’s BufferUtils only uses the CryptoJS library to provide the functionality needed by our web Crypto class for: - checking if something is a WordArray - converting something to a WordArray - converting a WordArray to an ArrayBuffer We will remove this remaining CryptoJS code after implementing #1299 (removing the use of CryptoJS in our web Crypto class). Resolves #1300.
Configuration menu - View commit details
-
Copy full SHA for bbd9c9d - Browse repository at this point
Copy the full SHA bbd9c9dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 73ccbe6 - Browse repository at this point
Copy the full SHA 73ccbe6View commit details -
It’s only a WordArray on web, not in Node.
Configuration menu - View commit details
-
Copy full SHA for b8881cf - Browse repository at this point
Copy the full SHA b8881cfView commit details -
This test is executed on all platforms, but WordArray is only used on web.
Configuration menu - View commit details
-
Copy full SHA for 50af8e7 - Browse repository at this point
Copy the full SHA 50af8e7View commit details -
Convert React Native platform config to a factory function
I’m going to want to inject a BufferUtils instance in an upcoming commit.
Configuration menu - View commit details
-
Copy full SHA for fd833ab - Browse repository at this point
Copy the full SHA fd833abView commit details -
Change getRandomWordArray to getRandomArrayBuffer
Preparation for #1292 (using Web Crypto API for encrypting and decrypting).
Configuration menu - View commit details
-
Copy full SHA for 7832b44 - Browse repository at this point
Copy the full SHA 7832b44View commit details -
Make CipherParams.key an ArrayBuffer on web instead of a WordArray
Preparation for #1292 (using Web Crypto API for encrypting and decrypting).
Configuration menu - View commit details
-
Copy full SHA for e14f1bf - Browse repository at this point
Copy the full SHA e14f1bfView commit details -
Change plain/ciphertext output of web Crypto to ArrayBuffer
The web crypto code now no longer emits any WordArray objects — it only uses them internally. Preparation for #1292 (using Web Crypto API for encrypting and decrypting).
Configuration menu - View commit details
-
Copy full SHA for af675d4 - Browse repository at this point
Copy the full SHA af675d4View commit details -
Remove blockLengthWords property of web CBCCipher
All of the rest of the crypto code is built around a non-configurable block length, so this property is just misleading.
Configuration menu - View commit details
-
Copy full SHA for dd848f3 - Browse repository at this point
Copy the full SHA dd848f3View commit details -
Configuration menu - View commit details
-
Copy full SHA for fcdb9f3 - Browse repository at this point
Copy the full SHA fcdb9f3View commit details