Enable more instances of the C Abstract Struct pattern#1025
Conversation
|
[CI] Important!
|
chris-eibl
left a comment
There was a problem hiding this comment.
Most probably this is generated, but at least I marked the spots to #ifdef.
| } | ||
| Hacl_Streaming_MD_state_64; | ||
|
|
||
| typedef struct Hacl_Streaming_Blake2_Types_two_vec128_s |
There was a problem hiding this comment.
| typedef struct Hacl_Streaming_Blake2_Types_two_vec128_s | |
| #if defined(HACL_CAN_COMPILE_VEC128) | |
| typedef struct Hacl_Streaming_Blake2_Types_two_vec128_s |
| Lib_IntVector_Intrinsics_vec128 *snd; | ||
| } | ||
| Hacl_Streaming_Blake2_Types_two_vec128; | ||
|
|
There was a problem hiding this comment.
| #endif | |
| } | ||
| Hacl_Streaming_Blake2_Types_two_vec128; | ||
|
|
||
| typedef struct Hacl_Streaming_Blake2_Types_two_vec256_s |
There was a problem hiding this comment.
| typedef struct Hacl_Streaming_Blake2_Types_two_vec256_s | |
| #if defined(HACL_CAN_COMPILE_VEC256) | |
| typedef struct Hacl_Streaming_Blake2_Types_two_vec256_s |
| Lib_IntVector_Intrinsics_vec256 *snd; | ||
| } | ||
| Hacl_Streaming_Blake2_Types_two_vec256; | ||
|
|
There was a problem hiding this comment.
| #endif | |
| } | ||
| Hacl_Streaming_Blake2_Types_block_state_blake2b_32; | ||
|
|
||
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2b_256_s |
There was a problem hiding this comment.
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2b_256_s | |
| #if defined(HACL_CAN_COMPILE_VEC256) | |
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2b_256_s |
| Hacl_Streaming_Blake2_Types_two_vec256 f3; | ||
| } | ||
| Hacl_Streaming_Blake2_Types_block_state_blake2b_256; | ||
|
|
There was a problem hiding this comment.
| #endif | |
| } | ||
| Hacl_Streaming_Blake2_Types_block_state_blake2s_32; | ||
|
|
||
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2s_128_s |
There was a problem hiding this comment.
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2s_128_s | |
| #if defined(HACL_CAN_COMPILE_VEC128) | |
| typedef struct Hacl_Streaming_Blake2_Types_block_state_blake2s_128_s |
| Hacl_Streaming_Blake2_Types_two_vec128 f3; | ||
| } | ||
| Hacl_Streaming_Blake2_Types_block_state_blake2s_128; | ||
|
|
There was a problem hiding this comment.
| #endif | |
|
I think, |
|
Regarding the #ifdef: I think this doesn't work, because I still need these types in scope for Hacl_Streaming_HMAC.c to compile, since its agile type contains references to those types in any case (but with the new libintvector-shim.h that should not be a problem). Regarding moving libintvector.h to internal: sadly there are other files in HACL* that do not have such a clean abstraction barrier (see e.g. Hacl_Hash_SHA3_Simd256.h) -- that latter file is used directly by other crypto implementations in other repositories, e.g. for SIMD ML-KEM. I would like to fix that latter point, eventually. |
|
The windows CI error is a legitimate one -- I need to fix up an abstraction. |
|
Ok at this stage I feel confident that this is in the right shape for Python, modulo my comments above. I intend to merge, and fix things up as they arise during the Python integration process. Thanks @chris-eibl for the feedback. The Nix CI will come back red until I merge FStarLang/karamel#542 |
If my analysis is correct, this means, that
Hopefully, I am mistaken? |
ok I did not realize about this side-effect, thanks for pointing it out in my opinion then, the best option is to split the Hacl_Streaming_Types.h header into three files Hacl_Streaming_Types{,_Simd128,_Simd256} -- and then inclusion is more precise and does not have that unpleasant side effect what do you think? thanks again for your detailed review |
Sounds even better than my
Thanks for all your efforts! |
|
Just a thought: include files with the same name only in different paths (e.g. If this introduces churn or is not easily doable in the code generators - just forget about it :) |
|
@chris-eibl just pushed a change to avoid the issue you described with SHA1 -- the SIMD types are now in their own separate files, only included by the corresponding Blake2 modules. Can you say more about the issue about the filenames? It's changeable, but I'm curious what issues you ran into. |
Oh sorry to have given that impression. I did not run into problems. Having the same filenames just can be a problem. If it is easy to avoid the same names - that would be just a "nice to have". |
|
Let me merge this first then make a note of the filename issue -- this PR has been open for a while and I'm kind of eager to get this going to see if it would solve Python's issues. |
|
I pushed one last simplification to the file structure that had become un-necessary with my latest changes to better support forward struct decls. Now the types that contains references to libintvector live in their respective Hacl_Hash_Blake2{b256,s128} files and are properly hidden behind the public header. If you don't mind taking one last look and confirming that this is good for Python, I'll go ahead and merge. |
|
I've just had a quick look - sorry, it's late here and I am busy the next days. AFAICT, when doing some find-in-files, etc, and quickly rushing over the last commits - this looks good to me. Sorry that I don't have more time right now. Don't feel blocked - but if you're in doubt about merging, maybe you can just start off a PR in Python based on your last commit and during working on it switch over? |
|
I caught some incorrect cross-algorithm dependencies with e.g. Hacl_MAC_Poly1305 including Hacl_Blake2b_32.h, which I eventually fixed with FStarLang/karamel#550 With that, everything is now green and I feel confident about merging. Thanks everyone |
terrific news! of course very happy to do a review there, cheers |
| -add-include 'Hacl_P256:"lib_intrinsics.h"' \ | ||
| -add-include 'Hacl_Bignum:"lib_intrinsics.h"' \ | ||
| -add-include 'Hacl_Bignum_Base:"lib_intrinsics.h"' \ | ||
| -add-include 'Hacl_Bignum_Base.h:"lib_intrinsics.h"' \ |
There was a problem hiding this comment.
This bit fixes the build (currently broken on main) after FStarLang/karamel#542. I can't really comment on the rest, the high-level idea makes sense to me but I'm not too familiar with the structure of the build here.
This is with FStarLang/karamel#542