This repository was archived by the owner on Jul 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Roughtime client #42
Open
sungjud
wants to merge
65
commits into
development
Choose a base branch
from
roughtime_client
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Roughtime client #42
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
80c6597
"add roughtime include flags"
c3aa9d6
"add roughtime submodule"
ad3b112
Merge branch 'mk_cpp' of github.com:GoogleCloudPlatform/iot-edge-sdk-…
6d5e216
Replacement of BoringSSL/ openSSL crypto library with mbedTLS and/or …
6b9d817
Merge branch 'bsp_migration' into esp_test
b40989b
WIP: Re-implement networking in Roughtime client to use BSP network API
a7e34a9
WIP_2: Re-implement networking in Roughtime client to use BSP network…
96483cd
Re-implement networking in Roughtime client to use BSP network API
4006b16
WIP: setting for ESP
9118568
WIP: run example running on ESP32
15bea84
WIP: Modify Networking API
e6ddc07
Add server test/ Modify BSP networking API
ab518ea
Merge 'bsp_migration' into branch
0dac9cc
modify the order of additional include flags
7e8821a
Merge branch 'bsp_migration' into esp_test
034bcbe
deleting conflitcted file of echoserver header
7890c56
delete conflicted file of echoserver header
410e015
Add roughtime submoudle
d17ded1
define iotc_crypto_key_data for roughtime client example
bb50fb4
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
0695c4a
Relace perror with iotc_debug_logger
fe00de9
print time information on example
64c9bb4
Handle with return value of getaddrinfo function
ce4696c
Error handling for iotc_bsp_io_net_select
cf42579
Revise return type & Remove system offset & Make execute with one fun…
043954d
Merge branch 'time' into roughtime_client
d209469
Replace function getting monotonic time with the one in iotc_bsp_time
acbc5ee
only include test files as gtest sources
fredrec 8b88337
update build configuration for Roughtime client
fredrec d7fcc63
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec 7b7b8dd
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec f47c86a
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
5efba0b
fix: include test utils from src/tests
fredrec 2b170e7
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec 7cdc18d
apply iotc_bsp_rng, change in roughtime & handling return value
6faeba1
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
e9cca31
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec e5d3690
expand IOTC_GTEST_SOURCES at define time
fredrec bf2c358
add IOTC_ENABLE_ROUGHTIME build flag
fredrec 9ad5552
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec 3c187a8
filter out c++ test files using IOTC_GTEST_SOURCES
fredrec 6b1b038
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec 8741ffd
merge 'bsp_migration' into 'roughtime_client'
c08752e
Merge branch 'development' into roughtime_client
ff33657
Precision of monotonic time: microseconds -> milliseconds
ef33a8b
Precision of monotonic time: microseconds -> milliseconds
2b8849a
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec 470f4a7
remove unused code
fredrec 17b951c
Set retrial time for connection
2ed88db
revert files supposedely modified by mistake
fredrec 11e8862
Refactoring
bddd718
fix: include mt-roughtime.mk in mt-config
fredrec 9fd1a5a
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec 624d7e4
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec 29fb404
rename *_test_XXX.cc to *_XXX_test.cc
fredrec 18e7d9a
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec e03fc88
Changed data type of time_data
06062f1
refactoring
7b24ac8
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec f6ebc6c
Removed duplicated error checking
a001d5c
Reorganized include lines
9888fed
initialized nonce variable
e0dd3d7
Detached socket closing part from receive_time()
b33ae71
Added unit test for invalid parameter which is nullptr
27924ce
Typo
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| [submodule "third_party/googletest"] | ||
| path = third_party/googletest | ||
| url = https://github.com/google/googletest | ||
| [submodule "third_party/roughtime"] | ||
| path = third_party/roughtime | ||
| url = https://user.git.corp.google.com/sungju/roughtime/ | ||
| [submodule "third_party/cryptoauthlib"] | ||
| path = third_party/cryptoauthlib | ||
| url = https://github.com/MicrochipTech/cryptoauthlib.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| IOTC_EXAMPLE_NAME := iotc_roughtime_client | ||
|
|
||
| include ../common/rules.mk | ||
| include ../common/targets.mk | ||
|
|
||
| include $(IOTC_CLIENT_PATH)/make/mt-config/mt-roughtime.mk | ||
|
|
||
| IOTC_FLAGS_LINKER += -lstdc++ | ||
| IOTC_FLAGS_LINKER += -L$(ROUGHTIME_DIR) -lroughtime |
28 changes: 28 additions & 0 deletions
28
examples/iotc_roughtime_client/src/iotc_roughtime_client.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #include <iotc_roughtime_client.h> | ||
|
|
||
| #include "string.h" | ||
| #include <inttypes.h> | ||
| #include <stdint.h> | ||
| #include <stdio.h> | ||
|
|
||
| #include "../../common/src/example_utils.h" | ||
|
|
||
| /* Application variables. */ | ||
| iotc_crypto_key_data_t iotc_connect_private_key_data; | ||
|
|
||
| int main() { | ||
| const char* public_key = "gD63hSj3ScS+wuOeGrubXlq35N1c5Lby/S+T7MNTjxo="; | ||
| const char* server_address = "roughtime.cloudflare.com:2002"; | ||
| iotc_roughtime_state_t state; | ||
| iotc_roughtime_timedata_t time_data; | ||
| if ((state = iotc_roughtime_getcurrenttime(public_key, server_address, | ||
| &time_data)) != IOTC_ROUGHTIME_OK) { | ||
| return state; | ||
| } | ||
|
|
||
| printf("Received reply in %" PRIu64 "ms.\n", time_data.reply_time); | ||
| printf("Current time is %" PRIu64 "ms from the epoch, ±%uμs \n", | ||
| time_data.timestamp, time_data.radius); | ||
|
|
||
| return state; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #include <iotc_time.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * @typedef iotc_bsp_io_net_state_e | ||
| * @brief Returns result of process receiving time from roughtime server. | ||
| */ | ||
| typedef enum iotc_roughtime_state_e { | ||
| IOTC_ROUGHTIME_OK = 0, | ||
| IOTC_ROUGHTIME_RECEIVE_TIME_ERROR = 1, | ||
| IOTC_ROUGHTIME_NETWORK_ERROR = 2, | ||
| IOTC_ROUGHTIME_TIMEOUT_ERROR = 3, | ||
| IOTC_ROUGHTIME_ERROR = 4, | ||
| } iotc_roughtime_state_t; | ||
|
|
||
| /** | ||
| * @typedef iotc_roughtime_timedata_s | ||
| * @brief Ties time data received from roughtime server. | ||
| */ | ||
| typedef struct iotc_roughtime_timedata_s { | ||
| /** | ||
| * reply_time - time spent on receiving current time from the server | ||
| * timestamp - current time received from the server | ||
| * radius - certainty of timestamp | ||
| */ | ||
| uint64_t reply_time; | ||
| uint64_t timestamp; | ||
| uint32_t radius; | ||
| } iotc_roughtime_timedata_t; | ||
|
|
||
| /** | ||
| * @function | ||
| * @brief Gets current time from roughtime server | ||
| * | ||
| * @param [out] time_data the struct which contains time data got from roughtime | ||
| * server. | ||
| * @param [in] name the name of server from which get current time. | ||
| * @param [in] public_key the public key for server | ||
| * @param [in] server_address the address of server from which get current time. | ||
| * @return | ||
| * - iotc_roughtime_state t - the state of error caused while creating socket | ||
| * and receiving time from roughtime server. | ||
| */ | ||
| iotc_roughtime_state_t | ||
| iotc_roughtime_getcurrenttime(const char* public_key, | ||
| const char* server_address, | ||
| iotc_roughtime_timedata_t* time_data); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Copyright 2018-2019 Google LLC | ||
| # | ||
| # This is part of the Google Cloud IoT Device SDK for Embedded C, | ||
| # it is licensed under the BSD 3-Clause license; you may not use this file | ||
| # except in compliance with the License. | ||
| # | ||
| # You may obtain a copy of the License at: | ||
| # https://opensource.org/licenses/BSD-3-Clause | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Build configuration for Roughtime client support | ||
|
|
||
| ifdef IOTC_ENABLE_ROUGHTIME | ||
|
|
||
| ifneq ($(IOTC_BSP_TLS), wolfssl) | ||
| $(error Roughtime feature needs wolfssl as crypto BSP; was IOTC_BSP_TLS="$(IOTC_BSP_TLS)") | ||
| endif | ||
|
|
||
| LIBIOTC ?= $(CURDIR)/../.. | ||
|
|
||
| ROUGHTIME_DIR := $(LIBIOTC)/third_party/roughtime | ||
| ROUGHTIME_FAKE_INCLUDE_DIR := $(ROUGHTIME_DIR)/roughtime | ||
| ROUGHTIME_LIBRARY := $(ROUGHTIME_DIR)/libroughtime.a | ||
|
|
||
| ROUGHTIME_SOURCES := $(ROUGHTIME_DIR)/client.cc \ | ||
| $(ROUGHTIME_DIR)/protocol.cc | ||
|
|
||
| ROUGHTIME_OBJS := $(filter-out $(ROUGHTIME_SOURCES), $(ROUGHTIME_SOURCES:.cc=.o)) | ||
| IOTC_INCLUDE_FLAGS += -I$(ROUGHTIME_DIR) | ||
|
|
||
| $(ROUGHTIME_DIR)/%.o: $(ROUGHTIME_DIR)/%.cc | ||
| $(info [$(CXX)] $@) | ||
| $(MD) $(CXX) $(IOTC_INCLUDE_FLAGS) $(IOTC_COMMON_COMPILER_FLAGS) $(IOTC_CXX_FLAGS) \ | ||
| -c $< $(IOTC_COMPILER_OUTPUT) | ||
|
|
||
| $(ROUGHTIME_LIBRARY): $(ROUGHTIME_OBJS) | ||
| $(info [$(AR)] $@ ) | ||
| $(MD) $(AR) -rs -c $@ $^ | ||
|
|
||
| IOTC_ROUGHTIME_LIB_DEP ?= $(ROUGHTIME_LIBRARY) | ||
|
|
||
| IOTC_LIB_FLAGS += -L$(ROUGHTIME_DIR) | ||
| IOTC_LIB_FLAGS += -lroughtime | ||
|
|
||
| endif # IOTC_ENABLE_ROUGHTIME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ IOTC_CONFIG_FLAGS += -DHAVE_ECC | |
| IOTC_CONFIG_FLAGS += -DTFM_TIMING_RESISTANT -DECC_TIMING_RESISTANT -DWC_RSA_BLINDING | ||
| IOTC_CONFIG_FLAGS += -DUSE_FAST_MATH | ||
| IOTC_CONFIG_FLAGS += -DWOLFSSL_X86_64_BUILD | ||
| #TODO(frec): define the SHA512 and ed5139 stuff here ? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These preprocessor defines define how the Device SDK sees the wolfssl API, i.e. they affect only the wolfssl API, not the library functionality itself. Wolfssl lib content is defined by |
||
|
|
||
| # libiotc OCSP stapling feature switch | ||
| IOTC_CONFIG_FLAGS += -DIOTC_TLS_OCSP_STAPLING | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| CFLAGS= --enable-sni --enable-debug=no --enable-static=yes --enable-shared=no --disable-examples --disable-filesystem --enable-ocspstapling --disable-oldtls --enable-ecc --enable-harden | ||
| CFLAGS= --enable-sni --enable-debug=no --enable-static=yes --enable-shared=no --disable-examples --disable-filesystem --enable-ocspstapling --disable-oldtls --enable-ecc --enable-ed25519 --enable-sha512 --enable-harden |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include-->exclude