pq-code-package / mlkem-native

High-assurance, high-performance ML-KEM implementation for mobile, pc, and server targets
https://pq-code-package.github.io/mlkem-native/dev/bench/
Apache License 2.0
11 stars 9 forks source link

FIPS202: Add _ctx_release() functions to support 3rd party FIPS202 implementations using dynamically allocated state #354

Closed mkannwischer closed 2 weeks ago

mkannwischer commented 2 weeks ago

Some consumers may want to provide their own Kecak implementations instead of using the ones provided by us. Such implementations may be using Keccak implementations using dynamic memory allocations, e.g., the Keccak from OpenSSL does that. In that case, we need to explicitly free the state once it is no longer needed.

This PR adds corresponding functions called _ctx_release() and calls them in the appropriate places. Since all of our Keccak implementations use a statically allocated state, the xxx_ctx_release() is implemented as a no-op here.

Naming of functions follows PQClean and liboqs.

mkannwischer commented 2 weeks ago

I'll need to look at the gen_matrix_entry CBMC proof first - that one breaks with this change.