Commit Graph

66 Commits

Author SHA1 Message Date
Yawning Angel 41fdcfeecf core/crypto/sha2: Add SHA-512/256 2023-11-17 19:31:51 +09:00
Yawning Angel 70ba4b5321 core/crypto: Add more assertions to the low level API
Assertions here are "fine" and it matches what the code that has the
checks in init/update/final already does.
2023-11-17 19:31:51 +09:00
Yawning Angel 71da3ef925 core/crypto/sha2: Fix overflow for large amounts of hashed data 2023-11-17 19:31:51 +09:00
Yawning Angel 582bd760b7 core/crypto/shake: Add a TODO comment (NFC) 2023-11-17 19:31:51 +09:00
Yawning Angel e86bb3a795 core/crypto: Change hash asserts to panics
Assertions can be disabled, but at the point where cryptographic
anything is involved, a single branch has an infinitesimally small
performance impact.

The correct thing to do is to punch the caller in the face if they do
something that is blatantly incorrect, especially in a security critical
setting.
2023-11-17 19:31:51 +09:00
Yawning Angel e3a836f93c core/crypto/sha2: Fix hash_stream_224 and hash_stream_256 2023-11-17 19:31:51 +09:00
Yawning Angel 31b42a53fc core/crypto/siphash: Fix the low-level API
The `update` and `final` routines were written with the assumption that
update will only be called once, and that the underlying data does not
change between the calls.
2023-11-17 19:31:51 +09:00
Yawning Angel b71d3c739a core/crypto/sm3: Cleanups
- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
2023-11-17 19:31:50 +09:00
Yawning Angel a162b51588 core/crypto/siphash: Cleanups
- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
- Minor optimization
2023-11-17 16:53:29 +09:00
Yawning Angel 7c1119f217 core/crypto/_sha3: Cleanups
- Use `math/bits`
2023-11-17 16:53:29 +09:00
Yawning Angel b0397581db core/crypto/sha2: Cleanups
- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
2023-11-17 16:53:29 +09:00
Yawning Angel c7dc1220b3 core/crypto/sha1: Cleanups
- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
2023-11-17 16:53:29 +09:00
Yawning Angel d16acdc89c core/crypto/md5: Cleanups
- Use `encoding/endian`
- Use `math/bits`
- Add `@(private)` annotations to internals
2023-11-17 16:53:29 +09:00
Yawning Angel 1279ebe948 core/crypto/poly1305: Cleanups
- Use `encoding/endian`
2023-11-17 16:53:29 +09:00
Yawning Angel aa5a95a4d1 core/crypto/chacha20poly1305: Cleanups
- Use `encoding/endian`
2023-11-17 16:53:29 +09:00
Yawning Angel fa1cb28c8f core/crypto/chacha20: Cleanups
- Use `encoding/endian`
- Use `math/bits`
2023-11-17 16:53:29 +09:00
Yawning Angel 3902273d68 core/crypto/_blake2: Cleanups
- Use `encoding/endian`
- Add `@(private)` annotations to internals
- Add some descriptive comments in the unrolled compression functions
2023-11-17 16:53:29 +09:00
Yawning Angel 811132ccbd core/crypto/sm3: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel 391b3090c9 core/crypto/siphash: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel d50380709d core/crypto/sha3: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel 14a46c6d5e core/crypto/sha2: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel b4e3da84c5 core/crypto/sha1: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel 9d627e453a core/crypto/md5: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
Yawning Angel d6e0e5d3f6 core/crypto/blake2: odinfmt (NFC) 2023-11-17 16:53:29 +09:00
gingerBill eb261f5b28 Merge branch 'master' into new-sys-unix 2023-10-31 12:16:25 +00:00
Damian Tarnawski 49da19e013 Replace Math.random with crypto.getRandomValues for _system_number 2023-10-27 12:06:35 +02:00
flysand7 4d65b1ab9c Implement new sys/unix package 2023-10-27 10:51:21 +11:00
Damian Tarnawski 11a2b2a942 Add system_random and random_bytes for js target 2023-10-27 00:05:38 +02:00
gingerBill 4c22982732 Rename files to not start with _ 2023-09-26 13:15:21 +01:00
gingerBill 9ee4b76cd9 Just make the io.Reader etc aliases 2023-06-08 16:38:57 +01:00
gingerBill 3f6775e29b Update to new io interface 2023-06-08 16:35:24 +01:00
Yawning Angel 7fc2081543 core/crypto: Add private attributes for internals
These constants and internal routines are not intended for use outside
the actual implementations themselves.
2023-04-08 10:15:00 +09:00
Yawning Angel b8c2b0105b core/crypto: Disable optimization for the ct byte compare
Hedge against the possibility of a compiler getting clever enough to
optimize this pattern as well.
2023-04-08 10:11:04 +09:00
Yawning Angel d72db2698b core/crypto/_fiat: Hedge against LLVM cleverness
Recent LLVM is getting smart to the point where the optimizer can change
a traditional constant-time conditional swap into a pointer swap.

Ensure that this does not happen by force-disabling optimization.
Additionally, disable inlining the relevant routines such that manual
inspection in optimized builds is still reasonably easy to do.
2023-04-08 09:57:47 +09:00
Lucas Perlind c59ad24856 Make tests scripts error if a test fails
Additionally fixes tests that were found broken because
of this.
2023-04-03 16:49:14 +10:00
Colin Davidson edd78ae129 cleanup of os/linux 2023-02-28 01:17:43 -08:00
cui fliter dc8b7a0eb8 fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-08-05 20:10:20 +08:00
zhibog 0e91e63043 Fix issue 1761. Added the test vector to the core and vendor tests 2022-05-04 22:13:50 +02:00
Jeroen van Rijn 63331ef731 Revert "Merge pull request #1702 from Kelimion/filename_generation"
This reverts commit a40a53b104, reversing
changes made to 5422a3b17e.
2022-04-24 19:53:36 +02:00
Jeroen van Rijn 3d2856db31 Update tests to use new filename generation code. 2022-04-24 14:19:25 +02:00
Jeroen van Rijn 26ffec845b [crypto] Remove unused mem import for siphash. 2022-03-08 19:38:36 +01:00
zhibog 3b4199a669 Added rand_bytes for Windows in core:crypto 2022-03-02 21:22:56 +01:00
Sébastien Marie 5676c9e7eb initial OpenBSD support 2022-02-25 08:49:25 +00:00
zhibog b6dc253d8b Add generic procedure for default SipHash 2-4 2022-02-22 20:02:34 +01:00
zhibog e7be9493ba Added SipHash + tests and fixed remaining semicolons in vendor/botan 2022-02-22 19:56:07 +01:00
gingerBill f5697dd7f2 Merge branch 'master' into odin-global-constants-as-enums 2022-02-15 15:47:24 +00:00
gingerBill 1bf8328606 Strip unneeded semicolons 2022-01-25 16:40:25 +00:00
gingerBill 3d7d347192 Convert ODIN_OS and ODIN_ARCH to use enums rather than use strings 2022-01-20 19:56:05 +00:00
gingerBill f0529535e0 ODIN_ENDIAN changed to an enum constant; ODIN_ENUM_STRING is the new string version of the old constant 2022-01-15 17:53:18 +00:00
gingerBill 29ebe0c3c9 Rename architecture 386 to i386 2022-01-15 17:40:00 +00:00