Lines Matching refs:token

61 hidl_vec<uint8_t> authToken2HidlVec(const HardwareAuthToken& token) {  in authToken2HidlVec()  argument
62 static_assert(1 /* version size */ + sizeof(token.challenge) + sizeof(token.userId) + in authToken2HidlVec()
63 sizeof(token.authenticatorId) + sizeof(token.authenticatorType) + in authToken2HidlVec()
64 sizeof(token.timestamp) + kHmacSize == in authToken2HidlVec()
72 pos = copy_bytes_to_iterator(token.challenge, pos); in authToken2HidlVec()
73 pos = copy_bytes_to_iterator(token.userId, pos); in authToken2HidlVec()
74 pos = copy_bytes_to_iterator(token.authenticatorId, pos); in authToken2HidlVec()
75 auto auth_type = htonl(static_cast<uint32_t>(token.authenticatorType)); in authToken2HidlVec()
77 auto timestamp = htonq(token.timestamp); in authToken2HidlVec()
79 if (token.mac.size() != kHmacSize) { in authToken2HidlVec()
82 std::copy(token.mac.begin(), token.mac.end(), pos); in authToken2HidlVec()
89 HardwareAuthToken token; in hidlVec2AuthToken() local
90 static_assert(1 /* version size */ + sizeof(token.challenge) + sizeof(token.userId) + in hidlVec2AuthToken()
91 sizeof(token.authenticatorId) + sizeof(token.authenticatorType) + in hidlVec2AuthToken()
92 sizeof(token.timestamp) + kHmacSize == in hidlVec2AuthToken()
100 pos = copy_bytes_from_iterator(&token.challenge, pos); in hidlVec2AuthToken()
101 pos = copy_bytes_from_iterator(&token.userId, pos); in hidlVec2AuthToken()
102 pos = copy_bytes_from_iterator(&token.authenticatorId, pos); in hidlVec2AuthToken()
103 pos = copy_bytes_from_iterator(&token.authenticatorType, pos); in hidlVec2AuthToken()
104 token.authenticatorType = static_cast<HardwareAuthenticatorType>( in hidlVec2AuthToken()
105 ntohl(static_cast<uint32_t>(token.authenticatorType))); in hidlVec2AuthToken()
106 pos = copy_bytes_from_iterator(&token.timestamp, pos); in hidlVec2AuthToken()
107 token.timestamp = ntohq(token.timestamp); in hidlVec2AuthToken()
108 token.mac.resize(kHmacSize); in hidlVec2AuthToken()
109 std::copy(pos, pos + kHmacSize, token.mac.data()); in hidlVec2AuthToken()
111 return token; in hidlVec2AuthToken()
146 std::optional<std::vector<uint8_t>> serializeVerificationToken(const VerificationToken& token) { in serializeVerificationToken() argument
147 if (token.parametersVerified.size() > 0) { in serializeVerificationToken()
151 if (!(token.mac.size() == 0 || token.mac.size() == 32)) { in serializeVerificationToken()
152 LOG(ERROR) << "Unexpected MAC size " << token.mac.size() << ", expected 0 or 32"; in serializeVerificationToken()
156 appendUint64(serializedToken, token.challenge); in serializeVerificationToken()
157 appendUint64(serializedToken, token.timestamp); in serializeVerificationToken()
158 appendUint32(serializedToken, uint32_t(token.securityLevel)); in serializeVerificationToken()
159 appendUint32(serializedToken, token.mac.size()); in serializeVerificationToken()
160 serializedToken.insert(serializedToken.end(), token.mac.begin(), token.mac.end()); in serializeVerificationToken()
171 VerificationToken token; in deserializeVerificationToken() local
172 token.challenge = extractUint64(serializedToken, 0); in deserializeVerificationToken()
173 token.timestamp = extractUint64(serializedToken, 8); in deserializeVerificationToken()
174 token.securityLevel = SecurityLevel(extractUint32(serializedToken, 16)); in deserializeVerificationToken()
183 token.mac = std::vector<uint8_t>(serializedToken.begin() + 24, serializedToken.end()); in deserializeVerificationToken()
185 return token; in deserializeVerificationToken()