rustpq / pqcrypto

Rust Post-Quantum cryptography
226 stars 41 forks source link

Refactor pqcrypto-templates build.rs.j2 and ffi.rs.j2 #30

Closed RW-sec closed 2 years ago

RW-sec commented 2 years ago

Hi Thom, this PR refactors the template files build.rs.j2 and ffi.rs.j2 and changes how the different variants for each scheme are specified (implementations.yaml). In the implementations.yaml file I added for each scheme an overall implementations property, this will be used by the build.rs.j2 template to build for each variant a macro. This implementations property would have been sufficient in order to build all combinations for each scheme and variant, as nearly all schemes have for each variant besides the clean implementation an avx2 or other implementation. Only Sphincs+ needs for some schemes AES support and for other schemes AVX2 support. Therefore the implementations per scheme are still in use (changed it to a list). Otherwise, as stated, only the overall implementation property would be sufficient. In general this PR will reduce the code size of the generated build.rs files and will make it easier to add new build options. Only for Sphincs+ the way it is generated has changed, as the variants, which need AES are now separated from the ones which need AVX2. After this PR the next step is to update PQClean and add support for Aarch64 builds, which were recently added to some schemes of PQClean. The functionality should be the same as before. All tests were successful. I uploaded only the relevant template changes so that it is easier to see the differences. If you want, I can add the generated files later. Also the CHANGELOG file is already updated and the versions for the crates were adjusted. Additionally some small changes to the README file were made.