Skip to content

Commit

Permalink
std.crypto.hash.sha2: cleanup add add more docs (ziglang#19744)
Browse files Browse the repository at this point in the history
* std.crypto.hash.sha2: generalize sha512 truncation

Replace `Sha512224`, `Sha512256`, and `Sha512T224` with
`fn Sha512Truncated(digest_bits: comptime_int)`.

This required refactoring `Sha2x64(comptime params)` to
`Sha2x64(comptime iv: [8]u64, digest_bits: comptime_int)`
for user-specified `digest_bits`.

I left ziglang#19697 alone but added a compile-time check that digest_bits is
divisible by 8.

Remove docs which restate type name. Add module docs and reference where
IVs come from.

* std.crypto.sha2: make Sha512_224 and Sha512_256 pub

* make generic type implementation detail, add comments

* fix iv

* address @jedisct1 feedback

* fix typo

* renaming

* add truncation clarifying comment and Sha259T192 tests
  • Loading branch information
clickingbuttons committed Apr 28, 2024
1 parent 25f1526 commit 8a36a1f
Showing 1 changed file with 238 additions and 283 deletions.
Loading

0 comments on commit 8a36a1f

Please sign in to comment.