-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Move out crypto/aes
#4431
Move out crypto/aes
#4431
Conversation
9382923
to
b6ad99f
Compare
b6ad99f
to
ca95c3d
Compare
9b867d2
to
83bcbb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the right direction! A few suggestions for improvements.
src/utils/calculateKeyCheck.ts
Outdated
// string of zeroes, for calculating the key check | ||
const ZERO_STR = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | ||
|
||
/** Calculate the MAC for checking the key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Calculate the MAC for checking the key. | |
/** | |
* Calculate the MAC for checking a secret storage key. | |
* | |
* See https://spec.matrix.org/v1.11/client-server-api/#msecret_storagev1aes-hmac-sha2, steps 3 and 4. |
- Move into `src/@types`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4431 (comment) seems to have got lost.
LGTM otherwise
* Move `SecretEncryptedPayload` in `src/utils/@types` * Move `encryptAES` to a dedicated file. Moved in a utils folder. * Move `deriveKeys` to a dedicated file in order to share it * Move `decryptAES` to a dedicated file. Moved in a utils folder. * Move `calculateKeyCheck` to a dedicated file. Moved in a utils folder. * Remove AES functions in `aes.ts` and export new ones for backward compatibility * Update import to use new functions * Add `src/utils` entrypoint in `README.md` * - Rename `SecretEncryptedPayload` to `AESEncryptedSecretStoragePayload`. - Move into `src/@types` * Move `calculateKeyCheck` into `secret-storage.ts`. * Move `deriveKeys` into `src/utils/internal` folder. * - Rename `encryptAES` on `encryptAESSecretStorageItem` - Change named export by default export * - Rename `decryptAES` on `decryptAESSecretStorageItem` - Change named export by default export * Update documentation * Update `decryptAESSecretStorageItem` doc * Add lnk to spec for `calculateKeyCheck` * Fix downstream tests
182a802
to
25a34c1
Compare
Checklist
public
/exported
symbols have accurate TSDoc documentation.Task element-hq/element-web#26922
The goal of the new
src/utils
folder is to share utility functions without to have to import all the js-sdk content (ie:src/matrix.ts
). See #4339Changes:
decryptAES
andencryptAES
are moved intosrc/utils
.deriveKeys
is used only bydecryptAES
andencryptAES
. Moved intosrc/
to keep it internal.IEncryptedPayload
toAESEncryptedSecretStoragePayload
. Move it intosrc/@types/
The PR can be reviewed by commit.