Another attempt to make sha1/sha256 states memcpyable - #785
Conversation
|
ping @MarekKnapek |
|
Yes, looks good, as I mentioned previously in #742 (comment) replacing the aligned mem-loads with unaligned mem-loads should be enough. Currently, there are still aligned mem-loads present. Not when reading or storing the hash state, but when reading the constants table in SHA-256. The constants table is heavily decorated with macros forcing it to be aligned to 16 bytes. In old C, this is not possible to achieve via any standards means, only with compiler specific means. In newer C, it is possible to achieve this via standards means. So maybe the hash state could be macro decorated also? I believe that if you have a compiler capable of using intrinsics, the same compiler should be able to align a struct stricter than largest fundamental data type. I suggested this before, but it was rejected. |
The main idea:
_mm_loadu_si128instead of_mm_load_si128_mm_storeu_si128instead of_mm_store_si128However, it looks soooo simple that I am not sure whether I have overlooked something.