Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix concatkdf failures on big endian architectures (cisco#78)
Several of the elements used to compute the digest in ECDH-ES key agreement computation are represented in binary form as a 32-bit integer length followed by that number of octets. The 32-bit length integer is represented in big endian format (the 8 most significant bits are in the first octet.). The conversion to a 4 byte big endian integer was being computed in a manner that only worked on little endian architectures. The function htonl() returns a 32-bit integer whose octet sequence given the address of the integer is big endian. There is no need for any further manipulation. The existing code used bit shifting on a 32-bit value. In C bit shifting is endian agnostic for multi-octet values, a right shift moves most significant bits toward least significant bits. The result of a bit shift of a multi-octet value on either big or little archictures will always be the same provided you "view" it as the same data type (e.g. 32-bit integer). But indexing the octets of that mulit-octet value will be different depending on endianness, hence the assembled octets differed depending on endianness. Issue: cisco#77 Signed-off-by: John Dennis <[email protected]>
- Loading branch information