Skip to content
Merged

Dev #89

Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 20 additions & 9 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
{
"env": {
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/dist/*/build/*-extern-prefix/src/**",
"${workspaceFolder}/examples/**",
"${workspaceFolder}/tests/**"
],
"defines": [
"STORED_HAVE_ZMQ",
"STORED_HAVE_AES",
"STORED_HAVE_HEATSHRINK",
"AES256"
]
},
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/**"
"${env:includePath}"
],
"defines": [
"STORED_HAVE_ZMQ"
"${env:defines}"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
Expand All @@ -17,23 +30,21 @@
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/**"
"${env:includePath}"
],
"defines": [
"STORED_HAVE_ZMQ"
"${env:defines}"
],
"cStandard": "c17",
"cppStandard": "c++17"
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/include",
"${workspaceFolder}/**"
"${env:includePath}"
],
"defines": [
"STORED_HAVE_ZMQ"
"${env:defines}"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@ The format is based on `Keep a Changelog`_, and this project adheres to
Added
`````

...

.. _Unreleased: https://github.com/DEMCON/libstored/compare/v2.1.0...HEAD



`2.1.0`_ - 2025-12-05
---------------------

Added
`````

- Operations such as ``-=`` and ``++`` for store variables in C++.
- YAML export of store meta-data.
- ``stored::MuxLayer`` to multiplex multiple protocol layers over a single connection.
- ``stored::Aes256Layer`` and ``libstored.protocol.Aes256Layer`` for encrypted communication using
AES-256 CTR.
- Allow adding a protocol layer stack to ``ZmqClient`` on top of the ZeroMQ socket. If putting
the ``Aes256Layer`` in the stack, encrypted debug communication is enabled with the target.
- ``lossy_sync`` example that shows how to use the Synchronizer over a lossy protocol, and how to
use encryption in both the Synchronizer and Debugger stacks.

Changed
```````
Expand All @@ -40,7 +58,7 @@ Fixed

- Init value of CRC32 in Python ``libstored.protocol.Crc32Layer``.

.. _Unreleased: https://github.com/DEMCON/libstored/compare/v2.0.0...HEAD
.. _2.1.0: https://github.com/DEMCON/libstored/releases/tag/v2.1.0



Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ if(LIBSTORED_HAVE_ZTH)
find_package(Zth REQUIRED)
endif()

option(LIBSTORED_HAVE_AES "Use AES" ON)

if(LIBSTORED_HAVE_AES)
find_package(TinyAES REQUIRED)
endif()

set(LIBSTORED_CLANG_TIDY_DEFAULT OFF)

if(${CMAKE_VERSION} VERSION_GREATER "3.6.0")
Expand Down
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ device. However, once you implemented this data transport, you can access the
store, and observe and manipulate it using an Embedded Debugger (PC) client.
Moreover, the protocol supports arbitrary streams (like stdout) from the
application to the client, and has high-speed tracing of store variables. These
streams are optionally heatshrink_ compressed. libstored provides Python
classes for your custom scripts, a CLI and GUI interface.
streams are optionally heatshrink_ compressed, and AES-256 encrypted via tiny-AES-c_.
libstored provides Python classes for your custom scripts, a CLI and GUI interface.

Your application can have one store with one debugging interface, but also
multiple stores with one debugging interface, or one store with multiple
Expand Down Expand Up @@ -457,7 +457,7 @@ generate stuff for you. This is how to integrate it in your project:

Before including ``libstored``, you can specify several options (see
``cmake/libstored.cmake``), such as enabling ASan or clang-tidy.
Especially the library dependencies (ZeroMQ, Zth, heatshrink) are
Especially the library dependencies (ZeroMQ, Zth, heatshrink, tiny-AES-c) are
relevant to consider. For example, to enable ZeroMQ:

.. code:: cmake
Expand Down Expand Up @@ -514,7 +514,7 @@ approach. In that case:
3. In your project, call ``find_package(Libstored)``, while having the
generated ``FindLibstored.cmake`` in your ``CMAKE_MODULE_PATH``.

``Libstored`` accepts ``ZeroMQ``, ``Zth``, ``Heatshrink`` as ``COMPONENTS``.
``Libstored`` accepts ``ZeroMQ``, ``Zth``, ``Heatshrink``, and ``AES`` as ``COMPONENTS``.
Setting these enables integration of these libraries with libstored. When
possible, they are taken from your host system, or built from source. If you
want more control over these libraries, you can also use the mechanism
Expand All @@ -540,6 +540,7 @@ License, v. 2.0, as specified in LICENSE. This project complies to `REUSE`_.
.. _documentation: https://demcon.github.io/libstored
.. _8_sync: https://github.com/DEMCON/libstored/tree/main/examples/8_sync
.. _heatshrink: https://github.com/atomicobject/heatshrink
.. _tiny-AES-c: https://github.com/kokke/tiny-AES-c
.. _Kst: https://kst-plot.kde.org/
.. _python: https://github.com/DEMCON/libstored/tree/main/python
.. _REUSE: https://reuse.software/
3 changes: 3 additions & 0 deletions cmake/FindLibstored.cmake.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ if(EXISTS ${LIBSTORED_SOURCE_DIR}/cmake/libstored.cmake)
elseif("${c}" STREQUAL "Heatshrink")
find_package(Heatshrink ${_req})
set(LIBSTORED_HAVE_HEATSHRINK ON CACHE INTERNAL "Enable heatshrink" FORCE)
elseif("${c}" STREQUAL "AES")
find_package(TinyAES ${_req})
set(LIBSTORED_HAVE_AES ON CACHE INTERNAL "Enable AES" FORCE)
endif()
endforeach()

Expand Down
3 changes: 2 additions & 1 deletion cmake/LibstoredStoresConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2020-2023 Jochem Rutgers
# SPDX-FileCopyrightText: 2020-2025 Jochem Rutgers
#
# SPDX-License-Identifier: MPL-2.0

Expand Down Expand Up @@ -47,6 +47,7 @@ endif()

include(${LIBSTORED_STORES_CMAKE_PATH}/libstored.cmake OPTIONAL)
include(${LIBSTORED_STORES_CMAKE_PATH}/heatshrink.cmake OPTIONAL)
include(${LIBSTORED_STORES_CMAKE_PATH}/tinyaes.cmake OPTIONAL)
find_package(Zth)

file(GLOB _stores ${LIBSTORED_STORES_CMAKE_PATH}/*Store.cmake)
Expand Down
55 changes: 51 additions & 4 deletions cmake/libstored.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ option(LIBSTORED_HAVE_LIBZMQ "Use libzmq" OFF)
# from source.
option(LIBSTORED_HAVE_ZTH "Use Zth" OFF)

# When enabled, TinyAES is used for AES-256 CTR. It is searched via find_package(TinyAES). When
# provided by the system, make sure it is configured for AES-256 CTR mode.
option(LIBSTORED_HAVE_AES "Use AES-256 CTR from TinyAES" OFF)

# ##################################################################################################
# Prepare environment

Expand Down Expand Up @@ -198,6 +202,7 @@ Relationship: SPDXRef-compiler BUILD_DEPENDENCY_OF SPDXRef-libstored
${LIBSTORED_SOURCE_DIR}/include/stored
${LIBSTORED_SOURCE_DIR}/include/stored.h
${LIBSTORED_SOURCE_DIR}/include/stored_config.h
${LIBSTORED_SOURCE_DIR}/include/libstored/aes.h
${LIBSTORED_SOURCE_DIR}/include/libstored/allocator.h
${LIBSTORED_SOURCE_DIR}/include/libstored/compress.h
${LIBSTORED_SOURCE_DIR}/include/libstored/config.h
Expand All @@ -212,6 +217,7 @@ Relationship: SPDXRef-compiler BUILD_DEPENDENCY_OF SPDXRef-libstored
${LIBSTORED_SOURCE_DIR}/include/libstored/util.h
${LIBSTORED_SOURCE_DIR}/include/libstored/version.h
${LIBSTORED_SOURCE_DIR}/include/libstored/zmq.h
${LIBSTORED_SOURCE_DIR}/src/aes.cpp
${LIBSTORED_SOURCE_DIR}/src/compress.cpp
${LIBSTORED_SOURCE_DIR}/src/directory.cpp
${LIBSTORED_SOURCE_DIR}/src/debugger.cpp
Expand Down Expand Up @@ -403,7 +409,7 @@ Relationship: SPDXRef-libstored DEPENDS_ON SPDXRef-libzmq
target_compile_definitions(
${LIBSTORED_LIB_TARGET} PUBLIC -DSTORED_HAVE_HEATSHRINK=1
)
target_link_libraries(${LIBSTORED_LIB_TARGET} PUBLIC heatshrink)
target_link_libraries(${LIBSTORED_LIB_TARGET} PRIVATE heatshrink)

set(_fields)

Expand Down Expand Up @@ -442,6 +448,46 @@ Relationship: SPDXRef-libstored DEPENDS_ON SPDXRef-heatshrink
)
endif()

if(LIBSTORED_HAVE_AES)
target_compile_definitions(${LIBSTORED_LIB_TARGET} PUBLIC -DSTORED_HAVE_AES=1)
target_link_libraries(${LIBSTORED_LIB_TARGET} PRIVATE tinyaes)

set(_fields)

if("${TinyAES_VERSION}" STREQUAL "")
set(_fields
"${_fields}
PackageVersion: preinstalled
PackageDownloadLocation: NOASSERTION
ExternalRef: PACKAGE-MANAGER purl pkg:github/kokke/tiny-AES-c"
)
else()
set(_fields
"${_fields}
PackageVersion: ${TinyAES_VERSION}
PackageDownloadLocation: https://github.com/kokke/tiny-AES-c/commit/${TinyAES_VERSION}
ExternalRef: PACKAGE-MANAGER purl pkg:github/kokke/tiny-AES-c@${TinyAES_VERSION}"
)
endif()

file(
APPEND "${LIBSTORED_LIB_SBOM_CMAKE}"
"
file(APPEND \"${LIBSTORED_LIB_DESTINATION}/doc/sbom.spdx\" \"
PackageName: TinyAES
SPDXID: SPDXRef-TinyAES${_fields}
PackageHomePage: https://github.com/kokke/tiny-AES-c
FilesAnalyzed: false
PackageLicenseConcluded: Unlicense
PackageLicenseDeclared: Unlicense
PackageSummary: <text>This is a small and portable implementation of the AES ECB, CTR and CBC encryption algorithms written in C.</text>
PrimaryPackagePurpose: LIBRARY
Relationship: SPDXRef-libstored DEPENDS_ON SPDXRef-TinyAES
\")
"
)
endif()

set(DO_CLANG_TIDY "")

if(${CMAKE_VERSION} VERSION_GREATER "3.6.0")
Expand Down Expand Up @@ -621,12 +667,13 @@ function(libstored_copy_dlls target)
if(WIN32)
get_target_property(target_type ${target} TYPE)
get_property(LIBSTORED_RUNTIME_LIBS GLOBAL PROPERTY LIBSTORED_RUNTIME_LIBS)
if(target_type STREQUAL "EXECUTABLE" AND NOT "${LIBSTORED_RUNTIME_LIBS}" STREQUAL "")
if(target_type STREQUAL "EXECUTABLE" AND NOT "${LIBSTORED_RUNTIME_LIBS}" STREQUAL
""
)
add_custom_command(
TARGET ${target}
PRE_LINK
COMMAND
${CMAKE_COMMAND} -E copy ${LIBSTORED_RUNTIME_LIBS}
COMMAND ${CMAKE_COMMAND} -E copy ${LIBSTORED_RUNTIME_LIBS}
$<TARGET_FILE_DIR:${target}>/
VERBATIM
)
Expand Down
5 changes: 0 additions & 5 deletions dist/common/FindHeatshrink.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ set_source_files_properties(${heatshrink_src} PROPERTIES GENERATED 1)

if(MSVC)
target_compile_options(heatshrink PRIVATE /W1)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(heatshrink PUBLIC /MTd)
else()
target_compile_options(heatshrink PUBLIC /MT)
endif()
endif()

target_include_directories(
Expand Down
69 changes: 69 additions & 0 deletions dist/common/FindTinyAES.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-FileCopyrightText: 2020-2025 Jochem Rutgers
#
# SPDX-License-Identifier: MIT

cmake_policy(VERSION 3.10)

include(ExternalProject)
include(GNUInstallDirs)
find_package(Git)

if("${TINYAES_GIT_URL}" STREQUAL "")
if(DEFINED ENV{LIBSTORED_GIT_CACHE})
set(TINYAES_GIT_URL $ENV{LIBSTORED_GIT_CACHE}/tinyaes)
else()
set(TINYAES_GIT_URL "https://github.com/kokke/tiny-AES-c.git")
endif()
endif()

set(TinyAES_VERSION 23856752fbd139da0b8ca6e471a13d5bcc99a08d)

ExternalProject_Add(
tinyaes-extern
GIT_REPOSITORY ${TINYAES_GIT_URL}
GIT_TAG ${TinyAES_VERSION}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ${CMAKE_COMMAND} -E chdir <SOURCE_DIR> ${GIT_EXECUTABLE} checkout -- .
LOG_CONFIGURE 0
LOG_BUILD 0
LOG_TEST 0
LOG_INSTALL 0
)

ExternalProject_Get_Property(tinyaes-extern SOURCE_DIR)

# The source files are considered generated files. Upon a clean, they are removed. Hence the
# UPDATE_COMMAND to recover them.
add_library(tinyaes STATIC ${SOURCE_DIR}/aes.c)
set_target_properties(tinyaes PROPERTIES PUBLIC_HEADER "${SOURCE_DIR}/aes.h")
add_dependencies(tinyaes tinyaes-extern)

get_target_property(tinyaes_src tinyaes SOURCES)
set_source_files_properties(${tinyaes_src} PROPERTIES GENERATED 1)

if(MSVC)
target_compile_options(tinyaes PRIVATE /W1)
endif()

target_include_directories(
tinyaes PUBLIC $<BUILD_INTERFACE:${SOURCE_DIR}> $<INSTALL_INTERFACE:include>
)

target_compile_definitions(tinyaes PUBLIC AES256=1 CTR=1 CBC=0 ECB=0)

install(
TARGETS tinyaes
EXPORT tinyaes
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

if(WIN32)
install(EXPORT tinyaes DESTINATION CMake)
else()
install(EXPORT tinyaes DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libstored/cmake)
endif()

set(TinyAES_FOUND 1)
Loading
Loading