Skip to content
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

Migrate cryptography to rust #74

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

Conversation

gargakshit
Copy link
Collaborator

@gargakshit gargakshit commented Mar 3, 2022

This comes with many benefits such as:

  • Speed. In fact, in our testing, backup times are slashed to under a
    second for 100 notes in debug mode. This can be improved by reducing
    memory copying and enabling hardware AES and SIMD in rustc flags.

  • Auditability. We use audited cryptography libraries such as ring and
    aes-gcm which provide better security.

  • Predictability. Due to the lack of a runtime, boxing and unboxing, the
    speed is predictable reducing many attacks which depend on timing
    information. The libraries are made to be run in constant-time which
    further improves security.

Todo

  • Setup build scripts to use hardware AES, SIMD and LTO when available
    • x86_64-pc-msvc-windows
    • x86_64-linux-android
    • aarch64-linux-android
    • armv7-linux-androideabi
    • x86_64-apple-ios
    • x86_64-apple-darwin
    • aarch64-apple-ios
    • aarch64-apple-ios-sim
  • Remove debug log statements I added for testing
  • Improve error checking on the rust side
  • Perform final compatibility testing (some old backups fail to restore, List<int> to Uint8List issue migration suspected). Implementations are 100% compatible. The system errors out with null folder, last_changed. Need to retain backwards compatibility with old backups @HrX03
  • Integrate cargo with build systems for
    • Windows
    • Android
    • Linux
    • iOS
    • macOS
  • Add documentation for
    • How to build
    • Algorithm and file format

Signed-off-by: Akshit Garg [email protected]

This comes with many benefits such as:

- Speed. In fact, in our testing, backup times are slashed to under a
  second for 100 notes in debug mode. This can be improved by reducing
  memory copying and enabling hardware AES and SIMD in `rustc` flags.

- Auditability. We use audited cryptography libraries such as `ring` and
  `aes-gcm` which provide better security.

- Predictability. Due to the lack of a runtime, boxing and unboxing, the
  speed is predictable reducing many attacks which depend on timing
  information. The libraries are made to be run in constant-time which
  further improves security.

Todo:

- [ ] Setup build scripts to use hardware AES and SIMD when available
- [ ] Remove debug log statements I added for testing
- [ ] Improve error checking on the rust side
- [ ] Setup build scripts for other platforms like `Linux`, `iOS`,
  `Android` and `macOS`. Current scripts only integrate with `windows`.

Signed-off-by: Akshit Garg <[email protected]>
This relies on a build script hack as `cargo-xcode` uses wrong triplets
for iOS simulator on x86_64 hosts.

Signed-off-by: Akshit Garg <[email protected]>
It still needs testing though

Signed-off-by: Akshit Garg <[email protected]>
Signed-off-by: Akshit Garg <[email protected]>
@gargakshit gargakshit self-assigned this Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant