Set --git-dir and --work-tree explicitly to prevent Git from finding
unrelated repositories for source directories without version information
(for example in the OpenWrt build system, where version information of
the OpenWrt repo was returned instead).
By reserving encrypt_headroom bytes in the methods' decrypt functions,
realignment can be avoided for all methods except for null.
We must be careful to subtract what is pulled from the buffer
afterwards, so no oversized buffer is allocated that might fail the
max_buffer check.
A decrypted packet may be aligned correctly, but have too little headroom
to be encrypted using a different method. This led to an assertion
failure, crashing fastd.
Also move the realignment to the receive path, so it is only checked for
forwarded packets.
Misaligned buffers come from the null method, as it uses a 1-byte header
rather than (16*n+8)-byte like all other methods. When such a buffer enters
the transmit path again through fastd's forward feature, it will violate
the fastd_block128_t alignment (when there are other sessions that do
not use the null method).
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Consider the optimized x86 implementations before the generic ones, so
the optimized versions can actually get selected.
Fixes: c095ce9b4d ("build: switch to Meson build system")
The variable gains an additional meaning: In addition to the tailroom
needed in the source buffer for decryption, is also refers to the
tailroom in the destination buffer for encryption.
With a very small MTU and a great number of configured methods, the
receive buffer may be too small for a handshake packet. Always allocate
receive buffers of at least 1232 bytes, even with smaller MTU.
We also check that we never allocate a buffer for a bigger handshakes
and abort otherwise. This could be turned into a soft error in the
future, but so far we have a nice marging until we hit that number
(maximum handshake with all methods is ~640 bytes).