RustCrypto / hashes

Collection of cryptographic hash functions written in pure Rust
1.82k stars 247 forks source link

blake2: add Cargo feature to optimize for code size. #440

Closed Dirbaio closed 1 year ago

Dirbaio commented 1 year ago

The implementation uses some inline(always) to force inline the round and quarter_round functions for performance. This PR adds an opt-in Cargo feature to disable them, to allow optimizing for size instead.

Building for thumbv6m-none-eabi:

This saves 3.4kb of code size, which is 60%.

I'm trying to use blake2 on a microcontroller with 32kb of Flash memory (where the code is stored), so saving 3.4kb is quite substantial.

newpavlov commented 1 year ago

Thank you! I will release it shortly.