Yawning Angel
38665431dd
core/crypto/_aes/ct64: Disable bounds checking
2025-03-23 19:17:18 +09:00
Yawning Angel
2f301e46dc
core/crypto: Switch to using ensure
2025-03-23 19:14:33 +09:00
Yawning Angel
dc94452fb9
core/crypto/blake2: Add the ability to easily alter digest size
2025-03-23 19:14:33 +09:00
Yawning Angel
93951ac72a
core/crypto/sha2: Clean up the portable code slightly
2025-03-23 19:14:33 +09:00
Yawning Angel
982ab11aa1
core/crypto/sha2: Use hardware SHA224/256 when available (AMD64)
2025-03-23 19:14:33 +09:00
Yawning Angel
f3f5fbd373
test/benchmarks/crypto: Improve benchmarks
...
- Use text/table for results
- Add more benchmarks
2025-03-23 19:14:33 +09:00
Yawning Angel
b220df60b8
core:crypto/deoxysii: Initial import
2025-03-23 19:14:33 +09:00
Yawning Angel
c2786a6dd5
core/crypto/aegis: Initial import
2025-03-23 19:14:33 +09:00
Yawning Angel
9fdcc4e39a
core/crypto/x448: Initial import
2025-03-23 19:14:33 +09:00
Yawning Angel
bb395aeb41
core/crypto: Add rodata annotations (NFC)
2025-03-23 19:14:33 +09:00
Yawning Angel
50d40c2a26
core/crypto/chacha20poly1305: Add missing assertions
2025-03-23 19:14:33 +09:00
Yawning Angel
6e8710fce4
core/crypto/chacha20: Misc Simd128 improvements
...
- Detect the RISC-V `v` profile
- Don't bother trying to process 4 blocks at a time if emulated
2025-03-23 19:14:33 +09:00
Yawning Angel
e4e76f27f6
core/crypto: Use panic_contextless instead of intrinsics.trap
2025-03-23 19:14:33 +09:00
Yawning Angel
4c28f6d170
core/crypto/_aes/hw_intel: Fix comment (NFC)
2025-03-23 19:14:33 +09:00
Yawning Angel
3a5440e4ed
base/runtime: Add ensure and ensure_contextless
...
This provides an equivalent to `assert` and `assert_contextless` that
are always evaluated, ignoring `ODIN_DISABLE_ASSERT`, which is useful
for enforcing API contracts or "asserting" on conditionals with
side-effects.
2024-12-25 00:08:09 +09:00
Yawning Angel and flysand7
111f10cbbf
src/big_int.cpp: Use square-multiply for exponentiation
...
For utterly unrealistic constant sizes, this still crashes on my system,
but it crashes fast due to the OOM killer, and people using rediculously
large exponents get what they deserve.
2024-12-01 11:54:51 +11:00
Yawning Angel
61795232f4
src/big_int.cpp: Use square-multiply for exponentiation
...
For utterly unrealistic constant sizes, this still crashes on my system,
but it crashes fast due to the OOM killer, and people using rediculously
large exponents get what they deserve.
2024-10-25 11:46:47 +09:00
Yawning Angel
cf7d705c1f
core/crypto/_sha3: Fix edge case in cSHAKE bytepad
...
If the domain separator happens to be exactly the rate, we would
previously incorrectly add another rate-bytes of 0s.
2024-09-30 21:50:18 +09:00
Yawning Angel
9e65e229d0
core/bytes: Tweak index_byte and last_index_byte
...
- Assume unaligned loads are cheap
- Explicilty use 256-bit or 128-bit SIMD to avoid AVX512
- Limit "vectorized" scanning to 128-bits if SIMD is emulated via SWAR
- Add a few more benchmark cases
2024-08-19 11:40:36 +09:00
Yawning Angel
7020e9b66a
core/simd: Add IS_EMULTATED so there is one place to look for potatos
2024-08-18 22:52:39 +09:00
Yawning Angel
ba1ad82c2b
core/crypto/aead: Initial import
2024-08-10 18:32:37 +09:00
Yawning Angel
38aea1f907
core/crypto/aes,chacha20poly1305: Add require_results to open
2024-08-10 18:32:37 +09:00
Yawning Angel
b381791f42
core/crypto/chacha20: Change API terminology to be consistent with AES
2024-08-10 18:32:37 +09:00
Yawning Angel
14ceb0b19d
core/crypto/chacha20poly1305: Support AEAD_XChaCha20_Poly1305
...
IETF-draft flavor (32-bit counter) though this makes no practical
difference.
2024-08-10 18:32:37 +09:00
Yawning Angel
8efc98ce90
core/crypto/chacha20poly1305: Change the interface to match GCM
2024-08-10 18:32:37 +09:00
Yawning Angel
1f3107e693
core/crypto/chacha20: Use 128-bit/256-bit SIMD
2024-08-10 18:32:37 +09:00
Yawning Angel
708f053fe6
core/crypto/aes: Use NIST terminology for the IV
2024-08-10 18:32:37 +09:00
Yawning Angel
ac7f44b1b8
core/crypto/aes: Slightly tweak GHASH to look less spooky
2024-08-10 18:32:37 +09:00
Yawning Angel
b1d6e4139e
core/crypto/aes: Disable bounds checking for the CTR loops
2024-08-10 18:32:37 +09:00
Yawning Angel
dfc4df9807
core/crypto/_aes/hw_intel: Use a constant for the PSHUFB indicies
2024-08-10 18:32:37 +09:00
Yawning Angel
b9293334ca
core/crypto/ed25519: Rename a member for clarity
...
This better matches the spec.
2024-08-10 18:32:37 +09:00
Yawning Angel
b68311d777
core/crypto/hash: Make the _to_buffer routines return the hash slice
...
Quality of life improvement.
2024-08-10 18:32:37 +09:00
Yawning Angel
c0f9655ec4
test/core/crypto: Minor changes to AES related tests
...
- Test against the non-standard GCM nonce length vectors
- Fix the CTR mode test to match the comment
Correctness was fine without this change.
2024-08-10 18:32:37 +09:00
Yawning Angel
33dae2e26c
core/crypto/aes: Support the full range of GCM nonce sizes
2024-07-16 01:29:43 +09:00
Yawning Angel
69026852ce
core/crypto/aes: Add Intel AES-NI support
...
This supports AES-NI + PCLMUL, and provides optimized key schedule, ECB,
CTR, and GCM. Other modes are trivial to add later if required.
2024-07-16 01:29:43 +09:00
Yawning Angel
f578994fa6
core/simd/x86: Make the AES-NI intrinsics consistent with Intel
2024-07-16 01:29:43 +09:00
Yawning Angel
1bc21c3481
core/crypto/_aes: Remove redundant sanity checks
2024-07-16 01:29:43 +09:00
Yawning Angel
c9c0b9ea7b
core/crypto: Fix/add some documentation (NFC)
2024-07-16 01:29:43 +09:00
Yawning Angel
390cd3c30d
core/simd/x86: Fix some intrinsics
...
- _mm_slli_si128 produced totally incorrect output
- _mm_storeu_si128 refered to a LLVM intrinsic that is missing
2024-07-16 01:29:43 +09:00
Yawning Angel
401877184f
tests/benchmark/crypto: Benchmark AES256-CTR
2024-07-16 01:29:43 +09:00
Yawning Angel
4815154c31
test/core/crypto: Fix a copy-paste issue in failure spew
2024-07-16 01:29:43 +09:00
Yawning Angel
0d8dadec8a
tests/core/crypto: Fix new -vet issues
2024-07-16 01:29:43 +09:00
Yawning Angel
ff13ee3281
core/crypto: Enforce aliasing restrictions
2024-07-16 01:29:43 +09:00
Yawning Angel
dcaf085bfa
core/bytes: Add alias and alias_inexactly
2024-07-16 01:29:43 +09:00
Yawning Angel
1a30d47ee8
repo: Cleanup the .gitignore to match the new test runner
2024-07-15 21:25:07 +09:00
Yawning Angel
c751e4b2eb
core/crypto/aes: Add AES implementation
2024-06-01 22:55:42 +09:00
Yawning Angel
1ade62b630
core/crypto/_aes/ct64: Add GHASH
2024-06-01 22:55:42 +09:00
Yawning Angel
cba58924a8
core/crypto/_aes: 64-bit portable implementation
2024-06-01 22:55:42 +09:00
Yawning Angel
f49575f1fb
core/simd/x86: Add the AES-NI intrinsics
2024-06-01 22:55:42 +09:00
Yawning Angel
e2fa9be7e2
core/math/rand: Use core:crypto for the system RNG
...
This removes some code duplication and expands support for the system
RNG to all targets that `core:crypto` supports.
2024-04-23 11:47:43 +09:00
Yawning Angel
a6eb64df6c
core/crypto: Add a HAS_RAND_BYTES constant
2024-04-23 11:47:43 +09:00
Yawning Angel
902e877467
repo: Add more test binaries to .gitignore
2024-04-21 21:22:05 +09:00
Yawning Angel
fa1d681e65
tests/core/crypto: Start adding comprehensive curve25519 tests
2024-04-09 14:37:59 +09:00
Yawning Angel
893c3bef9a
core/crypto/ed25519: Initial import
2024-04-09 14:37:59 +09:00
Yawning Angel
d96f8bb5c1
core/crypto/ristretto255: Initial import
2024-04-09 14:37:59 +09:00
Yawning Angel
563c527419
core/crypto/_edwards25519: Initial import
2024-04-09 14:37:59 +09:00
Yawning Angel
fec42a6d74
core/crypto/_fiat/field_scalar25519: Initial import
2024-04-09 10:23:58 +09:00
Yawning Angel
4defe88dec
core/crypto/_fiat/field_poly1305: Mark more functions contextless
2024-04-09 10:23:58 +09:00
Yawning Angel
36f3001d59
core/crypto/_fiat/field_poly1305: Use multiply to calculate the mask
2024-04-09 10:23:58 +09:00
Yawning Angel
1ce279e6a1
core/crypto/_fiat/field_curve25519: Mark more functions contextless
2024-04-09 10:23:58 +09:00
Yawning Angel
c951cbdbbc
core/crypto/_fiat: odinfmt (NFC)
2024-04-09 10:23:58 +09:00
Yawning Angel
31aba5a728
core/crypto/_fiat/field_poly1305: Move routines (NFC)
2024-04-09 10:23:58 +09:00
Yawning Angel
9a418fd27b
core/crypto/_fiat/field_curve25519: Move routines (NFC)
2024-04-09 10:23:58 +09:00
Yawning Angel
f9b9521bf0
core/crypto/_fiat/field_curve25519: Use multiply to calculate the mask
...
Largely for consistency with the generic code, either is valid with Odin
semantics, but this is easier to comprehend.
2024-04-09 10:23:58 +09:00
Yawning Angel
b155fdf8c9
core/crypto: Add has_rand_bytes
...
This allows runtime detection as to if `rand_bytes` is supported or not,
and lets us enable the test-case on all of the supported targets.
2024-04-09 10:23:58 +09:00
Yawning Angel
a43a5b053c
core/crypto: Add more documentation about assumptions (NFC)
2024-04-09 10:23:58 +09:00
Yawning Angel
a45721e9ad
core/crypto/poly1305: The final addition is NOT mod p
2024-04-05 23:45:41 +09:00
Yawning Angel
c044e295ce
vendor/botan: Remove
...
This is infrequently maintained, and has been a strict subset of what is
available in `core:crypto` for a while. Instead of improving the
bindings, it is better to spend resources improving `core:crypto`.
2024-03-04 18:20:56 +09:00
Yawning Angel
87ab3f5dc8
tests/core/crypto: Use the tests/common boilerplate
2024-03-04 18:20:56 +09:00
Yawning Angel
fa8dd5a13b
core/crypto: Misc cleanups and documentation improvements
2024-03-04 17:50:45 +09:00
Yawning Angel
b818ebc02f
core/crypto/kmac: Initial import
2024-03-04 17:50:45 +09:00
Yawning Angel
c04a53e453
core/crypto/tuplehash: Initial import
2024-03-04 17:50:43 +09:00
Yawning Angel
15287a771f
core/crypto/shake: Support cSHAKE
2024-03-04 17:50:24 +09:00
Yawning Angel
2db31cf0d5
core/crypto/_sha3: Cleanups, prepare for cSHAKE
2024-03-04 14:51:38 +09:00
Yawning Angel
550e798c1b
core/crypto/hkdf: Initial import
2024-03-04 14:51:38 +09:00
Yawning Angel
290168f862
core/crypto/pbkdf2: Initial import
2024-03-04 14:51:38 +09:00
Yawning Angel
2f2a92866b
core/crypto/hmac: Add a clone method
2024-03-04 14:51:38 +09:00
Yawning Angel
874d6ccb60
core/container/avl: Initial import
2024-02-24 14:05:15 +09:00
Yawning Angel
db3279e7da
test/core/container: Refactor for multiple container types
2024-02-24 14:05:15 +09:00
Yawning Angel
9251e06143
tests/core: Bring the Makefile more in-sync with build.bat
2024-02-24 14:05:15 +09:00
Yawning Angel
44758f2a60
core/crypto: Stop using context.temp_allocator
...
The max digest size for the foreseeable future will be 512 bits, and the
max block size is currently 1152 bits (SHA3-224). If people add more
exotic hash algorithms without bumping the constants when required,
tests will fail.
The stream buffer will currently be 576 bytes, which is "fine" to just
stick on the stack, and is a sensible multiple of the more common block
size of 64 bytes.
2024-02-07 02:33:53 +09:00
Yawning Angel
56516ee8b2
core/crypto/poly1305: Relax the tag length check on the verify helper
2024-02-07 00:42:01 +09:00
Yawning Angel
1cc639bc93
core/crypto/hmac: Initial import
2024-02-07 00:42:01 +09:00
Yawning Angel
2357293e05
core/crypto/hash: Make the low level interface allocator-less
...
Just (ab)using reflect to victory is probably fine.
2024-02-07 00:37:18 +09:00
Yawning Angel
7a8b1669b0
core/crypto: Expose the block sizes for every hash algorithm
...
While I just went and made this private, this information is required
for keying HMAC.
2024-02-07 00:37:18 +09:00
Yawning Angel
bc160d2eb7
tests/core/crypto: Reorganize
...
All of our crypto is modern now unless exiled to the legacy sub-package,
so move the test cases for the currently un-unified algorithms into the
main test driver file, and rename the benchmark driver to reflect
reality.
2024-02-07 00:37:18 +09:00
Yawning Angel
b02b85d242
core/crypto/shake: SHAKE is an XOF, not a hash
2024-02-07 00:37:18 +09:00
Yawning Angel
1d151c4c92
tests/core/crypto: Cleanup/modernize a bit
2024-02-07 00:37:18 +09:00
Yawning Angel
899fab64d9
core/crypto: Documentation cleanups
2024-02-07 00:37:18 +09:00
Yawning Angel
00ab3beed9
core:crypto/hash: Add a generic higher level hash interface
...
There is a lot of code duplicated in convenience methods in each hash
implementation, and having a generic hash type makes implementing
higher-level constructs such as HMAC significantly easier down the road.
2024-02-07 00:37:18 +09:00
Yawning Angel
ca10fc2d47
repo: Add yet another test binary to .gitignore
2024-02-07 00:37:18 +09:00
Yawning Angel
8d7c37e384
core/simd/x86: Use the none calling convention for intrinsics
...
The LLVM intrinsics that live under `llvm.x86` are not actual functions,
so trying to invoke them as such using the platform's native C
calling convention causes incorrect types to be emitted in the IR.
Thanks to laytanl for assistance in testing.
2024-01-07 20:04:40 +09:00
Yawning Angel
cd65a15d81
src: enable_target_feature should add features, not overwrite
...
`llvm_features` being empty is the default state, and implies the
presence of certain features.
Previously if any target features were explicitly enabled by the
`enable_target_feature` attribute, they were added comma separated
to `llvm_features`.
For example: `lzcnt,popcnt,...,sse4.2,sse`
This was causing LLVM to try to target a CPU that *ONLY* has the
explicitly enabled features. This now will prefix explicitly enabled
features with a `+`, and preserve the existing `llvm_features` string
by appending to it if it is set.
2024-01-07 20:04:40 +09:00
Yawning Angel
9235e82451
core/simd/x86: Correct a target feature name
2024-01-07 20:04:40 +09:00
Yawning Angel
ecee0e2db2
repo: Add more test binaries to .gitignore
2024-01-07 20:04:40 +09:00
Yawning Angel
29c80c238d
core: Fixed build constraints
...
Multiple constraints on the same line are combined with logical OR,
while combining multiple negated constraints needs to be done with
logical AND (each constraint on a separate line).
2023-12-17 23:02:46 +09:00
Yawning Angel
9cc5cd9d40
core/crypto: Update the documentation (NFC)
2023-11-17 19:54:06 +09:00
Yawning Angel
59950bcad6
core/crypto: Exile keccak, md5 and sha1 to legacy
...
In an perfect world these would just be removed, but the world is
imperfect, and people are forced to interact/interface with things
that are broken.
2023-11-17 19:32:11 +09:00
Yawning Angel
4587a55486
core/crypto/sm3: API cleanup
...
- sm3.Sm3_Context -> sm3.Context
2023-11-17 19:32:09 +09:00
Yawning Angel
7640fb0483
core/crypto/shake: API cleanup
...
- shake.Shake_Context -> shake.Context
2023-11-17 19:31:51 +09:00