aboutsummaryrefslogtreecommitdiff
path: root/lib/std/crypto/gimli.zig
AgeCommit message (Collapse)Author
2023-03-21Remove Gimli and Xoodoo from the standard library (#14928)Frank Denis
These are great permutations, and there's nothing wrong with them from a practical security perspective. However, both were competing in the NIST lightweight crypto competition. Gimli didn't pass the 3rd selection round, and is not much used in the wild besides Zig and libhydrogen. It will never be standardized and is unlikely to get more traction in the future. Xoodyak, that Xoodoo is the permutation of, was a finalist. It has a lot of advantages and *might* be standardized without NIST. But this is too early to tell, and too risky to commit to it in a standard library. For lightweight crypto, Ascon is the one that we know NIST will standardize and that we can safely rely on from a usage perspective. Switch to a traditional ChaCha-based CSPRNG, with an Ascon-based one as an option for constrained systems. Add a RNG benchmark by the way. Gimli and Xoodoo served us well. Their code will be maintained, but outside the standard library.
2023-03-06std: reenable vectorized code with the C backendJacob Young
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2022-11-01std: avoid vector usage with the C backendJacob Young
Vectors are not yet implemented in the C backend, so no reason to prevent code using the standard library from compiling in the meantime.
2022-03-30replace other uses of `std.meta.Vector` with `@Vector` (#11346)Meghan
2021-11-20std: add `writer` methods on all crypto.hash types (#10168)Meghan
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
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-06-21fix code broken from previous commitJacob G-W
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
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-21std: Add more error checking in hexToBytesLemonBoy
Prevent the function from turning into an endless loop that may or may not perform OOB accesses.
2021-02-10Convert inline fn to callconv(.Inline) everywhereTadeo Kondrak
2020-12-31Year++Frank Denis
2020-12-23Fix Gimli hash on 16n byte inputsMatt Sicker
2020-11-05std/crypto: don't constrain Gimli hash output to a fixed lengthFrank Denis
As documented in the comment right above the finalization function, Gimli can be used as a XOF, i.e. the output doesn't have a fixed length. So, allow it to be used that way, just like BLAKE3.
2020-11-05Now that they support vectors, use math.rot{l,r}Frank Denis
2020-11-03Make Gimli test vector look like the python implementationFrank Denis
2020-11-03Another big-endian fix for GimliFrank Denis
We read and write bytes directly from the state, but in the init function, we potentially endian-swap them. Initialize bytes in native format since we will be reading them in native format as well later. Also use the public interface in the "permute" test rather than an internal interface. The state itself is not meant to be accessed directly, even in tests.
2020-11-02Fix Gimli for big-endian targetsFrank Denis
2020-10-26std/crypto: API cleanupŽiga Željko
2020-10-17std/crypto: make the whole APIs more consistentFrank Denis
- use `PascalCase` for all types. So, AES256GCM is now Aes256Gcm. - consistently use `_length` instead of mixing `_size` and `_length` for the constants we expose - Use `minimum_key_length` when it represents an actual minimum length. Otherwise, use `key_length`. - Require output buffers (for ciphertexts, macs, hashes) to be of the right size, not at least of that size in some functions, and the exact size elsewhere. - Use a `_bits` suffix instead of `_length` when a size is represented as a number of bits to avoid confusion. - Functions returning a constant-sized slice are now defined as a slice instead of a pointer + a runtime assertion. This is the case for most hash functions. - Use `camelCase` for all functions instead of `snake_case`. No functional changes, but these are breaking API changes.
2020-10-16Vectorize GimliFrank Denis
2020-10-15std.rand: set DefaultCsprng to Gimli, and require a larger seedFrank Denis
`DefaultCsprng` is documented as a cryptographically secure RNG. While `ISAAC` is a CSPRNG, the variant we have, `ISAAC64` is not. A 64 bit seed is a bit small to satisfy that claim. We also saw it being used with the current date as a seed, that also defeats the point of a CSPRNG. Set `DefaultCsprng` to `Gimli` instead of `ISAAC64`, rename the parameter from `init_s` to `secret_seed` + add a comment to clarify what kind of seed is expected here. Instead of directly touching the internals of the Gimli implementation (which can change/be architecture-specific), add an `init()` function to the state. Our Gimli-based CSPRNG was also not backtracking resistant. Gimli is a permutation; it can be reverted. So, if the state was ever leaked, future secrets, but also all the previously generated ones could be recovered. Clear the rate after a squeeze in order to prevent this. Finally, a dumb test was added just to exercise `DefaultCsprng` since we don't use it anywhere.
2020-09-29gimli: make permute a constant, remove leading underscoreFrank Denis
2020-09-29Don't unroll the gimli permutation on release-smallFrank Denis
2020-09-29Use mem.copy() instead of manual iterationsFrank Denis
2020-09-29std/crypto: make gimli slightly fasterFrank Denis
Before: gimli-hash: 120 MiB/s gimli-aead: 130 MiB/s After: gimli-hash: 195 MiB/s gimli-aead: 208 MiB/s Also fixes in-place decryption by the way. If the input & output buffers were the same, decryption used to fail. Return on decryption error in the benchmark to detect similar issues in future AEADs even in non release-fast mode.
2020-08-26Rename `at` to `tag` in AEADsFrank Denis
2020-08-26Improve crypto benchmarksFrank Denis
- 1MiB objects on the stack doesn't play well with wasmtime. Reduce these to 512KiB so that the webassembly benchmarks can run. - Pass expected results to a blackBox() function. Without this, in release-fast mode, the compiler could detected unused return values, and would produce results that didn't make sense for siphash. - Add AEAD constructions to the benchmarks. - Inline chacha20Core() makes it 4 times faster. - benchmarkSignatures() -> benchmarkSignature() for consistency.
2020-08-21Hash functions now accept an option setFrank Denis
- This avoids having multiple `init()` functions for every combination of optional parameters - The API is consistent across all hash functions - New options can be added later without breaking existing applications. For example, this is going to come in handy if we implement parallelization for BLAKE2 and BLAKE3. - We don't have a mix of snake_case and camelCase functions any more, at least in the public crypto API Support for BLAKE2 salt and personalization (more commonly called context) parameters have been implemented by the way to illustrate this.
2020-08-20Remove the reset() function from hash functionsFrank Denis
Justification: - reset() is unnecessary; states that have to be reused can be copied - reset() is error-prone. Copying a previous state prevents forgetting struct members. - reset() forces implementation to store sensitive data (key, initial state) in memory even when they are not needed. - reset() is confusing as it has a different meaning elsewhere in Zig.
2020-08-20Breaking: sort std/crypto functions into categoriesFrank Denis
Instead of having all primitives and constructions share the same namespace, they are now organized by category and function family. Types within the same category are expected to share the exact same API.
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-08-17std/crypto: gimli.Aead.decrypt()'s ad should be constFrank Denis
2020-04-24Add mips support to standard libraryTimon Kruiper
2020-03-30std lib API deprecations for the upcoming 0.6.0 releaseAndrew Kelley
See #3811
2020-02-21remove @bytesToSlice, @sliceToBytes from std libxackus
2020-02-06std: add AEAD modes for gimlidaurnimator
2020-02-06add gimli to crypto hash benchmarkdaurnimator
2019-11-27remove type coercion from array values to referencesAndrew Kelley
* Implements #3768. This is a sweeping breaking change that requires many (trivial) edits to Zig source code. Array values no longer coerced to slices; however one may use `&` to obtain a reference to an array value, which may then be coerced to a slice. * Adds `IrInstruction::dump`, for debugging purposes. It's useful to call to inspect the instruction when debugging Zig IR. * Fixes bugs with result location semantics. See the new behavior test cases, and compile error test cases. * Fixes bugs with `@typeInfo` not properly resolving const values. * Behavior tests are passing but std lib tests are not yet. There is more work to do before merging this branch.
2019-11-08update the codebase to use `@as`Andrew Kelley
2019-09-25mv std/ lib/Andrew Kelley
that's all this commit does. further commits will fix cli flags and such. see #2221