Skip to content

Commit abc954b

Browse files
authored
Migrate to ESP-IDF (#19)
1 parent 3323555 commit abc954b

File tree

159 files changed

+9340
-11492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+9340
-11492
lines changed

Diff for: .devcontainer/Dockerfile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM espressif/idf
2+
3+
ARG DEBIAN_FRONTEND=nointeractive
4+
ARG CONTAINER_USER=esp
5+
ARG USER_UID=1000
6+
ARG USER_GID=$USER_UID
7+
8+
RUN apt-get update \
9+
&& apt install -y -q \
10+
cmake \
11+
git \
12+
hwdata \
13+
libglib2.0-0 \
14+
libnuma1 \
15+
libpixman-1-0 \
16+
linux-tools-virtual \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
RUN update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
20+
21+
# QEMU
22+
ENV QEMU_REL=esp-develop-20220919
23+
ENV QEMU_SHA256=f6565d3f0d1e463a63a7f81aec94cce62df662bd42fc7606de4b4418ed55f870
24+
ENV QEMU_DIST=qemu-${QEMU_REL}.tar.bz2
25+
ENV QEMU_URL=https://github.com/espressif/qemu/releases/download/${QEMU_REL}/${QEMU_DIST}
26+
27+
ENV LC_ALL=C.UTF-8
28+
ENV LANG=C.UTF-8
29+
30+
RUN wget --no-verbose ${QEMU_URL} \
31+
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \
32+
&& tar -xf $QEMU_DIST -C /opt \
33+
&& rm ${QEMU_DIST}
34+
35+
ENV PATH=/opt/qemu/bin:${PATH}
36+
37+
RUN groupadd --gid $USER_GID $CONTAINER_USER \
38+
&& adduser --uid $USER_UID --gid $USER_GID --disabled-password --gecos "" ${CONTAINER_USER} \
39+
&& usermod -a -G dialout $CONTAINER_USER
40+
USER ${CONTAINER_USER}
41+
ENV USER=${CONTAINER_USER}
42+
WORKDIR /home/${CONTAINER_USER}
43+
44+
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
45+
46+
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
47+
48+
CMD ["/bin/bash", "-c"]

Diff for: .devcontainer/devcontainer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/ubuntu
3+
{
4+
"name": "ESP-IDF QEMU",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
// Add the IDs of extensions you want installed when the container is created
9+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
10+
/* the path of workspace folder to be opened after container is running
11+
*/
12+
"workspaceFolder": "${localWorkspaceFolder}",
13+
"mounts": [
14+
"source=extensionCache,target=/root/.vscode-server/extensions,type=volume"
15+
],
16+
"customizations": {
17+
"vscode": {
18+
"settings": {
19+
"terminal.integrated.defaultProfile.linux": "bash",
20+
"idf.espIdfPath": "/opt/esp/idf",
21+
"idf.customExtraPaths": "",
22+
"idf.pythonBinPath": "/opt/esp/python_env/idf5.1_py3.8_env/bin/python",
23+
"idf.toolsPath": "/opt/esp",
24+
"idf.gitPath": "/usr/bin/git"
25+
},
26+
"extensions": [
27+
"ms-vscode.cpptools",
28+
"espressif.esp-idf-extension"
29+
],
30+
},
31+
"codespaces": {
32+
"settings": {
33+
"terminal.integrated.defaultProfile.linux": "bash",
34+
"idf.espIdfPath": "/opt/esp/idf",
35+
"idf.customExtraPaths": "",
36+
"idf.pythonBinPath": "/opt/esp/python_env/idf5.1_py3.8_env/bin/python",
37+
"idf.toolsPath": "/opt/esp",
38+
"idf.gitPath": "/usr/bin/git"
39+
},
40+
"extensions": [
41+
"ms-vscode.cpptools",
42+
"espressif.esp-idf-extension"
43+
],
44+
}
45+
},
46+
"runArgs": ["--privileged"]
47+
}

Diff for: .github/workflows/esp_idf.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: ESP-IDF build
2+
on:
3+
pull_request:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build_esp32:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v2
13+
with:
14+
submodules: 'recursive'
15+
- name: ESP-IDF v5.1.2 build esp32s3
16+
uses: espressif/esp-idf-ci-action@v1
17+
with:
18+
esp_idf_version: 5.1.2
19+
target: esp32s3
20+
command: 'idf.py set-target esp32s3 build'

Diff for: .github/workflows/platformio.yml

-29
This file was deleted.

Diff for: .gitignore

+64-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,65 @@
1+
.config
2+
*.o
3+
*.pyc
4+
5+
# gtags
6+
GTAGS
7+
GRTAGS
8+
GPATH
9+
10+
# emacs
11+
.dir-locals.el
12+
13+
# emacs temp file suffixes
14+
*~
15+
.#*
16+
\#*#
17+
18+
# eclipse setting
19+
.settings
20+
21+
# MacOS directory files
122
.DS_Store
2-
.pio
3-
.vscode/.browse.c_cpp.db*
4-
.vscode/c_cpp_properties.json
5-
.vscode/settings.json
6-
.vscode/launch.json
7-
.vscode/ipch
23+
24+
# cache dir
25+
.cache/
26+
27+
# Components Unit Test Apps files
28+
components/**/build/
29+
components/**/build_*_*/
30+
components/**/sdkconfig
31+
components/**/sdkconfig.old
32+
33+
# VS Code Settings
34+
.vscode
35+
36+
# VIM files
37+
*.swp
38+
*.swo
39+
40+
# Sublime Text files
41+
*.sublime-project
42+
*.sublime-workspace
43+
44+
# Clion IDE CMake build & config
45+
.idea/
46+
cmake-build-*/
47+
48+
# Results for the checking of the Python coding style and static analysis
49+
.mypy_cache
50+
flake8_output.txt
51+
52+
# ESP-IDF default build directory name
53+
build
54+
build_esp*_*
55+
sdkconfig
56+
sdkconfig.old
57+
58+
# managed_components for examples
59+
managed_components
60+
61+
# clang config (for LSP)
62+
.clangd
63+
64+
# Vale
65+
.vale/styles/*

Diff for: .gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "components/wolfssl"]
2+
path = components/wolfssl
3+
url = https://github.com/buglloc/wolfssl-idf.git
4+
[submodule "components/wolfssh"]
5+
path = components/wolfssh
6+
url = https://github.com/buglloc/wolfssh-idf.git

Diff for: .vscode/extensions.json

-10
This file was deleted.

Diff for: CMakeLists.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.5)
6+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
7+
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -DWOLFSSL_USER_SETTINGS")
8+
9+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
10+
project(BoundBoxESP)
11+
12+
idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE=1" APPEND)
13+
idf_build_set_property(COMPILE_OPTIONS "-I../hacks" APPEND)
14+
15+
# Display Compile Time Information
16+
message(STATUS "--------------Compile Info------------")
17+
message(STATUS "IDF_PATH = ${IDF_PATH}")
18+
message(STATUS "IDF_TARGET = ${IDF_TARGET}")
19+
message(STATUS "PROJECT_NAME = ${PROJECT_NAME}")
20+
message(STATUS "PROJECT_DIR = ${PROJECT_DIR}")
21+
message(STATUS "BUILD_DIR = ${BUILD_DIR}")
22+
message(STATUS "SDKCONFIG = ${SDKCONFIG}")
23+
message(STATUS "SDKCONFIG_DEFAULTS = ${SDKCONFIG_DEFAULTS}")
24+
message(STATUS "CONFIG_LV_CONF_SKIP = ${CONFIG_LV_CONF_SKIP}")
25+
#message(STATUS "COMPILE_OPTIONS = ${COMPILE_OPTIONS}")
26+
message(STATUS "---------------------------------------")
27+
message(STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
28+
message(STATUS "CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}")
29+
message(STATUS "---------------------------------------")

Diff for: README.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22

33
SSH/HMAC-based network boundary for secrets.
44

5+
**Disclaimer: Under development, anything can happen**
6+
7+
![](https://raw.githubusercontent.com/buglloc/BoundBoxESP/main/assets/cover_0.jpg)
8+
9+
![](https://raw.githubusercontent.com/buglloc/BoundBoxESP/main/assets/cover_1.jpg)
10+
11+
512
## How it works?
613
**TBD**

Diff for: assets/cover_0.jpg

120 KB
Loading

Diff for: assets/cover_0.orig.jpg

3.11 MB
Loading

Diff for: assets/cover_1.jpg

202 KB
Loading

Diff for: assets/cover_1.orig.jpg

3.01 MB
Loading

Diff for: components/blob/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
idf_component_register(
2+
SRCS
3+
"src/base64.cc"
4+
"src/hash.cc"
5+
"src/hex.cc"
6+
INCLUDE_DIRS
7+
"include"
8+
REQUIRES
9+
wolfssl
10+
)

Diff for: components/blob/include/blob/base64.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include "bytes.h"
4+
5+
namespace Blob
6+
{
7+
std::string Base64Encode(const Bytes& bytes);
8+
Bytes Base64Decode(const std::string_view b64);
9+
}

Diff for: components/blob/include/blob/bytes.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include <string>
4+
5+
namespace Blob
6+
{
7+
typedef std::basic_string<uint8_t> Bytes;
8+
}

Diff for: components/blob/include/blob/errors.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
namespace Blob
6+
{
7+
enum class Error: uint8_t
8+
{
9+
None = 0,
10+
Unsupported,
11+
InitFailed,
12+
InvalidKey,
13+
ShitHappens,
14+
};
15+
}

Diff for: components/blob/include/blob/hash.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#pragma once
2+
3+
#include <expected>
4+
5+
#include "wolfssl_init.h"
6+
#include <wolfssl/wolfcrypt/hmac.h>
7+
8+
#include "bytes.h"
9+
#include "errors.h"
10+
11+
namespace Blob
12+
{
13+
enum class HashType: uint8_t
14+
{
15+
None = 0,
16+
SHA1,
17+
SHA256,
18+
SHA512,
19+
};
20+
21+
struct HKDFConfig
22+
{
23+
const Blob::Bytes& Key;
24+
const Blob::Bytes& Salt;
25+
Blob::HashType HashType = HashType::SHA256;
26+
};
27+
28+
std::expected<Bytes, Error> HMACSum(const Blob::Bytes& key, const Blob::Bytes& msg, HashType hashType = HashType::SHA256);
29+
std::expected<Bytes, Error> HKDF(const Blob::Bytes& info, size_t outLen, const HKDFConfig& cfg);
30+
31+
class HMAC
32+
{
33+
public:
34+
explicit HMAC(const Blob::Bytes& key, HashType type = HashType::SHA256);
35+
Error Write(const Blob::Bytes& data);
36+
std::expected<Blob::Bytes, Error> Sum();
37+
38+
~HMAC();
39+
private:
40+
Error err = Error::None;
41+
Hmac ctx;
42+
};
43+
}

Diff for: components/blob/include/blob/hex.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <string>
4+
5+
#include "bytes.h"
6+
7+
8+
namespace Blob
9+
{
10+
std::string HexEncode(const Bytes& bytes);
11+
Bytes HexDecode(const std::string_view hex);
12+
}

Diff for: components/blob/include/blob/wolfssl_init.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* make sure this appears before any other wolfSSL headers */
2+
#include <wolfssl/wolfcrypt/settings.h>
3+
#include <user_settings.h>

0 commit comments

Comments
 (0)