aboutsummaryrefslogtreecommitdiff
path: root/lib/std/crypto/bcrypt.zig
AgeCommit message (Collapse)Author
2025-02-19crypto.pwhash.bcrypt: make silently_truncate_password a member of Params ↵Frank Denis
(#22792) * bcrypt: make silently_truncate_password a member of Params This removes the need for having both `bcrypt()` and `bcryptWithTruncation()` in the public API. And whether truncation happens or not becomes even more explicit. * Update crypto benchmark
2024-11-22std.crypto.bcrypt: implement the actual OpenSSH KDF (#22027)Frank Denis
They way OpenSSH does key derivation to protect keys using a password is not the standard PBKDF2, but something funky, picking key material non-linearly.
2024-08-09std.crypto: better names for everything in utilsAndrew Kelley
std.crypto has quite a few instances of breaking naming conventions. This is the beginning of an effort to address that. Deprecates `std.crypto.utils`.
2024-07-23Fix compilation issues in crypto.bccrypt and poly1305 (#20756)Frank Denis
2024-07-07std.crypto.pwhash: Add recommended parameters (#20527)Shun Sakai
These parameters according to the OWASP cheat sheet.
2023-11-19lib: correct unnecessary uses of 'var'mlugg
2023-11-03x86_64: fix std test failuresJacob Young
2023-10-31std.builtin.Endian: make the tags lower caseAndrew Kelley
Let's take this breaking change opportunity to fix the style of this enum.
2023-10-31mem: fix ub in writeIntJacob Young
Use inline to vastly simplify the exposed API. This allows a comptime-known endian parameter to be propogated, making extra functions for a specific endianness completely unnecessary.
2023-10-22Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""Jacob Young
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"Andrew Kelley
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727. This caused a CI failure when it landed in master branch due to a 128-bit `@byteSwap` in std.mem.
2023-10-21x86_64: fix bugs and disable erroring testsJacob Young
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-06crypto.bcrypt: allow very large passwords to be pre-hashed (#15955)Frank Denis
crypto.bcrypt: allow very large passwords to be pre-hashed bcrypt has a slightly annoying limitation: passwords are limited to 72 characters. In the original implementation, additional characters are silently ignored. When they care, applications adopt different strategies to work around this, in incompatible ways. Ideally, large passwords should be pre-hashed using a hash function that hinders GPU attackers, and the hashed function should not be deterministic in order to defeat shucking attacks. This change improves the developer experience by adding a very explicit `silently_truncate_password` option, that can be set to `false` in order to do that automatically, and consistently across Zig applications. By default, passwords are still truncated, so this is not a breaking change. Add some inline documentation for our beloved autodoc by the way.
2023-04-28update codebase to use `@memset` and `@memcpy`Andrew Kelley
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2022-11-14crypto.bcrypt: fix massive speed regression when using stage2 (#13518)Frank Denis
state: State -> state: *const State Suggested by @nektro Fixes #13510
2022-11-03std.crypto.pwhash.bcrypt: inline the Feistel network function (#13416)Frank Denis
std/crypto/benchmark.zig results: * Intel i5 before: 3.144 s/ops after: 1.922 s/ops * Apple M1 before: 2.067 s/ops after: 1.373 s/ops
2022-10-25crypto/bcrypt: don't reimplement base64, just use a custom alphabetFrank Denis
Now that std.base64 supports everything bcrypt needs to encode its parameters, we don't need to include another implementation.
2022-06-20std.crypto: fix invalid pass by valueVeikka Tuominen
2022-06-12std: disable failing tests, add zig2 build test-std to CIVeikka Tuominen
2022-01-28std: break up some long linesAndrew Kelley
This makes packaging Zig for Debian slightly easier since it will no longer trigger a Lintian warning for long lines.
2021-12-27Bcrypt pbkdf (#10331)daurnimator
* Make bcrypt State struct public This is useful to implement the various protocols outside of the standard library * Implement bcrypt pbkdf This variant is used in e.g. SSH The OpenBSD implementation was used as a reference
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-24add scrypt kdf (#9577)lucky
add phc encoding parser add password hash functions to benchmark change bcrypt to be consistent with scrypt Co-authored-by: lucky <>
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-04-20std/crypto: use finer-grained error sets in function signatures (#8558)Frank Denis
std/crypto: use finer-grained error sets in function signatures Returning the `crypto.Error` error set for all crypto operations was very convenient to ensure that errors were used consistently, and to avoid having multiple error names for the same thing. The flipside is that callers were forced to always handle all possible errors, even those that could never be returned by a function. This PR makes all functions return union sets of the actual errors they can return. The error sets themselves are all limited to a single error. Larger sets are useful for platform-specific APIs, but we don't have any of these in `std/crypto`, and I couldn't find any meaningful way to build larger sets.
2021-03-14Use a unified error set for std/crypto/*Frank Denis
This ensures that errors are used consistently across all operations.
2021-02-24zig fmt the std libAndrew Kelley
2021-01-02std: Use {s} instead of {} when printing stringsLemonBoy
2020-12-31Year++Frank Denis
2020-12-18std: introduce a thread-local CSPRNG for general useAndrew Kelley
std.crypto.random * cross platform, even freestanding * can't fail. on initialization for some systems requires calling os.getrandom(), in which case there are rare but theoretically possible errors. The code panics in these cases, however the application may choose to override the default seed function and then handle the failure another way. * thread-safe * supports the full Random interface * cryptographically secure * no syscall required to initialize on Linux (AT_RANDOM) * calls arc4random on systems that support it `std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`. I moved some of the Random implementations into their own files in the interest of organization. stage2 no longer requires passing a RNG; instead it uses this API. Closes #6704
2020-11-07Add mem.timingSafeEql() for constant-time array comparisonFrank Denis
This is a trivial implementation that just does a or[xor] loop. However, this pattern is used by virtually all crypto libraries and in practice, even without assembly barriers, LLVM never turns it into code with conditional jumps, even if one of the parameters is constant. This has been verified to still be the case with LLVM 11.0.0.
2020-10-26std/*: add missing MIT license headersFrank Denis
2020-10-25std/crypto: add the bcrypt password hashing functionFrank Denis
The bcrypt function intentionally requires quite a lot of CPU cycles to complete. In addition to that, not having its full state constantly in the CPU L1 cache causes a massive performance drop. These properties slow down brute-force attacks against low-entropy inputs (typically passwords), and GPU-based attacks get little to no advantages over CPUs.