Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
80c6597
"add roughtime include flags"
Jan 16, 2019
c3aa9d6
"add roughtime submodule"
Jan 16, 2019
ad3b112
Merge branch 'mk_cpp' of github.com:GoogleCloudPlatform/iot-edge-sdk-…
Jan 16, 2019
6d5e216
Replacement of BoringSSL/ openSSL crypto library with mbedTLS and/or …
Jan 21, 2019
6b9d817
Merge branch 'bsp_migration' into esp_test
Jan 21, 2019
b40989b
WIP: Re-implement networking in Roughtime client to use BSP network API
Jan 22, 2019
a7e34a9
WIP_2: Re-implement networking in Roughtime client to use BSP network…
Jan 23, 2019
96483cd
Re-implement networking in Roughtime client to use BSP network API
Jan 24, 2019
4006b16
WIP: setting for ESP
Jan 25, 2019
9118568
WIP: run example running on ESP32
Jan 28, 2019
15bea84
WIP: Modify Networking API
Feb 12, 2019
e6ddc07
Add server test/ Modify BSP networking API
Feb 26, 2019
ab518ea
Merge 'bsp_migration' into branch
Mar 4, 2019
0dac9cc
modify the order of additional include flags
Mar 5, 2019
7e8821a
Merge branch 'bsp_migration' into esp_test
Mar 5, 2019
034bcbe
deleting conflitcted file of echoserver header
Mar 5, 2019
7890c56
delete conflicted file of echoserver header
Mar 5, 2019
410e015
Add roughtime submoudle
Mar 5, 2019
d17ded1
define iotc_crypto_key_data for roughtime client example
Mar 5, 2019
bb50fb4
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
Mar 5, 2019
0695c4a
Relace perror with iotc_debug_logger
Mar 5, 2019
fe00de9
print time information on example
Mar 5, 2019
64c9bb4
Handle with return value of getaddrinfo function
Mar 5, 2019
ce4696c
Error handling for iotc_bsp_io_net_select
Mar 5, 2019
cf42579
Revise return type & Remove system offset & Make execute with one fun…
Mar 6, 2019
043954d
Merge branch 'time' into roughtime_client
Mar 6, 2019
d209469
Replace function getting monotonic time with the one in iotc_bsp_time
Mar 6, 2019
acbc5ee
only include test files as gtest sources
fredrec Mar 6, 2019
8b88337
update build configuration for Roughtime client
fredrec Mar 6, 2019
d7fcc63
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec Mar 6, 2019
7b7b8dd
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec Mar 6, 2019
f47c86a
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
Mar 6, 2019
5efba0b
fix: include test utils from src/tests
fredrec Mar 6, 2019
2b170e7
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec Mar 6, 2019
7cdc18d
apply iotc_bsp_rng, change in roughtime & handling return value
Mar 6, 2019
6faeba1
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
Mar 6, 2019
e9cca31
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec Mar 7, 2019
e5d3690
expand IOTC_GTEST_SOURCES at define time
fredrec Mar 8, 2019
bf2c358
add IOTC_ENABLE_ROUGHTIME build flag
fredrec Mar 8, 2019
9ad5552
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec Mar 8, 2019
3c187a8
filter out c++ test files using IOTC_GTEST_SOURCES
fredrec Mar 8, 2019
6b1b038
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec Mar 8, 2019
8741ffd
merge 'bsp_migration' into 'roughtime_client'
Mar 8, 2019
c08752e
Merge branch 'development' into roughtime_client
Mar 8, 2019
ff33657
Precision of monotonic time: microseconds -> milliseconds
Mar 8, 2019
ef33a8b
Precision of monotonic time: microseconds -> milliseconds
Mar 8, 2019
2b8849a
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec Mar 8, 2019
470f4a7
remove unused code
fredrec Mar 8, 2019
17b951c
Set retrial time for connection
Mar 8, 2019
2ed88db
revert files supposedely modified by mistake
fredrec Mar 8, 2019
11e8862
Refactoring
Mar 11, 2019
bddd718
fix: include mt-roughtime.mk in mt-config
fredrec Mar 11, 2019
9fd1a5a
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec Mar 11, 2019
624d7e4
Merge branch 'development' of github.com:GoogleCloudPlatform/iot-devi…
fredrec Mar 11, 2019
29fb404
rename *_test_XXX.cc to *_XXX_test.cc
fredrec Mar 11, 2019
18e7d9a
Merge branch 'fix_gtest_src' of github.com:GoogleCloudPlatform/iot-de…
fredrec Mar 11, 2019
e03fc88
Changed data type of time_data
Mar 11, 2019
06062f1
refactoring
Mar 11, 2019
7b24ac8
Merge branch 'roughtime_client' of github.com:GoogleCloudPlatform/iot…
fredrec Mar 11, 2019
f6ebc6c
Removed duplicated error checking
Mar 11, 2019
a001d5c
Reorganized include lines
Mar 11, 2019
9888fed
initialized nonce variable
Mar 13, 2019
e0dd3d7
Detached socket closing part from receive_time()
Mar 13, 2019
b33ae71
Added unit test for invalid parameter which is nullptr
Mar 13, 2019
27924ce
Typo
Mar 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ifdef TRAVIS_OS_NAME
IOTC_TRAVIS_BUILD=1
endif


include make/mt-config/mt-presets.mk

include make/mt-config/mt-config.mk
Expand Down Expand Up @@ -136,7 +137,7 @@ clean_all: clean

libiotc: $(XI)

$(XI): $(IOTC_TLS_LIB_DEP) $(IOTC_CRYPTO_LIB_DEP) $(IOTC_PROTOFILES_C) $(IOTC_OBJS) $(IOTC_BUILD_PRECONDITIONS) | $(IOTC_BIN_DIRS)
$(XI): $(IOTC_TLS_LIB_DEP) $(IOTC_CRYPTO_LIB_DEP) $(IOTC_ROUGHTIME_LIB_DEP) $(IOTC_PROTOFILES_C) $(IOTC_OBJS) $(IOTC_BUILD_PRECONDITIONS) | $(IOTC_BIN_DIRS)
$(info [$(AR)] $@ )
$(MD) $(AR) $(IOTC_ARFLAGS) $(IOTC_OBJS) $(IOTC_EXTRA_ARFLAGS)

Expand Down
9 changes: 9 additions & 0 deletions examples/iotc_roughtime_client/Makefile
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 examples/iotc_roughtime_client/src/iotc_roughtime_client.c
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;
}
56 changes: 56 additions & 0 deletions include/iotc_roughtime_client.h
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
11 changes: 9 additions & 2 deletions make/mt-config/mt-config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ ifneq (,$(findstring tls_bsp,$(CONFIG)))
include make/mt-config/mt-crypto.mk
endif

include make/mt-config/mt-roughtime.mk
include make/mt-config/tests/mt-gtest.mk # For IOTC_GTEST_SOURCES

IOTC_UNIT_TEST_TARGET ?= native

Expand Down Expand Up @@ -229,14 +231,19 @@ IOTC_SOURCES += $(foreach layerdir,$(IOTC_SRCDIRS),\
IOTC_SOURCES_CXX := $(wildcard ./src/*.cc)
IOTC_SOURCES_CXX += $(foreach layerdir,$(IOTC_SRCDIRS),\
$(wildcard $(layerdir)/*.cc))
IOTC_SOURCES_CXX := $(filter-out %_test.cc, $(IOTC_SOURCES_CXX)) # Filter out tests

IOTC_SOURCES_CXX := $(filter-out $(IOTC_GTEST_SOURCES), $(IOTC_SOURCES_CXX)) # Filter out tests

ifeq ($(IOTC_DEBUG_OUTPUT),0)
IOTC_SOURCES := $(filter-out $(LIBIOTC_SOURCE_DIR)/iotc_debug.c, $(IOTC_SOURCES) )
IOTC_SOURCES := $(filter-out $(LIBIOTC)/third_party/mqtt-protocol-c/iotc_debug_data_desc_dump.c, $(IOTC_SOURCES) )
endif

# conditionaly include Roughtime client sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include-->exclude

ifndef IOTC_ENABLE_ROUGHTIME
IOTC_SOURCES_CXX := $(filter-out $(LIBIOTC_SOURCE_DIR)/iotc_roughtime_client.cc, $(IOTC_SOURCES_CXX) )
endif


ifdef MAKEFILE_DEBUG
$(info --mt-config-- Using [$(IOTC_BSP_PLATFORM)] BSP configuration)
$(info --mt-config-- event_loop=$(IOTC_EVENT_LOOP))
Expand Down
50 changes: 50 additions & 0 deletions make/mt-config/mt-roughtime.mk
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
1 change: 1 addition & 0 deletions make/mt-config/mt-tls-wolfssl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Copy link
Contributor

Choose a reason for hiding this comment

The 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 res/tls/wolfssl.conf.
In theory this list should match with AM_CFLAGS in file third_party/tls/wolfssl/config.log, which is generated during wolfssl build. In practice only API affecting flags have to be defined.


# libiotc OCSP stapling feature switch
IOTC_CONFIG_FLAGS += -DIOTC_TLS_OCSP_STAPLING
Expand Down
6 changes: 5 additions & 1 deletion make/mt-config/tests/mt-gtest.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ GTEST_OBJS := $(GTEST_OBJDIR)/gtest-all.o \
# Set up iotc googletest tests.
IOTC_GTEST_SUITE ?= iotc_gtests
IOTC_GTEST_OBJDIR := $(IOTC_TEST_OBJDIR)/gtests
IOTC_GTEST_SOURCES = $(shell find $(LIBIOTC)/src -name "*.cc")

# Test cases: files ending in _test.cc or _test_something.cc
IOTC_GTEST_SOURCES := $(shell find $(LIBIOTC)/src -name "*_test.cc")
# Test utils: .cc files in src/tests/
IOTC_GTEST_SOURCES += $(shell find $(LIBIOTC)/src/tests -name "*.cc")

IOTC_GTEST_OBJS := $(filter-out $(IOTC_GTEST_SOURCES), $(IOTC_GTEST_SOURCES:.cc=.o))
IOTC_GTEST_OBJS := $(subst $(LIBIOTC_SRC), $(IOTC_GTEST_OBJDIR)/, $(IOTC_GTEST_OBJS))
Expand Down
2 changes: 1 addition & 1 deletion res/tls/wolfssl.conf
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
Loading