roughtime.googlesource.com/roughtime.git@v0.0.0-20201210012726-dd529367052d/client.h (about) 1 /* Copyright 2016 The Roughtime Authors. 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. */ 14 15 #ifndef SECURITY_ROUGHTIME_CLIENT_H_ 16 #define SECURITY_ROUGHTIME_CLIENT_H_ 17 18 #include <string> 19 20 #include "protocol.h" 21 22 namespace roughtime { 23 24 // Creates a client time request with the supplied |nonce|. 25 std::string CreateRequest(const uint8_t nonce[kNonceLength]); 26 27 // If the supplied |response_bytes| can be parsed, sets |*out_time| and 28 // |*out_radius| and returns true. Otherwise returns false and sets 29 // |*out_error|. The response must contain a path from the supplied |nonce| 30 // and a certificate signed with a private key that matches |root_public_key|. 31 bool ParseResponse(uint64_t *out_time, uint32_t *out_radius, 32 std::string *out_error, 33 const uint8_t root_public_key[kPublicKeyLength], 34 const uint8_t *response_bytes, size_t response_len, 35 const uint8_t nonce[kNonceLength]); 36 37 } // namespace roughtime 38 39 #endif // SECURITY_ROUGHTIME_CLIENT_H_