Commit Graph

127 Commits

Author SHA1 Message Date
Andreas T Jonsson
8ffe577a15 Added missing build tags in core 2024-04-25 09:43:54 +02:00
Andreas T Jonsson
1b15d8b453 Added build tag
Added build tag to rand_bsd.odin and fixed build warning.
2024-04-22 09:32:19 +02: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
gingerBill
703eab2f15 Merge pull request #3229 from Yawning/feature/moar-crypto
core/crypto: More improvements/additions
2024-03-06 14:49:15 +00: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
Laytan Laats
88e6980b13 fix build tags 2024-02-13 17:34:40 +01:00
Laytan Laats
0d413b8136 implement part of core foundation framework bindings for err message 2024-02-13 17:34:40 +01:00
Laytan Laats
32a4a5e601 remove darwin from bsd filename 2024-02-13 17:34:40 +01:00
Laytan Laats
91cf0826c1 use Security.framework with SecRandomCopyBytes for rand_bytes on darwin 2024-02-13 17:34:40 +01:00
Laytan Laats
3bc172c70b add crypto.rand_bytes for Darwin and FreeBSD 2024-02-13 17:34:00 +01: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
b02b85d242 core/crypto/shake: SHAKE is an XOF, not a hash 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
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
Yawning Angel
b8f9deb3d8 core/crypto/sha3: API cleanup
- sha3.Sha3_Context -> sha3.Context
2023-11-17 19:31:51 +09:00
Yawning Angel
92aad90c6b core/crypto/sha2: API cleanup
- sha2.Sha256_Context -> sha2.Context_256
- sha2.Sha512_Context -> sha2.Context_512
2023-11-17 19:31:51 +09:00
Yawning Angel
506adfb105 core/crypto/sha1: API cleanup
-sha1.Sha1_Context -> Context
2023-11-17 19:31:51 +09:00
Yawning Angel
e819eebc63 core/crypto/md5: API cleanup
- md5.Md5_Context -> md5.Context
2023-11-17 19:31:51 +09:00
Yawning Angel
841e73fcd5 core/crypto/keccak: API cleanup
- keccak.Keccak_Context -> keccak.Context
2023-11-17 19:31:51 +09:00
Yawning Angel
aa821991b8 core/crypto/blake2: API cleanup and bug fixes
- blake2s.Blake2s_Context -> blake2s.Context
- blake2b.Blake2b_Context -> blake2b.Context
- Fix the BLAKE2s low level API (context type was incorrect)
- Support the configurable output size
2023-11-17 19:31:51 +09:00
Yawning Angel
b71afdc3ee core/crypto/sha2: Refactor update/final
This is largely modeled off the SM3 versions of these routines, since
the relevant parts of the code are the same between SHA-256 and SM3,
and the alterations required to support SHA-512 are relatively simple.

The prior versions of update and the transform would leak memory, and
doing things this way also reduces the context buffer sizes by 1 block.
2023-11-17 19:31:51 +09:00
Yawning Angel
bc139ba6c6 core/crypto/util: Remove, no longer needed 2023-11-17 19:31:51 +09:00