Byte swapping
Hal Murray
hmurray at megapathdsl.net
Thu Jan 31 10:44:23 UTC 2019
The Internet is big endian. Intel is little endian. When I say byte swap
below, I'm assuming they turn into no-ops on a big endian system.
We have to byte swap integers and floats. We don't swap arrays of bytes --
text or binary blobs like cookies.
On transmit, we have to do the byte swapping before the
authentication/encryption.
On receive, we have to do the authentication/decryption before the byte
swapping.
The RefID is the only ugly case I know about. If you define it as a string,
we don't swap it near the wire but we have to swap IP Addresses (integers) as
we store into that slot or load from it. If you define it as an integer, we
swap it near the wire, you can load/store IP Addresses directly, but you have
to swap text when you load/store them.
Crypto gets interesting. I think what's going on is that the implementation
has to understand byte swapping. If the RFC for the algorithm is described in
bytes, the obvious implementation just works. If the algorithm is described
in words but the API uses bytes, then the implementation has to think in byte
swapped terms. For example, if the algorithm is xor data words with
0x11223344, the actual implementation would xor with byte-swap(0x11223344).
---------
I think a cleaned up version of the above should be captured someplace --
after people check it.
--
These are my opinions. I hate spam.
More information about the devel
mailing list