aboutsummaryrefslogtreecommitdiff
path: root/src/crypto.rs
AgeCommit message (Collapse)Author
2022-11-13Remove get_random_64()Samuel Tardieu
Its uses are replaced by get_randm_bytes() or encode_random_bytes().
2022-11-11Use constant size generic parameter for random bytes generationSamuel Tardieu
All uses of `get_random()` were in the form of: `&get_random(vec![0u8; SIZE])` with `SIZE` being a constant. Building a `Vec` is unnecessary for two reasons. First, it uses a very short-lived dynamic memory allocation. Second, a `Vec` is a resizable object, which is useless in those context when random data have a fixed size and will only be read. `get_random_bytes()` takes a constant as a generic parameter and returns an array with the requested number of random bytes. Stack safety analysis: the random bytes will be allocated on the caller stack for a very short time (until the encoding function has been called on the data). In some cases, the random bytes take less room than the `Vec` did (a `Vec` is 24 bytes on a 64 bit computer). The maximum used size is 180 bytes, which makes it for 0.008% of the default stack size for a Rust thread (2MiB), so this is a non-issue. Also, most of the uses of those random bytes are to encode them using an `Encoding`. The function `crypto::encode_random_bytes()` generates random bytes and encode them with the provided `Encoding`, leading to code deduplication. `generate_id()` has also been converted to use a constant generic parameter as well since the length of the requested String is always a constant.
2022-01-24Increase length limit for email token generationJeremy Lin
The current limit of 19 is an artifact of the implementation, which can be easily rewritten in terms of a more general string generation function. The new limit is 255 (max value of a `u8`); using a larger type would probably be overkill.
2022-01-21Add support for API keysJeremy Lin
This is mainly useful for CLI-based login automation.
2021-05-25Rework file ID generationJeremy Lin
2021-05-25Add support for v2 attachment upload APIsJeremy Lin
Upstream PR: https://github.com/bitwarden/server/pull/1229
2021-04-06Modify rustfmt fileJake Howard
2021-01-31Updated dependencies and small mail fixesBlackDex
- Updated rust nightly - Updated depenencies - Removed unicode support for regex (less dependencies) - Fixed dependency and nightly changes/deprications - Some mail changes for less spam point triggering
2020-08-22Generate tokens more simply and uniformlyJeremy Lin
2020-07-14Removed try_trait and some formatting, particularly around importsDaniel García
2020-03-16Updated ringBlackDex
Some small changes to match the updated ring package.
2019-12-27FormattingDaniel García
2019-11-24Implement change-email, email-verification, account-recovery, and welcome ↵tomuta
notifications
2019-05-11Update ring to 0.14, jwt to 6.0, and u2fDaniel García
2019-04-26FormattingDaniel García
2019-04-11Update dependencies and fix some warningsDaniel García
2019-04-05Implement user duo, initial versionDaniel García
TODO: - At the moment each user needs to configure a DUO application and input the API keys, we need to check if multiple users can register with the same keys correctly and if so we could implement a global setting. - Sometimes the Duo frame doesn't load correctly, but canceling, reloading the page and logging in again seems to fix it for me.
2019-02-11Implement constant time equal check for admin, 2fa recover and 2fa remember ↵Daniel García
tokens
2018-12-30Start using rustfmt and some style changes to make some lines shorterDaniel García
2018-02-23Fixed cipher import, created missing data structs instead of using generic ↵Daniel García
Value, and fixed some warnings
2018-02-10First working versionDaniel García