crypto icon indicating copy to clipboard operation
crypto copied to clipboard

Add xorBlock for RISC-V architecture

Open nmeum opened this issue 3 years ago • 1 comments

The xorBlock function does not have support for RISC-V and thus software depending on crypto e.g. gocryptfs does not compile on RISC-V:

https://github.com/jacobsa/crypto/blob/e7a907a814d5c104f87bf371bd4f27a96ed310f9/cmac/hash_64bit.go#L16

Unfortunately, unaligned loads (which are used by the present xorBlock implementation) are implementation-defined behavior on RISC-V and should thus not be relied on (Section 2.6, "Load and Store Instructions" in the unprivileged ISA specification):

Loads and stores where the effective address is not naturally aligned to the referenced datatype (i.e., on a four-byte boundary for 32-bit accesses, and a two-byte boundary for 16-bit accesses) have behavior dependent on the EEI.

Maybe it makes sense to add a generic fallback implementation of the xorBlock function which does not make use of unaligned loads?

Alpine Linux downstream issue where this was originally reported: https://gitlab.alpinelinux.org/alpine/aports/-/issues/12793

nmeum avatar Jan 08 '22 13:01 nmeum

https://github.com/rfjakob/gocryptfs/issues/666

paralin avatar Jun 25 '22 21:06 paralin