summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Bray <ncbray@google.com>2018-10-31 10:39:41 -0700
committerNick Bray <ncbray@google.com>2018-10-31 10:39:41 -0700
commit27748e24c1a1fbfb2919817333b6270ace62c16c (patch)
treee78593bde7eedd8f39dce50eba8cb3fd4a8fbb47
parent35df5144c069aae2e958af0531bc137d79034d35 (diff)
downloadgatekeeper-27748e24c1a1fbfb2919817333b6270ace62c16c.tar.gz
htonl is supposed to be defined in arpa/inet.h, not endian.h. This code compiles thanks to non-standard endian.h. Being stricter helps make it more portable. It would be possible to switch header files instead of switching functions, but htobe64 is used elsewhere in the code. There is no "network" function for 64-bit types. It seems slightly cleaner to be consistent naming things "big endian" rather than mixing terms. Bug: 110161494 Change-Id: I9b66b967c587d7c0853631d1fbb12e2e41c7d1b2
-rw-r--r--gatekeeper.cpp2
-rw-r--r--tests/gatekeeper_device_test.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/gatekeeper.cpp b/gatekeeper.cpp
index 052c4db..1d71684 100644
--- a/gatekeeper.cpp
+++ b/gatekeeper.cpp
@@ -232,7 +232,7 @@ void GateKeeper::MintAuthToken(UniquePtr<uint8_t> *auth_token, uint32_t *length,
token->challenge = challenge;
token->user_id = user_id;
token->authenticator_id = authenticator_id;
- token->authenticator_type = htonl(HW_AUTH_PASSWORD);
+ token->authenticator_type = htobe32(HW_AUTH_PASSWORD);
token->timestamp = htobe64(timestamp);
const uint8_t *auth_token_key = NULL;
diff --git a/tests/gatekeeper_device_test.cpp b/tests/gatekeeper_device_test.cpp
index 0e7ace6..f166ca8 100644
--- a/tests/gatekeeper_device_test.cpp
+++ b/tests/gatekeeper_device_test.cpp
@@ -98,7 +98,7 @@ TEST_F(GateKeeperDeviceTest, EnrollAndVerify) {
hat = reinterpret_cast<hw_auth_token_t *>(auth_token);
ASSERT_EQ(HW_AUTH_TOKEN_VERSION, hat->version);
- ASSERT_EQ(htonl(HW_AUTH_PASSWORD), hat->authenticator_type);
+ ASSERT_EQ(htobe32(HW_AUTH_PASSWORD), hat->authenticator_type);
}
TEST_F(GateKeeperDeviceTest, EnrollAndVerifyTimeout) {