Skip to content
Draft
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
7646769
Refactor crypto handling to support multiple backends (OpenSSL and mb…
Jakio815 Oct 15, 2025
9683b99
Minor fixes.
Jakio815 Oct 15, 2025
86b6d15
Fix on error logging.
Jakio815 Oct 15, 2025
38cde97
Add mbedtls implementation.
Jakio815 Oct 15, 2025
634ab49
Minor fix.
Jakio815 Oct 15, 2025
9d7836c
Minor fix.
Jakio815 Oct 15, 2025
dd36d10
Minor fix.
Jakio815 Oct 15, 2025
85b38f0
Fixed until private decrypt.
Jakio815 Oct 15, 2025
475ab9e
Update CMakeLists.txt to change library linkage for sst-c-api from PR…
Jakio815 Oct 15, 2025
c8b8360
Update mbedtls.
Jakio815 Oct 15, 2025
23bdf45
Fix ci.
Jakio815 Oct 15, 2025
1ffb0dc
Add TOODs and formatting.
Jakio815 Oct 15, 2025
379a448
Add pico-sdk as submodule
Jakio815 Oct 15, 2025
a77c653
Add embedded examples with a client application and README for prereq…
Jakio815 Oct 16, 2025
57337d2
Fix compile warnings.
Jakio815 Oct 16, 2025
5463df8
Minor fix on logging.
Jakio815 Oct 16, 2025
6d31fec
Fix logs on crypto test.
Jakio815 Oct 16, 2025
13e3b8d
Pass compile definitions to crypto test.
Jakio815 Oct 16, 2025
172070c
Merge branch 'mbedtls' of https://github.com/iotauth/sst-c-api into m…
Jakio815 Oct 16, 2025
44dfa28
Format.
Jakio815 Oct 16, 2025
236fe5c
Fix CI.
Jakio815 Oct 16, 2025
59a657d
Minor fix.
Jakio815 Oct 16, 2025
25dfb09
Remove padding.
Jakio815 Oct 16, 2025
9423a66
Minor fix.
Jakio815 Oct 16, 2025
6f21722
Formatting...
Jakio815 Oct 16, 2025
683aeed
Fix on mbed crypto.
Jakio815 Oct 16, 2025
1b01503
Formatting.
Jakio815 Oct 16, 2025
50cc8c4
Remove unused mbedtls header and update encryption test to use nonce …
Jakio815 Oct 17, 2025
7255120
Cleanup headers.
Jakio815 Oct 20, 2025
645d28c
Remove sst_mbedtls.c and .h
Jakio815 Oct 20, 2025
2383318
Fix examples to use their own threads.
Jakio815 Oct 20, 2025
a4400f5
Fix example
Jakio815 Oct 20, 2025
2742805
Fix pico cmake.
Jakio815 Oct 21, 2025
0bf8679
Generate custom mbedtls config file.
Jakio815 Oct 22, 2025
0d8f349
Fix configs.
Jakio815 Oct 23, 2025
992d179
Minor fix.
Jakio815 Oct 23, 2025
dbb375e
Fix CMake.
Jakio815 Oct 23, 2025
e097a6b
Fix CI. Remove Mbedtls tests.
Jakio815 Oct 23, 2025
2795c63
Add FreeRTOS as submodule.
Jakio815 Oct 23, 2025
8c553f6
Add free_rtos builds.
Jakio815 Oct 23, 2025
53133ad
Add freeRTOS cmake and configs. Also lwip options.h
Jakio815 Oct 23, 2025
e5144dc
Fix on headers.
Jakio815 Oct 23, 2025
0ecdaec
Make sure to completely read message according to the message header'…
Jakio815 Dec 5, 2025
46ab515
Merge branch 'bug-fix' of https://github.com/iotauth/sst-c-api into m…
Jakio815 Dec 5, 2025
21b8f84
Add readme for examples.
Jakio815 Dec 5, 2025
3682401
Simplify main directory.
Jakio815 Dec 5, 2025
ff32011
Minor fix.
Jakio815 Dec 5, 2025
e6f1e71
Add link.
Jakio815 Dec 5, 2025
3753140
Minor fix.
Jakio815 Dec 5, 2025
ea689c1
Update on dates.
Jakio815 Dec 5, 2025
85d5ef4
Update scenario_examples to SST_Testbed
Jakio815 Dec 5, 2025
1a87f41
Merge branch 'bug-fix' of https://github.com/iotauth/sst-c-api into m…
Jakio815 Dec 5, 2025
8104a60
Fix on ifdefs.
Jakio815 Dec 18, 2025
ddae0e8
Add ebug messages, and split pico and openssl build on loading pub ke…
Jakio815 Dec 18, 2025
0f14573
Fix mbedtls priv key pub key load.
Jakio815 Dec 18, 2025
71ac9cf
Add pico load config.
Jakio815 Dec 18, 2025
a19bcf8
Fix headers.
Jakio815 Dec 18, 2025
242eb8e
Fix cllient server example to include threads.
Jakio815 Dec 18, 2025
1ba93d5
Fix FreeRTOS, mbedtls, lwip options.
Jakio815 Dec 18, 2025
f8d2ac4
Remove
Jakio815 Dec 18, 2025
973add6
Fix CMake build
Jakio815 Dec 18, 2025
a3dcefd
Fix embedded_cllient.c example.
Jakio815 Dec 18, 2025
256d23d
Working until initSST
Jakio815 Dec 18, 2025
946e3bc
Remove mbedtls.
Jakio815 Dec 18, 2025
4c32604
Update FreeRTOS
Jakio815 Dec 18, 2025
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
38 changes: 35 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ jobs:
path: entity/c
ref: ${{ github.ref }}
if: ${{ github.ref}}

- name: Init and update submodules for sst-c-api (pico-sdk, mbedtls)
working-directory: entity/c
run: |
git submodule sync --recursive
git submodule update --init --recursive

- name: Install openssl
run: sudo apt-get update && sudo apt-get install -y openssl
- name: Set up JDK 17
Expand All @@ -87,15 +94,15 @@ jobs:
nohup java -jar target/auth-server-jar-with-dependencies.jar -p ../properties/exampleAuth101.properties --password=asdf &
echo $! > auth.pid # Save the PID

- name: Run the file_block_encrypt_example examples.
- name: Run the file_block_encrypt_example examples using openssl.
working-directory: entity/c/examples/file_block_encrypt_example
run: |
mkdir build && cd build && cmake ../ && make
./block_writer ../block_writer.config
./block_reader ../block_reader.config
./block_reader_load_s_key_list

- name: Run the server_client_example examples.
- name: Run the server_client_example examples using openssl.
working-directory: entity/c/examples/server_client_example
run: |
mkdir build && cd build && cmake ../ && make
Expand All @@ -104,14 +111,39 @@ jobs:
./threaded_get_target_id_client ../c_client.config
./threaded_get_target_id_server ../c_server.config

- name: Run the tests examples.
- name: Run the tests examples using openssl.
working-directory: entity/c/tests
run: |
mkdir build && cd build && cmake ../ && make
./save_load_session_key_list_with_password_test ../test_configs/client.config
# ./encrypt_buf_with_session_key_without_malloc_execution_time_test ../test_configs/client.config
./multi_thread_get_session_key_test ../test_configs/client.config

# - name: Run the file_block_encrypt_example examples using mbedtls.
# working-directory: entity/c/examples/file_block_encrypt_example
# run: |
# rm -rf build && mkdir build && cd build && cmake -DUSE_MBEDTLS=ON ../ && make
# ./block_writer ../block_writer.config
# ./block_reader ../block_reader.config
# ./block_reader_load_s_key_list

# - name: Run the server_client_example examples using mbedtls.
# working-directory: entity/c/examples/server_client_example
# run: |
# rm -rf build && mkdir build && cd build && cmake -DUSE_MBEDTLS=ON ../ && make
# ./entity_server ../c_server.config &
# ./entity_client ../c_client.config
# ./threaded_get_target_id_client ../c_client.config
# ./threaded_get_target_id_server ../c_server.config

# - name: Run the tests examples using mbedtls.
# working-directory: entity/c/tests
# run: |
# rm -rf build && mkdir build && cd build && cmake -DUSE_MBEDTLS=ON ../ && make
# ./save_load_session_key_list_with_password_test ../test_configs/client.config
# # ./encrypt_buf_with_session_key_without_malloc_execution_time_test ../test_configs/client.config
# ./multi_thread_get_session_key_test ../test_configs/client.config

- name: Stop auth server
working-directory: auth/auth-server
run: |
Expand Down
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "embedded/lib/mbedtls"]
path = embedded/lib/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "embedded/lib/pico-sdk"]
path = embedded/lib/pico-sdk
url = https://github.com/raspberrypi/pico-sdk.git
[submodule "embedded/lib/FreeRTOS-Kernel"]
path = embedded/lib/FreeRTOS-Kernel
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
129 changes: 78 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,53 @@
# $ cmake -DCMAKE_BUILD_TYPE=Debug ../

cmake_minimum_required(VERSION 3.19)
project(sst-lib VERSION 1.0.0 LANGUAGES C)

find_package(OpenSSL REQUIRED)
find_package(Threads REQUIRED)
project(sst-lib VERSION 1.0.0 LANGUAGES C CXX ASM)

add_library(sst-c-api STATIC
# Crypto backend selection
option(USE_OPENSSL "Use OpenSSL (default)" ON)

# Pico build off as default
option(SST_PLATFORM_PICO "Build SST library for Raspberry Pi Pico targets" OFF)

set(SST_CORE_SOURCES
${CMAKE_CURRENT_LIST_DIR}/c_api.c
${CMAKE_CURRENT_LIST_DIR}/c_common.c
${CMAKE_CURRENT_LIST_DIR}/c_crypto.c
${CMAKE_CURRENT_LIST_DIR}/c_secure_comm.c
${CMAKE_CURRENT_LIST_DIR}/load_config.c
${CMAKE_CURRENT_LIST_DIR}/ipfs.c)

set_target_properties(sst-c-api PROPERTIES POSITION_INDEPENDENT_CODE ON)
)

# Statically link OpenSSL into sst-c-api
target_link_libraries(sst-c-api PUBLIC OpenSSL::Crypto OpenSSL::SSL Threads::Threads)
add_library(sst-c-api STATIC ${SST_CORE_SOURCES})

# Add crypto backend source files
if(USE_OPENSSL)
target_sources(sst-c-api PRIVATE
${CMAKE_CURRENT_LIST_DIR}/crypto_openssl.c
${CMAKE_CURRENT_LIST_DIR}/ipfs.c)
target_compile_definitions(sst-c-api PUBLIC USE_OPENSSL)
find_package(OpenSSL REQUIRED)
target_link_libraries(sst-c-api PUBLIC OpenSSL::Crypto OpenSSL::SSL)
# list(APPEND SST_CORE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/ipfs.c)
elseif(SST_PLATFORM_PICO)
set(FREERTOS_KERNEL_PATH "${CMAKE_CURRENT_LIST_DIR}/embedded/lib/FreeRTOS-Kernel" CACHE PATH "Path to FreeRTOS Kernel" FORCE)
include(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
pico_sdk_init()
target_link_libraries(sst-c-api PRIVATE
pico_cyw43_arch_lwip_sys_freertos
pico_stdlib
pico_mbedtls
FreeRTOS-Kernel-Heap4
)
target_sources(sst-c-api PRIVATE ${CMAKE_CURRENT_LIST_DIR}/crypto_mbedtls.c)
target_compile_definitions(sst-c-api PUBLIC USE_MBEDTLS)
target_compile_definitions(sst-c-api PUBLIC SST_PLATFORM_PICO)
# Include lwipopts.h & mbedtls_sst_config.h & FreeRTOSConfig.h
target_include_directories(sst-c-api PRIVATE
# ${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/embedded/include
)
endif()

target_include_directories(sst-c-api PUBLIC
$<INSTALL_INTERFACE:include>
Expand All @@ -28,8 +58,11 @@ target_include_directories(sst-c-api PUBLIC
# Compiler flags
if(MSVC)
target_compile_options(sst-c-api PRIVATE /W4 /WX)
elseif(SST_PLATFORM_PICO)
target_compile_options(sst-c-api PRIVATE -Wall -Wextra)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Exclude errors, because some can use GNU-specific variadic arguments. This is done for only compiling the SST library.
target_compile_options(sst-c-api PRIVATE -Wall -Wextra)
else()
target_compile_options(sst-c-api PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
Expand All @@ -40,49 +73,43 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
target_compile_definitions(sst-c-api PRIVATE DEBUG=1)
endif()

# Install the library
# Installs in /usr/local/lib/cmake/sst-lib/sst-libTargets.cmake & sst-libTargets-noconfig.cmake
# Contains target definitions for sst-c-api
# Helps CMake know how to link against sst-c-api

# sst-libTargets-noconfig.cmake Acts as the entry point for find_package(sst-lib)
# Defines where to look for sst-libTargets.cmake
install(TARGETS sst-c-api
EXPORT sst-libTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

# Export targets for find_package()
include(CMakePackageConfigHelpers)

install(
EXPORT sst-libTargets
FILE sst-libTargets.cmake
NAMESPACE sst-lib::
DESTINATION lib/cmake/sst-lib
)

# Creates in /usr/local/lib/cmake/sst-lib/sst-libConfig.cmake
# Acts as the entry point for find_package(sst-lib)
# Defines where to look for sst-libTargets.cmake
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/sst-libConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/sst-libConfig.cmake
INSTALL_DESTINATION lib/cmake/sst-lib
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/sst-libConfig.cmake
DESTINATION lib/cmake/sst-lib
)
# Install/export only when not vendoring mbedTLS
if(USE_OPENSSL)
# Install the library and export target
install(TARGETS sst-c-api
EXPORT sst-libTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)

include(CMakePackageConfigHelpers)

install(
EXPORT sst-libTargets
FILE sst-libTargets.cmake
NAMESPACE sst-lib::
DESTINATION lib/cmake/sst-lib
)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/sst-libConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/sst-libConfig.cmake
INSTALL_DESTINATION lib/cmake/sst-lib
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/sst-libConfig.cmake
DESTINATION lib/cmake/sst-lib
)
endif()

# Install headers
install(FILES c_api.h DESTINATION include/sst-c-api)

# Build unit tests
enable_testing()

add_executable(crypto_test ${CMAKE_CURRENT_SOURCE_DIR}/tests/c_crypto_test.c)
target_link_libraries(crypto_test PRIVATE sst-c-api)
add_test(NAME crypto_test COMMAND crypto_test)
# Build unit tests only for host builds (not Pico SDK)
if(USE_OPENSSL)
enable_testing()
add_executable(crypto_test ${CMAKE_CURRENT_SOURCE_DIR}/tests/c_crypto_test.c)
target_link_libraries(crypto_test PRIVATE sst-c-api)
add_test(NAME crypto_test COMMAND crypto_test)
endif()
20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,7 @@ $sudo make install

# Example

- Turn on two different terminals at `$SST_ROOT/entity/c/examples/server_client_example/build`, and turn on Auth on the third terminal.

Execute

`$./entity_client ../c_client.config`

`$./entity_server ../c_server.config`

on each terminal

To test AES_128_CTR mode, with noHMAC when exchanging messages, execute

`$./entity_client ../c_computenode_CTR_noHMAC.config`

`$./entity_server ../c_compactionnode_CTR_noHMAC.config`

This will get all keys encrypted in AES_128_CTR mode, and send all messages in CTR mode, with no HMAC.
To run examples, please checkout the [`examples/`](./examples/README.md) directory.

# For Developers

Expand All @@ -168,4 +152,4 @@ This will get all keys encrypted in AES_128_CTR mode, and send all messages in C

- Implement an additional API function for extracting session key from cached session keys.

*Last updated on February 2, 2024*
*Last updated on December 5, 2025*
Loading
Loading