zig/lib/std/crypto
Ryan Liptak bbd13ab961 rescanMac: Avoid overallocating/overreading by millions of bytes
readAtLeast is greedy and will read the entire length of the buffer if it can. However, reading past the end of the cert in this case is useless, so reading the full length of the buffer just puts an increasingly large (due to the growth algorithm of ArrayList) collection of wasted bytes after each cert in cb.bytes.

In practical terms, this ends up saving potentially millions of bytes of wasted reads/allocations. In my testing, after reading the keychain files on my machine, cb.bytes ends up with these capacities:

- Before: cb.bytes.capacity = 32720747
- After: cb.bytes.capacity = 251937

That's a decrease of 99.2%

Additionally, swaps to readNoEof since it should be an error to hit EOF without reading the full cert size.
2025-02-20 22:16:05 +01:00
..
25519 Clarify that ed25519.generateDeterministic() can be used outside tests 2025-02-20 09:01:13 +01:00
aes x86_64: fix crashes compiling the compiler and tests 2025-01-16 20:47:30 -05:00
Certificate rescanMac: Avoid overallocating/overreading by millions of bytes 2025-02-20 22:16:05 +01:00
pcurves compiler: handle eval branch quota in memoized calls 2024-08-21 01:26:55 +01:00
tls x86_64: looped instructions 2025-01-16 20:42:08 -05:00
aegis.zig crypto.auth.Aegis128X*Mac: properly absorb tags in the first lane (#22922) 2025-02-17 17:56:09 +00:00
aes.zig std.crypto.aes: introduce AES block vectors (#22023) 2024-11-22 10:00:49 +01:00
aes_gcm.zig std.crypto: better names for everything in utils 2024-08-09 19:47:06 -07:00
aes_ocb.zig std.crypto: better names for everything in utils 2024-08-09 19:47:06 -07:00
argon2.zig argon2: bail out if m < 8p (#22232) 2024-12-14 19:26:55 +00:00
ascon.zig crypto.ascon: support up to 16 rounds, and update links (#21953) 2024-11-10 20:43:09 +00:00
bcrypt.zig crypto.pwhash.bcrypt: make silently_truncate_password a member of Params (#22792) 2025-02-19 22:37:51 +01:00
benchmark.zig crypto.pwhash.bcrypt: make silently_truncate_password a member of Params (#22792) 2025-02-19 22:37:51 +01:00
blake2.zig std: update eval branch quotas after bdbc485 2024-08-21 01:30:46 +01:00
blake3.zig x86_64: implement more shuffles 2024-02-25 11:22:10 +01:00
Certificate.zig std.crypto.tls: implement TLSv1.2 2024-11-07 20:25:26 -05:00
chacha20.zig x86_64: looped instructions 2025-01-16 20:42:08 -05:00
cmac.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
ecdsa.zig std.crypto: make the key pair API creation consistent (#21955) 2024-11-19 18:05:09 +01:00
errors.zig crypto.edwards25519: add the ability to check for group membership (#20175) 2024-06-04 10:11:05 +02:00
ff.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
ghash_polyval.zig std.crypto: better names for everything in utils 2024-08-09 19:47:06 -07:00
hash_composition.zig x86_64: implement enough to pass unicode tests 2023-10-23 22:42:18 -04:00
hkdf.zig closes #21824 (#21832) 2024-10-28 14:54:02 +00:00
hmac.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
isap.zig std.crypto: better names for everything in utils 2024-08-09 19:47:06 -07:00
keccak_p.zig crypto.keccak.State: add checks to prevent insecure transitions (#22020) 2024-11-20 11:16:09 +01:00
md5.zig Remove redundant test name prefixes now that test names are fully qualified 2024-02-26 15:18:31 -08:00
ml_kem.zig std.crypto: make the key pair API creation consistent (#21955) 2024-11-19 18:05:09 +01:00
modes.zig update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
pbkdf2.zig lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
phc_encoding.zig crypto/phc-encoding: forbid parameters named 'v' (#22569) 2025-02-06 16:37:42 +01:00
poly1305.zig std: avoid field/decl name conflicts 2024-08-29 20:39:11 +01:00
salsa20.zig std.crypto: make the key pair API creation consistent (#21955) 2024-11-19 18:05:09 +01:00
scrypt.zig std.crypto.pwhash: Add recommended parameters (#20527) 2024-07-07 20:18:33 +00:00
sha1.zig std.builtin.Endian: make the tags lower case 2023-10-31 21:37:35 -04:00
sha2.zig std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
sha3.zig closes #21824 (#21832) 2024-10-28 14:54:02 +00:00
siphash.zig std.builtin.Endian: make the tags lower case 2023-10-31 21:37:35 -04:00
test.zig update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
timing_safe.zig std.crypto: add the ability to explicitly tag a value as secret (#19907) 2025-02-20 12:32:37 +01:00
tlcsprng.zig adjust runtime page size APIs 2025-02-06 14:23:23 -08:00
tls.zig std.crypto.tls: advertise all supported signature algorithms 2024-11-07 20:25:26 -05:00