Merge branch 'master' of https://github.com/wolfSSL/wolfssl into zd19378
This commit is contained in:
@@ -13,6 +13,7 @@ rsource "Kconfig.tls-generic"
|
||||
const uint8_t* hashIn, int hashSz)
|
||||
XMEMCPY(hash + (curveSz - hashSz), hashIn, hashSz);
|
||||
0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, /* creen would be i */
|
||||
0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, /* creen would be i */
|
||||
\pagenumbering{alph}
|
||||
DES3_KEY_SIZE = 24, /* 3 des ede */
|
||||
/* functions added to support above needed, removed TOOM and KARATSUBA */
|
||||
|
||||
108
.github/renode-test/stm32h753/CMakeLists.txt
vendored
Normal file
108
.github/renode-test/stm32h753/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(wolfcrypt_stm32h753 LANGUAGES C ASM)
|
||||
|
||||
set(WOLFSSL_ROOT "/opt/wolfssl" CACHE PATH "wolfSSL source")
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
enable_language(ASM)
|
||||
|
||||
# Include paths for CMSIS device headers and STM32 HAL
|
||||
# Order matters: CMSIS must come before HAL
|
||||
include_directories(BEFORE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
/opt/CMSIS_5/CMSIS/Core/Include # Core CMSIS (core_cm7.h, etc.) - must be first
|
||||
/opt/cmsis-device-h7/Include # Device-specific CMSIS (stm32h7xx.h)
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc
|
||||
)
|
||||
|
||||
# STM32 HAL source files (minimal set for CRYP and HASH)
|
||||
# Note: These files are cloned in the Dockerfile before CMake runs
|
||||
set(HAL_SRC_DIR /opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Src)
|
||||
|
||||
# Check if HAL directory exists, then add source files
|
||||
if(EXISTS ${HAL_SRC_DIR})
|
||||
set(HAL_SOURCES
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_rcc.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_rcc_ex.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_cortex.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_dma.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_dma_ex.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_rng.c
|
||||
# CRYP HAL files enabled for AES_GCM only
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_cryp.c
|
||||
${HAL_SRC_DIR}/stm32h7xx_hal_cryp_ex.c
|
||||
# HASH HAL files disabled - Renode doesn't implement HASH peripheral
|
||||
# ${HAL_SRC_DIR}/stm32h7xx_hal_hash.c
|
||||
# ${HAL_SRC_DIR}/stm32h7xx_hal_hash_ex.c
|
||||
)
|
||||
else()
|
||||
message(WARNING "HAL source directory not found: ${HAL_SRC_DIR}")
|
||||
set(HAL_SOURCES "")
|
||||
endif()
|
||||
|
||||
# wolfSSL build options
|
||||
set(WOLFSSL_USER_SETTINGS ON CACHE BOOL "Use user_settings.h")
|
||||
set(WOLFSSL_CRYPT_TESTS OFF CACHE BOOL "")
|
||||
set(WOLFSSL_EXAMPLES OFF CACHE BOOL "")
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
|
||||
|
||||
add_subdirectory(${WOLFSSL_ROOT} ${CMAKE_BINARY_DIR}/wolfssl-build EXCLUDE_FROM_ALL)
|
||||
target_include_directories(wolfssl PRIVATE
|
||||
/opt/CMSIS_5/CMSIS/Core/Include # Core CMSIS first
|
||||
/opt/cmsis-device-h7/Include # Device CMSIS
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc
|
||||
${CMAKE_SOURCE_DIR} # For stm32h7xx_hal_conf.h
|
||||
)
|
||||
# Suppress the GENSEED_FORTEST warning (expected for emulation/test builds)
|
||||
target_compile_options(wolfssl PRIVATE -Wno-cpp)
|
||||
|
||||
# wolfSSL STM32 port source file (needed for HASH and CRYPTO hardware acceleration)
|
||||
set(WOLFSSL_STM32_PORT_SRC ${WOLFSSL_ROOT}/wolfcrypt/src/port/st/stm32.c)
|
||||
|
||||
add_executable(wolfcrypt_test.elf
|
||||
startup_stm32h753.c
|
||||
main.c
|
||||
${WOLFSSL_ROOT}/wolfcrypt/test/test.c
|
||||
${HAL_SOURCES}
|
||||
${WOLFSSL_STM32_PORT_SRC}
|
||||
)
|
||||
|
||||
target_include_directories(wolfcrypt_test.elf PRIVATE
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${WOLFSSL_ROOT}
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc
|
||||
/opt/STM32CubeH7/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy
|
||||
)
|
||||
|
||||
target_compile_definitions(wolfcrypt_test.elf PRIVATE
|
||||
WOLFSSL_USER_SETTINGS
|
||||
STM32H753xx
|
||||
USE_HAL_DRIVER
|
||||
USE_HAL_CONF # Enable HAL configuration
|
||||
# NO_AES_CBC is defined in user_settings.h, no need to define it here
|
||||
)
|
||||
|
||||
# HAL source files need the same compile options and must include stdint.h
|
||||
# Disable all warnings for HAL files (third-party code we don't control)
|
||||
set_source_files_properties(${HAL_SOURCES} PROPERTIES
|
||||
COMPILE_FLAGS "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Os -include stdint.h -w"
|
||||
)
|
||||
|
||||
target_compile_options(wolfcrypt_test.elf PRIVATE
|
||||
-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard
|
||||
-ffunction-sections -fdata-sections -Os
|
||||
)
|
||||
|
||||
target_link_options(wolfcrypt_test.elf PRIVATE
|
||||
-T${CMAKE_SOURCE_DIR}/stm32h753.ld
|
||||
-Wl,--gc-sections
|
||||
-nostartfiles
|
||||
-specs=nano.specs
|
||||
-specs=nosys.specs
|
||||
)
|
||||
|
||||
target_link_libraries(wolfcrypt_test.elf PRIVATE wolfssl m c gcc nosys)
|
||||
|
||||
194
.github/renode-test/stm32h753/entrypoint.sh
vendored
Executable file
194
.github/renode-test/stm32h753/entrypoint.sh
vendored
Executable file
@@ -0,0 +1,194 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
LOG=/tmp/wolfcrypt-renode.log
|
||||
TIMEOUT=300 # Maximum 5 minutes
|
||||
|
||||
echo "Running wolfCrypt test in Renode..."
|
||||
|
||||
# Try to find Renode binary in common installation locations
|
||||
# When installed via .deb package, Renode is typically in /usr/bin/renode
|
||||
RENODE_BIN="${RENODE_BIN:-$(command -v renode 2>/dev/null || true)}"
|
||||
if [ -z "$RENODE_BIN" ]; then
|
||||
# Check common installation paths (order matters - check standard locations first)
|
||||
for path in /usr/bin/renode /usr/local/bin/renode /opt/renode/renode; do
|
||||
if [ -x "$path" ]; then
|
||||
RENODE_BIN="$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -z "$RENODE_BIN" ] || [ ! -x "$RENODE_BIN" ]; then
|
||||
echo "Renode binary not found in image."
|
||||
echo "Checked paths: /usr/bin/renode, /usr/local/bin/renode, /opt/renode/renode"
|
||||
echo "PATH: $PATH"
|
||||
which renode || echo "renode not in PATH"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "Using Renode binary: $RENODE_BIN"
|
||||
|
||||
# Determine Renode root directory (where platforms/ directory is located)
|
||||
if [ -d "/opt/renode/platforms" ]; then
|
||||
RENODE_ROOT="/opt/renode"
|
||||
elif [ -d "/usr/lib/renode/platforms" ]; then
|
||||
RENODE_ROOT="/usr/lib/renode"
|
||||
elif [ -d "/usr/share/renode/platforms" ]; then
|
||||
RENODE_ROOT="/usr/share/renode"
|
||||
else
|
||||
# Try to find Renode root by checking where the binary is
|
||||
RENODE_DIR=$(dirname "$(readlink -f "${RENODE_BIN}" 2>/dev/null || echo "${RENODE_BIN}")")
|
||||
if [ -d "${RENODE_DIR}/../platforms" ]; then
|
||||
RENODE_ROOT=$(readlink -f "${RENODE_DIR}/.." 2>/dev/null || echo "${RENODE_DIR}/..")
|
||||
else
|
||||
echo "Warning: Could not determine Renode root directory"
|
||||
RENODE_ROOT=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# Set RENODE_ROOT environment variable (Renode uses this to find platform files)
|
||||
if [ -n "$RENODE_ROOT" ]; then
|
||||
export RENODE_ROOT
|
||||
echo "Using Renode root: ${RENODE_ROOT}"
|
||||
# Also create .renode-root file in firmware directory as backup
|
||||
echo "${RENODE_ROOT}" > /opt/firmware/.renode-root
|
||||
chmod 644 /opt/firmware/.renode-root
|
||||
else
|
||||
echo "ERROR: Could not determine Renode root directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify platform file exists
|
||||
PLATFORM_FILE="${RENODE_ROOT}/platforms/cpus/stm32h753.repl"
|
||||
if [ ! -f "${PLATFORM_FILE}" ]; then
|
||||
echo "ERROR: Platform file not found at ${PLATFORM_FILE}"
|
||||
echo "Searching for platform files..."
|
||||
find "${RENODE_ROOT}" -name "stm32h753.repl" 2>/dev/null | head -5 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Platform file found at: ${PLATFORM_FILE}"
|
||||
|
||||
# Change to firmware directory
|
||||
cd /opt/firmware
|
||||
|
||||
# Create a modified Renode script with absolute path to platform file
|
||||
# This avoids the .renode-root file lookup issue
|
||||
cat > /opt/firmware/run-renode-absolute.resc <<EOF
|
||||
# Renode test script for STM32H753 (with absolute platform path)
|
||||
using sysbus
|
||||
|
||||
mach create "stm32h753"
|
||||
|
||||
# Use absolute path to platform file to avoid .renode-root lookup issues
|
||||
machine LoadPlatformDescription @${PLATFORM_FILE}
|
||||
|
||||
sysbus LoadELF @/opt/firmware/wolfcrypt_test.elf
|
||||
|
||||
# Connect USART3 to the console for wolfCrypt output
|
||||
showAnalyzer usart3
|
||||
|
||||
# Start emulation and run for a long time
|
||||
# The entrypoint script will kill Renode when test completes
|
||||
emulation RunFor "600s"
|
||||
EOF
|
||||
|
||||
# Start Renode in background, output to log (unbuffered)
|
||||
# Use the modified script with absolute path
|
||||
echo "Starting Renode with command: ${RENODE_BIN} --disable-xwt --console -e \"i @/opt/firmware/run-renode-absolute.resc\""
|
||||
stdbuf -oL -eL "${RENODE_BIN}" --disable-xwt --console -e "i @/opt/firmware/run-renode-absolute.resc" > "${LOG}" 2>&1 &
|
||||
RENODE_PID=$!
|
||||
echo "Renode PID: $RENODE_PID"
|
||||
|
||||
# Monitor the log for completion, errors, and flush output frequently
|
||||
START_TIME=$(date +%s)
|
||||
RESULT=""
|
||||
LAST_LOG_SIZE=0
|
||||
|
||||
while true; do
|
||||
# Check if Renode is still running
|
||||
if ! kill -0 "$RENODE_PID" 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
|
||||
# Flush new log content to stdout (unbuffered)
|
||||
if [ -f "${LOG}" ]; then
|
||||
CURRENT_LOG_SIZE=$(stat -f%z "${LOG}" 2>/dev/null || stat -c%s "${LOG}" 2>/dev/null || echo 0)
|
||||
if [ "$CURRENT_LOG_SIZE" -gt "$LAST_LOG_SIZE" ]; then
|
||||
# Output new lines
|
||||
tail -c +$((LAST_LOG_SIZE + 1)) "${LOG}" 2>/dev/null | head -c $((CURRENT_LOG_SIZE - LAST_LOG_SIZE))
|
||||
LAST_LOG_SIZE=$CURRENT_LOG_SIZE
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for Renode errors (must check before completion to catch errors early)
|
||||
if grep -q "\[ERROR\]" "${LOG}" 2>/dev/null; then
|
||||
echo ""
|
||||
echo "ERROR: Renode reported an error!"
|
||||
RESULT="renode_error"
|
||||
break
|
||||
fi
|
||||
|
||||
# Check for completion messages
|
||||
if grep -q "=== wolfCrypt test passed! ===" "${LOG}" 2>/dev/null; then
|
||||
RESULT="passed"
|
||||
break
|
||||
fi
|
||||
|
||||
if grep -q "=== wolfCrypt test FAILED ===" "${LOG}" 2>/dev/null; then
|
||||
RESULT="failed"
|
||||
break
|
||||
fi
|
||||
|
||||
# Check timeout
|
||||
CURRENT_TIME=$(date +%s)
|
||||
ELAPSED=$((CURRENT_TIME - START_TIME))
|
||||
if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
|
||||
echo ""
|
||||
echo "Timeout after ${TIMEOUT} seconds"
|
||||
RESULT="timeout"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
# Kill Renode if still running
|
||||
if kill -0 "$RENODE_PID" 2>/dev/null; then
|
||||
kill "$RENODE_PID" 2>/dev/null || true
|
||||
wait "$RENODE_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Show the log output
|
||||
cat "${LOG}"
|
||||
|
||||
# Report result
|
||||
case "$RESULT" in
|
||||
passed)
|
||||
echo ""
|
||||
echo "wolfCrypt tests completed successfully."
|
||||
exit 0
|
||||
;;
|
||||
failed)
|
||||
echo ""
|
||||
echo "wolfCrypt tests FAILED."
|
||||
exit 1
|
||||
;;
|
||||
renode_error)
|
||||
echo ""
|
||||
echo "Renode reported an error - test aborted."
|
||||
exit 1
|
||||
;;
|
||||
timeout)
|
||||
echo ""
|
||||
echo "wolfCrypt tests timed out after ${TIMEOUT} seconds."
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
echo "wolfCrypt tests did not report a result."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
137
.github/renode-test/stm32h753/main.c
vendored
Normal file
137
.github/renode-test/stm32h753/main.c
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
/* main.c - Entry point for wolfCrypt test on STM32H753 under Renode
|
||||
*
|
||||
* Runs the wolfCrypt test suite with output via USART3.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* wolfCrypt test entry point */
|
||||
extern int wolfcrypt_test(void *args);
|
||||
|
||||
/* USART3 registers (STM32H7) */
|
||||
#define USART3_BASE 0x40004800UL
|
||||
#define USART3_CR1 (*(volatile uint32_t *)(USART3_BASE + 0x00))
|
||||
#define USART3_BRR (*(volatile uint32_t *)(USART3_BASE + 0x0C))
|
||||
#define USART3_ISR (*(volatile uint32_t *)(USART3_BASE + 0x1C))
|
||||
#define USART3_TDR (*(volatile uint32_t *)(USART3_BASE + 0x28))
|
||||
|
||||
#define USART_CR1_UE (1 << 0)
|
||||
#define USART_CR1_TE (1 << 3)
|
||||
#define USART_ISR_TXE (1 << 7)
|
||||
|
||||
/* RCC registers for enabling USART3 clock */
|
||||
#define RCC_BASE 0x58024400UL
|
||||
#define RCC_APB1LENR (*(volatile uint32_t *)(RCC_BASE + 0xE8))
|
||||
#define RCC_APB1LENR_USART3EN (1 << 18)
|
||||
|
||||
static void uart_init(void)
|
||||
{
|
||||
/* Enable USART3 clock */
|
||||
RCC_APB1LENR |= RCC_APB1LENR_USART3EN;
|
||||
|
||||
/* Configure USART3: 115200 baud at 64MHz HSI */
|
||||
USART3_BRR = 64000000 / 115200;
|
||||
USART3_CR1 = USART_CR1_UE | USART_CR1_TE;
|
||||
}
|
||||
|
||||
static void uart_putc(char c)
|
||||
{
|
||||
while (!(USART3_ISR & USART_ISR_TXE))
|
||||
;
|
||||
USART3_TDR = c;
|
||||
}
|
||||
|
||||
static void uart_puts(const char *s)
|
||||
{
|
||||
while (*s) {
|
||||
if (*s == '\n')
|
||||
uart_putc('\r');
|
||||
uart_putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
/* newlib _write syscall - redirects printf to UART */
|
||||
int _write(int fd, const char *buf, int len)
|
||||
{
|
||||
(void)fd;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (buf[i] == '\n')
|
||||
uart_putc('\r');
|
||||
uart_putc(buf[i]);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/* Heap management for malloc - required by printf with format strings */
|
||||
extern char __heap_start__;
|
||||
extern char __heap_end__;
|
||||
|
||||
void *_sbrk(ptrdiff_t incr)
|
||||
{
|
||||
static char *heap_ptr = NULL;
|
||||
char *prev_heap_ptr;
|
||||
|
||||
if (heap_ptr == NULL) {
|
||||
heap_ptr = &__heap_start__;
|
||||
}
|
||||
|
||||
prev_heap_ptr = heap_ptr;
|
||||
|
||||
if (heap_ptr + incr > &__heap_end__) {
|
||||
/* Out of heap memory */
|
||||
return (void *)-1;
|
||||
}
|
||||
|
||||
heap_ptr += incr;
|
||||
return prev_heap_ptr;
|
||||
}
|
||||
|
||||
/* Simple counter for time - used by GENSEED_FORTEST */
|
||||
static volatile uint32_t tick_counter = 0;
|
||||
|
||||
/* time() stub for wolfSSL GENSEED_FORTEST */
|
||||
#include <time.h>
|
||||
time_t time(time_t *t)
|
||||
{
|
||||
tick_counter += 12345; /* Simple pseudo-random increment */
|
||||
time_t val = (time_t)tick_counter;
|
||||
if (t)
|
||||
*t = val;
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Result variable - can be monitored by Renode at fixed address */
|
||||
volatile int test_result __attribute__((section(".data"))) = -1;
|
||||
volatile int test_complete __attribute__((section(".data"))) = 0;
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
uart_init();
|
||||
uart_puts("\n\n=== Starting wolfCrypt test ===\n\n");
|
||||
|
||||
test_result = wolfcrypt_test(NULL);
|
||||
test_complete = 1;
|
||||
|
||||
if (test_result == 0) {
|
||||
uart_puts("\n\n=== wolfCrypt test passed! ===\n");
|
||||
} else {
|
||||
uart_puts("\n\n=== wolfCrypt test FAILED ===\n");
|
||||
}
|
||||
|
||||
/* Spin forever after the test completes */
|
||||
while (1) {
|
||||
__asm__ volatile ("wfi");
|
||||
}
|
||||
|
||||
return test_result;
|
||||
}
|
||||
|
||||
20
.github/renode-test/stm32h753/run-renode.resc
vendored
Normal file
20
.github/renode-test/stm32h753/run-renode.resc
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# Renode test script for STM32H753
|
||||
# Note: @platforms/cpus/stm32h753.repl is relative to Renode root
|
||||
# If RENODE_ROOT is set, Renode will use it; otherwise it looks for .renode-root file
|
||||
using sysbus
|
||||
|
||||
mach create "stm32h753"
|
||||
|
||||
# Try relative path first (works if RENODE_ROOT or .renode-root is set correctly)
|
||||
# If this fails, the absolute path will be tried in entrypoint.sh
|
||||
machine LoadPlatformDescription @platforms/cpus/stm32h753.repl
|
||||
|
||||
sysbus LoadELF @/opt/firmware/wolfcrypt_test.elf
|
||||
|
||||
# Connect USART3 to the console for wolfCrypt output
|
||||
showAnalyzer usart3
|
||||
|
||||
# Start emulation and run for a long time
|
||||
# The entrypoint script will kill Renode when test completes
|
||||
emulation RunFor "600s"
|
||||
|
||||
101
.github/renode-test/stm32h753/startup_stm32h753.c
vendored
Normal file
101
.github/renode-test/stm32h753/startup_stm32h753.c
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/* Minimal startup code for STM32H753 running under Renode */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern int main(int argc, char** argv);
|
||||
|
||||
void Default_Handler(void);
|
||||
void Reset_Handler(void);
|
||||
|
||||
/* Symbols provided by the linker script */
|
||||
extern unsigned long _estack;
|
||||
extern unsigned long __data_start__;
|
||||
extern unsigned long __data_end__;
|
||||
extern unsigned long __bss_start__;
|
||||
extern unsigned long __bss_end__;
|
||||
extern unsigned long _sidata; /* start of .data in flash */
|
||||
|
||||
/* Minimal init_array support */
|
||||
extern void (*__preinit_array_start[])(void);
|
||||
extern void (*__preinit_array_end[])(void);
|
||||
extern void (*__init_array_start[])(void);
|
||||
extern void (*__init_array_end[])(void);
|
||||
|
||||
static void call_init_array(void)
|
||||
{
|
||||
size_t count, i;
|
||||
|
||||
count = __preinit_array_end - __preinit_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__preinit_array_start[i]();
|
||||
|
||||
count = __init_array_end - __init_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__init_array_start[i]();
|
||||
}
|
||||
|
||||
void Reset_Handler(void)
|
||||
{
|
||||
unsigned long *src, *dst;
|
||||
|
||||
/* Copy .data from flash to RAM */
|
||||
src = &_sidata;
|
||||
for (dst = &__data_start__; dst < &__data_end__;)
|
||||
*dst++ = *src++;
|
||||
|
||||
/* Zero .bss */
|
||||
for (dst = &__bss_start__; dst < &__bss_end__;)
|
||||
*dst++ = 0;
|
||||
|
||||
/* Call static constructors */
|
||||
call_init_array();
|
||||
|
||||
/* Call main */
|
||||
(void)main(0, (char**)0);
|
||||
|
||||
/* Infinite loop after main returns */
|
||||
while (1) {
|
||||
__asm__ volatile ("wfi");
|
||||
}
|
||||
}
|
||||
|
||||
void Default_Handler(void)
|
||||
{
|
||||
while (1) {
|
||||
__asm__ volatile ("wfi");
|
||||
}
|
||||
}
|
||||
|
||||
/* Exception handlers - all weak aliases to Default_Handler */
|
||||
void NMI_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void HardFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void MemManage_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void BusFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void UsageFault_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void SVC_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void DebugMon_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void PendSV_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
void SysTick_Handler(void) __attribute__((weak, alias("Default_Handler")));
|
||||
|
||||
/* Vector table */
|
||||
__attribute__ ((section(".isr_vector"), used))
|
||||
void (* const g_pfnVectors[])(void) = {
|
||||
(void (*)(void))(&_estack), /* Initial stack pointer */
|
||||
Reset_Handler, /* Reset Handler */
|
||||
NMI_Handler, /* NMI Handler */
|
||||
HardFault_Handler, /* Hard Fault Handler */
|
||||
MemManage_Handler, /* MPU Fault Handler */
|
||||
BusFault_Handler, /* Bus Fault Handler */
|
||||
UsageFault_Handler, /* Usage Fault Handler */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
0, /* Reserved */
|
||||
SVC_Handler, /* SVCall Handler */
|
||||
DebugMon_Handler, /* Debug Monitor Handler */
|
||||
0, /* Reserved */
|
||||
PendSV_Handler, /* PendSV Handler */
|
||||
SysTick_Handler /* SysTick Handler */
|
||||
/* IRQ vectors would continue here */
|
||||
};
|
||||
109
.github/renode-test/stm32h753/stm32h753.ld
vendored
Normal file
109
.github/renode-test/stm32h753/stm32h753.ld
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/* Minimal STM32H753 memory map for Renode run */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
|
||||
DTCM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
|
||||
}
|
||||
|
||||
_estack = ORIGIN(RAM) + LENGTH(RAM);
|
||||
_Min_Heap_Size = 128K;
|
||||
_Min_Stack_Size = 128K;
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector))
|
||||
. = ALIGN(4);
|
||||
} > FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.eh_frame)
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN(__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array*))
|
||||
PROVIDE_HIDDEN(__preinit_array_end = .);
|
||||
} > FLASH
|
||||
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN(__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array*))
|
||||
PROVIDE_HIDDEN(__init_array_end = .);
|
||||
} > FLASH
|
||||
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array*))
|
||||
PROVIDE_HIDDEN(__fini_array_end = .);
|
||||
} > FLASH
|
||||
|
||||
/* Location in flash where .data will be stored */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__data_start__ = .;
|
||||
*(.data*)
|
||||
. = ALIGN(4);
|
||||
__data_end__ = .;
|
||||
} > RAM AT> FLASH
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} > RAM
|
||||
|
||||
.heap_stack (NOLOAD):
|
||||
{
|
||||
. = ALIGN(8);
|
||||
PROVIDE(__heap_start__ = .);
|
||||
. = . + _Min_Heap_Size;
|
||||
PROVIDE(__heap_end__ = .);
|
||||
PROVIDE(end = __heap_end__);
|
||||
. = ALIGN(8);
|
||||
PROVIDE(__stack_start__ = .);
|
||||
. = . + _Min_Stack_Size;
|
||||
PROVIDE(__stack_end__ = .);
|
||||
} > RAM
|
||||
}
|
||||
|
||||
PROVIDE(_init = 0);
|
||||
PROVIDE(_fini = 0);
|
||||
|
||||
208
.github/renode-test/stm32h753/stm32h7xx_hal_conf.h
vendored
Normal file
208
.github/renode-test/stm32h753/stm32h7xx_hal_conf.h
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
/* Minimal HAL configuration for STM32H753 wolfCrypt build under Renode.
|
||||
* RNG and CRYP HAL are enabled. CRYP is used for AES_GCM only (other AES modes disabled).
|
||||
* HASH is disabled as Renode doesn't implement it.
|
||||
*/
|
||||
|
||||
#ifndef STM32H7xx_HAL_CONF_H
|
||||
#define STM32H7xx_HAL_CONF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------- Module Selection ----------------------------- */
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_CORTEX_MODULE_ENABLED
|
||||
#define HAL_RCC_MODULE_ENABLED
|
||||
#define HAL_GPIO_MODULE_ENABLED
|
||||
#define HAL_RNG_MODULE_ENABLED
|
||||
#define HAL_CRYP_MODULE_ENABLED /* Enabled for AES_GCM only */
|
||||
/* #define HAL_HASH_MODULE_ENABLED */ /* Disabled - Renode doesn't implement HASH */
|
||||
#define HAL_DMA_MODULE_ENABLED
|
||||
#define HAL_FLASH_MODULE_ENABLED
|
||||
#define HAL_PWR_MODULE_ENABLED
|
||||
#define HAL_EXTI_MODULE_ENABLED
|
||||
|
||||
/* Disabled modules (explicit for clarity) */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
|
||||
/* ------------------------- Oscillator Values ---------------------------- */
|
||||
#if !defined(HSE_VALUE)
|
||||
#define HSE_VALUE 25000000UL /* External oscillator frequency in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(HSE_STARTUP_TIMEOUT)
|
||||
#define HSE_STARTUP_TIMEOUT 100UL /* Time out for HSE start up in ms */
|
||||
#endif
|
||||
|
||||
#if !defined(CSI_VALUE)
|
||||
#define CSI_VALUE 4000000UL /* Internal oscillator CSI in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(HSI_VALUE)
|
||||
#define HSI_VALUE 64000000UL /* Internal oscillator HSI in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(HSI48_VALUE)
|
||||
#define HSI48_VALUE 48000000UL /* Value of the Internal High Speed oscillator for USB in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(LSE_VALUE)
|
||||
#define LSE_VALUE 32768UL /* External low speed oscillator in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT 5000UL /* Time out for LSE start up in ms */
|
||||
#endif
|
||||
|
||||
#if !defined(LSI_VALUE)
|
||||
#define LSI_VALUE 32000UL /* Internal low speed oscillator in Hz */
|
||||
#endif
|
||||
|
||||
#if !defined(EXTERNAL_CLOCK_VALUE)
|
||||
#define EXTERNAL_CLOCK_VALUE 12288000UL /* External audio clock in Hz */
|
||||
#endif
|
||||
|
||||
/* ------------------------- System Configuration -------------------------- */
|
||||
#define VDD_VALUE 3300UL /* Value of VDD in mV */
|
||||
#define TICK_INT_PRIORITY 0x0FUL /* Tick interrupt priority */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 0U
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_COMP_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DMA_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_DTS_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_JPEG_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_MDIOS_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_OTFDEC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_PSSI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SD_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_UART_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_USART_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U
|
||||
#define USE_HAL_XSPI_REGISTER_CALLBACKS 0U
|
||||
|
||||
/* ------------------------- SPI peripheral configuration ------------------ */
|
||||
#define USE_SPI_CRC 0U
|
||||
|
||||
/* ------------------------- Assertion ------------------------------------- */
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
#define assert_param(expr) ((void)0U)
|
||||
|
||||
/* ------------------------- Ethernet Configuration ------------------------ */
|
||||
#define ETH_TX_DESC_CNT 4U
|
||||
#define ETH_RX_DESC_CNT 4U
|
||||
#define ETH_MAC_ADDR0 0x02U
|
||||
#define ETH_MAC_ADDR1 0x00U
|
||||
#define ETH_MAC_ADDR2 0x00U
|
||||
#define ETH_MAC_ADDR3 0x00U
|
||||
#define ETH_MAC_ADDR4 0x00U
|
||||
#define ETH_MAC_ADDR5 0x00U
|
||||
|
||||
/* ------------------------- Include HAL headers --------------------------- */
|
||||
/**
|
||||
* @brief Include module's header file
|
||||
*/
|
||||
|
||||
#ifdef HAL_RCC_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_rcc.h"
|
||||
#endif /* HAL_RCC_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_GPIO_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_gpio.h"
|
||||
#endif /* HAL_GPIO_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_DMA_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_dma.h"
|
||||
#endif /* HAL_DMA_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_CORTEX_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_cortex.h"
|
||||
#endif /* HAL_CORTEX_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_EXTI_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_exti.h"
|
||||
#endif /* HAL_EXTI_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_FLASH_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_flash.h"
|
||||
#endif /* HAL_FLASH_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_PWR_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_pwr.h"
|
||||
#endif /* HAL_PWR_MODULE_ENABLED */
|
||||
|
||||
#ifdef HAL_RNG_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_rng.h"
|
||||
#endif /* HAL_RNG_MODULE_ENABLED */
|
||||
|
||||
/* CRYP enabled for AES_GCM only */
|
||||
#ifdef HAL_CRYP_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_cryp.h"
|
||||
#endif
|
||||
|
||||
/* #ifdef HAL_HASH_MODULE_ENABLED
|
||||
#include "stm32h7xx_hal_hash.h"
|
||||
#endif */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr: If expr is false, it calls assert_failed function
|
||||
* which reports the name of the source file and the source
|
||||
* line number of the call that failed.
|
||||
* If expr is true, it returns no value.
|
||||
* @retval None
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void assert_failed(uint8_t *file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0U)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STM32H7xx_HAL_CONF_H */
|
||||
|
||||
24
.github/renode-test/stm32h753/toolchain-arm-none-eabi.cmake
vendored
Normal file
24
.github/renode-test/stm32h753/toolchain-arm-none-eabi.cmake
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
|
||||
|
||||
set(CMAKE_AR arm-none-eabi-ar)
|
||||
set(CMAKE_RANLIB arm-none-eabi-ranlib)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
set(CPU_FLAGS "-mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard")
|
||||
set(OPT_FLAGS "-Os -ffunction-sections -fdata-sections")
|
||||
set(CMSIS_INCLUDES "-I/opt/cmsis-device-h7/Include -I/opt/CMSIS_5/CMSIS/Core/Include -I/opt/firmware")
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "${CPU_FLAGS} ${OPT_FLAGS} ${CMSIS_INCLUDES} -DSTM32H753xx")
|
||||
set(CMAKE_CXX_FLAGS_INIT "${CPU_FLAGS} ${OPT_FLAGS} ${CMSIS_INCLUDES} -DSTM32H753xx")
|
||||
set(CMAKE_ASM_FLAGS_INIT "${CPU_FLAGS}")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--gc-sections -static")
|
||||
|
||||
95
.github/renode-test/stm32h753/user_settings.h
vendored
Normal file
95
.github/renode-test/stm32h753/user_settings.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/* user_settings_renode.h - wolfSSL/wolfCrypt configuration for STM32H753 under Renode
|
||||
*
|
||||
* Minimal, semihosting-friendly build for Cortex-M7 / STM32H753.
|
||||
* Hardware RNG and CRYPTO (AES-GCM only) are enabled via Renode's STM32H753 emulation.
|
||||
* HASH is disabled as Renode doesn't implement the HASH peripheral.
|
||||
*/
|
||||
|
||||
#ifndef USER_SETTINGS_RENODE_H
|
||||
#define USER_SETTINGS_RENODE_H
|
||||
|
||||
/* ------------------------- Platform ------------------------------------- */
|
||||
#define WOLFSSL_ARM_CORTEX_M
|
||||
#define WOLFSSL_STM32H7 /* STM32H7 series (includes H753) */
|
||||
#define WOLFSSL_STM32_CUBEMX /* Use STM32 HAL for CRYPTO */
|
||||
/* NO_STM32_CRYPTO is NOT defined, so CRYPTO will be enabled */
|
||||
/* Disable HASH - Renode doesn't implement HASH peripheral */
|
||||
#define NO_STM32_HASH
|
||||
|
||||
/* Required for consistent math library settings (CTC_SETTINGS) */
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
|
||||
/* ------------------------- Threading / OS ------------------------------- */
|
||||
#define SINGLE_THREADED
|
||||
|
||||
/* ------------------------- Filesystem / I/O ----------------------------- */
|
||||
#define WOLFSSL_NO_CURRDIR
|
||||
#define NO_FILESYSTEM
|
||||
#define NO_WRITEV
|
||||
|
||||
/* ------------------------- wolfCrypt Only ------------------------------- */
|
||||
#define WOLFCRYPT_ONLY
|
||||
#define NO_DH
|
||||
#define NO_DSA
|
||||
/* Disable DES/3DES - Renode CRYPTO only supports AES_GCM */
|
||||
#define NO_DES
|
||||
#define NO_DES3
|
||||
|
||||
/* ------------------------- AES Mode Configuration ----------------------- */
|
||||
/* Disable all AES modes except GCM - Renode CRYPTO only supports AES_GCM */
|
||||
/* NO_AES_CBC prevents HAVE_AES_CBC from being defined in settings.h */
|
||||
#define NO_AES_CBC
|
||||
|
||||
/* ------------------------- RNG Configuration ---------------------------- */
|
||||
/* Enable STM32 hardware RNG (emulated by Renode) using direct register access */
|
||||
#define WOLFSSL_STM32_RNG_NOLIB
|
||||
/* NO_STM32_RNG is NOT defined, so STM32_RNG will be auto-enabled */
|
||||
#define NO_DEV_RANDOM
|
||||
#define HAVE_HASHDRBG
|
||||
|
||||
/* ------------------------- Math Library --------------------------------- */
|
||||
/* Use SP Math (Single Precision) - modern, efficient, and secure */
|
||||
#define WOLFSSL_SP_MATH_ALL
|
||||
#define WOLFSSL_HAVE_SP_RSA
|
||||
#define WOLFSSL_HAVE_SP_DH
|
||||
#define WOLFSSL_HAVE_SP_ECC
|
||||
#define WOLFSSL_SP_ARM_CORTEX_M_ASM
|
||||
#define SP_WORD_SIZE 32
|
||||
|
||||
/* ------------------------- Crypto Hardening ----------------------------- */
|
||||
#define WC_RSA_BLINDING
|
||||
#define ECC_TIMING_RESISTANT
|
||||
|
||||
/* ------------------------- Size Optimization ---------------------------- */
|
||||
#define WOLFSSL_SMALL_STACK
|
||||
|
||||
/* ------------------------- Test Configuration --------------------------- */
|
||||
/* Use smaller key sizes for faster test runs in emulation */
|
||||
#define BENCH_EMBEDDED
|
||||
|
||||
/* Use our own main() instead of the one in test.c */
|
||||
#define NO_MAIN_DRIVER
|
||||
|
||||
/* ------------------------- Post-options.h cleanup ----------------------- */
|
||||
/* Ensure unsupported AES modes stay disabled even after options.h processing */
|
||||
/* These undefs will be processed after options.h includes, preventing
|
||||
* Renode-unsupported modes from being used */
|
||||
#ifdef HAVE_AES_CBC
|
||||
#undef HAVE_AES_CBC
|
||||
#endif
|
||||
#ifdef HAVE_AES_ECB
|
||||
#undef HAVE_AES_ECB
|
||||
#endif
|
||||
#ifdef HAVE_AES_CTR
|
||||
#undef HAVE_AES_CTR
|
||||
#endif
|
||||
#ifdef HAVE_AES_CFB
|
||||
#undef HAVE_AES_CFB
|
||||
#endif
|
||||
#ifdef HAVE_AES_OFB
|
||||
#undef HAVE_AES_OFB
|
||||
#endif
|
||||
|
||||
#endif /* USER_SETTINGS_RENODE_H */
|
||||
|
||||
51
.github/workflows/arduino.yml
vendored
51
.github/workflows/arduino.yml
vendored
@@ -59,7 +59,7 @@ on:
|
||||
pull_request:
|
||||
branches: [ '**' ]
|
||||
paths:
|
||||
- 'github/workflows/arduino.yml'
|
||||
- '.github/workflows/arduino.yml'
|
||||
- 'IDE/ARDUINO/**'
|
||||
- 'src/**'
|
||||
- 'wolfcrypt/**'
|
||||
@@ -122,6 +122,15 @@ jobs:
|
||||
REPO_OWNER: ${{ github.repository_owner }}
|
||||
|
||||
steps:
|
||||
- name: Free disk space
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet
|
||||
sudo rm -rf /usr/local/lib/android
|
||||
sudo rm -rf /opt/ghc
|
||||
sudo rm -rf /opt/hostedtoolcache/CodeQL
|
||||
sudo apt-get clean
|
||||
df -h
|
||||
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -248,7 +257,8 @@ jobs:
|
||||
path: |
|
||||
~/.arduino15
|
||||
~/.cache/arduino
|
||||
~/.arduino15/staging
|
||||
# Exclude staging directory from cache to save space
|
||||
!~/.arduino15/staging
|
||||
|
||||
# Arduino libraries
|
||||
# Specific to Arduino CI Build (2 of 4) Arduinbo Release wolfSSL for Local Examples
|
||||
@@ -405,6 +415,9 @@ jobs:
|
||||
WOLFSSL_EXAMPLES_DIRECTORY="$ARDUINO_ROOT/wolfssl/examples"
|
||||
echo "WOLFSSL_EXAMPLES_DIRECTORY: $WOLFSSL_EXAMPLES_DIRECTORY"
|
||||
|
||||
# Limit the number of jobs to 1 to avoid running out of memory
|
||||
export ARDUINO_CLI_MAX_JOBS=1
|
||||
|
||||
echo "Change directory to Arduino examples..."
|
||||
pushd "$WOLFSSL_EXAMPLES_DIRECTORY"
|
||||
chmod +x ./compile-all-examples.sh
|
||||
@@ -416,3 +429,37 @@ jobs:
|
||||
bash ./compile-all-examples.sh ./board_list.txt "${{ matrix.fqbn }}"
|
||||
popd
|
||||
# End Compile Arduino Sketches for Various Boards
|
||||
|
||||
- name: Cleanup to Save Disk Space
|
||||
if: always()
|
||||
run: |
|
||||
echo "Disk usage before cleanup:"
|
||||
df -h
|
||||
echo ""
|
||||
echo "Cleaning up build artifacts and temporary files..."
|
||||
|
||||
# Clean up Arduino build artifacts
|
||||
find ~/Arduino -name "*.hex" -delete 2>/dev/null || true
|
||||
find ~/Arduino -name "*.elf" -delete 2>/dev/null || true
|
||||
find ~/Arduino -name "*.bin" -delete 2>/dev/null || true
|
||||
find ~/Arduino -name "build" -type d -exec rm -rf {} + 2>/dev/null || true
|
||||
|
||||
rm -rf ~/.arduino15/packages/esp32/tools || true
|
||||
rm -rf ~/.arduino15/packages/esp32/hardware || true
|
||||
rm -rf ~/.espressif || true
|
||||
|
||||
# Clean up staging directories
|
||||
rm -rf ~/.arduino15/staging/* || true
|
||||
rm -rf ~/.cache/arduino/* || true
|
||||
|
||||
# Clean up git clone of wolfssl-examples
|
||||
GITHUB_WORK=$(realpath "$GITHUB_WORKSPACE/../..")
|
||||
rm -rf "$GITHUB_WORK/wolfssl-examples-publish" || true
|
||||
|
||||
# Clean up any temporary files in workspace
|
||||
find "$GITHUB_WORKSPACE" -name "*.o" -delete 2>/dev/null || true
|
||||
find "$GITHUB_WORKSPACE" -name "*.a" -delete 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "Disk usage after cleanup:"
|
||||
df -h
|
||||
|
||||
2
.github/workflows/async.yml
vendored
2
.github/workflows/async.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
4
.github/workflows/bind.yml
vendored
4
.github/workflows/bind.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 9.18.0, 9.18.28, 9.18.33 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/codespell.yml
vendored
4
.github/workflows/codespell.yml
vendored
@@ -14,7 +14,7 @@ concurrency:
|
||||
jobs:
|
||||
codespell:
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
check_filenames: true
|
||||
check_hidden: true
|
||||
# Add comma separated list of words that occur multiple times that should be ignored (sorted alphabetically, case sensitive)
|
||||
ignore_words_list: adin,aNULL,brunch,carryIn,chainG,ciph,cLen,cliKs,dout,haveA,inCreated,inOut,inout,larg,LEAPYEAR,Merget,optionA,parm,parms,repid,rIn,userA,ser,siz,te,Te,
|
||||
ignore_words_list: adin,aNULL,brunch,carryIn,chainG,ciph,cLen,cliKs,dout,haveA,inCreated,inOut,inout,larg,LEAPYEAR,Merget,optionA,parm,parms,repid,rIn,userA,ser,siz,te,Te,HSI,
|
||||
# The exclude_file contains lines of code that should be ignored. This is useful for individual lines which have non-words that can safely be ignored.
|
||||
exclude_file: '.codespellexcludelines'
|
||||
# To skip files entirely from being processed, add it to the following list:
|
||||
|
||||
2
.github/workflows/coverity-scan-fixes.yml
vendored
2
.github/workflows/coverity-scan-fixes.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
jobs:
|
||||
coverity:
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
||||
4
.github/workflows/curl.yml
vendored
4
.github/workflows/curl.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
build_wolfssl:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
test_curl:
|
||||
name: ${{ matrix.curl_ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 15
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/cyrus-sasl.yml
vendored
4
.github/workflows/cyrus-sasl.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
ref: [ 2.1.28 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/disable-pk-algs.yml
vendored
2
.github/workflows/disable-pk-algs.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
6
.github/workflows/docker-Espressif.yml
vendored
6
.github/workflows/docker-Espressif.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
espressif_latest:
|
||||
name: latest Docker container
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 12
|
||||
container:
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
espressif_v4_4:
|
||||
name: v4.4 Docker container
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: espressif/idf:release-v4.4
|
||||
steps:
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
espressif_v5_0:
|
||||
name: v5.0 Docker container
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: espressif/idf:release-v5.0
|
||||
steps:
|
||||
|
||||
4
.github/workflows/docker-OpenWrt.yml
vendored
4
.github/workflows/docker-OpenWrt.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
build_library:
|
||||
name: Compile libwolfssl.so
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
container:
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
compile_container:
|
||||
name: Compile container
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 2
|
||||
needs: build_library
|
||||
|
||||
2
.github/workflows/fil-c.yml
vendored
2
.github/workflows/fil-c.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 30
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
name: ${{ matrix.config }}
|
||||
steps:
|
||||
- name: Download fil-c release
|
||||
|
||||
4
.github/workflows/grpc.yml
vendored
4
.github/workflows/grpc.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
h2_ssl_cert_test h2_ssl_session_reuse_test
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 30
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/haproxy.yml
vendored
4
.github/workflows/haproxy.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
build_wolfssl:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
test_haproxy:
|
||||
name: ${{ matrix.haproxy_ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 15
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/hostap-vm.yml
vendored
2
.github/workflows/hostap-vm.yml
vendored
@@ -80,7 +80,7 @@ jobs:
|
||||
|
||||
- name: Checkout hostap
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: git clone git://w1.fi/hostap.git hostap
|
||||
run: git clone https://w1.fi/hostap.git hostap
|
||||
|
||||
build_uml_linux:
|
||||
name: Build UML (UserMode Linux)
|
||||
|
||||
2
.github/workflows/intelasm-c-fallback.yml
vendored
2
.github/workflows/intelasm-c-fallback.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
6
.github/workflows/ipmitool.yml
vendored
6
.github/workflows/ipmitool.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -48,11 +48,11 @@ jobs:
|
||||
git_ref: [ c3939dac2c060651361fc71516806f9ab8c38901 ]
|
||||
name: ${{ matrix.git_ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_wolfssl
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: export DEBIAN_FRONTEND=noninteractive && sudo apt-get update && sudo apt-get install -y libreadline8
|
||||
run: export DEBIAN_FRONTEND=noninteractive && sudo apt-get update && sudo apt-get install -y libreadline-dev
|
||||
- name: Download lib
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
|
||||
6
.github/workflows/jwt-cpp.yml
vendored
6
.github/workflows/jwt-cpp.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
# Just to keep it the same as the testing target
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,9 +47,9 @@ jobs:
|
||||
matrix:
|
||||
config:
|
||||
- ref: 0.7.0
|
||||
runner: ubuntu-22.04
|
||||
runner: ubuntu-24.04
|
||||
- ref: 0.6.0
|
||||
runner: ubuntu-22.04
|
||||
runner: ubuntu-24.04
|
||||
name: ${{ matrix.config.ref }}
|
||||
runs-on: ${{ matrix.config.runner }}
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/libspdm.yml
vendored
4
.github/workflows/libspdm.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
ref: [ 3.7.0 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/libvncserver.yml
vendored
4
.github/workflows/libvncserver.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
# Just to keep it the same as the testing target
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 0.9.13, 0.9.14 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_wolfssl
|
||||
steps:
|
||||
- name: Download lib
|
||||
|
||||
4
.github/workflows/memcached.yml
vendored
4
.github/workflows/memcached.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
# Just to keep it the same as the testing target
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Build wolfSSL
|
||||
uses: wolfSSL/actions-build-autotools-project@v1
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
- ref: 1.6.22
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_wolfssl
|
||||
steps:
|
||||
- name: Download lib
|
||||
|
||||
4
.github/workflows/mosquitto.yml
vendored
4
.github/workflows/mosquitto.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
# Just to keep it the same as the testing target
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
ref: [ 2.0.18 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
12
.github/workflows/multi-compiler.yml
vendored
12
.github/workflows/multi-compiler.yml
vendored
@@ -31,18 +31,12 @@ jobs:
|
||||
- CC: gcc-12
|
||||
CXX: g++-12
|
||||
OS: ubuntu-24.04
|
||||
- CC: clang-11
|
||||
CXX: clang++-11
|
||||
OS: ubuntu-22.04
|
||||
- CC: clang-12
|
||||
CXX: clang++-12
|
||||
OS: ubuntu-22.04
|
||||
- CC: clang-13
|
||||
CXX: clang++-13
|
||||
OS: ubuntu-22.04
|
||||
- CC: clang-14
|
||||
CXX: clang++-14
|
||||
OS: ubuntu-24.04
|
||||
- CC: clang-19
|
||||
CXX: clang++-19
|
||||
OS: ubuntu-24.04
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ${{ matrix.OS }}
|
||||
# This should be a safe limit for the tests to run.
|
||||
|
||||
4
.github/workflows/net-snmp.yml
vendored
4
.github/workflows/net-snmp.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
test_opts: -e 'agentxperl'
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/nginx.yml
vendored
4
.github/workflows/nginx.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -107,7 +107,7 @@ jobs:
|
||||
stream_proxy_ssl_verify.t
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/no-malloc.yml
vendored
2
.github/workflows/no-malloc.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
2
.github/workflows/no-tls.yml
vendored
2
.github/workflows/no-tls.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
4
.github/workflows/nss.yml
vendored
4
.github/workflows/nss.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
build_nss:
|
||||
name: Build nss
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
nss_test:
|
||||
name: Test interop with nss
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_nss
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
|
||||
4
.github/workflows/ntp.yml
vendored
4
.github/workflows/ntp.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 4.2.8p15, 4.2.8p17 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/ocsp.yml
vendored
2
.github/workflows/ocsp.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
ocsp_stapling:
|
||||
name: ocsp stapling
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout wolfSSL
|
||||
|
||||
4
.github/workflows/openldap.yml
vendored
4
.github/workflows/openldap.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
git_ref: OPENLDAP_REL_ENG_2_6_7
|
||||
name: ${{ matrix.osp_ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 20
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/openssh.yml
vendored
4
.github/workflows/openssh.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -71,7 +71,7 @@ jobs:
|
||||
connection-timeout
|
||||
name: ${{ matrix.osp_ver }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_wolfssl
|
||||
steps:
|
||||
- name: Download lib
|
||||
|
||||
2
.github/workflows/opensslcoexist.yml
vendored
2
.github/workflows/opensslcoexist.yml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
4
.github/workflows/openvpn.yml
vendored
4
.github/workflows/openvpn.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
ref: [ release/2.6, master ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
needs: build_wolfssl
|
||||
|
||||
8
.github/workflows/os-check.yml
vendored
8
.github/workflows/os-check.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-22.04, macos-latest ]
|
||||
os: [ ubuntu-24.04, macos-latest ]
|
||||
config: [
|
||||
# Add new configs here
|
||||
'',
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-22.04, macos-latest ]
|
||||
os: [ ubuntu-24.04, macos-latest ]
|
||||
user-settings: [
|
||||
# Add new user_settings.h here
|
||||
'examples/configs/user_settings_all.h',
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-22.04, macos-latest ]
|
||||
os: [ ubuntu-24.04, macos-latest ]
|
||||
user-settings: [
|
||||
# Add new user_settings.h here
|
||||
'examples/configs/user_settings_eccnonblock.h',
|
||||
@@ -140,7 +140,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-22.04, macos-latest ]
|
||||
os: [ ubuntu-24.04, macos-latest ]
|
||||
name: make user_setting.h (with sed)
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
2
.github/workflows/packaging.yml
vendored
2
.github/workflows/packaging.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
build_wolfssl:
|
||||
name: Package wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
|
||||
4
.github/workflows/pam-ipmi.yml
vendored
4
.github/workflows/pam-ipmi.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
git_ref: [ e4b13e6725abb178f62ee897fe1c0e81b06a9431 ]
|
||||
name: ${{ matrix.git_ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build_wolfssl
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
|
||||
2
.github/workflows/pq-all.yml
vendored
2
.github/workflows/pq-all.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
2
.github/workflows/psk.yml
vendored
2
.github/workflows/psk.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
]
|
||||
name: make check
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
271
.github/workflows/renode-stm32h753.yml
vendored
Normal file
271
.github/workflows/renode-stm32h753.yml
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
name: Renode STM32H753 Test
|
||||
|
||||
# Platform-specific configuration
|
||||
# To add a new platform, create a new workflow file based on this template
|
||||
# and update these variables for the target MCU
|
||||
env:
|
||||
PLATFORM_NAME: stm32h753
|
||||
PLATFORM_DISPLAY_NAME: STM32H753
|
||||
CMSIS_DEVICE_REPO: cmsis-device-h7
|
||||
CMSIS_DEVICE_PATH: /opt/cmsis-device-h7
|
||||
CMSIS_DEVICE_CACHE_KEY: cmsis-device-h7-v1
|
||||
STM32CUBE_REPO: STM32CubeH7
|
||||
STM32CUBE_BRANCH: v1.11.2
|
||||
STM32CUBE_PATH: /opt/STM32CubeH7
|
||||
STM32CUBE_CACHE_KEY: stm32cubeh7-v1.11.2-v1
|
||||
HAL_CONFIG_FILE: stm32h7xx_hal_conf.h
|
||||
HAL_DRIVER_INC_PATH: STM32H7xx_HAL_Driver/Inc
|
||||
HAL_DRIVER_SRC_PATH: STM32H7xx_HAL_Driver/Src
|
||||
RENODE_PLATFORM_NAME: stm32h753
|
||||
RENODE_REPL_PATH: platforms/cpus/stm32h753.repl
|
||||
RENODE_TEST_DIR: .github/renode-test/stm32h753
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master, develop ]
|
||||
pull_request:
|
||||
branches: [ main, master, develop ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout wolfSSL
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up build environment
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
ninja-build \
|
||||
python3 \
|
||||
git \
|
||||
gcc-arm-none-eabi \
|
||||
libnewlib-arm-none-eabi \
|
||||
libstdc++-arm-none-eabi-newlib \
|
||||
wget \
|
||||
unzip
|
||||
|
||||
- name: Cache CMSIS Device
|
||||
id: cache-cmsis-device
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.CMSIS_DEVICE_PATH }}
|
||||
key: ${{ env.CMSIS_DEVICE_CACHE_KEY }}
|
||||
restore-keys: |
|
||||
${{ env.CMSIS_DEVICE_CACHE_KEY }}-
|
||||
|
||||
- name: Cache CMSIS 5
|
||||
id: cache-cmsis-5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /opt/CMSIS_5
|
||||
key: cmsis-5-v1
|
||||
restore-keys: |
|
||||
cmsis-5-
|
||||
|
||||
- name: Cache STM32Cube
|
||||
id: cache-stm32cube
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.STM32CUBE_PATH }}
|
||||
key: ${{ env.STM32CUBE_CACHE_KEY }}
|
||||
restore-keys: |
|
||||
${{ env.STM32CUBE_CACHE_KEY }}-
|
||||
|
||||
- name: Cache Renode
|
||||
id: cache-renode
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /opt/renode
|
||||
key: renode-1.15.3-v1
|
||||
restore-keys: |
|
||||
renode-1.15.3-
|
||||
|
||||
- name: Install Renode dependencies
|
||||
run: |
|
||||
# Install Mono and other dependencies needed for Renode (always needed, even when cached)
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
mono-runtime \
|
||||
libmono-cil-dev \
|
||||
screen \
|
||||
policykit-1 || true
|
||||
|
||||
- name: Install Renode (if not cached)
|
||||
if: steps.cache-renode.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
# Install Renode by extracting .deb (avoids GUI dependency issues for headless use)
|
||||
cd /tmp
|
||||
wget -q https://github.com/renode/renode/releases/download/v1.15.3/renode_1.15.3_amd64.deb
|
||||
# Extract the .deb file
|
||||
dpkg-deb -x renode_1.15.3_amd64.deb /tmp/renode-extract
|
||||
# Copy Renode files to system locations
|
||||
sudo mkdir -p /opt/renode
|
||||
sudo cp -r /tmp/renode-extract/opt/renode/* /opt/renode/ || true
|
||||
sudo cp -r /tmp/renode-extract/usr/* /usr/ || true
|
||||
# Create symlink for easy access
|
||||
if [ -f /opt/renode/renode ]; then
|
||||
sudo ln -sf /opt/renode/renode /usr/local/bin/renode
|
||||
elif [ -f /usr/bin/renode ]; then
|
||||
echo "Renode already in PATH at /usr/bin/renode"
|
||||
fi
|
||||
# Cleanup
|
||||
rm -rf /tmp/renode-extract renode_1.15.3_amd64.deb
|
||||
|
||||
- name: Setup Renode symlinks and permissions
|
||||
run: |
|
||||
# When Renode is cached, we need to recreate /usr/bin/renode wrapper script
|
||||
# The /usr/bin/renode is a wrapper that checks Mono and calls /opt/renode/bin/Renode.exe
|
||||
if [ -d /opt/renode ] && [ ! -x /usr/bin/renode ]; then
|
||||
echo "Renode cached but /usr/bin/renode wrapper missing, recreating..."
|
||||
# Create the wrapper script
|
||||
sudo bash -c 'cat > /usr/bin/renode << '\''SCRIPT_EOF'\''
|
||||
#!/bin/sh
|
||||
MONOVERSION=5.20
|
||||
REQUIRED_MAJOR=5
|
||||
REQUIRED_MINOR=20
|
||||
|
||||
LAUNCHER=mono
|
||||
|
||||
if ! [ -x "$(command -v $LAUNCHER)" ]
|
||||
then
|
||||
echo "$LAUNCHER not found. Renode requires Mono $MONOVERSION or newer. Please refer to documentation for installation instructions. Exiting!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check installed mono version
|
||||
INSTALLED_MONO=`$LAUNCHER --version | head -n1 | cut -d'\'' '\'' -f5`
|
||||
INSTALLED_MONO_MAJOR=`echo $INSTALLED_MONO | cut -d'\''.'\'' -f1`
|
||||
INSTALLED_MONO_MINOR=`echo $INSTALLED_MONO | cut -d'\''.'\'' -f2`
|
||||
|
||||
if [ $INSTALLED_MONO_MAJOR -lt $REQUIRED_MAJOR ] || [ $INSTALLED_MONO_MAJOR -eq $REQUIRED_MAJOR -a $INSTALLED_MONO_MINOR -lt $REQUIRED_MINOR ]
|
||||
then
|
||||
echo "Wrong Mono version detected: $INSTALLED_MONO. Renode requires Mono $MONOVERSION or newer. Please refer to documentation for installation instructions. Exiting!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec $LAUNCHER $MONO_OPTIONS /opt/renode/bin/Renode.exe "$@"
|
||||
SCRIPT_EOF'
|
||||
sudo chmod +x /usr/bin/renode
|
||||
echo "Created /usr/bin/renode wrapper script"
|
||||
fi
|
||||
|
||||
# Also ensure /usr/local/bin/renode symlink exists
|
||||
if [ -x /usr/bin/renode ] && [ ! -x /usr/local/bin/renode ]; then
|
||||
sudo ln -sf /usr/bin/renode /usr/local/bin/renode
|
||||
echo "Created symlink: /usr/local/bin/renode -> /usr/bin/renode"
|
||||
fi
|
||||
|
||||
- name: Verify Renode installation
|
||||
run: |
|
||||
# Verify Renode is installed and accessible
|
||||
RENODE_FOUND=false
|
||||
RENODE_BIN=""
|
||||
|
||||
# Check various possible locations
|
||||
for path in /opt/renode/renode /opt/renode/bin/renode /usr/local/bin/renode /usr/bin/renode; do
|
||||
if [ -x "$path" ]; then
|
||||
echo "Renode found at $path"
|
||||
"$path" --version || true
|
||||
RENODE_BIN="$path"
|
||||
RENODE_FOUND=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$RENODE_FOUND" != "true" ]; then
|
||||
echo "ERROR: Renode binary not found or not executable!"
|
||||
echo "Searching for renode..."
|
||||
find /opt /usr -name renode -type f 2>/dev/null | head -10 || true
|
||||
echo "Checking /opt/renode contents:"
|
||||
ls -la /opt/renode/ 2>/dev/null | head -10 || true
|
||||
if [ -d /opt/renode ]; then
|
||||
echo "Checking /opt/renode subdirectories:"
|
||||
find /opt/renode -type f -name "*renode*" 2>/dev/null | head -10 || true
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
- name: Clone CMSIS Device (if not cached)
|
||||
if: steps.cache-cmsis-device.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
sudo mkdir -p /opt
|
||||
sudo git clone --depth 1 https://github.com/STMicroelectronics/${{ env.CMSIS_DEVICE_REPO }}.git ${{ env.CMSIS_DEVICE_PATH }}
|
||||
|
||||
- name: Clone CMSIS 5 (if not cached)
|
||||
if: steps.cache-cmsis-5.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
sudo mkdir -p /opt
|
||||
sudo git clone --depth 1 https://github.com/ARM-software/CMSIS_5.git /opt/CMSIS_5
|
||||
|
||||
- name: Clone STM32Cube (if not cached)
|
||||
if: steps.cache-stm32cube.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
sudo mkdir -p /opt
|
||||
sudo git clone --depth 1 --branch ${{ env.STM32CUBE_BRANCH }} --recurse-submodules https://github.com/STMicroelectronics/${{ env.STM32CUBE_REPO }}.git ${{ env.STM32CUBE_PATH }} || \
|
||||
(sudo git clone --depth 1 --branch ${{ env.STM32CUBE_BRANCH }} https://github.com/STMicroelectronics/${{ env.STM32CUBE_REPO }}.git ${{ env.STM32CUBE_PATH }} && \
|
||||
cd ${{ env.STM32CUBE_PATH }} && sudo git submodule update --init --recursive --depth 1)
|
||||
|
||||
- name: Setup firmware build directory and helper files
|
||||
run: |
|
||||
sudo mkdir -p /opt/firmware
|
||||
# Copy helper files from repository
|
||||
sudo cp -r ${{ github.workspace }}/${{ env.RENODE_TEST_DIR }}/* /opt/firmware/
|
||||
# Copy HAL config to STM32Cube directory
|
||||
sudo cp /opt/firmware/${{ env.HAL_CONFIG_FILE }} ${{ env.STM32CUBE_PATH }}/Drivers/${{ env.HAL_DRIVER_INC_PATH }}/ 2>/dev/null || true
|
||||
sudo chmod +x /opt/firmware/entrypoint.sh
|
||||
# Create .renode-root file so Renode can find platform files
|
||||
# Try to find Renode installation directory and create .renode-root with proper permissions
|
||||
if [ -d "/opt/renode/platforms" ]; then
|
||||
echo "/opt/renode" | sudo tee /opt/firmware/.renode-root > /dev/null
|
||||
sudo chmod 644 /opt/firmware/.renode-root
|
||||
elif [ -d "/usr/lib/renode/platforms" ]; then
|
||||
echo "/usr/lib/renode" | sudo tee /opt/firmware/.renode-root > /dev/null
|
||||
sudo chmod 644 /opt/firmware/.renode-root
|
||||
elif [ -d "/usr/share/renode/platforms" ]; then
|
||||
echo "/usr/share/renode" | sudo tee /opt/firmware/.renode-root > /dev/null
|
||||
sudo chmod 644 /opt/firmware/.renode-root
|
||||
fi
|
||||
|
||||
- name: Build wolfSSL firmware (NOT CACHED - rebuilds on every run)
|
||||
env:
|
||||
WOLFSSL_ROOT: /opt/wolfssl
|
||||
run: |
|
||||
# Copy wolfSSL source (this is NOT cached - fresh checkout each time)
|
||||
sudo cp -r ${{ github.workspace }} /opt/wolfssl
|
||||
# Build with CMake
|
||||
cd /opt/firmware
|
||||
sudo cmake -G Ninja \
|
||||
-DWOLFSSL_USER_SETTINGS=ON \
|
||||
-DUSER_SETTINGS_FILE=/opt/firmware/user_settings.h \
|
||||
-DCMAKE_TOOLCHAIN_FILE=/opt/firmware/toolchain-arm-none-eabi.cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DWOLFSSL_CRYPT_TESTS=OFF \
|
||||
-DWOLFSSL_EXAMPLES=OFF \
|
||||
-B /opt/firmware/build \
|
||||
-S /opt/firmware
|
||||
sudo cmake --build /opt/firmware/build
|
||||
# Verify ELF file was created and copy it to expected location
|
||||
if [ -f "/opt/firmware/build/wolfcrypt_test.elf" ]; then
|
||||
sudo cp /opt/firmware/build/wolfcrypt_test.elf /opt/firmware/wolfcrypt_test.elf
|
||||
echo "ELF file copied to /opt/firmware/wolfcrypt_test.elf"
|
||||
ls -lh /opt/firmware/wolfcrypt_test.elf
|
||||
else
|
||||
echo "ERROR: ELF file not found at /opt/firmware/build/wolfcrypt_test.elf"
|
||||
echo "Searching for ELF files..."
|
||||
find /opt/firmware/build -name "*.elf" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Run Renode test
|
||||
run: |
|
||||
# Ensure PATH includes standard binary locations for sudo
|
||||
sudo env PATH="$PATH" /opt/firmware/entrypoint.sh
|
||||
|
||||
4
.github/workflows/rng-tools.yml
vendored
4
.github/workflows/rng-tools.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 6.16 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/smallStackSize.yml
vendored
2
.github/workflows/smallStackSize.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
]
|
||||
name: build library
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
4
.github/workflows/socat.yml
vendored
4
.github/workflows/socat.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
build_wolfssl:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
- name: Build wolfSSL
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
|
||||
socat_check:
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 30
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/softhsm.yml
vendored
4
.github/workflows/softhsm.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 2.6.1 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 20
|
||||
needs: build_wolfssl
|
||||
|
||||
4
.github/workflows/sssd.yml
vendored
4
.github/workflows/sssd.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
name: Build wolfSSL
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
ref: [ 2.9.1 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: quay.io/sssd/ci-client-devel:ubuntu-latest
|
||||
env:
|
||||
|
||||
4
.github/workflows/stunnel.yml
vendored
4
.github/workflows/stunnel.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
name: Build wolfSSL
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
# Just to keep it the same as the testing target
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
steps:
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
ref: [ 5.67 ]
|
||||
name: ${{ matrix.ref }}
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 4
|
||||
needs: build_wolfssl
|
||||
|
||||
2
.github/workflows/symbol-prefixes.yml
vendored
2
.github/workflows/symbol-prefixes.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
]
|
||||
name: make and analyze
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
2
.github/workflows/threadx.yml
vendored
2
.github/workflows/threadx.yml
vendored
@@ -9,7 +9,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
|
||||
2
.github/workflows/wolfCrypt-Wconversion.yml
vendored
2
.github/workflows/wolfCrypt-Wconversion.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
||||
]
|
||||
name: build library
|
||||
if: github.repository_owner == 'wolfssl'
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-24.04
|
||||
# This should be a safe limit for the tests to run.
|
||||
timeout-minutes: 6
|
||||
steps:
|
||||
|
||||
2
.github/workflows/zephyr.yml
vendored
2
.github/workflows/zephyr.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
||||
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
|
||||
autoconf automake bison build-essential ca-certificates cargo ccache chrpath cmake \
|
||||
cpio device-tree-compiler dfu-util diffstat dos2unix doxygen file flex g++ gawk gcc \
|
||||
gcovr git git-core gnupg gperf gtk-sharp2 help2man iproute2 lcov libcairo2-dev \
|
||||
gcovr git git-core gnupg gperf gtk-sharp3 help2man iproute2 lcov libcairo2-dev \
|
||||
libglib2.0-dev libgtk2.0-0 liblocale-gettext-perl libncurses5-dev libpcap-dev \
|
||||
libpopt0 libsdl1.2-dev libsdl2-dev libssl-dev libtool libtool-bin locales make \
|
||||
net-tools ninja-build openssh-client parallel pkg-config python3-dev python3-pip \
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -468,3 +468,5 @@ wrapper/Ada/obj/
|
||||
# Autogenerated debug trace headers
|
||||
wolfssl/debug-trace-error-codes.h
|
||||
wolfssl/debug-untrace-error-codes.h
|
||||
|
||||
AGENTS.md
|
||||
|
||||
@@ -478,6 +478,7 @@ REDIRECTION_OUT2_KEYELMID
|
||||
REDIRECTION_OUT2_KEYID
|
||||
RENESAS_T4_USE
|
||||
RHEL_MAJOR
|
||||
RHEL_RELEASE_CODE
|
||||
RTC_ALARMSUBSECONDMASK_ALL
|
||||
RTE_CMSIS_RTOS_RTX
|
||||
RTOS_MODULE_NET_AVAIL
|
||||
@@ -544,6 +545,11 @@ STM32WL55xx
|
||||
STM32_AESGCM_PARTIAL
|
||||
STM32_HW_CLOCK_AUTO
|
||||
STM32_NUTTX_RNG
|
||||
STSAFE_HOST_KEY_CIPHER
|
||||
STSAFE_HOST_KEY_MAC
|
||||
STSAFE_I2C_BUS
|
||||
STSE_CONF_ECC_BRAINPOOL_P_256
|
||||
STSE_CONF_ECC_BRAINPOOL_P_384
|
||||
TASK_EXTRA_STACK_SIZE
|
||||
TCP_NODELAY
|
||||
TFM_ALREADY_SET
|
||||
@@ -622,6 +628,7 @@ WC_LMS_FULL_HASH
|
||||
WC_NO_ASYNC_SLEEP
|
||||
WC_NO_RNG_SIMPLE
|
||||
WC_NO_STATIC_ASSERT
|
||||
WC_NO_VERBOSE_RNG
|
||||
WC_PKCS11_FIND_WITH_ID_ONLY
|
||||
WC_PROTECT_ENCRYPTED_MEM
|
||||
WC_RNG_BLOCKING
|
||||
@@ -788,6 +795,7 @@ WOLFSSL_MONT_RED_CT
|
||||
WOLFSSL_MP_COND_COPY
|
||||
WOLFSSL_MP_INVMOD_CONSTANT_TIME
|
||||
WOLFSSL_MULTICIRCULATE_ALTNAMELIST
|
||||
WOLFSSL_NEW_PRIME_CHECK
|
||||
WOLFSSL_NONBLOCK_OCSP
|
||||
WOLFSSL_NOSHA3_384
|
||||
WOLFSSL_NOT_WINDOWS_API
|
||||
@@ -799,6 +807,7 @@ WOLFSSL_NO_COPY_KEY
|
||||
WOLFSSL_NO_CRL_DATE_CHECK
|
||||
WOLFSSL_NO_CRL_NEXT_DATE
|
||||
WOLFSSL_NO_CT_MAX_MIN
|
||||
WOLFSSL_NO_DEBUG_CERTS
|
||||
WOLFSSL_NO_DECODE_EXTRA
|
||||
WOLFSSL_NO_DER_TO_PEM
|
||||
WOLFSSL_NO_DH186
|
||||
@@ -887,7 +896,6 @@ WOLFSSL_SP_INT_SQR_VOLATILE
|
||||
WOLFSSL_STACK_CHECK
|
||||
WOLFSSL_STM32F427_RNG
|
||||
WOLFSSL_STM32U5_DHUK
|
||||
WOLFSSL_STM32_RNG_NOLIB
|
||||
WOLFSSL_STRONGEST_HASH_SIG
|
||||
WOLFSSL_STSAFE_TAKES_SLOT
|
||||
WOLFSSL_TELIT_M2MB
|
||||
@@ -1072,6 +1080,7 @@ __WATCOMC__
|
||||
__WATCOM_INT64__
|
||||
__XC32
|
||||
__XTENSA__
|
||||
__ZEPHYR__
|
||||
__aarch64__
|
||||
__alpha__
|
||||
__arch64__
|
||||
|
||||
@@ -603,6 +603,11 @@ add_option(WOLFSSL_MLKEM
|
||||
"Enable the wolfSSL PQ ML-KEM library (default: disabled)"
|
||||
"no" "yes;no")
|
||||
|
||||
# Dilithium
|
||||
add_option(WOLFSSL_DILITHIUM
|
||||
"Enable the wolfSSL PQ Dilithium (ML-DSA) implementation (default: disabled)"
|
||||
"no" "yes;no")
|
||||
|
||||
# LMS
|
||||
add_option(WOLFSSL_LMS
|
||||
"Enable the PQ LMS Stateful Hash-based Signature Scheme (default: disabled)"
|
||||
@@ -700,6 +705,22 @@ if (WOLFSSL_EXPERIMENTAL)
|
||||
message(STATUS "Looking for WOLFSSL_LMS - not found")
|
||||
endif()
|
||||
|
||||
# Checking for experimental feature: Dilithium
|
||||
message(STATUS "Looking for WOLFSSL_DILITHIUM")
|
||||
if (WOLFSSL_DILITHIUM)
|
||||
set(WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1)
|
||||
|
||||
message(STATUS "Automatically set related requirements for Dilithium:")
|
||||
set_wolfssl_definitions("HAVE_DILITHIUM" RESUlT)
|
||||
set_wolfssl_definitions("WOLFSSL_WC_DILITHIUM" RESUlT)
|
||||
set_wolfssl_definitions("WOLFSSL_SHA3" RESUlT)
|
||||
set_wolfssl_definitions("WOLFSSL_SHAKE128" RESUlT)
|
||||
set_wolfssl_definitions("WOLFSSL_SHAKE256" RESUlT)
|
||||
message(STATUS "Looking for WOLFSSL_DILITHIUM - found")
|
||||
else()
|
||||
message(STATUS "Looking for WOLFSSL_DILITHIUM - not found")
|
||||
endif()
|
||||
|
||||
# Other experimental feature detection can be added here...
|
||||
|
||||
# Were any experimental features found? Display a message.
|
||||
@@ -713,7 +734,9 @@ if (WOLFSSL_EXPERIMENTAL)
|
||||
if(WOLFSSL_OQS AND WOLFSSL_MLKEM)
|
||||
message(FATAL_ERROR "Error: cannot enable both WOLFSSL_OQS and WOLFSSL_MLKEM at the same time.")
|
||||
endif()
|
||||
|
||||
if(WOLFSSL_OQS AND WOLFSSL_DILITHIUM)
|
||||
message(FATAL_ERROR "Error: cannot enable both WOLFSSL_OQS and WOLFSSL_DILITHIUM at the same time.")
|
||||
endif()
|
||||
else()
|
||||
# Experimental mode not enabled, but were any experimental features enabled? Error out if so:
|
||||
message(STATUS "Looking for WOLFSSL_EXPERIMENTAL - not found")
|
||||
@@ -723,6 +746,9 @@ else()
|
||||
if(WOLFSSL_MLKEM)
|
||||
message(FATAL_ERROR "Error: WOLFSSL_MLKEM requires WOLFSSL_EXPERIMENTAL at this time.")
|
||||
endif()
|
||||
if(WOLFSSL_DILITHIUM)
|
||||
message(FATAL_ERROR "Error: WOLFSSL_DILITHIUM requires WOLFSSL_EXPERIMENTAL at this time.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# LMS
|
||||
@@ -1866,6 +1892,15 @@ if(NOT WOLFSSL_PKCS12)
|
||||
list(APPEND WOLFSSL_DEFINITIONS "-DNO_PKCS12")
|
||||
endif()
|
||||
|
||||
# PKCS#11
|
||||
add_option("WOLFSSL_PKCS11"
|
||||
"Enable PKCS#11 (default: disabled)"
|
||||
"no" "yes;no")
|
||||
|
||||
if(WOLFSSL_PKCS11 AND NOT WIN32)
|
||||
list(APPEND WOLFSSL_LINK_LIBS ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
|
||||
# PWDBASED has to come after certservice since we want it on w/o explicit on
|
||||
# PWDBASED
|
||||
@@ -1964,7 +1999,6 @@ add_option("WOLFSSL_CRYPT_TESTS_HELP"
|
||||
"no" "yes;no")
|
||||
|
||||
# TODO: - LIBZ
|
||||
# - PKCS#11
|
||||
# - Cavium
|
||||
# - Cavium V
|
||||
# - Cavium Octeon
|
||||
@@ -2705,6 +2739,13 @@ if(WOLFSSL_EXAMPLES)
|
||||
tests/api/test_ossl_x509_str.c
|
||||
tests/api/test_ossl_x509_lu.c
|
||||
tests/api/test_ossl_pem.c
|
||||
tests/api/test_ossl_rand.c
|
||||
tests/api/test_ossl_obj.c
|
||||
tests/api/test_ossl_p7p12.c
|
||||
tests/api/test_evp_digest.c
|
||||
tests/api/test_evp_cipher.c
|
||||
tests/api/test_evp_pkey.c
|
||||
tests/api/test_certman.c
|
||||
tests/api/test_tls13.c
|
||||
tests/srp.c
|
||||
tests/suites.c
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
9D2E31E3291CE4800082B941 /* dtls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dtls.c; path = ../../../src/dtls.c; sourceTree = "<group>"; };
|
||||
9D2E31E6291CE4AC0082B941 /* dtls13.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dtls13.c; path = ../../../src/dtls13.c; sourceTree = "<group>"; };
|
||||
9D2E31E8291CE5CB0082B941 /* kdf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = kdf.c; path = ../../../wolfcrypt/src/kdf.c; sourceTree = "<group>"; };
|
||||
A46FE14C2493E8F500A25BE7 /* armv8-chacha-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-chacha-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-chacha-asm.S"; sourceTree = "<group>"; };
|
||||
A46FE14C2493E8F500A25BE7 /* armv8-chacha-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-chacha-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-chacha-asm.S"; sourceTree = "<group>"; };
|
||||
A46FE14D2493E8F600A25BE7 /* sp_int.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sp_int.c; path = ../../../wolfcrypt/src/sp_int.c; sourceTree = "<group>"; };
|
||||
A46FE1512493E8F600A25BE7 /* sp_cortexm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sp_cortexm.c; path = ../../../wolfcrypt/src/sp_cortexm.c; sourceTree = "<group>"; };
|
||||
A46FE1522493E8F600A25BE7 /* blake2s.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = blake2s.c; path = ../../../wolfcrypt/src/blake2s.c; sourceTree = "<group>"; };
|
||||
@@ -201,10 +201,10 @@
|
||||
A4ADF8CE1FCE0C5500A06E90 /* coding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = coding.c; path = ../../../wolfcrypt/src/coding.c; sourceTree = "<group>"; };
|
||||
A4ADF8D01FCE0C5500A06E90 /* ge_low_mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ge_low_mem.c; path = ../../../wolfcrypt/src/ge_low_mem.c; sourceTree = "<group>"; };
|
||||
A4DFEC0C1FD4CAA300A7BB33 /* benchmark.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = benchmark.c; path = ../../../wolfcrypt/benchmark/benchmark.c; sourceTree = "<group>"; };
|
||||
A4DFEC0E1FD4CB8500A7BB33 /* armv8-sha256-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-sha256-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-sha256-asm.S"; sourceTree = "<group>"; };
|
||||
A4DFEC0F1FD4CB8500A7BB33 /* armv8-aes-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-aes-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-aes-asm.S"; sourceTree = "<group>"; };
|
||||
A4DFEC0E1FD4CB8500A7BB33 /* armv8-sha256-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-sha256-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-sha256-asm.S"; sourceTree = "<group>"; };
|
||||
A4DFEC0F1FD4CB8500A7BB33 /* armv8-aes-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-aes-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-aes-asm.S"; sourceTree = "<group>"; };
|
||||
A4DFEC3B1FD6B9CC00A7BB33 /* test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = test.c; path = ../../../wolfcrypt/test/test.c; sourceTree = "<group>"; };
|
||||
CB81DE1C24C9284700B98DA6 /* armv8-poly1305-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "armv8-poly1305-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-poly1305-asm.S"; sourceTree = "<group>"; };
|
||||
CB81DE1C24C9284700B98DA6 /* armv8-poly1305-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-poly1305-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-poly1305-asm.S"; sourceTree = "<group>"; };
|
||||
CB81DE1E24C93EC000B98DA6 /* armv8-curve25519.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-curve25519.S"; path = "../../../wolfcrypt/src/port/arm/armv8-curve25519.S"; sourceTree = "<group>"; };
|
||||
CB81DE2224C93FB300B98DA6 /* armv8-sha512-asm.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = "armv8-sha512-asm.S"; path = "../../../wolfcrypt/src/port/arm/armv8-sha512-asm.S"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -17,6 +17,10 @@ Fetchmail
|
||||
|
||||
OpenVPN
|
||||
|
||||
SWUpdate
|
||||
|
||||
RPCS3
|
||||
|
||||
For our users who cannot use wolfSSL under GPLv3, a commercial license to
|
||||
wolfSSL and wolfCrypt is available.
|
||||
|
||||
|
||||
5
README
5
README
@@ -7,8 +7,9 @@ and feature set. It is commonly used in standard operating environments as well
|
||||
because of its royalty-free pricing and excellent cross platform support.
|
||||
wolfSSL supports industry standards up to the current TLS 1.3 and DTLS 1.3
|
||||
levels, is up to 20 times smaller than OpenSSL, and offers progressive ciphers
|
||||
such as ChaCha20, Curve25519, and Blake2b. User benchmarking and feedback
|
||||
reports dramatically better performance when using wolfSSL over OpenSSL.
|
||||
such as ChaCha20, Curve25519, BLAKE2b/BLAKE2s and Post-Quantum TLS 1.3 groups.
|
||||
User benchmarking and feedback reports dramatically better performance when
|
||||
using wolfSSL over OpenSSL.
|
||||
|
||||
wolfSSL is powered by the wolfCrypt library. Two versions of the wolfCrypt
|
||||
cryptography library have been FIPS 140-2 validated (Certificate #2425 and
|
||||
|
||||
@@ -8,8 +8,8 @@ standard operating environments as well because of its royalty-free pricing
|
||||
and excellent cross platform support. wolfSSL supports industry standards up
|
||||
to the current [TLS 1.3](https://www.wolfssl.com/tls13) and DTLS 1.3, is up to
|
||||
20 times smaller than OpenSSL, and offers progressive ciphers such as ChaCha20,
|
||||
Curve25519, Blake2b and Post-Quantum TLS 1.3 groups. User benchmarking and
|
||||
feedback reports dramatically better performance when using wolfSSL over
|
||||
Curve25519, BLAKE2b/BLAKE2s and Post-Quantum TLS 1.3 groups. User benchmarking
|
||||
and feedback reports dramatically better performance when using wolfSSL over
|
||||
OpenSSL.
|
||||
|
||||
wolfSSL is powered by the wolfCrypt cryptography library. Two versions of
|
||||
|
||||
@@ -5,8 +5,14 @@ WOLFSSL_DIR=../
|
||||
|
||||
CFLAGS+=-I${WOLFSSL_DIR}
|
||||
CFLAGS+=-DWOLFSSL_IGNORE_FILE_WARN -DHAVE_CONFIG_H -DNO_MAIN_DRIVER
|
||||
# debug printing
|
||||
# CFLAGS+=-DWOLFSSL_BSDKM_VERBOSE_DEBUG
|
||||
#
|
||||
# debug options
|
||||
# verbose printing:
|
||||
# CFLAGS+=-DWOLFSSL_BSDKM_VERBOSE_DEBUG
|
||||
#
|
||||
# print memory mallocs / frees:
|
||||
# CFLAGS+=-DWOLFSSL_BSDKM_MEMORY_DEBUG
|
||||
#
|
||||
CFLAGS+=$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
|
||||
|
||||
# FreeBSD make does not support GNU make's patsubst and related. Filter
|
||||
|
||||
102
bsdkm/README.md
Normal file
102
bsdkm/README.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# wolfSSL bsdkm (bsd kernel module)
|
||||
|
||||
libwolfssl supports building as a FreeBSD kernel module (`libwolfssl.ko`).
|
||||
When loaded, wolfCrypt is made available to the rest of the kernel, allowing
|
||||
other loadable modules to link to wolfCrypt.
|
||||
|
||||
Supported features:
|
||||
- wolfCrypt in kernel.
|
||||
- FIPS-wolfcrypt.
|
||||
|
||||
Planned features:
|
||||
- crypto acceleration: AES-NI, AVX, etc.
|
||||
- kernel opencrypto driver registration.
|
||||
- full wolfSSL in kernel (kernel TLS).
|
||||
|
||||
## Building and Installing
|
||||
|
||||
Build bsdkm with:
|
||||
|
||||
```sh
|
||||
./configure --enable-freebsdkm --enable-cryptonly && make
|
||||
```
|
||||
|
||||
The default freebsdkm build assumes kernel source tree root at `/usr/src/sys/`.
|
||||
Use `--with-kernel-source=PATH` to configure a different path.
|
||||
|
||||
Assuming you are targeting your native system, install with:
|
||||
|
||||
```sh
|
||||
sudo kldload bsdkm/libwolfssl.ko
|
||||
```
|
||||
|
||||
You should see it now:
|
||||
```sh
|
||||
kldstat -m libwolfssl
|
||||
Id Refs Name
|
||||
509 1 libwolfssl
|
||||
```
|
||||
|
||||
Unload with:
|
||||
```sh
|
||||
sudo kldunload libwolfssl
|
||||
```
|
||||
|
||||
### options
|
||||
|
||||
| freebsdkm option | description |
|
||||
| :------------------------------- | :--------------------------------------- |
|
||||
| --with-bsd-export-syms=LIST | Export list of symbols as global. <br>. Options are 'all', 'none', or <br> comma separated list of symbols. |
|
||||
| --with-kernel-source=PATH | Path to kernel tree root (default `/usr/src/sys`) |
|
||||
|
||||
### FIPS
|
||||
|
||||
Building with FIPS is largely the same, with the additional step of
|
||||
configuring a fips hash.
|
||||
|
||||
1. Build bsdkm (the `fips_hash` here is a placeholder):
|
||||
|
||||
```sh
|
||||
fips_hash=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
|
||||
./configure --enable-freebsdkm --enable-cryptonly --enable-fips=v6 \
|
||||
CFLAGS="-DWOLFCRYPT_FIPS_CORE_HASH_VALUE=$fips_hash" && make
|
||||
```
|
||||
|
||||
2. Attempt first install. This is expected to fail, because the hash was a
|
||||
placeholder.
|
||||
```sh
|
||||
$ sudo kldload bsdkm/libwolfssl.ko
|
||||
kldload: an error occurred while loading module bsdkm/libwolfssl.ko. Please check dmesg(8) for more details.
|
||||
```
|
||||
|
||||
3. Check dmesg output for the updated hash value (yours will be different).
|
||||
```sh
|
||||
$ dmesg | tail -n5
|
||||
In-core integrity hash check failure.
|
||||
Rebuild with "WOLFCRYPT_FIPS_CORE_HASH_VALUE=3B144A08F291DBA536324646BBD127447B8F222D29A135780E330351E0DF9F0F".
|
||||
error: wc_RunAllCast_fips failed at shutdown with return value 19
|
||||
info: libwolfssl unloaded
|
||||
module_register_init: MOD_LOAD (libwolfssl_fips, 0xffffffff842c28d0, 0) error 85
|
||||
```
|
||||
|
||||
4. Repeat steps 1-2 with the new hash value. The load should succeed now.
|
||||
|
||||
```
|
||||
$ kldstat -m libwolfssl_fips
|
||||
Id Refs Name
|
||||
523 1 libwolfssl_fips
|
||||
```
|
||||
|
||||
Unload with
|
||||
```
|
||||
sudo kldunload libwolfssl
|
||||
```
|
||||
|
||||
On unload, the FIPS self-test will run a final time and print its status
|
||||
to system message buffer:
|
||||
|
||||
```
|
||||
info: wolfCrypt FIPS re-self-test succeeded at unload: all algorithms re-verified.
|
||||
info: libwolfssl unloaded
|
||||
```
|
||||
|
||||
@@ -37,11 +37,28 @@
|
||||
#include <sys/limits.h>
|
||||
#endif /* !CHAR_BIT*/
|
||||
|
||||
#define NO_THREAD_LS
|
||||
#define NO_ATTRIBUTE_CONSTRUCTOR
|
||||
|
||||
/* <time.h> and TIME(3) are userspace only in FreeBSD.
|
||||
* Use a small wrapper around <sys/time.h> time_second instead. */
|
||||
#include <sys/time.h>
|
||||
static inline time_t wolfkmod_time(time_t * tloc) {
|
||||
time_t _now = time_second;
|
||||
if (tloc) {
|
||||
*tloc = _now;
|
||||
}
|
||||
return _now;
|
||||
}
|
||||
#define XTIME wolfkmod_time
|
||||
|
||||
/* needed to prevent wolfcrypt/src/asn.c version shadowing
|
||||
* extern global version from /usr/src/sys/sys/systm.h */
|
||||
#define version wc_version
|
||||
|
||||
#define wc_km_printf printf
|
||||
/* printf and logging defines */
|
||||
#define wc_km_printf printf
|
||||
#define WOLFSSL_DEBUG_PRINTF_FN printf
|
||||
|
||||
/* str and char utility functions */
|
||||
#define XATOI(s) ({ \
|
||||
@@ -51,7 +68,7 @@
|
||||
_xatoi_ret = 0; \
|
||||
} \
|
||||
(int)_xatoi_ret; \
|
||||
})
|
||||
})
|
||||
|
||||
#if !defined(XMALLOC_OVERRIDE)
|
||||
#error bsdkm requires XMALLOC_OVERRIDE
|
||||
@@ -60,21 +77,44 @@
|
||||
/* use malloc and free from /usr/include/sys/malloc.h */
|
||||
extern struct malloc_type M_WOLFSSL[1];
|
||||
|
||||
#define XMALLOC(s, h, t) \
|
||||
({(void)(h); (void)(t); malloc(s, M_WOLFSSL, M_WAITOK | M_ZERO);})
|
||||
#if defined(WOLFSSL_BSDKM_MEMORY_DEBUG)
|
||||
#define XMALLOC(s, h, t) ({ \
|
||||
(void)(h); (void)(t); \
|
||||
void * _ptr = malloc(s, M_WOLFSSL, M_WAITOK | M_ZERO); \
|
||||
printf("info: malloc: %p, M_WOLFSSL, %zu\n", _ptr, (size_t) s); \
|
||||
(void *)_ptr; \
|
||||
})
|
||||
|
||||
#ifdef WOLFSSL_XFREE_NO_NULLNESS_CHECK
|
||||
#define XFREE(p, h, t) \
|
||||
({(void)(h); (void)(t); free(p, M_WOLFSSL);})
|
||||
#define XFREE(p, h, t) ({ \
|
||||
void* _xp; (void)(h); (void)(t); _xp = (p); \
|
||||
printf("info: free: %p, M_WOLFSSL\n", p); \
|
||||
if(_xp) free(_xp, M_WOLFSSL); \
|
||||
})
|
||||
#else
|
||||
#define XFREE(p, h, t) \
|
||||
({void* _xp; (void)(h); (void)(t); _xp = (p); \
|
||||
if(_xp) free(_xp, M_WOLFSSL);})
|
||||
#endif
|
||||
#define XMALLOC(s, h, t) ({ \
|
||||
(void)(h); (void)(t); \
|
||||
void * _ptr = malloc(s, M_WOLFSSL, M_WAITOK | M_ZERO); \
|
||||
(void *)_ptr; \
|
||||
})
|
||||
|
||||
#define XFREE(p, h, t) ({ \
|
||||
void* _xp; (void)(h); (void)(t); _xp = (p); \
|
||||
if(_xp) free(_xp, M_WOLFSSL); \
|
||||
})
|
||||
#endif /* WOLFSSL_BSDKM_DEBUG_MEMORY */
|
||||
|
||||
#if !defined(SINGLE_THREADED)
|
||||
#define WC_MUTEX_OPS_INLINE
|
||||
|
||||
/* Copied from wc_port.h */
|
||||
#if defined(HAVE_FIPS) && !defined(WOLFSSL_API_PREFIX_MAP)
|
||||
/* For FIPS keep the function names the same */
|
||||
#define wc_InitMutex InitMutex
|
||||
#define wc_FreeMutex FreeMutex
|
||||
#define wc_LockMutex LockMutex
|
||||
#define wc_UnLockMutex UnLockMutex
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
typedef struct wolfSSL_Mutex {
|
||||
struct mtx lock;
|
||||
} wolfSSL_Mutex;
|
||||
@@ -106,12 +146,18 @@ extern struct malloc_type M_WOLFSSL[1];
|
||||
|
||||
#if defined(WOLFSSL_HAVE_ATOMIC_H) && !defined(WOLFSSL_NO_ATOMICS)
|
||||
#include <machine/atomic.h>
|
||||
typedef volatile int wolfSSL_Atomic_Int;
|
||||
typedef volatile int wolfSSL_Atomic_Int;
|
||||
typedef volatile unsigned int wolfSSL_Atomic_Uint;
|
||||
#define WOLFSSL_ATOMIC_INITIALIZER(x) (x)
|
||||
#define WOLFSSL_ATOMIC_LOAD(x) (int)atomic_load_acq_int(&(x))
|
||||
#define WOLFSSL_ATOMIC_STORE(x, v) atomic_store_rel_int(&(x), (v))
|
||||
#define WOLFSSL_ATOMIC_OPS
|
||||
|
||||
#if defined(HAVE_FIPS)
|
||||
/* There is no corresponding ATOMIC_INIT macro in FreeBSD.
|
||||
* The FreeBSD equivalent is just an integer initialization. */
|
||||
#define ATOMIC_INIT(x) (x)
|
||||
#endif
|
||||
#endif /* WOLFSSL_HAVE_ATOMIC_H && !WOLFSSL_NO_ATOMICS */
|
||||
|
||||
#endif /* WOLFSSL_BSDKM */
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
|
||||
EXTRA_DIST += m4/ax_bsdkm.m4 \
|
||||
bsdkm/Makefile \
|
||||
bsdkm/README.md \
|
||||
bsdkm/wolfkmod.c \
|
||||
bsdkm/bsdkm_wc_port.h
|
||||
|
||||
202
bsdkm/wolfkmod.c
202
bsdkm/wolfkmod.c
@@ -33,10 +33,20 @@
|
||||
#else
|
||||
#include <wolfssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
#ifdef USE_CONTESTMUTEX
|
||||
#error USE_CONTESTMUTEX is incompatible with WOLFSSL_BSDKM
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/fips_test.h>
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#if !defined(NO_CRYPT_TEST)
|
||||
#include <wolfcrypt/test/test.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/random.h>
|
||||
|
||||
MALLOC_DEFINE(M_WOLFSSL, "libwolfssl", "wolfSSL kernel memory");
|
||||
|
||||
static int wolfkmod_init(void);
|
||||
@@ -44,47 +54,140 @@ static int wolfkmod_cleanup(void);
|
||||
static int wolfkmod_load(void);
|
||||
static int wolfkmod_unload(void);
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
#define WOLFKMOD_FIPS_ERR_MSG(hash) ({ \
|
||||
printf("In-core integrity hash check failure.\n"); \
|
||||
if ((hash)) \
|
||||
printf("Rebuild with \"WOLFCRYPT_FIPS_CORE_HASH_VALUE=%s\".\n", \
|
||||
hash); \
|
||||
else \
|
||||
printf("error: could not compute new hash. " \
|
||||
"Contact customer support.\n"); \
|
||||
})
|
||||
|
||||
static void wolfkmod_fips_cb(int ok, int err, const char * hash)
|
||||
{
|
||||
if ((!ok) || (err != 0)) {
|
||||
printf("error: libwolfssl FIPS error: %s\n",
|
||||
wc_GetErrorString(err));
|
||||
}
|
||||
|
||||
if (err == WC_NO_ERR_TRACE(IN_CORE_FIPS_E)) {
|
||||
WOLFKMOD_FIPS_ERR_MSG(hash);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
static int wolfkmod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int error = 0;
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
error = wolfCrypt_SetCb_fips(wolfkmod_fips_cb);
|
||||
if (error != 0) {
|
||||
printf("error: wolfCrypt_SetCb_fips failed: %s\n",
|
||||
wc_GetErrorString(error));
|
||||
return (ECANCELED);
|
||||
}
|
||||
|
||||
fipsEntry();
|
||||
|
||||
error = wolfCrypt_GetStatus_fips();
|
||||
if (error != 0) {
|
||||
printf("error: wolfCrypt_GetStatus_fips failed: %d: %s\n",
|
||||
error, wc_GetErrorString(error));
|
||||
if (error == WC_NO_ERR_TRACE(IN_CORE_FIPS_E)) {
|
||||
const char *newhash = wolfCrypt_GetCoreHash_fips();
|
||||
WOLFKMOD_FIPS_ERR_MSG(newhash);
|
||||
}
|
||||
return (ECANCELED);
|
||||
}
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#ifdef WC_RNG_SEED_CB
|
||||
error = wc_SetSeed_Cb(WC_GENERATE_SEED_DEFAULT);
|
||||
if (error < 0) {
|
||||
printf("error: wc_SetSeed_Cb failed: %d\n", error);
|
||||
return (ECANCELED);
|
||||
}
|
||||
#endif /* WC_RNG_SEED_CB */
|
||||
|
||||
#ifdef WOLFCRYPT_ONLY
|
||||
ret = wolfCrypt_Init();
|
||||
if (ret != 0) {
|
||||
printf("error: wolfCrypt_Init failed: %s\n", wc_GetErrorString(ret));
|
||||
error = wolfCrypt_Init();
|
||||
if (error != 0) {
|
||||
printf("error: wolfCrypt_Init failed: %s\n", wc_GetErrorString(error));
|
||||
return (ECANCELED);
|
||||
}
|
||||
#else
|
||||
ret = wolfSSL_Init();
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
printf("error: wolfSSL_Init failed: %s\n", wc_GetErrorString(ret));
|
||||
error = wolfSSL_Init();
|
||||
if (error != WOLFSSL_SUCCESS) {
|
||||
printf("error: wolfSSL_Init failed: %s\n", wc_GetErrorString(error));
|
||||
return (ECANCELED);
|
||||
}
|
||||
#endif /* WOLFCRYPT_ONLY */
|
||||
|
||||
#ifdef HAVE_FIPS
|
||||
error = wc_RunAllCast_fips();
|
||||
if (error != 0) {
|
||||
printf("error: wc_RunAllCast_fips failed with "
|
||||
"return value %d\n", error);
|
||||
return (ECANCELED);
|
||||
}
|
||||
else {
|
||||
printf("info: FIPS 140-3 wolfCrypt-fips v%d.%d.%d%s%s startup "
|
||||
"self-test succeeded.\n",
|
||||
#ifdef HAVE_FIPS_VERSION_MAJOR
|
||||
HAVE_FIPS_VERSION_MAJOR,
|
||||
#else
|
||||
HAVE_FIPS_VERSION,
|
||||
#endif
|
||||
#ifdef HAVE_FIPS_VERSION_MINOR
|
||||
HAVE_FIPS_VERSION_MINOR,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
#ifdef HAVE_FIPS_VERSION_PATCH
|
||||
HAVE_FIPS_VERSION_PATCH,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
#ifdef HAVE_FIPS_VERSION_PORT
|
||||
"-",
|
||||
HAVE_FIPS_VERSION_PORT
|
||||
#else
|
||||
"",
|
||||
""
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int wolfkmod_cleanup(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int error = 0;
|
||||
|
||||
#ifdef WOLFCRYPT_ONLY
|
||||
ret = wolfCrypt_Cleanup();
|
||||
if (ret != 0) {
|
||||
printf("error: wolfCrypt_Cleanup failed: %s\n", wc_GetErrorString(ret));
|
||||
error = wolfCrypt_Cleanup();
|
||||
if (error != 0) {
|
||||
printf("error: wolfCrypt_Cleanup failed: %s\n",
|
||||
wc_GetErrorString(error));
|
||||
return (ECANCELED);
|
||||
}
|
||||
#else
|
||||
ret = wolfSSL_Cleanup();
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
printf("error: wolfSSL_Cleanup failed: %s\n", wc_GetErrorString(ret));
|
||||
error = wolfSSL_Cleanup();
|
||||
if (error != WOLFSSL_SUCCESS) {
|
||||
printf("error: wolfSSL_Cleanup failed: %s\n",
|
||||
wc_GetErrorString(error));
|
||||
return (ECANCELED);
|
||||
}
|
||||
#endif /* WOLFCRYPT_ONLY */
|
||||
|
||||
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
|
||||
printf("info: libwolfssl " LIBWOLFSSL_VERSION_STRING " cleanup complete.\n");
|
||||
printf("info: libwolfssl " LIBWOLFSSL_VERSION_STRING
|
||||
" cleanup complete.\n");
|
||||
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
|
||||
|
||||
return (0);
|
||||
@@ -92,23 +195,21 @@ static int wolfkmod_cleanup(void)
|
||||
|
||||
static int wolfkmod_load(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int error = 0;
|
||||
|
||||
ret = wolfkmod_init();
|
||||
if (ret != 0) {
|
||||
error = wolfkmod_init();
|
||||
if (error != 0) {
|
||||
return (ECANCELED);
|
||||
}
|
||||
|
||||
#ifndef NO_CRYPT_TEST
|
||||
ret = wolfcrypt_test(NULL);
|
||||
if (ret != 0) {
|
||||
printf("error: wolfcrypt test failed with return code: %d\n", ret);
|
||||
error = wolfcrypt_test(NULL);
|
||||
if (error != 0) {
|
||||
printf("error: wolfcrypt test failed: %d\n", error);
|
||||
(void)wolfkmod_cleanup();
|
||||
return (ECANCELED);
|
||||
}
|
||||
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
|
||||
printf("info: wolfCrypt self-test passed.\n");
|
||||
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
|
||||
#endif /* NO_CRYPT_TEST */
|
||||
|
||||
/**
|
||||
@@ -123,52 +224,83 @@ static int wolfkmod_load(void)
|
||||
|
||||
static int wolfkmod_unload(void)
|
||||
{
|
||||
int ret = 0;
|
||||
int error = 0;
|
||||
|
||||
ret = wolfkmod_cleanup();
|
||||
#ifdef HAVE_FIPS
|
||||
error = wc_RunAllCast_fips();
|
||||
if (error != 0) {
|
||||
printf("error: wc_RunAllCast_fips failed at shutdown with "
|
||||
"return value %d\n", error);
|
||||
}
|
||||
else
|
||||
printf("info: wolfCrypt FIPS re-self-test succeeded at unload: "
|
||||
"all algorithms re-verified.\n");
|
||||
#endif
|
||||
|
||||
error = wolfkmod_cleanup();
|
||||
|
||||
/**
|
||||
* todo: unregister wolfcrypt algs here with crypto_unregister_all
|
||||
* and related.
|
||||
* */
|
||||
|
||||
if (ret == 0) {
|
||||
if (error == 0) {
|
||||
printf("info: libwolfssl unloaded\n");
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
|
||||
static const char * wolfkmod_event_to_str(modeventtype_t what)
|
||||
{
|
||||
switch (what) {
|
||||
case MOD_LOAD:
|
||||
return "MOD_LOAD";
|
||||
case MOD_UNLOAD:
|
||||
return "MOD_UNLOAD";
|
||||
case MOD_SHUTDOWN:
|
||||
return "MOD_SHUTDOWN";
|
||||
case MOD_QUIESCE:
|
||||
return "MOD_QUIESCE";
|
||||
}
|
||||
}
|
||||
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
|
||||
|
||||
/* see /usr/include/sys/module.h for more info. */
|
||||
static int
|
||||
wolfkmod_event(struct module * m, int what, void * arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int error = 0;
|
||||
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
|
||||
printf("info: wolfkmod_event: %s\n", wolfkmod_event_to_str(what));
|
||||
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
|
||||
|
||||
switch (what) {
|
||||
case MOD_LOAD:
|
||||
ret = wolfkmod_load();
|
||||
error = wolfkmod_load();
|
||||
break;
|
||||
case MOD_UNLOAD:
|
||||
ret = wolfkmod_unload();
|
||||
error = wolfkmod_unload();
|
||||
break;
|
||||
case MOD_SHUTDOWN:
|
||||
case MOD_QUIESCE:
|
||||
default:
|
||||
#if defined(WOLFSSL_BSDKM_VERBOSE_DEBUG)
|
||||
printf("info: not implemented: %d\n", what);
|
||||
#endif /* WOLFSSL_BSDKM_VERBOSE_DEBUG */
|
||||
ret = EOPNOTSUPP;
|
||||
error = EOPNOTSUPP;
|
||||
}
|
||||
|
||||
(void)m;
|
||||
(void)arg;
|
||||
|
||||
return (ret);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static moduledata_t libwolfmod = {
|
||||
#ifdef HAVE_FIPS
|
||||
"libwolfssl_fips", /* module name */
|
||||
#else
|
||||
"libwolfssl", /* module name */
|
||||
#endif /* HAVE_FIPS */
|
||||
wolfkmod_event, /* module event handler */
|
||||
NULL /* extra data, unused */
|
||||
};
|
||||
|
||||
13
certs/crl/bad_time_fmt.pem
Normal file
13
certs/crl/bad_time_fmt.pem
Normal file
@@ -0,0 +1,13 @@
|
||||
-----BEGIN X509 CRL-----
|
||||
MIIB7DCB1QIBATANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJVUzELMAkGA1UE
|
||||
CAwCVVMxCzAJBgNVBAcMAlVTMQswCQYDVQQKDAJVUzELMAkGA1UEAwwCVVMxCzAJ
|
||||
BgNVBAsMAlVTGA0yNDAxMjMwMDAwMDBaGA0zNDAxMjAwMDAwMDBaMDUwMwIUHIAC
|
||||
LvgfJAXulqYS3LYf4KxwHl4XDTI1MDMxMzAyNDQ0MFowDDAKBgNVHRUEAwoBBqAc
|
||||
MBowGAYDVR0UBBECDxnP/97adO3y9qRGDM7hQDANBgkqhkiG9w0BAQsFAAOCAQEA
|
||||
aDY9jBdAJiAujUkaLYLVtzNWF/0SxD5CB4dYIcZMqtPKLn5ykcxkXvnRbVihJ+Kn
|
||||
AAv9Fkn5iwj77EGwxNjyZktQ4gAmcMhCTBEcAHbmi92tHttot9Sr44+CN+0NaaQD
|
||||
OflIeVw7Zir90TWufjScy8/e7FkVm+aD5CicrbJWqoe21pB1Q1jS49iNrZzqZ2vw
|
||||
HLiqNAzpecxwUih/YPe5+CBk5Nq4vICeieGVC/JO9r5SkdDwWQTl0I3kSK6n4Jh7
|
||||
53FmIen80F2ZZuZu4/fhJ7C4rlr6W9i6FrK06s5mk1PeYFHKhCkwI8wp8cIudJQD
|
||||
lLsK2u4CTcuTKdbDLsszYA==
|
||||
-----END X509 CRL-----
|
||||
43
certs/crl/extra-crls/large_crlnum.pem
Normal file
43
certs/crl/extra-crls/large_crlnum.pem
Normal file
@@ -0,0 +1,43 @@
|
||||
Certificate Revocation List (CRL):
|
||||
Version 2 (0x1)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com, emailAddress=info@wolfssl.com
|
||||
Last Update: Jan 8 07:15:25 2026 GMT
|
||||
Next Update: Oct 4 07:15:25 2028 GMT
|
||||
CRL extensions:
|
||||
X509v3 CRL Number:
|
||||
0xD8AFADA7F08B38E6178BD0E5CD7B0DF80071BA74
|
||||
Revoked Certificates:
|
||||
Serial Number: 01
|
||||
Revocation Date: Jan 8 07:15:25 2026 GMT
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Signature Value:
|
||||
0c:45:a0:2e:ba:ad:28:48:eb:61:29:a6:fa:d0:76:8c:96:bb:
|
||||
1a:9a:79:90:05:06:78:8e:d2:f6:4d:6d:4c:75:62:d2:b2:91:
|
||||
f8:e4:59:a9:db:6f:e6:58:fe:f9:2e:7a:67:a7:01:a3:68:ee:
|
||||
b1:23:a6:25:2a:85:84:3d:bf:86:bf:6d:d5:a6:2d:03:8e:d1:
|
||||
ac:0f:73:4c:47:ea:fb:75:2e:85:1f:dc:fa:5e:b2:eb:d1:f4:
|
||||
75:e9:ae:a9:90:6e:ec:c9:05:db:61:39:30:a8:4e:c3:d2:ce:
|
||||
77:2d:ba:bf:fd:74:dc:c6:41:db:65:c4:83:66:9c:91:60:43:
|
||||
57:a3:52:bb:9c:b7:fa:30:d3:01:89:7f:5e:c8:06:0a:34:1b:
|
||||
77:ce:e8:b4:85:c5:6e:63:50:f3:88:cc:e3:54:7b:29:5c:08:
|
||||
4a:7b:35:b4:3f:01:2e:c5:93:4f:7c:7a:17:bf:0d:bd:be:3e:
|
||||
a9:1b:ef:a0:9c:bc:78:9e:91:99:91:e7:38:63:f1:24:86:02:
|
||||
63:81:cb:67:3a:f7:3c:5c:45:87:54:f4:9a:16:25:a2:e5:bd:
|
||||
ee:7e:9a:28:c0:db:4e:bc:4a:0d:c2:5f:14:ea:9c:8a:42:db:
|
||||
d2:1d:27:b8:d2:3c:57:4a:bf:46:4a:95:ac:7f:f4:47:22:dd:
|
||||
d5:dc:52:3f
|
||||
-----BEGIN X509 CRL-----
|
||||
MIICGTCCAQECAQEwDQYJKoZIhvcNAQELBQAwgZQxCzAJBgNVBAYTAlVTMRAwDgYD
|
||||
VQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290
|
||||
aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t
|
||||
MR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tFw0yNjAxMDgwNzE1MjVa
|
||||
Fw0yODEwMDQwNzE1MjVaMBQwEgIBARcNMjYwMTA4MDcxNTI1WqAiMCAwHgYDVR0U
|
||||
BBcCFQDYr62n8Is45heL0OXNew34AHG6dDANBgkqhkiG9w0BAQsFAAOCAQEADEWg
|
||||
LrqtKEjrYSmm+tB2jJa7Gpp5kAUGeI7S9k1tTHVi0rKR+ORZqdtv5lj++S56Z6cB
|
||||
o2jusSOmJSqFhD2/hr9t1aYtA47RrA9zTEfq+3UuhR/c+l6y69H0demuqZBu7MkF
|
||||
22E5MKhOw9LOdy26v/103MZB22XEg2ackWBDV6NSu5y3+jDTAYl/XsgGCjQbd87o
|
||||
tIXFbmNQ84jM41R7KVwISns1tD8BLsWTT3x6F78Nvb4+qRvvoJy8eJ6RmZHnOGPx
|
||||
JIYCY4HLZzr3PFxFh1T0mhYlouW97n6aKMDbTrxKDcJfFOqcikLb0h0nuNI8V0q/
|
||||
RkqVrH/0RyLd1dxSPw==
|
||||
-----END X509 CRL-----
|
||||
43
certs/crl/extra-crls/large_crlnum2.pem
Normal file
43
certs/crl/extra-crls/large_crlnum2.pem
Normal file
@@ -0,0 +1,43 @@
|
||||
Certificate Revocation List (CRL):
|
||||
Version 2 (0x1)
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com, emailAddress=info@wolfssl.com
|
||||
Last Update: Jan 8 07:15:25 2026 GMT
|
||||
Next Update: Oct 4 07:15:25 2028 GMT
|
||||
CRL extensions:
|
||||
X509v3 CRL Number:
|
||||
0x8BC28C3B3F7A6344CD464A9FDC837F2009DEB94FD3
|
||||
Revoked Certificates:
|
||||
Serial Number: 01
|
||||
Revocation Date: Jan 8 07:15:25 2026 GMT
|
||||
Signature Algorithm: sha256WithRSAEncryption
|
||||
Signature Value:
|
||||
47:71:aa:8d:29:11:90:57:c9:70:78:a5:de:40:ee:c3:da:81:
|
||||
68:d0:20:09:af:5b:5f:30:f9:69:14:ff:8a:cf:46:0d:e8:0d:
|
||||
45:df:1d:49:ce:05:01:28:a5:34:50:b6:cb:54:9d:a1:42:6c:
|
||||
f6:e2:66:de:be:e4:90:55:c1:83:e5:4c:26:96:43:29:39:84:
|
||||
ad:68:3c:0d:5a:d4:e7:ba:7c:21:e9:a1:c2:0c:ad:6f:0c:32:
|
||||
71:81:9f:df:7d:c3:0d:92:a4:6f:43:9f:8f:b7:ef:2d:6d:92:
|
||||
a6:17:cb:c7:4c:2e:3b:a5:2b:2c:74:fa:d1:be:6d:dc:19:04:
|
||||
d6:b6:56:6c:26:94:8e:13:15:29:12:fe:1a:a4:73:55:df:a5:
|
||||
c8:d3:d5:99:4a:c6:be:64:1f:90:a9:d8:94:d1:3b:b1:0e:ff:
|
||||
e4:81:d0:e5:a4:8a:a7:a9:82:fb:a6:86:be:e7:e1:a8:b5:0d:
|
||||
87:bb:76:5b:0e:05:1f:d4:82:3c:68:99:ec:ae:ae:8e:4a:72:
|
||||
cf:3f:8a:7f:b0:a2:69:d9:8c:68:7d:2f:3e:54:e9:fb:70:cf:
|
||||
d4:ed:1b:61:68:33:4f:93:9b:5f:5e:e9:de:e8:51:66:fd:c8:
|
||||
35:40:a0:7d:42:bd:d7:f4:96:cd:c8:72:14:84:cd:f5:19:8c:
|
||||
a0:5a:b7:72
|
||||
-----BEGIN X509 CRL-----
|
||||
MIICGjCCAQICAQEwDQYJKoZIhvcNAQELBQAwgZQxCzAJBgNVBAYTAlVTMRAwDgYD
|
||||
VQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290
|
||||
aDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t
|
||||
MR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tFw0yNjAxMDgwNzE1MjVa
|
||||
Fw0yODEwMDQwNzE1MjVaMBQwEgIBARcNMjYwMTA4MDcxNTI1WqAjMCEwHwYDVR0U
|
||||
BBgCFgCLwow7P3pjRM1GSp/cg38gCd65T9MwDQYJKoZIhvcNAQELBQADggEBAEdx
|
||||
qo0pEZBXyXB4pd5A7sPagWjQIAmvW18w+WkU/4rPRg3oDUXfHUnOBQEopTRQtstU
|
||||
naFCbPbiZt6+5JBVwYPlTCaWQyk5hK1oPA1a1Oe6fCHpocIMrW8MMnGBn999ww2S
|
||||
pG9Dn4+37y1tkqYXy8dMLjulKyx0+tG+bdwZBNa2VmwmlI4TFSkS/hqkc1XfpcjT
|
||||
1ZlKxr5kH5Cp2JTRO7EO/+SB0OWkiqepgvumhr7n4ai1DYe7dlsOBR/Ugjxomeyu
|
||||
ro5Kcs8/in+womnZjGh9Lz5U6ftwz9TtG2FoM0+Tm19e6d7oUWb9yDVAoH1Cvdf0
|
||||
ls3IchSEzfUZjKBat3I=
|
||||
-----END X509 CRL-----
|
||||
@@ -219,4 +219,26 @@ openssl crl -in crl_rsapss.pem -text > tmp
|
||||
check_result $?
|
||||
mv tmp crl_rsapss.pem
|
||||
|
||||
echo "Step 29 large CRL number( = 20 octets )"
|
||||
echo d8afada7f08b38e6178bd0e5cd7b0df80071ba74 > crlnumber
|
||||
openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out extra-crls/large_crlnum.pem -keyfile ../ca-key.pem -cert ../ca-cert.pem
|
||||
check_result $?
|
||||
|
||||
# metadata
|
||||
echo "Step 29"
|
||||
openssl crl -in extra-crls/large_crlnum.pem -text > tmp
|
||||
check_result $?
|
||||
mv tmp extra-crls/large_crlnum.pem
|
||||
|
||||
echo "Step 30 large CRL number( > 20 octets )"
|
||||
echo 8bc28c3b3f7a6344cd464a9fdc837f2009deb94fd3 > crlnumber
|
||||
openssl ca -config ../renewcerts/wolfssl.cnf -gencrl -crldays 1000 -out extra-crls/large_crlnum2.pem -keyfile ../ca-key.pem -cert ../ca-cert.pem
|
||||
check_result $?
|
||||
|
||||
# metadata
|
||||
echo "Step 30"
|
||||
openssl crl -in extra-crls/large_crlnum2.pem -text > tmp
|
||||
check_result $?
|
||||
mv tmp extra-crls/large_crlnum2.pem
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -16,7 +16,8 @@ EXTRA_DIST += \
|
||||
certs/crl/wolfssl.cnf \
|
||||
certs/crl/crl.der \
|
||||
certs/crl/crl2.der \
|
||||
certs/crl/crl_rsapss.pem
|
||||
certs/crl/crl_rsapss.pem \
|
||||
certs/crl/bad_time_fmt.pem
|
||||
|
||||
EXTRA_DIST += \
|
||||
certs/crl/crl.revoked \
|
||||
|
||||
5
certs/external/README.txt
vendored
5
certs/external/README.txt
vendored
@@ -1,3 +1,2 @@
|
||||
ca_collection.pem contains the two possible Root CA's that login.live.com can
|
||||
return, either the Baltimore Cyber Trust Root CA or the DigiCert Global Sign
|
||||
Root CA.
|
||||
ca_collection.pem contains the Root CA certificates that login.live.com can
|
||||
return: DigiCert Global Root CA and DigiCert Global Root G2.
|
||||
|
||||
83
certs/external/ca_collection.pem
vendored
83
certs/external/ca_collection.pem
vendored
@@ -1,63 +1,3 @@
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number:
|
||||
08:3b:e0:56:90:42:46:b1:a1:75:6a:c9:59:91:c7:4a
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
|
||||
Validity
|
||||
Not Before: Nov 10 00:00:00 2006 GMT
|
||||
Not After : Nov 10 00:00:00 2031 GMT
|
||||
Subject: C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public-Key: (2048 bit)
|
||||
Modulus:
|
||||
00:e2:3b:e1:11:72:de:a8:a4:d3:a3:57:aa:50:a2:
|
||||
8f:0b:77:90:c9:a2:a5:ee:12:ce:96:5b:01:09:20:
|
||||
cc:01:93:a7:4e:30:b7:53:f7:43:c4:69:00:57:9d:
|
||||
e2:8d:22:dd:87:06:40:00:81:09:ce:ce:1b:83:bf:
|
||||
df:cd:3b:71:46:e2:d6:66:c7:05:b3:76:27:16:8f:
|
||||
7b:9e:1e:95:7d:ee:b7:48:a3:08:da:d6:af:7a:0c:
|
||||
39:06:65:7f:4a:5d:1f:bc:17:f8:ab:be:ee:28:d7:
|
||||
74:7f:7a:78:99:59:85:68:6e:5c:23:32:4b:bf:4e:
|
||||
c0:e8:5a:6d:e3:70:bf:77:10:bf:fc:01:f6:85:d9:
|
||||
a8:44:10:58:32:a9:75:18:d5:d1:a2:be:47:e2:27:
|
||||
6a:f4:9a:33:f8:49:08:60:8b:d4:5f:b4:3a:84:bf:
|
||||
a1:aa:4a:4c:7d:3e:cf:4f:5f:6c:76:5e:a0:4b:37:
|
||||
91:9e:dc:22:e6:6d:ce:14:1a:8e:6a:cb:fe:cd:b3:
|
||||
14:64:17:c7:5b:29:9e:32:bf:f2:ee:fa:d3:0b:42:
|
||||
d4:ab:b7:41:32:da:0c:d4:ef:f8:81:d5:bb:8d:58:
|
||||
3f:b5:1b:e8:49:28:a2:70:da:31:04:dd:f7:b2:16:
|
||||
f2:4c:0a:4e:07:a8:ed:4a:3d:5e:b5:7f:a3:90:c3:
|
||||
af:27
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Key Usage: critical
|
||||
Digital Signature, Certificate Sign, CRL Sign
|
||||
X509v3 Basic Constraints: critical
|
||||
CA:TRUE
|
||||
X509v3 Subject Key Identifier:
|
||||
03:DE:50:35:56:D1:4C:BB:66:F0:A3:E2:1B:1B:C3:97:B2:3D:D1:55
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:03:DE:50:35:56:D1:4C:BB:66:F0:A3:E2:1B:1B:C3:97:B2:3D:D1:55
|
||||
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
cb:9c:37:aa:48:13:12:0a:fa:dd:44:9c:4f:52:b0:f4:df:ae:
|
||||
04:f5:79:79:08:a3:24:18:fc:4b:2b:84:c0:2d:b9:d5:c7:fe:
|
||||
f4:c1:1f:58:cb:b8:6d:9c:7a:74:e7:98:29:ab:11:b5:e3:70:
|
||||
a0:a1:cd:4c:88:99:93:8c:91:70:e2:ab:0f:1c:be:93:a9:ff:
|
||||
63:d5:e4:07:60:d3:a3:bf:9d:5b:09:f1:d5:8e:e3:53:f4:8e:
|
||||
63:fa:3f:a7:db:b4:66:df:62:66:d6:d1:6e:41:8d:f2:2d:b5:
|
||||
ea:77:4a:9f:9d:58:e2:2b:59:c0:40:23:ed:2d:28:82:45:3e:
|
||||
79:54:92:26:98:e0:80:48:a8:37:ef:f0:d6:79:60:16:de:ac:
|
||||
e8:0e:cd:6e:ac:44:17:38:2f:49:da:e1:45:3e:2a:b9:36:53:
|
||||
cf:3a:50:06:f7:2e:e8:c4:57:49:6c:61:21:18:d5:04:ad:78:
|
||||
3c:2c:3a:80:6b:a7:eb:af:15:14:e9:d8:89:c1:b9:38:6c:e2:
|
||||
91:6c:8a:ff:64:b9:77:25:57:30:c0:1b:24:a3:e1:dc:e9:df:
|
||||
47:7c:b5:b4:24:08:05:30:ec:2d:bd:0b:bf:45:bf:50:b9:a9:
|
||||
f3:eb:98:01:12:ad:c8:88:c6:98:34:5f:8d:0a:3c:c6:e9:d5:
|
||||
95:95:6d:de
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
@@ -80,3 +20,26 @@ PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
|
||||
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
|
||||
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH
|
||||
MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT
|
||||
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
|
||||
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG
|
||||
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI
|
||||
2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx
|
||||
1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ
|
||||
q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz
|
||||
tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ
|
||||
vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP
|
||||
BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV
|
||||
5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY
|
||||
1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4
|
||||
NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG
|
||||
Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91
|
||||
8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe
|
||||
pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
|
||||
MrY=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@@ -201,6 +201,9 @@ function(generate_build_flags)
|
||||
if(WOLFSSL_MLKEM OR WOLFSSL_USER_SETTINGS)
|
||||
set(BUILD_WC_MLKEM "yes" PARENT_SCOPE)
|
||||
endif()
|
||||
if(WOLFSSL_DILITHIUM OR WOLFSSL_USER_SETTINGS)
|
||||
set(BUILD_DILITHIUM "yes" PARENT_SCOPE)
|
||||
endif()
|
||||
if(WOLFSSL_OQS OR WOLFSSL_USER_SETTINGS)
|
||||
set(BUILD_FALCON "yes" PARENT_SCOPE)
|
||||
set(BUILD_SPHINCS "yes" PARENT_SCOPE)
|
||||
@@ -389,6 +392,10 @@ function(generate_lib_src_list LIB_SOURCES)
|
||||
|
||||
if(BUILD_INTELASM)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/aes_gcm_asm.S)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/sha3_asm.S)
|
||||
elseif(BUILD_ARMASM)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha3-asm_c.c)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/port/arm/armv8-sha3-asm.S)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -563,11 +570,13 @@ function(generate_lib_src_list LIB_SOURCES)
|
||||
if(BUILD_ARMASM_INLINE)
|
||||
list(APPEND LIB_SOURCES
|
||||
wolfcrypt/src/port/arm/armv8-sha256.c
|
||||
wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c)
|
||||
wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.c
|
||||
wolfcrypt/src/port/arm/armv8-sha256-asm_c.c)
|
||||
else()
|
||||
list(APPEND LIB_SOURCES
|
||||
wolfcrypt/src/port/arm/armv8-sha256-asm.S
|
||||
wolfcrypt/src/port/arm/armv8-32-sha256-asm.S)
|
||||
wolfcrypt/src/port/arm/armv8-sha256.c
|
||||
wolfcrypt/src/port/arm/armv8-32-sha256-asm.S
|
||||
wolfcrypt/src/port/arm/armv8-sha256-asm.S)
|
||||
endif()
|
||||
if(BUILD_ARMASM_INLINE AND BUILD_ARM_THUMB)
|
||||
list(APPEND LIB_SOURCES
|
||||
@@ -990,6 +999,10 @@ function(generate_lib_src_list LIB_SOURCES)
|
||||
|
||||
if(BUILD_DILITHIUM)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/dilithium.c)
|
||||
|
||||
if(BUILD_INTELASM)
|
||||
list(APPEND LIB_SOURCES wolfcrypt/src/wc_mldsa_asm.S)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_WC_MLKEM)
|
||||
|
||||
@@ -96,6 +96,8 @@ extern "C" {
|
||||
#cmakedefine HAVE_CURVE448
|
||||
#undef HAVE_DH_DEFAULT_PARAMS
|
||||
#cmakedefine HAVE_DH_DEFAULT_PARAMS
|
||||
#undef HAVE_DILITHIUM
|
||||
#cmakedefine HAVE_DILITHIUM
|
||||
#undef HAVE_ECC
|
||||
#cmakedefine HAVE_ECC
|
||||
#undef HAVE_ECH
|
||||
@@ -354,6 +356,8 @@ extern "C" {
|
||||
#cmakedefine WOLFSSL_TLS13
|
||||
#undef WOLFSSL_USE_ALIGN
|
||||
#cmakedefine WOLFSSL_USE_ALIGN
|
||||
#undef WOLFSSL_USER_SETTINGS
|
||||
#cmakedefine WOLFSSL_USER_SETTINGS
|
||||
#undef WOLFSSL_USER_SETTINGS_ASM
|
||||
#cmakedefine WOLFSSL_USER_SETTINGS_ASM
|
||||
#undef WOLFSSL_W64_WRAPPER
|
||||
@@ -370,6 +374,8 @@ extern "C" {
|
||||
#cmakedefine WOLFSSL_HAVE_MLKEM
|
||||
#undef WOLFSSL_WC_MLKEM
|
||||
#cmakedefine WOLFSSL_WC_MLKEM
|
||||
#undef WOLFSSL_WC_DILITHIUM
|
||||
#cmakedefine WOLFSSL_WC_DILITHIUM
|
||||
#undef NO_WOLFSSL_STUB
|
||||
#cmakedefine NO_WOLFSSL_STUB
|
||||
#undef HAVE_ECC_SECPR2
|
||||
|
||||
118
configure.ac
118
configure.ac
@@ -314,6 +314,11 @@ AC_ARG_ENABLE([32bit],
|
||||
[ ENABLED_32BIT=no ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_32BIT" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWC_32BIT_CPU"
|
||||
fi
|
||||
|
||||
# 16-bit compiler support
|
||||
AC_ARG_ENABLE([16bit],
|
||||
[AS_HELP_STRING([--enable-16bit],[Enables 16-bit support (default: disabled)])],
|
||||
@@ -830,6 +835,11 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DXMALLOC_OVERRIDE -DWOLFCRYPT_ONLY"
|
||||
AM_CFLAGS="$AM_CFLAGS -DNO_ASN_TIME"
|
||||
|
||||
if test "$ax_enable_debug" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_BSDKM_VERBOSE_DEBUG"
|
||||
AM_CFLAGS="$AM_CFLAGS -DNO_WOLFSSL_DEBUG_CERTS"
|
||||
fi
|
||||
|
||||
if test "$KERNEL_ROOT" = ""; then
|
||||
AC_PATH_DEFAULT_BSDKM_SOURCE
|
||||
KERNEL_ROOT="$DEFAULT_BSDKM_ROOT"
|
||||
@@ -936,9 +946,21 @@ AC_ARG_ENABLE([fasthugemath],
|
||||
[ ENABLED_FASTHUGEMATH=no ]
|
||||
)
|
||||
|
||||
# ssl bump build
|
||||
AC_ARG_ENABLE([bump],
|
||||
[AS_HELP_STRING([--enable-bump],[Enable SSL Bump build (default: disabled)])],
|
||||
[ ENABLED_BUMP=$enableval ],
|
||||
[ ENABLED_BUMP=no ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_BUMP" = "yes"
|
||||
then
|
||||
ENABLED_FASTHUGEMATH="yes"
|
||||
AM_CFLAGS="$AM_CFLAGS -DLARGE_STATIC_BUFFERS -DWOLFSSL_CERT_GEN -DWOLFSSL_KEY_GEN -DHUGE_SESSION_CACHE -DWOLFSSL_DER_LOAD -DWOLFSSL_ALT_NAMES -DWOLFSSL_TEST_CERT"
|
||||
DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096
|
||||
if test "$ENABLED_SP_MATH" = "no" && test "$ENABLED_SP_MATH_ALL" = "no"
|
||||
then
|
||||
ENABLED_FASTHUGEMATH="yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$ENABLED_FASTHUGEMATH" = "yes"
|
||||
@@ -946,7 +968,8 @@ then
|
||||
ENABLED_FASTMATH="yes"
|
||||
fi
|
||||
|
||||
if test "$host_cpu" = "x86_64" || test "$host_cpu" = "amd64"
|
||||
if (test "$host_cpu" = "x86_64" || test "$host_cpu" = "amd64") &&
|
||||
test "$ENABLED_32BIT" != "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_X86_64_BUILD"
|
||||
fi
|
||||
@@ -1428,6 +1451,7 @@ then
|
||||
test "$enable_md5" = "" && enable_md5=yes
|
||||
test "$enable_anon" = "" && enable_anon=yes
|
||||
test "$enable_ssh" = "" && test "$enable_hmac" != "no" && enable_ssh=yes
|
||||
test "$enable_rng_bank" = "" && enable_rng_bank=yes
|
||||
|
||||
# the compiler optimizer generates a weird out-of-bounds bss reference for
|
||||
# find_hole() in the FP_ECC implementation.
|
||||
@@ -2208,6 +2232,19 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWC_NO_RNG"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([rng-bank],
|
||||
[AS_HELP_STRING([--enable-rng-bank],[Enable compiling and using RNG banks (default: disabled)])],
|
||||
[ ENABLED_RNG_BANK=$enableval ],
|
||||
[ ENABLED_RNG_BANK=$KERNEL_MODE_DEFAULTS ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_RNG_BANK" = "yes"
|
||||
then
|
||||
AS_IF([test "$ENABLED_RNG" = "no"],
|
||||
AC_MSG_ERROR([--enable-rng-bank requires --enable-rng]))
|
||||
AM_CFLAGS="$AM_CFLAGS -DWC_RNG_BANK_SUPPORT"
|
||||
fi
|
||||
|
||||
|
||||
# DTLS-SCTP
|
||||
AC_ARG_ENABLE([sctp],
|
||||
@@ -2469,13 +2506,6 @@ AC_ARG_ENABLE([qt],
|
||||
[ ENABLED_QT=no ]
|
||||
)
|
||||
|
||||
# ssl bump build
|
||||
AC_ARG_ENABLE([bump],
|
||||
[AS_HELP_STRING([--enable-bump],[Enable SSL Bump build (default: disabled)])],
|
||||
[ ENABLED_BUMP=$enableval ],
|
||||
[ ENABLED_BUMP=no ]
|
||||
)
|
||||
|
||||
# SNIFFER
|
||||
AC_ARG_ENABLE([sniffer],
|
||||
[AS_HELP_STRING([--enable-sniffer],[Enable wolfSSL sniffer support (default: disabled)])],
|
||||
@@ -2779,14 +2809,6 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DFORTRESS -DWOLFSSL_ALWAYS_VERIFY_CB -DWOLFSSL_AES_COUNTER -DWOLFSSL_AES_DIRECT -DWOLFSSL_DER_LOAD -DWOLFSSL_KEY_GEN"
|
||||
fi
|
||||
|
||||
|
||||
if test "$ENABLED_BUMP" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DLARGE_STATIC_BUFFERS -DWOLFSSL_CERT_GEN -DWOLFSSL_KEY_GEN -DHUGE_SESSION_CACHE -DWOLFSSL_DER_LOAD -DWOLFSSL_ALT_NAMES -DWOLFSSL_TEST_CERT"
|
||||
DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS=4096
|
||||
fi
|
||||
|
||||
|
||||
# lean TLS build (TLS 1.2 client only (no client auth), ECC256, AES128 and SHA256 w/o Shamir)
|
||||
AC_ARG_ENABLE([leantls],
|
||||
[AS_HELP_STRING([--enable-leantls],[Enable Lean TLS build (default: disabled)])],
|
||||
@@ -3389,6 +3411,13 @@ then
|
||||
ENABLED_ARMASM_CRYPTO=no
|
||||
;;
|
||||
sha256-small)
|
||||
case $host_cpu in
|
||||
*arm*)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([SHA256 small option only available on 32-bit ARM CPU.])
|
||||
break;;
|
||||
esac
|
||||
ENABLED_ARMASM_SHA256_SMALL=yes
|
||||
;;
|
||||
sha512-crypto | sha3-crypto)
|
||||
@@ -3458,8 +3487,25 @@ then
|
||||
esac
|
||||
ENABLED_ARMASM_BARRIER_DETECT=yes
|
||||
;;
|
||||
aes-block-dup)
|
||||
case $host_cpu in
|
||||
*arm*)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([AES assembly option only available on 32-bit ARM CPU.])
|
||||
break;;
|
||||
esac
|
||||
ENABLED_ARMASM_AES_BLOCK_INLINE=yes
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, sha512-crypto, sha3-crypto): $ENABLED_ARMASM.])
|
||||
case $host_cpu in
|
||||
*aarch64*)
|
||||
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, inline, no-crypto, sha512-crypto, sha3-crypto, no-sha512-crypto, no-sha3-crypto, barrier-sb, barrier-detect): $ENABLED_ARMASM.])
|
||||
break;;
|
||||
*arm*)
|
||||
AC_MSG_ERROR([Invalid choice of ARM asm inclusions (yes, inline, no-crypto, sha256-small, aes-block-dup): $ENABLED_ARMASM.])
|
||||
break;;
|
||||
esac
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
@@ -3624,6 +3670,9 @@ fi
|
||||
if test "$ENABLED_ARMASM_INLINE" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_INLINE"
|
||||
fi
|
||||
if test "$ENABLED_ARMASM_AES_BLOCK_INLINE" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_AES_BLOCK_INLINE"
|
||||
fi
|
||||
|
||||
# RISC-V Assembly
|
||||
AC_ARG_ENABLE([riscv-asm],
|
||||
@@ -3721,6 +3770,9 @@ then
|
||||
inline)
|
||||
ENABLED_PPC32_ASM_INLINE=yes
|
||||
;;
|
||||
inline-reg)
|
||||
ENABLED_PPC32_ASM_INLINE_REG=yes
|
||||
;;
|
||||
small)
|
||||
ENABLED_PPC32_ASM_SMALL=yes
|
||||
;;
|
||||
@@ -3738,7 +3790,7 @@ then
|
||||
AC_MSG_NOTICE([32-bit PowerPC assembly for SHA-256])
|
||||
ENABLED_PPC32_ASM=yes
|
||||
fi
|
||||
if test "$ENABLED_PPC32_ASM_INLINE" = "yes"; then
|
||||
if test "$ENABLED_PPC32_ASM_INLINE" = "yes" || test "$ENABLED_PPC32_ASM_INLINE_REG" = "yes"; then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PPC32_ASM_INLINE"
|
||||
else
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_PPC32_ASM"
|
||||
@@ -3954,12 +4006,17 @@ then
|
||||
fi
|
||||
|
||||
# AMD RDSEED
|
||||
AC_ARG_ENABLE([amdrand],
|
||||
[AS_HELP_STRING([--enable-amdrand],[Enable AMD rdseed as preferred RNG seeding source (default: disabled)])],
|
||||
AC_ARG_ENABLE([amdrdseed],
|
||||
[AS_HELP_STRING([--enable-amdrdseed],[Enable AMD rdseed as preferred RNG seeding source (default: disabled)])],
|
||||
[ ENABLED_AMDRDSEED=$enableval ],
|
||||
[ ENABLED_AMDRDSEED=no ]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE([amdrand],
|
||||
[AS_HELP_STRING([--enable-amdrand],[Enable AMD rdseed as preferred RNG seeding source (default: disabled)])],
|
||||
[ ENABLED_AMDRDSEED=$enableval ]
|
||||
)
|
||||
|
||||
if test "$ENABLED_AMDRDSEED" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_AMD_RDSEED"
|
||||
@@ -7835,7 +7892,7 @@ fi
|
||||
if test "$ENABLED_HAPROXY" = "yes"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAPROXY -DOPENSSL_COMPATIBLE_DEFAULTS"
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SIGNER_DER_CERT"
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SIGNER_DER_CERT -DWOLFSSL_KEEP_RNG_SEED_FD_OPEN"
|
||||
# --enable-all defines its own DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS
|
||||
if test -z "$DEFAULT_MAX_CLASSIC_ASYM_KEY_BITS"
|
||||
then
|
||||
@@ -10287,6 +10344,12 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CURVE25519_USE_ED25519"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_CURVE25519_USE_ED25519"
|
||||
fi
|
||||
if test "$ENABLED_CURVE25519" = "not-ed"
|
||||
then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CURVE25519_NOT_USE_ED25519"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_CURVE25519_NOT_USE_ED25519"
|
||||
fi
|
||||
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_CURVE25519"
|
||||
AM_CCASFLAGS="$AM_CCASFLAGS -DHAVE_CURVE25519"
|
||||
@@ -10861,6 +10924,11 @@ fi
|
||||
LIB_SOCKET_NSL
|
||||
AX_HARDEN_CC_COMPILER_FLAGS
|
||||
|
||||
# -Wdeprecated-enum-enum-conversion is on by default in C++20, but conflicts with
|
||||
# our use of enum constructs to define fungible constants.
|
||||
AX_CHECK_COMPILE_FLAG([-Werror -Wno-deprecated-enum-enum-conversion],
|
||||
[AX_APPEND_FLAG([-Wno-deprecated-enum-enum-conversion], [AM_CFLAGS])])
|
||||
|
||||
case $host_os in
|
||||
mingw*)
|
||||
# if mingw then link to ws2_32 for sockets, and crypt32
|
||||
@@ -11006,6 +11074,7 @@ AM_CONDITIONAL([BUILD_ARM_64],[test "$ENABLED_ARM_64" = "yes" || test "$ENABLED
|
||||
AM_CONDITIONAL([BUILD_RISCV_ASM],[test "x$ENABLED_RISCV_ASM" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_PPC32_ASM],[test "x$ENABLED_PPC32_ASM" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_PPC32_ASM_INLINE],[test "x$ENABLED_PPC32_ASM_INLINE" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_PPC32_ASM_INLINE_REG],[test "x$ENABLED_PPC32_ASM_INLINE_REG" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_XILINX],[test "x$ENABLED_XILINX" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_AESNI],[test "x$ENABLED_AESNI" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_INTELASM],[test "x$ENABLED_INTELASM" = "xyes"])
|
||||
@@ -11042,6 +11111,7 @@ AM_CONDITIONAL([BUILD_ECCSI],[test "x$ENABLED_ECCSI" = "xyes" || test "x$ENABLED
|
||||
AM_CONDITIONAL([BUILD_SAKKE],[test "x$ENABLED_SAKKE" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_MEMORY],[test "x$ENABLED_MEMORY" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_MEMUSE],[test "x$ENABLED_ENTROPY_MEMUSE" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_RNG_BANK],[test "$ENABLED_RNG_BANK" = "yes" || test "$ENABLED_USERSETTINGS" = "yes"])
|
||||
AM_CONDITIONAL([BUILD_RSA],[test "x$ENABLED_RSA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_DH],[test "x$ENABLED_DH" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
AM_CONDITIONAL([BUILD_ASN],[test "x$ENABLED_ASN" != "xno" || test "x$ENABLED_RSA" = "xyes" || test "x$ENABLED_USERSETTINGS" = "xyes"])
|
||||
@@ -11677,6 +11747,10 @@ if test "$ENABLED_PPC32_ASM_INLINE" = "yes"
|
||||
then
|
||||
ENABLED_PPC32_ASM="inline C"
|
||||
fi
|
||||
if test "$ENABLED_PPC32_ASM_INLINE_REG" = "yes"
|
||||
then
|
||||
ENABLED_PPC32_ASM="inline C Reg"
|
||||
fi
|
||||
echo " * PPC32 ASM $ENABLED_PPC32_ASM"
|
||||
echo " * Write duplicate: $ENABLED_WRITEDUP"
|
||||
echo " * Xilinx Hardware Acc.: $ENABLED_XILINX"
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
rules:
|
||||
- name: no-void-functions
|
||||
trigger: >-
|
||||
All functions must return a value. Avoid using void return types to ensure
|
||||
error values can be propagated upstream.
|
||||
solution: >-
|
||||
Change the function to return an appropriate error code or result instead
|
||||
of void. Ensure all return paths provide a meaningful value.
|
||||
- name: avoid-recursion
|
||||
trigger: >-
|
||||
Recursion is not allowed. Prefer iterative solutions to reduce stack usage
|
||||
and prevent potential stack overflows.
|
||||
solution: >-
|
||||
Refactor the recursive function into an iterative one using loops or other
|
||||
control structures.
|
||||
- name: use-forcezero
|
||||
trigger: >-
|
||||
Sensitive data such as private keys must be zeroized using `ForceZero()`
|
||||
to prevent the compiler from optimizing away the zeroization.
|
||||
solution: >-
|
||||
Replace `memset` or similar functions with `ForceZero(variable, size)` to
|
||||
ensure sensitive data is properly cleared from memory.
|
||||
- name: check-all-return-codes
|
||||
trigger: >-
|
||||
Every return code from function calls must be checked to handle errors
|
||||
appropriately and prevent unexpected behavior.
|
||||
solution: >-
|
||||
After each function call, add error handling logic to check the return
|
||||
value and respond accordingly.
|
||||
- name: no-memory-leaks
|
||||
trigger: >-
|
||||
Memory or resources allocated must have a clear path to being released to
|
||||
prevent memory leaks.
|
||||
solution: >-
|
||||
Ensure that every allocation has a corresponding free or release call. Use
|
||||
resource management patterns to handle allocations and deallocations.
|
||||
- name: do-not-change-external-apis
|
||||
trigger: >-
|
||||
External facing APIs should not be altered. Instead of modifying an
|
||||
existing API, create a new version with the necessary parameters.
|
||||
solution: >-
|
||||
If additional parameters are needed, create a new function (e.g., `f_ex(a,
|
||||
b)`) and have the original function (`f(a)`) call the new one with default
|
||||
or null parameters.
|
||||
- name: limit-stack-usage
|
||||
trigger: >-
|
||||
Functions should not use more than 100 bytes of stack. Excessive stack
|
||||
usage can lead to stack overflows and reduced performance.
|
||||
solution: >-
|
||||
Apply the `WOLFSSL_SMALL_STACK` pattern by dynamically allocating large
|
||||
variables to minimize stack usage within the function.
|
||||
- name: prefer-constant-time
|
||||
trigger: >-
|
||||
Implement algorithms in constant time to prevent timing attacks and ensure
|
||||
security.
|
||||
solution: >-
|
||||
Review and refactor algorithms to ensure their execution time does not
|
||||
depend on input values. Use constant-time libraries or functions where
|
||||
applicable.
|
||||
- name: use-sizeof
|
||||
trigger: >-
|
||||
Avoid hard-coded numeric values for sizes. Use `sizeof()` to ensure
|
||||
portability and maintainability.
|
||||
solution: >-
|
||||
Replace hard-coded sizes with `sizeof(type)` to automatically adapt to
|
||||
changes in type sizes.
|
||||
- name: use-typedefs-not-stdint
|
||||
trigger: >-
|
||||
Use `byte`, `word16`, `word32` instead of standard integer types like
|
||||
`uint32_t` to maintain consistency across the codebase.
|
||||
solution: >-
|
||||
Replace instances of `uint32_t` and similar types with the designated
|
||||
typedefs such as `word32`.
|
||||
- name: use-c-style-comments
|
||||
trigger: >-
|
||||
Only C-style comments (`/* */`) are allowed in C code. C++ style comments
|
||||
(`//`) should not be used.
|
||||
solution: >-
|
||||
Replace all `//` comments with `/* */` to adhere to the project's
|
||||
commenting standards.
|
||||
- name: pointer-null-check
|
||||
trigger: >-
|
||||
Always check for null pointers using the `ptr != NULL` pattern to prevent
|
||||
dereferencing null pointers.
|
||||
solution: >-
|
||||
Add a condition to verify that the pointer is not null before using it,
|
||||
e.g., `if (ptr != NULL) { /* use ptr */ }`.
|
||||
- name: declare-const-pointers
|
||||
trigger: >-
|
||||
Pointer parameters that are not modified within a function should be
|
||||
declared as `const` to enhance code safety and clarity.
|
||||
solution: >-
|
||||
Add the `const` keyword to pointer parameters that are not intended to be
|
||||
modified, e.g., `const void *ptr`.
|
||||
- name: struct-member-order
|
||||
trigger: >-
|
||||
Struct members should be ordered in descending size to optimize memory
|
||||
alignment and reduce padding.
|
||||
solution: >-
|
||||
Reorder the members of the struct so that larger data types are declared
|
||||
before smaller ones.
|
||||
- name: no-always-success-stubs
|
||||
trigger: >-
|
||||
when implementing a stub function that is not fully developed, returning
|
||||
success unconditionally can hide real logic and debugging information
|
||||
solution: >-
|
||||
either implement the stub with real logic or return an appropriate error
|
||||
code to indicate "not yet implemented," so that failures are not silently
|
||||
ignored
|
||||
- name: free-allocated-memory
|
||||
trigger: |-
|
||||
allocating memory but forgetting to free it on all code paths
|
||||
or using functions that allocate buffers without a corresponding free
|
||||
solution: >-
|
||||
for every XMALLOC call, ensure there's a matching XFREE on every return
|
||||
path
|
||||
|
||||
if handing ownership off, confirm the new owner also properly frees it
|
||||
- name: check-return-codes
|
||||
trigger: >-
|
||||
calling library functions that return non-zero in case of error, but not
|
||||
checking or handling those return values
|
||||
solution: >-
|
||||
always verify and handle function return codes
|
||||
|
||||
if ret != 0, do not continue silently; either propagate the error or
|
||||
handle it
|
||||
- name: handle-partial-writes
|
||||
trigger: >-
|
||||
calling a write function (e.g., wolfSSL_write_ex) that may write only part
|
||||
of the data, returning fewer bytes than requested or a particular status
|
||||
solution: >-
|
||||
if partial writes are possible, loop until the entire buffer is written or
|
||||
an error occurs
|
||||
|
||||
do not assume a single call wrote or accepted all bytes
|
||||
- name: manage-ephemeral-objects-correctly
|
||||
trigger: >-
|
||||
generating or importing ephemeral objects (e.g., ephemeral keys, ephemeral
|
||||
certs) and forgetting to finalize or free them, or double-freeing them
|
||||
solution: >-
|
||||
coordinate ephemeral object ownership carefully
|
||||
|
||||
ensure ephemeral structures are freed once no longer needed, and avoid
|
||||
reusing pointers after free
|
||||
@@ -307,8 +307,8 @@ int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
|
||||
|
||||
\brief メッセージがRSAキーによって署名されたことを検証するために使用されます。出力は入力と同じバイト配列を使用します。
|
||||
|
||||
\return >0 テキストの長さ。
|
||||
\return <0 エラーが発生しました。
|
||||
\return `>0` ダイジェストの長さ。
|
||||
\return `<0` エラーが発生しました。
|
||||
|
||||
\param in 復号されるバイト配列。
|
||||
\param inLen 入力バッファの長さ。
|
||||
@@ -344,7 +344,7 @@ int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
|
||||
|
||||
\brief メッセージがキーによって署名されたことを検証するために使用されます。
|
||||
|
||||
\return Success エラーがない場合のテキストの長さ。
|
||||
\return Success エラーがない場合のダイジェストの長さ。
|
||||
\return MEMORY_E メモリ例外。
|
||||
|
||||
\param in 復号されるバイト配列。
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -57,3 +57,57 @@ int wc_Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length);
|
||||
\sa wc_Arc4Process
|
||||
*/
|
||||
int wc_Arc4SetKey(Arc4* arc4, const byte* key, word32 length);
|
||||
|
||||
/*!
|
||||
\ingroup ARC4
|
||||
\brief This function initializes an ARC4 structure for use with
|
||||
asynchronous cryptographic operations. It sets up the heap hint and
|
||||
device ID for hardware acceleration support.
|
||||
|
||||
\return 0 On success.
|
||||
\return BAD_FUNC_ARG If arc4 is NULL.
|
||||
|
||||
\param arc4 pointer to the Arc4 structure to initialize
|
||||
\param heap pointer to heap hint for memory allocation (can be NULL)
|
||||
\param devId device ID for hardware acceleration (use INVALID_DEVID
|
||||
for software)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Arc4 arc4;
|
||||
int ret = wc_Arc4Init(&arc4, NULL, INVALID_DEVID);
|
||||
if (ret != 0) {
|
||||
// initialization failed
|
||||
}
|
||||
// use arc4 for encryption/decryption
|
||||
wc_Arc4Free(&arc4);
|
||||
\endcode
|
||||
|
||||
\sa wc_Arc4SetKey
|
||||
\sa wc_Arc4Free
|
||||
*/
|
||||
int wc_Arc4Init(Arc4* arc4, void* heap, int devId);
|
||||
|
||||
/*!
|
||||
\ingroup ARC4
|
||||
\brief This function frees an ARC4 structure, releasing any resources
|
||||
allocated for asynchronous cryptographic operations. It should be
|
||||
called when the ARC4 structure is no longer needed.
|
||||
|
||||
\return none No return value.
|
||||
|
||||
\param arc4 pointer to the Arc4 structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Arc4 arc4;
|
||||
wc_Arc4Init(&arc4, NULL, INVALID_DEVID);
|
||||
wc_Arc4SetKey(&arc4, key, keyLen);
|
||||
// use arc4 for encryption/decryption
|
||||
wc_Arc4Free(&arc4);
|
||||
\endcode
|
||||
|
||||
\sa wc_Arc4Init
|
||||
\sa wc_Arc4SetKey
|
||||
*/
|
||||
void wc_Arc4Free(Arc4* arc4);
|
||||
|
||||
@@ -466,4 +466,109 @@ int wc_AsconAEAD128_DecryptUpdate(wc_AsconAEAD128* a, byte* out, const byte* in,
|
||||
*/
|
||||
int wc_AsconAEAD128_DecryptFinal(wc_AsconAEAD128* a, const byte* tag);
|
||||
|
||||
/*!
|
||||
\ingroup ASCON
|
||||
\brief This function allocates and initializes a new Ascon Hash256
|
||||
context. The returned context must be freed with wc_AsconHash256_Free
|
||||
when no longer needed.
|
||||
|
||||
\return Pointer to allocated wc_AsconHash256 structure on success.
|
||||
\return NULL on allocation or initialization failure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wc_AsconHash256* hash = wc_AsconHash256_New();
|
||||
if (hash == NULL) {
|
||||
// handle allocation error
|
||||
}
|
||||
byte data[]; // data to hash
|
||||
wc_AsconHash256_Update(hash, data, sizeof(data));
|
||||
byte digest[ASCON_HASH256_SZ];
|
||||
wc_AsconHash256_Final(hash, digest);
|
||||
wc_AsconHash256_Free(hash);
|
||||
\endcode
|
||||
|
||||
\sa wc_AsconHash256_Free
|
||||
\sa wc_AsconHash256_Init
|
||||
*/
|
||||
wc_AsconHash256* wc_AsconHash256_New(void);
|
||||
|
||||
/*!
|
||||
\ingroup ASCON
|
||||
\brief This function frees an Ascon Hash256 context that was allocated
|
||||
with wc_AsconHash256_New. It clears the context before freeing to
|
||||
prevent information leakage.
|
||||
|
||||
\return none No return value.
|
||||
|
||||
\param a pointer to the wc_AsconHash256 structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wc_AsconHash256* hash = wc_AsconHash256_New();
|
||||
if (hash != NULL) {
|
||||
// use hash context
|
||||
wc_AsconHash256_Free(hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AsconHash256_New
|
||||
\sa wc_AsconHash256_Clear
|
||||
*/
|
||||
void wc_AsconHash256_Free(wc_AsconHash256* a);
|
||||
|
||||
/*!
|
||||
\ingroup ASCON
|
||||
\brief This function clears an Ascon Hash256 context by zeroing all
|
||||
internal state. This should be called to securely erase sensitive
|
||||
data from memory.
|
||||
|
||||
\return none No return value.
|
||||
|
||||
\param a pointer to the wc_AsconHash256 structure to clear
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wc_AsconHash256 hash;
|
||||
wc_AsconHash256_Init(&hash);
|
||||
byte data[]; // data to hash
|
||||
wc_AsconHash256_Update(&hash, data, sizeof(data));
|
||||
byte digest[ASCON_HASH256_SZ];
|
||||
wc_AsconHash256_Final(&hash, digest);
|
||||
wc_AsconHash256_Clear(&hash);
|
||||
\endcode
|
||||
|
||||
\sa wc_AsconHash256_Init
|
||||
\sa wc_AsconHash256_Free
|
||||
*/
|
||||
void wc_AsconHash256_Clear(wc_AsconHash256* a);
|
||||
|
||||
/*!
|
||||
\ingroup ASCON
|
||||
\brief This function allocates and initializes a new Ascon AEAD128
|
||||
context. The returned context must be freed with wc_AsconAEAD128_Free
|
||||
when no longer needed.
|
||||
|
||||
\return Pointer to allocated wc_AsconAEAD128 structure on success.
|
||||
\return NULL on allocation or initialization failure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wc_AsconAEAD128* aead = wc_AsconAEAD128_New();
|
||||
if (aead == NULL) {
|
||||
// handle allocation error
|
||||
}
|
||||
byte key[ASCON_AEAD128_KEY_SZ] = { }; // key
|
||||
byte nonce[ASCON_AEAD128_NONCE_SZ] = { }; // nonce
|
||||
wc_AsconAEAD128_SetKey(aead, key);
|
||||
wc_AsconAEAD128_SetNonce(aead, nonce);
|
||||
// perform encryption/decryption
|
||||
wc_AsconAEAD128_Free(aead);
|
||||
\endcode
|
||||
|
||||
\sa wc_AsconAEAD128_Free
|
||||
\sa wc_AsconAEAD128_Init
|
||||
*/
|
||||
wc_AsconAEAD128* wc_AsconAEAD128_New(void);
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function converts BER (Basic Encoding Rules) formatted data
|
||||
to DER (Distinguished Encoding Rules) format. BER allows indefinite
|
||||
length encoding while DER requires definite lengths. This function
|
||||
calculates definite lengths for all indefinite length items.
|
||||
|
||||
\return 0 On success.
|
||||
\return ASN_PARSE_E If the BER data is invalid.
|
||||
\return BAD_FUNC_ARG If ber or derSz are NULL.
|
||||
\return BUFFER_E If der is not NULL and derSz is too small.
|
||||
|
||||
\param ber pointer to the buffer containing BER formatted data
|
||||
\param berSz size of the BER data in bytes
|
||||
\param der pointer to buffer to store DER formatted data (can be NULL
|
||||
to calculate required size)
|
||||
\param derSz pointer to size of der buffer; updated with actual size
|
||||
needed or used
|
||||
|
||||
\note This API is not public by default. Define WOLFSSL_PUBLIC_ASN to
|
||||
expose APIs marked WOLFSSL_ASN_API.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte ber[256] = { }; // BER encoded data
|
||||
byte der[256];
|
||||
word32 derSz = sizeof(der);
|
||||
|
||||
int ret = wc_BerToDer(ber, sizeof(ber), der, &derSz);
|
||||
if (ret == 0) {
|
||||
// der now contains DER formatted data of length derSz
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_EncodeObjectId
|
||||
*/
|
||||
int wc_BerToDer(const byte* ber, word32 berSz, byte* der, word32* derSz);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function frees a linked list of alternative names
|
||||
(DNS_entry structures). It deallocates each node and its associated
|
||||
name string, IP string, and RID string if present.
|
||||
|
||||
\return none No return value.
|
||||
|
||||
\param altNames pointer to the head of the alternative names linked list
|
||||
\param heap pointer to heap hint for memory deallocation (can be NULL)
|
||||
|
||||
\note This API is not public by default. Define WOLFSSL_PUBLIC_ASN to
|
||||
expose APIs marked WOLFSSL_ASN_API.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DNS_entry* altNames = NULL;
|
||||
// populate altNames with certificate alternative names
|
||||
|
||||
FreeAltNames(altNames, NULL);
|
||||
// altNames list is now freed
|
||||
\endcode
|
||||
|
||||
\sa AltNameNew
|
||||
*/
|
||||
void FreeAltNames(DNS_entry* altNames, void* heap);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function sets an extended callback for handling unknown
|
||||
certificate extensions during certificate parsing. The callback
|
||||
receives additional context information compared to the basic
|
||||
callback.
|
||||
|
||||
\return 0 On success.
|
||||
\return BAD_FUNC_ARG If cert is NULL.
|
||||
|
||||
\param cert pointer to the DecodedCert structure
|
||||
\param cb callback function to handle unknown extensions
|
||||
\param ctx context pointer passed to the callback
|
||||
|
||||
\note This API is not public by default. Define WOLFSSL_PUBLIC_ASN to
|
||||
expose APIs marked WOLFSSL_ASN_API.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DecodedCert cert;
|
||||
|
||||
int UnknownExtCallback(const byte* oid, word32 oidSz, int crit,
|
||||
const byte* der, word32 derSz, void* ctx) {
|
||||
// handle unknown extension
|
||||
return 0;
|
||||
}
|
||||
|
||||
wc_InitDecodedCert(&cert, derCert, derCertSz, NULL);
|
||||
wc_SetUnknownExtCallbackEx(&cert, UnknownExtCallback, myContext);
|
||||
wc_ParseCert(&cert, CERT_TYPE, NO_VERIFY, NULL);
|
||||
\endcode
|
||||
|
||||
\sa wc_SetUnknownExtCallback
|
||||
\sa wc_InitDecodedCert
|
||||
*/
|
||||
int wc_SetUnknownExtCallbackEx(DecodedCert* cert,
|
||||
wc_UnknownExtCallbackEx cb, void *ctx);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function verifies the signature on a certificate using a
|
||||
certificate manager. It checks that the certificate is properly
|
||||
signed by a trusted CA.
|
||||
|
||||
\return 0 On successful signature verification.
|
||||
\return ASN_SIG_CONFIRM_E If signature verification fails.
|
||||
\return Other negative values on error.
|
||||
|
||||
\param cert pointer to the DER encoded certificate
|
||||
\param certSz size of the certificate in bytes
|
||||
\param heap pointer to heap hint for memory allocation (can be NULL)
|
||||
\param cm pointer to certificate manager containing trusted CAs
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte cert[2048] = { }; // DER encoded certificate
|
||||
word32 certSz = sizeof(cert);
|
||||
WOLFSSL_CERT_MANAGER* cm;
|
||||
|
||||
cm = wolfSSL_CertManagerNew();
|
||||
wolfSSL_CertManagerLoadCA(cm, "ca-cert.pem", NULL);
|
||||
|
||||
int ret = wc_CheckCertSignature(cert, certSz, NULL, cm);
|
||||
if (ret == 0) {
|
||||
// certificate signature is valid
|
||||
}
|
||||
wolfSSL_CertManagerFree(cm);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_CertManagerNew
|
||||
\sa wolfSSL_CertManagerLoadCA
|
||||
*/
|
||||
int wc_CheckCertSignature(const byte* cert, word32 certSz, void* heap,
|
||||
void* cm);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function encodes an array of word16 values into an ASN.1
|
||||
Object Identifier (OID) in DER format. OIDs are used to identify
|
||||
algorithms, extensions, and other objects in certificates and
|
||||
cryptographic protocols.
|
||||
|
||||
\return 0 On success.
|
||||
\return BAD_FUNC_ARG If in, inSz, or outSz are invalid.
|
||||
\return BUFFER_E If out is not NULL and outSz is too small.
|
||||
|
||||
\param in pointer to array of word16 values representing OID components
|
||||
\param inSz number of components in the OID
|
||||
\param out pointer to buffer to store encoded OID (can be NULL to
|
||||
calculate size)
|
||||
\param outSz pointer to size of out buffer; updated with actual size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
word16 oid[] = {1, 2, 840, 113549, 1, 1, 11}; // sha256WithRSAEncryption
|
||||
byte encoded[32];
|
||||
word32 encodedSz = sizeof(encoded);
|
||||
|
||||
int ret = wc_EncodeObjectId(oid, sizeof(oid)/sizeof(word16),
|
||||
encoded, &encodedSz);
|
||||
if (ret == 0) {
|
||||
// encoded contains DER encoded OID
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_BerToDer
|
||||
*/
|
||||
int wc_EncodeObjectId(const word16* in, word32 inSz, byte* out,
|
||||
word32* outSz);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function sets the algorithm identifier in DER format. It
|
||||
encodes the algorithm OID and optional parameters based on the
|
||||
algorithm type and curve size.
|
||||
|
||||
\return Length of the encoded algorithm identifier on success.
|
||||
\return Negative value on error.
|
||||
|
||||
\param algoOID algorithm object identifier constant
|
||||
\param output pointer to buffer to store encoded algorithm ID
|
||||
\param type type of encoding (oidSigType, oidHashType, etc.)
|
||||
\param curveSz size of the curve for ECC algorithms (0 for non-ECC)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte algId[32];
|
||||
word32 len;
|
||||
|
||||
len = SetAlgoID(CTC_SHA256wRSA, algId, oidSigType, 0);
|
||||
if (len > 0) {
|
||||
// algId contains encoded algorithm identifier
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_EncodeObjectId
|
||||
*/
|
||||
word32 SetAlgoID(int algoOID, byte* output, int type, int curveSz);
|
||||
|
||||
/*!
|
||||
\ingroup ASN
|
||||
\brief This function decodes a DER encoded Diffie-Hellman public key.
|
||||
It extracts the public key value from the DER encoding and stores it
|
||||
in the DhKey structure.
|
||||
|
||||
\return 0 On success.
|
||||
\return BAD_FUNC_ARG If input, inOutIdx, key, or inSz are invalid.
|
||||
\return ASN_PARSE_E If the DER encoding is invalid.
|
||||
\return Other negative values on error.
|
||||
|
||||
\param input pointer to buffer containing DER encoded public key
|
||||
\param inOutIdx pointer to index in buffer; updated to end of key
|
||||
\param key pointer to DhKey structure to store decoded public key
|
||||
\param inSz size of the input buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte derKey[256] = { }; // DER encoded DH public key
|
||||
word32 idx = 0;
|
||||
DhKey key;
|
||||
|
||||
wc_InitDhKey(&key);
|
||||
int ret = wc_DhPublicKeyDecode(derKey, &idx, &key, sizeof(derKey));
|
||||
if (ret == 0) {
|
||||
// key now contains the decoded public key
|
||||
}
|
||||
wc_FreeDhKey(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDhKey
|
||||
\sa wc_DhKeyDecode
|
||||
*/
|
||||
int wc_DhPublicKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
|
||||
word32 inSz);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
||||
\code
|
||||
Blake2b b2b;
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
wc_InitBlake2b(&b2b, WC_BLAKE2B_DIGEST_SIZE);
|
||||
\endcode
|
||||
|
||||
\sa wc_Blake2bUpdate
|
||||
@@ -41,13 +41,13 @@ int wc_InitBlake2b(Blake2b* b2b, word32 digestSz);
|
||||
int ret;
|
||||
Blake2b b2b;
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
wc_InitBlake2b(&b2b, WC_BLAKE2B_DIGEST_SIZE);
|
||||
|
||||
byte plain[] = { // initialize input };
|
||||
|
||||
ret = wc_Blake2bUpdate(&b2b, plain, sizeof(plain));
|
||||
if( ret != 0) {
|
||||
// error updating blake2b
|
||||
if (ret != 0) {
|
||||
// error updating blake2b
|
||||
}
|
||||
\endcode
|
||||
|
||||
@@ -78,14 +78,14 @@ int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz);
|
||||
\code
|
||||
int ret;
|
||||
Blake2b b2b;
|
||||
byte hash[64];
|
||||
byte hash[WC_BLAKE2B_DIGEST_SIZE];
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
wc_InitBlake2b(&b2b, WC_BLAKE2B_DIGEST_SIZE);
|
||||
... // call wc_Blake2bUpdate to add data to hash
|
||||
|
||||
ret = wc_Blake2bFinal(&b2b, hash, 64);
|
||||
if( ret != 0) {
|
||||
// error generating blake2b hash
|
||||
ret = wc_Blake2bFinal(&b2b, hash, WC_BLAKE2B_DIGEST_SIZE);
|
||||
if (ret != 0) {
|
||||
// error generating blake2b hash
|
||||
}
|
||||
\endcode
|
||||
|
||||
@@ -93,3 +93,326 @@ int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz);
|
||||
\sa wc_Blake2bUpdate
|
||||
*/
|
||||
int wc_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Initialize an HMAC-BLAKE2b message authentication code computation.
|
||||
|
||||
\return 0 Returned upon successfully initializing the HMAC-BLAKE2b MAC
|
||||
computation.
|
||||
|
||||
\param b2b Blake2b structure to be used for the MAC computation.
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2b b2b;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
ret = wc_Blake2bHmacInit(&b2b, key);
|
||||
if (ret != 0) {
|
||||
// error generating HMAC-BLAKE2b
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2bHmacInit(Blake2b * b2b,
|
||||
const byte * key, size_t key_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Update an HMAC-BLAKE2b message authentication code computation with
|
||||
additional input data.
|
||||
|
||||
\return 0 Returned upon successfully updating the HMAC-BLAKE2b MAC
|
||||
computation.
|
||||
|
||||
\param b2b Blake2b structure to be used for the MAC computation.
|
||||
\param in pointer to the input data
|
||||
\param in_len length of the input data
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2b b2b;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
byte data[] = {1, 2, 3};
|
||||
ret = wc_Blake2bHmacInit(&b2b, key, sizeof(key));
|
||||
ret = wc_Blake2bHmacUpdate(&b2b, data, sizeof(data));
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2bHmacUpdate(Blake2b * b2b,
|
||||
const byte * in, size_t in_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Finalize an HMAC-BLAKE2b message authentication code computation.
|
||||
|
||||
\return 0 Returned upon successfully finalizing the HMAC-BLAKE2b MAC
|
||||
computation.
|
||||
|
||||
\param b2b Blake2b structure to be used for the MAC computation.
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
\param out output buffer to store computed MAC
|
||||
\param out_len length of output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2b b2b;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
byte data[] = {1, 2, 3};
|
||||
byte mac[WC_BLAKE2B_DIGEST_SIZE];
|
||||
ret = wc_Blake2bHmacInit(&b2b, key, sizeof(key));
|
||||
ret = wc_Blake2bHmacUpdate(&b2b, data, sizeof(data));
|
||||
ret = wc_Blake2bHmacFinalize(&b2b, key, sizeof(key), mac, sizezof(mac));
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2bHmacFinal(Blake2b * b2b,
|
||||
const byte * key, size_t key_len,
|
||||
byte * out, size_t out_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Compute the HMAC-BLAKE2b message authentication code of the given
|
||||
input data using the given key.
|
||||
|
||||
\return 0 Returned upon successfully computing the HMAC-BLAKE2b MAC.
|
||||
|
||||
\param in pointer to the input data
|
||||
\param in_len length of the input data
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
\param out output buffer to store computed MAC
|
||||
\param out_len length of output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte mac[WC_BLAKE2B_DIGEST_SIZE];
|
||||
byte data[] = {1, 2, 3};
|
||||
byte key[] = {4, 5, 6};
|
||||
ret = wc_Blake2bHmac(data, sizeof(data), key, sizeof(key), mac, sizeof(mac));
|
||||
if (ret != 0) {
|
||||
// error generating HMAC-BLAKE2b
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2bHmac(const byte * in, size_t in_len,
|
||||
const byte * key, size_t key_len,
|
||||
byte * out, size_t out_len);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function initializes a Blake2s structure for use with the
|
||||
Blake2 hash function.
|
||||
|
||||
\return 0 Returned upon successfully initializing the Blake2s structure and
|
||||
setting the digest size.
|
||||
|
||||
\param b2s pointer to the Blake2s structure to initialize
|
||||
\param digestSz length of the blake 2 digest to implement
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2s b2s;
|
||||
// initialize Blake2s structure with 32 byte digest
|
||||
wc_InitBlake2s(&b2s, WC_BLAKE2S_DIGEST_SIZE);
|
||||
\endcode
|
||||
|
||||
\sa wc_Blake2sUpdate
|
||||
*/
|
||||
int wc_InitBlake2s(Blake2s* b2s, word32 digestSz);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function updates the Blake2s hash with the given input data.
|
||||
This function should be called after wc_InitBlake2s, and repeated until
|
||||
one is ready for the final hash: wc_Blake2sFinal.
|
||||
|
||||
\return 0 Returned upon successfully update the Blake2s structure with
|
||||
the given data
|
||||
\return -1 Returned if there is a failure while compressing the input data
|
||||
|
||||
\param b2s pointer to the Blake2s structure to update
|
||||
\param data pointer to a buffer containing the data to append
|
||||
\param sz length of the input data to append
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Blake2s b2s;
|
||||
// initialize Blake2s structure with 32 byte digest
|
||||
wc_InitBlake2s(&b2s, WC_BLAKE2S_DIGEST_SIZE);
|
||||
|
||||
byte plain[] = { // initialize input };
|
||||
|
||||
ret = wc_Blake2sUpdate(&b2s, plain, sizeof(plain));
|
||||
if (ret != 0) {
|
||||
// error updating blake2s
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitBlake2s
|
||||
\sa wc_Blake2sFinal
|
||||
*/
|
||||
int wc_Blake2sUpdate(Blake2s* b2s, const byte* data, word32 sz);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function computes the Blake2s hash of the previously supplied
|
||||
input data. The output hash will be of length requestSz, or, if
|
||||
requestSz==0, the digestSz of the b2s structure. This function should be
|
||||
called after wc_InitBlake2s and wc_Blake2sUpdate has been processed for
|
||||
each piece of input data desired.
|
||||
|
||||
\return 0 Returned upon successfully computing the Blake2s hash
|
||||
\return -1 Returned if there is a failure while parsing the Blake2s hash
|
||||
|
||||
\param b2s pointer to the Blake2s structure to update
|
||||
\param final pointer to a buffer in which to store the blake2s hash.
|
||||
Should be of length requestSz
|
||||
\param requestSz length of the digest to compute. When this is zero,
|
||||
b2s->digestSz will be used instead
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Blake2s b2s;
|
||||
byte hash[WC_BLAKE2S_DIGEST_SIZE];
|
||||
// initialize Blake2s structure with 32 byte digest
|
||||
wc_InitBlake2s(&b2s, WC_BLAKE2S_DIGEST_SIZE);
|
||||
... // call wc_Blake2sUpdate to add data to hash
|
||||
|
||||
ret = wc_Blake2sFinal(&b2s, hash, WC_BLAKE2S_DIGEST_SIZE);
|
||||
if (ret != 0) {
|
||||
// error generating blake2s hash
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitBlake2s
|
||||
\sa wc_Blake2sUpdate
|
||||
*/
|
||||
int wc_Blake2sFinal(Blake2s* b2s, byte* final, word32 requestSz);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Initialize an HMAC-BLAKE2s message authentication code computation.
|
||||
|
||||
\return 0 Returned upon successfully initializing the HMAC-BLAKE2s MAC
|
||||
computation.
|
||||
|
||||
\param b2s Blake2s structure to be used for the MAC computation.
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2s b2s;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
ret = wc_Blake2sHmacInit(&b2s, key);
|
||||
if (ret != 0) {
|
||||
// error generating HMAC-BLAKE2s
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2sHmacInit(Blake2s * b2s,
|
||||
const byte * key, size_t key_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Update an HMAC-BLAKE2s message authentication code computation with
|
||||
additional input data.
|
||||
|
||||
\return 0 Returned upon successfully updating the HMAC-BLAKE2s MAC
|
||||
computation.
|
||||
|
||||
\param b2s Blake2s structure to be used for the MAC computation.
|
||||
\param in pointer to the input data
|
||||
\param in_len length of the input data
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2s b2s;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
byte data[] = {1, 2, 3};
|
||||
ret = wc_Blake2sHmacInit(&b2s, key, sizeof(key));
|
||||
ret = wc_Blake2sHmacUpdate(&b2s, data, sizeof(data));
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2sHmacUpdate(Blake2s * b2s,
|
||||
const byte * in, size_t in_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief Finalize an HMAC-BLAKE2s message authentication code computation.
|
||||
|
||||
\return 0 Returned upon successfully finalizing the HMAC-BLAKE2s MAC
|
||||
computation.
|
||||
|
||||
\param b2s Blake2s structure to be used for the MAC computation.
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
\param out output buffer to store computed MAC
|
||||
\param out_len length of output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2s b2s;
|
||||
int ret;
|
||||
byte key[] = {4, 5, 6};
|
||||
byte data[] = {1, 2, 3};
|
||||
byte mac[WC_BLAKE2S_DIGEST_SIZE];
|
||||
ret = wc_Blake2sHmacInit(&b2s, key, sizeof(key));
|
||||
ret = wc_Blake2sHmacUpdate(&b2s, data, sizeof(data));
|
||||
ret = wc_Blake2sHmacFinalize(&b2s, key, sizeof(key), mac, sizezof(mac));
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2sHmacFinal(Blake2s * b2s,
|
||||
const byte * key, size_t key_len,
|
||||
byte * out, size_t out_len);
|
||||
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function computes the HMAC-BLAKE2s message authentication code
|
||||
of the given input data using the given key.
|
||||
|
||||
\return 0 Returned upon successfully computing the HMAC-BLAKE2s MAC.
|
||||
|
||||
\param in pointer to the input data
|
||||
\param in_len length of the input data
|
||||
\param key pointer to the key
|
||||
\param key_len length of the key
|
||||
\param out output buffer to store computed MAC
|
||||
\param out_len length of output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte mac[WC_BLAKE2S_DIGEST_SIZE];
|
||||
byte data[] = {1, 2, 3};
|
||||
byte key[] = {4, 5, 6};
|
||||
ret = wc_Blake2sHmac(data, sizeof(data), key, sizeof(key), mac, sizeof(mac));
|
||||
if (ret != 0) {
|
||||
// error generating HMAC-BLAKE2s
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
int wc_Blake2sHmac(const byte * in, size_t in_len,
|
||||
const byte * key, size_t key_len,
|
||||
byte * out, size_t out_len);
|
||||
|
||||
@@ -97,3 +97,44 @@ int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
|
||||
\sa wc_Chacha_Process
|
||||
*/
|
||||
int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha
|
||||
\brief This function sets the key and nonce for an XChaCha cipher
|
||||
context. XChaCha extends ChaCha20 to use a 192-bit nonce instead of
|
||||
96 bits, providing better security for applications that need to
|
||||
encrypt many messages with the same key.
|
||||
|
||||
\return 0 On success.
|
||||
\return BAD_FUNC_ARG If ctx, key, or nonce is NULL, or if keySz is
|
||||
invalid, or if nonceSz is not XCHACHA_NONCE_BYTES (24 bytes).
|
||||
\return Other negative values on error.
|
||||
|
||||
\param ctx pointer to the ChaCha structure to initialize
|
||||
\param key pointer to the key buffer (16 or 32 bytes)
|
||||
\param keySz length of the key in bytes (16 or 32)
|
||||
\param nonce pointer to the nonce buffer (must be 24 bytes)
|
||||
\param nonceSz length of the nonce in bytes (must be 24)
|
||||
\param counter initial block counter value (usually 0)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaCha ctx;
|
||||
byte key[32] = { }; // 256-bit key
|
||||
byte nonce[24] = { }; // 192-bit nonce
|
||||
byte plaintext[100] = { }; // data to encrypt
|
||||
byte ciphertext[100];
|
||||
|
||||
int ret = wc_XChacha_SetKey(&ctx, key, 32, nonce, 24, 0);
|
||||
if (ret != 0) {
|
||||
// error setting XChaCha key
|
||||
}
|
||||
wc_Chacha_Process(&ctx, ciphertext, plaintext, 100);
|
||||
\endcode
|
||||
|
||||
\sa wc_Chacha_SetKey
|
||||
\sa wc_Chacha_SetIV
|
||||
\sa wc_Chacha_Process
|
||||
*/
|
||||
int wc_XChacha_SetKey(ChaCha *ctx, const byte *key, word32 keySz,
|
||||
const byte *nonce, word32 nonceSz, word32 counter);
|
||||
|
||||
@@ -122,3 +122,273 @@ int wc_ChaCha20Poly1305_Decrypt(
|
||||
const byte* inCiphertext, word32 inCiphertextLen,
|
||||
const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
|
||||
byte* outPlaintext);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Compares two authentication tags in constant time to prevent
|
||||
timing attacks.
|
||||
|
||||
\return 0 If tags match
|
||||
\return MAC_CMP_FAILED_E If tags do not match
|
||||
|
||||
\param authTag First authentication tag
|
||||
\param authTagChk Second authentication tag to compare
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte tag1[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
|
||||
byte tag2[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
|
||||
|
||||
int ret = wc_ChaCha20Poly1305_CheckTag(tag1, tag2);
|
||||
if (ret != 0) {
|
||||
// tags do not match
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Decrypt
|
||||
*/
|
||||
int wc_ChaCha20Poly1305_CheckTag(
|
||||
const byte authTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
|
||||
const byte authTagChk[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Initializes a ChaChaPoly_Aead structure for incremental
|
||||
encryption or decryption operations.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
|
||||
\param aead Pointer to ChaChaPoly_Aead structure to initialize
|
||||
\param inKey 32-byte encryption key
|
||||
\param inIV 12-byte initialization vector
|
||||
\param isEncrypt 1 for encryption, 0 for decryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaChaPoly_Aead aead;
|
||||
byte key[CHACHA20_POLY1305_AEAD_KEYSIZE];
|
||||
byte iv[CHACHA20_POLY1305_AEAD_IV_SIZE];
|
||||
|
||||
int ret = wc_ChaCha20Poly1305_Init(&aead, key, iv, 1);
|
||||
if (ret != 0) {
|
||||
// error initializing
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_UpdateAad
|
||||
\sa wc_ChaCha20Poly1305_UpdateData
|
||||
\sa wc_ChaCha20Poly1305_Final
|
||||
*/
|
||||
int wc_ChaCha20Poly1305_Init(ChaChaPoly_Aead* aead,
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
int isEncrypt);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Updates the AEAD context with additional authenticated data
|
||||
(AAD). Must be called after Init and before UpdateData.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
|
||||
\param aead Pointer to initialized ChaChaPoly_Aead structure
|
||||
\param inAAD Additional authenticated data
|
||||
\param inAADLen Length of AAD in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaChaPoly_Aead aead;
|
||||
byte aad[]; // AAD data
|
||||
|
||||
wc_ChaCha20Poly1305_Init(&aead, key, iv, 1);
|
||||
int ret = wc_ChaCha20Poly1305_UpdateAad(&aead, aad, sizeof(aad));
|
||||
if (ret != 0) {
|
||||
// error updating AAD
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Init
|
||||
\sa wc_ChaCha20Poly1305_UpdateData
|
||||
*/
|
||||
int wc_ChaCha20Poly1305_UpdateAad(ChaChaPoly_Aead* aead,
|
||||
const byte* inAAD, word32 inAADLen);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Encrypts or decrypts data incrementally. Can be called
|
||||
multiple times to process data in chunks.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
|
||||
\param aead Pointer to initialized ChaChaPoly_Aead structure
|
||||
\param inData Input data (plaintext or ciphertext)
|
||||
\param outData Output buffer for result
|
||||
\param dataLen Length of data to process
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaChaPoly_Aead aead;
|
||||
byte plain[]; // plaintext
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
wc_ChaCha20Poly1305_Init(&aead, key, iv, 1);
|
||||
wc_ChaCha20Poly1305_UpdateAad(&aead, aad, aadLen);
|
||||
int ret = wc_ChaCha20Poly1305_UpdateData(&aead, plain,
|
||||
cipher, sizeof(plain));
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Init
|
||||
\sa wc_ChaCha20Poly1305_Final
|
||||
*/
|
||||
int wc_ChaCha20Poly1305_UpdateData(ChaChaPoly_Aead* aead,
|
||||
const byte* inData, byte* outData, word32 dataLen);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Finalizes the AEAD operation and generates the
|
||||
authentication tag.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
|
||||
\param aead Pointer to ChaChaPoly_Aead structure
|
||||
\param outAuthTag Buffer to store 16-byte authentication tag
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaChaPoly_Aead aead;
|
||||
byte authTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
|
||||
|
||||
wc_ChaCha20Poly1305_Init(&aead, key, iv, 1);
|
||||
wc_ChaCha20Poly1305_UpdateAad(&aead, aad, aadLen);
|
||||
wc_ChaCha20Poly1305_UpdateData(&aead, plain, cipher, plainLen);
|
||||
int ret = wc_ChaCha20Poly1305_Final(&aead, authTag);
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Init
|
||||
\sa wc_ChaCha20Poly1305_UpdateData
|
||||
*/
|
||||
int wc_ChaCha20Poly1305_Final(ChaChaPoly_Aead* aead,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief Initializes XChaCha20-Poly1305 AEAD with extended nonce.
|
||||
XChaCha20 uses a 24-byte nonce instead of 12-byte.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
|
||||
\param aead Pointer to ChaChaPoly_Aead structure
|
||||
\param ad Additional authenticated data
|
||||
\param ad_len Length of AAD
|
||||
\param inKey Encryption key
|
||||
\param inKeySz Key size (must be 32)
|
||||
\param inIV Initialization vector
|
||||
\param inIVSz IV size (must be 24 for XChaCha20)
|
||||
\param isEncrypt 1 for encryption, 0 for decryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaChaPoly_Aead aead;
|
||||
byte key[32];
|
||||
byte iv[24];
|
||||
byte aad[]; // AAD
|
||||
|
||||
int ret = wc_XChaCha20Poly1305_Init(&aead, aad, sizeof(aad),
|
||||
key, 32, iv, 24, 1);
|
||||
\endcode
|
||||
|
||||
\sa wc_XChaCha20Poly1305_Encrypt
|
||||
\sa wc_XChaCha20Poly1305_Decrypt
|
||||
*/
|
||||
int wc_XChaCha20Poly1305_Init(ChaChaPoly_Aead* aead,
|
||||
const byte *ad, word32 ad_len,
|
||||
const byte *inKey, word32 inKeySz,
|
||||
const byte *inIV, word32 inIVSz,
|
||||
int isEncrypt);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief One-shot XChaCha20-Poly1305 encryption with 24-byte nonce.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
\return BUFFER_E If dst_space is insufficient
|
||||
|
||||
\param dst Output buffer for ciphertext and tag
|
||||
\param dst_space Size of output buffer
|
||||
\param src Input plaintext
|
||||
\param src_len Length of plaintext
|
||||
\param ad Additional authenticated data
|
||||
\param ad_len Length of AAD
|
||||
\param nonce 24-byte nonce
|
||||
\param nonce_len Nonce length (must be 24)
|
||||
\param key 32-byte encryption key
|
||||
\param key_len Key length (must be 32)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[32], nonce[24];
|
||||
byte plain[]; // plaintext
|
||||
byte cipher[sizeof(plain) + 16];
|
||||
|
||||
int ret = wc_XChaCha20Poly1305_Encrypt(cipher, sizeof(cipher),
|
||||
plain, sizeof(plain),
|
||||
NULL, 0, nonce, 24,
|
||||
key, 32);
|
||||
\endcode
|
||||
|
||||
\sa wc_XChaCha20Poly1305_Decrypt
|
||||
*/
|
||||
int wc_XChaCha20Poly1305_Encrypt(byte *dst, size_t dst_space,
|
||||
const byte *src, size_t src_len,
|
||||
const byte *ad, size_t ad_len,
|
||||
const byte *nonce, size_t nonce_len,
|
||||
const byte *key, size_t key_len);
|
||||
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
\brief One-shot XChaCha20-Poly1305 decryption with 24-byte nonce.
|
||||
|
||||
\return 0 On success
|
||||
\return BAD_FUNC_ARG If parameters are invalid
|
||||
\return BUFFER_E If dst_space is insufficient
|
||||
\return MAC_CMP_FAILED_E If authentication fails
|
||||
|
||||
\param dst Output buffer for plaintext
|
||||
\param dst_space Size of output buffer
|
||||
\param src Input ciphertext with tag
|
||||
\param src_len Length of ciphertext plus tag
|
||||
\param ad Additional authenticated data
|
||||
\param ad_len Length of AAD
|
||||
\param nonce 24-byte nonce
|
||||
\param nonce_len Nonce length (must be 24)
|
||||
\param key 32-byte decryption key
|
||||
\param key_len Key length (must be 32)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[32], nonce[24];
|
||||
byte cipher[]; // ciphertext + tag
|
||||
byte plain[sizeof(cipher) - 16];
|
||||
|
||||
int ret = wc_XChaCha20Poly1305_Decrypt(plain, sizeof(plain),
|
||||
cipher, sizeof(cipher),
|
||||
NULL, 0, nonce, 24,
|
||||
key, 32);
|
||||
if (ret == MAC_CMP_FAILED_E) {
|
||||
// authentication failed
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_XChaCha20Poly1305_Encrypt
|
||||
*/
|
||||
int wc_XChaCha20Poly1305_Decrypt(byte *dst, size_t dst_space,
|
||||
const byte *src, size_t src_len,
|
||||
const byte *ad, size_t ad_len,
|
||||
const byte *nonce, size_t nonce_len,
|
||||
const byte *key, size_t key_len);
|
||||
|
||||
@@ -206,3 +206,82 @@ int wc_AesCmacVerify(const byte* check, word32 checkSz,
|
||||
\endcode
|
||||
*/
|
||||
int wc_CMAC_Grow(Cmac* cmac, const byte* in, int inSz);
|
||||
|
||||
/*!
|
||||
\ingroup CMAC
|
||||
\brief Single shot AES-CMAC generation with extended parameters
|
||||
including heap and device ID.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
|
||||
\param cmac Pointer to Cmac structure (can be NULL for one-shot)
|
||||
\param out Buffer to store MAC output
|
||||
\param outSz Pointer to output size (in/out)
|
||||
\param in Input data to authenticate
|
||||
\param inSz Length of input data
|
||||
\param key AES key
|
||||
\param keySz Key size (16, 24, or 32 bytes)
|
||||
\param heap Heap hint for memory allocation (can be NULL)
|
||||
\param devId Device ID for hardware acceleration (use
|
||||
INVALID_DEVID for software)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte mac[AES_BLOCK_SIZE];
|
||||
word32 macSz = sizeof(mac);
|
||||
byte key[16], msg[64];
|
||||
|
||||
int ret = wc_AesCmacGenerate_ex(NULL, mac, &macSz, msg,
|
||||
sizeof(msg), key, sizeof(key),
|
||||
NULL, INVALID_DEVID);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesCmacGenerate
|
||||
\sa wc_AesCmacVerify_ex
|
||||
*/
|
||||
int wc_AesCmacGenerate_ex(Cmac *cmac, byte* out, word32* outSz,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* key, word32 keySz,
|
||||
void* heap, int devId);
|
||||
|
||||
/*!
|
||||
\ingroup CMAC
|
||||
\brief Single shot AES-CMAC verification with extended parameters
|
||||
including heap and device ID.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
\return MAC_CMP_FAILED_E if MAC verification fails
|
||||
|
||||
\param cmac Pointer to Cmac structure (can be NULL for one-shot)
|
||||
\param check Expected MAC value to verify
|
||||
\param checkSz Size of expected MAC
|
||||
\param in Input data to authenticate
|
||||
\param inSz Length of input data
|
||||
\param key AES key
|
||||
\param keySz Key size (16, 24, or 32 bytes)
|
||||
\param heap Heap hint for memory allocation (can be NULL)
|
||||
\param devId Device ID for hardware acceleration (use
|
||||
INVALID_DEVID for software)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte mac[AES_BLOCK_SIZE];
|
||||
byte key[16], msg[64];
|
||||
|
||||
int ret = wc_AesCmacVerify_ex(NULL, mac, sizeof(mac), msg,
|
||||
sizeof(msg), key, sizeof(key),
|
||||
NULL, INVALID_DEVID);
|
||||
if (ret == MAC_CMP_FAILED_E) {
|
||||
// MAC verification failed
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesCmacVerify
|
||||
\sa wc_AesCmacGenerate_ex
|
||||
*/
|
||||
int wc_AesCmacVerify_ex(Cmac* cmac, const byte* check, word32 checkSz,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* key, word32 keySz,
|
||||
void* heap, int devId);
|
||||
|
||||
@@ -235,3 +235,43 @@ int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
||||
*/
|
||||
|
||||
int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
||||
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
\brief This function decodes Base64 encoded input without using
|
||||
constant-time operations. This is faster than the constant-time
|
||||
version but may be vulnerable to timing attacks. Use only when
|
||||
timing attacks are not a concern.
|
||||
|
||||
\return 0 On successfully decoding the Base64 encoded input.
|
||||
\return BAD_FUNC_ARG If the output buffer is too small to store the
|
||||
decoded input.
|
||||
\return ASN_INPUT_E If a character in the input buffer falls outside
|
||||
of the Base64 range or if there is an invalid line ending.
|
||||
\return BUFFER_E If running out of buffer while decoding.
|
||||
|
||||
\param in pointer to the input buffer to decode
|
||||
\param inLen length of the input buffer to decode
|
||||
\param out pointer to the output buffer to store decoded message
|
||||
\param outLen pointer to length of output buffer; updated with bytes
|
||||
written
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte encoded[] = "SGVsbG8gV29ybGQ="; // "Hello World" in Base64
|
||||
byte decoded[64];
|
||||
word32 outLen = sizeof(decoded);
|
||||
|
||||
int ret = Base64_Decode_nonCT(encoded, sizeof(encoded)-1, decoded,
|
||||
&outLen);
|
||||
if (ret != 0) {
|
||||
// error decoding input
|
||||
}
|
||||
// decoded now contains "Hello World"
|
||||
\endcode
|
||||
|
||||
\sa Base64_Decode
|
||||
\sa Base64_Encode
|
||||
*/
|
||||
int Base64_Decode_nonCT(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
|
||||
@@ -70,3 +70,131 @@ int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 fla
|
||||
\sa wc_Compress
|
||||
*/
|
||||
int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz);
|
||||
|
||||
/*!
|
||||
\ingroup Compression
|
||||
\brief This function compresses the given input data using Huffman
|
||||
coding with extended parameters. This is similar to wc_Compress but
|
||||
allows specification of compression flags and window bits for more
|
||||
control over the compression process.
|
||||
|
||||
\return On successfully compressing the input data, returns the
|
||||
number of bytes stored in the output buffer
|
||||
\return COMPRESS_INIT_E Returned if there is an error initializing
|
||||
the stream for compression
|
||||
\return COMPRESS_E Returned if an error occurs during compression
|
||||
|
||||
\param out pointer to the output buffer in which to store the
|
||||
compressed data
|
||||
\param outSz size available in the output buffer for storage
|
||||
\param in pointer to the buffer containing the message to compress
|
||||
\param inSz size of the input message to compress
|
||||
\param flags flags to control how compression operates
|
||||
\param windowBits the base two logarithm of the window size (8..15)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte message[] = { // initialize text to compress };
|
||||
byte compressed[(sizeof(message) + sizeof(message) * .001 + 12)];
|
||||
word32 flags = 0;
|
||||
word32 windowBits = 15; // 32KB window
|
||||
|
||||
int ret = wc_Compress_ex(compressed, sizeof(compressed), message,
|
||||
sizeof(message), flags, windowBits);
|
||||
if (ret < 0) {
|
||||
// error compressing data
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Compress
|
||||
\sa wc_DeCompress_ex
|
||||
*/
|
||||
int wc_Compress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
|
||||
word32 flags, word32 windowBits);
|
||||
|
||||
/*!
|
||||
\ingroup Compression
|
||||
\brief This function decompresses the given compressed data using
|
||||
Huffman coding with extended parameters. This is similar to
|
||||
wc_DeCompress but allows specification of window bits for more
|
||||
control over the decompression process.
|
||||
|
||||
\return On successfully decompressing the input data, returns the
|
||||
number of bytes stored in the output buffer
|
||||
\return COMPRESS_INIT_E Returned if there is an error initializing
|
||||
the stream for decompression
|
||||
\return COMPRESS_E Returned if an error occurs during decompression
|
||||
|
||||
\param out pointer to the output buffer in which to store the
|
||||
decompressed data
|
||||
\param outSz size available in the output buffer for storage
|
||||
\param in pointer to the buffer containing the message to decompress
|
||||
\param inSz size of the input message to decompress
|
||||
\param windowBits the base two logarithm of the window size (8..15)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte compressed[] = { // initialize compressed message };
|
||||
byte decompressed[MAX_MESSAGE_SIZE];
|
||||
int windowBits = 15;
|
||||
|
||||
int ret = wc_DeCompress_ex(decompressed, sizeof(decompressed),
|
||||
compressed, sizeof(compressed),
|
||||
windowBits);
|
||||
if (ret < 0) {
|
||||
// error decompressing data
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DeCompress
|
||||
\sa wc_Compress_ex
|
||||
*/
|
||||
int wc_DeCompress_ex(byte* out, word32 outSz, const byte* in, word32 inSz,
|
||||
int windowBits);
|
||||
|
||||
/*!
|
||||
\ingroup Compression
|
||||
\brief This function decompresses the given compressed data using
|
||||
Huffman coding with dynamic memory allocation. The output buffer is
|
||||
allocated dynamically and the caller is responsible for freeing it.
|
||||
|
||||
\return On successfully decompressing the input data, returns the
|
||||
number of bytes stored in the output buffer
|
||||
\return COMPRESS_INIT_E Returned if there is an error initializing
|
||||
the stream for decompression
|
||||
\return COMPRESS_E Returned if an error occurs during decompression
|
||||
\return MEMORY_E Returned if memory allocation fails
|
||||
|
||||
\param out pointer to pointer that will be set to the allocated
|
||||
output buffer
|
||||
\param max maximum size to allocate for output buffer
|
||||
\param memoryType type of memory to allocate (DYNAMIC_TYPE_TMP_BUFFER)
|
||||
\param in pointer to the buffer containing the message to decompress
|
||||
\param inSz size of the input message to decompress
|
||||
\param windowBits the base two logarithm of the window size (8..15)
|
||||
\param heap heap hint for memory allocation (can be NULL)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte compressed[] = { // initialize compressed message };
|
||||
byte* decompressed = NULL;
|
||||
int max = 1024 * 1024; // 1MB max
|
||||
|
||||
int ret = wc_DeCompressDynamic(&decompressed, max,
|
||||
DYNAMIC_TYPE_TMP_BUFFER, compressed,
|
||||
sizeof(compressed), 15, NULL);
|
||||
if (ret < 0) {
|
||||
// error decompressing data
|
||||
}
|
||||
else {
|
||||
// use decompressed data
|
||||
XFREE(decompressed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DeCompress
|
||||
\sa wc_DeCompress_ex
|
||||
*/
|
||||
int wc_DeCompressDynamic(byte** out, int max, int memoryType,
|
||||
const byte* in, word32 inSz, int windowBits,
|
||||
void* heap);
|
||||
|
||||
@@ -109,3 +109,74 @@ int wc_CryptoCb_RegisterDevice(int devId, CryptoDevCallbackFunc cb, void* ctx);
|
||||
\sa wolfSSL_CTX_SetDevId
|
||||
*/
|
||||
void wc_CryptoCb_UnRegisterDevice(int devId);
|
||||
|
||||
/*!
|
||||
\ingroup CryptoCb
|
||||
\brief This function returns the default device ID for crypto
|
||||
callbacks. This is useful when you want to get the device ID that
|
||||
was set as the default for the library.
|
||||
|
||||
\return The default device ID, or INVALID_DEVID if no default is set.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int devId = wc_CryptoCb_DefaultDevID();
|
||||
if (devId != INVALID_DEVID) {
|
||||
// default device ID is set
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_CryptoCb_RegisterDevice
|
||||
\sa wc_CryptoCb_UnRegisterDevice
|
||||
*/
|
||||
int wc_CryptoCb_DefaultDevID(void);
|
||||
|
||||
/*!
|
||||
\ingroup CryptoCb
|
||||
\brief This function sets a callback for finding crypto devices.
|
||||
The callback is invoked when a device ID needs to be resolved to
|
||||
a device context. This is useful for dynamic device management.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param cb callback function with prototype:
|
||||
typedef void* (*CryptoDevCallbackFind)(int devId);
|
||||
|
||||
_Example_
|
||||
\code
|
||||
void* myDeviceFindCb(int devId) {
|
||||
// lookup device context by ID
|
||||
return deviceContext;
|
||||
}
|
||||
|
||||
wc_CryptoCb_SetDeviceFindCb(myDeviceFindCb);
|
||||
\endcode
|
||||
|
||||
\sa wc_CryptoCb_RegisterDevice
|
||||
*/
|
||||
void wc_CryptoCb_SetDeviceFindCb(CryptoDevCallbackFind cb);
|
||||
|
||||
/*!
|
||||
\ingroup CryptoCb
|
||||
\brief This function converts a wc_CryptoInfo structure to a
|
||||
human-readable string for debugging purposes. The string is printed
|
||||
to stdout and describes the cryptographic operation being performed.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param info pointer to the wc_CryptoInfo structure to convert
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int myCryptoCb(int devId, wc_CryptoInfo* info, void* ctx) {
|
||||
// print debug info about the operation
|
||||
wc_CryptoCb_InfoString(info);
|
||||
|
||||
// handle the operation
|
||||
return CRYPTOCB_UNAVAILABLE;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_CryptoCb_RegisterDevice
|
||||
*/
|
||||
void wc_CryptoCb_InfoString(wc_CryptoInfo* info);
|
||||
|
||||
@@ -46,7 +46,7 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key);
|
||||
|
||||
\brief This function computes a shared secret key given a secret private
|
||||
key and a received public key. It stores the generated secret key in the
|
||||
buffer out and assigns the variable of the secret key to outlen. Only
|
||||
buffer out and assigns the length of the secret key to outlen. Only
|
||||
supports big endian.
|
||||
|
||||
\return 0 Returned on successfully computing a shared secret key.
|
||||
@@ -93,7 +93,7 @@ int wc_curve25519_shared_secret(curve25519_key* private_key,
|
||||
|
||||
\brief This function computes a shared secret key given a secret private
|
||||
key and a received public key. It stores the generated secret key in the
|
||||
buffer out and assigns the variable of the secret key to outlen. Supports
|
||||
buffer out and assigns the length of the secret key to outlen. Supports
|
||||
both big and little endian.
|
||||
|
||||
\return 0 Returned on successfully computing a shared secret key.
|
||||
@@ -361,7 +361,7 @@ int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
|
||||
\return 0 Returned on successfully exporting the private key from the
|
||||
curve25519_key structure.
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
\return ECC_BAD_ARG_E Returned if *outLen is less than wc_curve25519_size().
|
||||
|
||||
\param [in] key Pointer to the structure from which to export the key.
|
||||
\param [out] out Pointer to the buffer in which to store the exported key.
|
||||
@@ -372,7 +372,7 @@ int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
|
||||
\code
|
||||
int ret;
|
||||
byte priv[32];
|
||||
int privSz;
|
||||
word32 privSz;
|
||||
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
@@ -402,7 +402,7 @@ int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
|
||||
\return 0 Returned on successfully exporting the private key from the
|
||||
curve25519_key structure.
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
\return ECC_BAD_ARG_E Returned if *outLen is less than wc_curve25519_size().
|
||||
|
||||
\param [in] key Pointer to the structure from which to export the key.
|
||||
\param [out] out Pointer to the buffer in which to store the exported key.
|
||||
@@ -416,7 +416,7 @@ int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
|
||||
int ret;
|
||||
|
||||
byte priv[32];
|
||||
int privSz;
|
||||
word32 privSz;
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
ret = wc_curve25519_export_private_raw_ex(&key, priv, &privSz,
|
||||
@@ -656,7 +656,7 @@ int wc_curve25519_export_public_ex(curve25519_key* key, byte* out,
|
||||
\return ECC_BAD_ARG_E Returned if privSz is less than CURVE25519_KEY_SIZE or
|
||||
pubSz is less than CURVE25519_PUB_KEY_SIZE.
|
||||
|
||||
\param [in] key Pointer to the curve448_key structure in from which to
|
||||
\param [in] key Pointer to the curve25519_key structure in from which to
|
||||
export the key pair.
|
||||
\param [out] priv Pointer to the buffer in which to store the private key.
|
||||
\param [in,out] privSz On in, is the size of the priv buffer in bytes.
|
||||
@@ -702,7 +702,7 @@ int wc_curve25519_export_key_raw(curve25519_key* key,
|
||||
\return ECC_BAD_ARG_E Returned if privSz is less than CURVE25519_KEY_SIZE or
|
||||
pubSz is less than CURVE25519_PUB_KEY_SIZE.
|
||||
|
||||
\param [in] key Pointer to the curve448_key structure in from which to
|
||||
\param [in] key Pointer to the curve25519_key structure in from which to
|
||||
export the key pair.
|
||||
\param [out] priv Pointer to the buffer in which to store the private key.
|
||||
\param [in,out] privSz On in, is the size of the priv buffer in bytes.
|
||||
@@ -725,7 +725,7 @@ int wc_curve25519_export_key_raw(curve25519_key* key,
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
|
||||
ret = wc_curve25519_export_key_raw_ex(&key,priv, &privSz, pub, &pubSz,
|
||||
ret = wc_curve25519_export_key_raw_ex(&key, priv, &privSz, pub, &pubSz,
|
||||
EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
@@ -769,3 +769,326 @@ int wc_curve25519_export_key_raw_ex(curve25519_key* key,
|
||||
*/
|
||||
|
||||
int wc_curve25519_size(curve25519_key* key);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function generates a Curve25519 public key from a given
|
||||
private key. This is a lower-level function that operates directly
|
||||
on byte buffers rather than curve25519_key structures.
|
||||
|
||||
\return 0 On successfully generating the public key
|
||||
\return ECC_BAD_ARG_E If the key sizes are invalid
|
||||
\return BAD_FUNC_ARG If any input parameters are NULL
|
||||
|
||||
\param public_size Size of the public key buffer (must be 32)
|
||||
\param pub Pointer to buffer to store the public key
|
||||
\param private_size Size of the private key (must be 32)
|
||||
\param priv Pointer to buffer containing the private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte priv[CURVE25519_KEYSIZE];
|
||||
byte pub[CURVE25519_KEYSIZE];
|
||||
|
||||
// initialize priv with private key
|
||||
int ret = wc_curve25519_make_pub(sizeof(pub), pub, sizeof(priv),
|
||||
priv);
|
||||
if (ret != 0) {
|
||||
// error generating public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_make_pub_blind
|
||||
*/
|
||||
int wc_curve25519_make_pub(int public_size, byte* pub, int private_size,
|
||||
const byte* priv);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function generates a Curve25519 public key from a given
|
||||
private key with blinding to resist side-channel attacks. This adds
|
||||
randomization to the scalar multiplication operation.
|
||||
|
||||
\return 0 On successfully generating the public key
|
||||
\return ECC_BAD_ARG_E If the key sizes are invalid
|
||||
\return BAD_FUNC_ARG If any input parameters are NULL
|
||||
|
||||
\param public_size Size of the public key buffer (must be 32)
|
||||
\param pub Pointer to buffer to store the public key
|
||||
\param private_size Size of the private key (must be 32)
|
||||
\param priv Pointer to buffer containing the private key
|
||||
\param rng Pointer to initialized RNG for blinding
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
byte priv[CURVE25519_KEYSIZE];
|
||||
byte pub[CURVE25519_KEYSIZE];
|
||||
|
||||
wc_InitRng(&rng);
|
||||
// initialize priv with private key
|
||||
int ret = wc_curve25519_make_pub_blind(sizeof(pub), pub,
|
||||
sizeof(priv), priv, &rng);
|
||||
if (ret != 0) {
|
||||
// error generating public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_make_pub
|
||||
\sa wc_curve25519_generic_blind
|
||||
*/
|
||||
int wc_curve25519_make_pub_blind(int public_size, byte* pub,
|
||||
int private_size, const byte* priv,
|
||||
WC_RNG* rng);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function performs a generic Curve25519 scalar
|
||||
multiplication with a custom basepoint. This allows computing
|
||||
scalar * basepoint for any basepoint, not just the standard
|
||||
generator.
|
||||
|
||||
\return 0 On successfully computing the result
|
||||
\return ECC_BAD_ARG_E If the sizes are invalid
|
||||
\return BAD_FUNC_ARG If any input parameters are NULL
|
||||
|
||||
\param public_size Size of the output buffer (must be 32)
|
||||
\param pub Pointer to buffer to store the result
|
||||
\param private_size Size of the scalar (must be 32)
|
||||
\param priv Pointer to buffer containing the scalar
|
||||
\param basepoint_size Size of the basepoint (must be 32)
|
||||
\param basepoint Pointer to buffer containing the basepoint
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte scalar[CURVE25519_KEYSIZE];
|
||||
byte basepoint[CURVE25519_KEYSIZE];
|
||||
byte result[CURVE25519_KEYSIZE];
|
||||
|
||||
// initialize scalar and basepoint
|
||||
int ret = wc_curve25519_generic(sizeof(result), result,
|
||||
sizeof(scalar), scalar,
|
||||
sizeof(basepoint), basepoint);
|
||||
if (ret != 0) {
|
||||
// error computing result
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_shared_secret
|
||||
\sa wc_curve25519_generic_blind
|
||||
*/
|
||||
int wc_curve25519_generic(int public_size, byte* pub, int private_size,
|
||||
const byte* priv, int basepoint_size,
|
||||
const byte* basepoint);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function performs a generic Curve25519 scalar
|
||||
multiplication with a custom basepoint and blinding to resist
|
||||
side-channel attacks.
|
||||
|
||||
\return 0 On successfully computing the result
|
||||
\return ECC_BAD_ARG_E If the sizes are invalid
|
||||
\return BAD_FUNC_ARG If any input parameters are NULL
|
||||
|
||||
\param public_size Size of the output buffer (must be 32)
|
||||
\param pub Pointer to buffer to store the result
|
||||
\param private_size Size of the scalar (must be 32)
|
||||
\param priv Pointer to buffer containing the scalar
|
||||
\param basepoint_size Size of the basepoint (must be 32)
|
||||
\param basepoint Pointer to buffer containing the basepoint
|
||||
\param rng Pointer to initialized RNG for blinding
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
byte scalar[CURVE25519_KEYSIZE];
|
||||
byte basepoint[CURVE25519_KEYSIZE];
|
||||
byte result[CURVE25519_KEYSIZE];
|
||||
|
||||
wc_InitRng(&rng);
|
||||
// initialize scalar and basepoint
|
||||
int ret = wc_curve25519_generic_blind(sizeof(result), result,
|
||||
sizeof(scalar), scalar,
|
||||
sizeof(basepoint), basepoint,
|
||||
&rng);
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_generic
|
||||
\sa wc_curve25519_make_pub_blind
|
||||
*/
|
||||
int wc_curve25519_generic_blind(int public_size, byte* pub,
|
||||
int private_size, const byte* priv,
|
||||
int basepoint_size, const byte* basepoint,
|
||||
WC_RNG* rng);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function generates a Curve25519 private key using the
|
||||
given random number generator. This is a lower-level function that
|
||||
generates only the private key bytes.
|
||||
|
||||
\return 0 On successfully generating the private key
|
||||
\return ECC_BAD_ARG_E If keysize is invalid
|
||||
\return BAD_FUNC_ARG If any input parameters are NULL
|
||||
\return RNG_FAILURE_E If random number generation fails
|
||||
|
||||
\param rng Pointer to initialized RNG
|
||||
\param keysize Size of the key to generate (must be 32)
|
||||
\param priv Pointer to buffer to store the private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
byte priv[CURVE25519_KEYSIZE];
|
||||
|
||||
wc_InitRng(&rng);
|
||||
int ret = wc_curve25519_make_priv(&rng, sizeof(priv), priv);
|
||||
if (ret != 0) {
|
||||
// error generating private key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_make_pub
|
||||
*/
|
||||
int wc_curve25519_make_priv(WC_RNG* rng, int keysize, byte* priv);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function initializes a Curve25519 key with extended
|
||||
parameters, allowing specification of custom heap and device ID
|
||||
for hardware acceleration.
|
||||
|
||||
\return 0 On successfully initializing the key
|
||||
\return BAD_FUNC_ARG If key is NULL
|
||||
|
||||
\param key Pointer to the curve25519_key structure to initialize
|
||||
\param heap Pointer to heap hint for memory allocation (can be
|
||||
NULL)
|
||||
\param devId Device ID for hardware acceleration (use
|
||||
INVALID_DEVID for software only)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
curve25519_key key;
|
||||
void* heap = NULL;
|
||||
int devId = INVALID_DEVID;
|
||||
|
||||
int ret = wc_curve25519_init_ex(&key, heap, devId);
|
||||
if (ret != 0) {
|
||||
// error initializing key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_free
|
||||
*/
|
||||
int wc_curve25519_init_ex(curve25519_key* key, void* heap, int devId);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function sets the RNG to be used with a Curve25519
|
||||
key. This is useful for operations that require randomness such
|
||||
as blinded scalar multiplication.
|
||||
|
||||
\return 0 On successfully setting the RNG
|
||||
\return BAD_FUNC_ARG If key or rng is NULL
|
||||
|
||||
\param key Pointer to the curve25519_key structure
|
||||
\param rng Pointer to initialized RNG
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
curve25519_key key;
|
||||
|
||||
wc_InitRng(&rng);
|
||||
wc_curve25519_init(&key);
|
||||
int ret = wc_curve25519_set_rng(&key, &rng);
|
||||
if (ret != 0) {
|
||||
// error setting RNG
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
*/
|
||||
int wc_curve25519_set_rng(curve25519_key* key, WC_RNG* rng);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function allocates and initializes a new Curve25519
|
||||
key structure with extended parameters. The caller is responsible
|
||||
for freeing the key with wc_curve25519_delete. These New/Delete
|
||||
functions are exposed to support allocation of the structure using
|
||||
dynamic memory to provide better ABI compatibility.
|
||||
|
||||
\note This API is only available when WC_NO_CONSTRUCTORS is not defined.
|
||||
WC_NO_CONSTRUCTORS is automatically defined when WOLFSSL_NO_MALLOC is
|
||||
defined.
|
||||
|
||||
\return Pointer to newly allocated curve25519_key on success
|
||||
\return NULL on failure
|
||||
|
||||
\param heap Pointer to heap hint for memory allocation (can be
|
||||
NULL)
|
||||
\param devId Device ID for hardware acceleration (use
|
||||
INVALID_DEVID for software only)
|
||||
\param result_code Pointer to store result code (0 on success)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
curve25519_key* key;
|
||||
|
||||
key = wc_curve25519_new(NULL, INVALID_DEVID, &ret);
|
||||
if (key == NULL || ret != 0) {
|
||||
// error allocating key
|
||||
}
|
||||
// use key
|
||||
wc_curve25519_delete(key, &key);
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_delete
|
||||
\sa wc_curve25519_init_ex
|
||||
*/
|
||||
curve25519_key* wc_curve25519_new(void* heap, int devId,
|
||||
int *result_code);
|
||||
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
\brief This function frees a Curve25519 key structure that was
|
||||
allocated with wc_curve25519_new and sets the pointer to NULL.
|
||||
These New/Delete functions are exposed to support allocation of the
|
||||
structure using dynamic memory to provide better ABI compatibility.
|
||||
|
||||
\note This API is only available when WC_NO_CONSTRUCTORS is not defined.
|
||||
WC_NO_CONSTRUCTORS is automatically defined when WOLFSSL_NO_MALLOC is
|
||||
defined.
|
||||
|
||||
\return 0 On successfully freeing the key
|
||||
\return BAD_FUNC_ARG If key or key_p is NULL
|
||||
|
||||
\param key Pointer to the curve25519_key structure to free
|
||||
\param key_p Pointer to the key pointer (will be set to NULL)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
curve25519_key* key;
|
||||
|
||||
key = wc_curve25519_new(NULL, INVALID_DEVID, &ret);
|
||||
// use key
|
||||
ret = wc_curve25519_delete(key, &key);
|
||||
if (ret != 0) {
|
||||
// error freeing key
|
||||
}
|
||||
// key is now NULL
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_new
|
||||
\sa wc_curve25519_free
|
||||
*/
|
||||
int wc_curve25519_delete(curve25519_key* key, curve25519_key** key_p);
|
||||
|
||||
@@ -766,3 +766,37 @@ int wc_curve448_export_key_raw_ex(curve448_key* key,
|
||||
*/
|
||||
|
||||
int wc_curve448_size(curve448_key* key);
|
||||
|
||||
/*!
|
||||
\ingroup Curve448
|
||||
\brief This function generates a Curve448 public key from a given
|
||||
private key. It computes the public key by performing scalar
|
||||
multiplication of the base point with the private key.
|
||||
|
||||
\return 0 On success.
|
||||
\return ECC_BAD_ARG_E If public_size is not CURVE448_PUB_KEY_SIZE or
|
||||
if private_size is not CURVE448_KEY_SIZE.
|
||||
\return BAD_FUNC_ARG If pub or priv is NULL.
|
||||
|
||||
\param public_size size of the public key buffer (must be 56 bytes)
|
||||
\param pub pointer to buffer to store the generated public key
|
||||
\param private_size size of the private key (must be 56 bytes)
|
||||
\param priv pointer to the private key buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte priv[CURVE448_KEY_SIZE] = { }; // private key
|
||||
byte pub[CURVE448_PUB_KEY_SIZE];
|
||||
|
||||
int ret = wc_curve448_make_pub(CURVE448_PUB_KEY_SIZE, pub,
|
||||
CURVE448_KEY_SIZE, priv);
|
||||
if (ret != 0) {
|
||||
// error generating public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve448_make_key
|
||||
\sa wc_curve448_import_private
|
||||
*/
|
||||
int wc_curve448_make_pub(int public_size, byte* pub, int private_size,
|
||||
const byte* priv);
|
||||
|
||||
@@ -330,3 +330,124 @@ int wc_Des3_CbcEncrypt(Des3* des, byte* out,
|
||||
*/
|
||||
int wc_Des3_CbcDecrypt(Des3* des, byte* out,
|
||||
const byte* in,word32 sz);
|
||||
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
\brief This function decrypts the input ciphertext and stores the
|
||||
resulting plaintext in the output buffer. It uses DES encryption
|
||||
with Electronic Codebook (ECB) mode. Warning: In nearly all use
|
||||
cases ECB mode is considered to be less secure. Please avoid using
|
||||
ECB APIs directly whenever possible.
|
||||
|
||||
\return 0 On successfully decrypting the given ciphertext
|
||||
|
||||
\param des pointer to the Des structure to use for decryption
|
||||
\param out pointer to the buffer in which to store the decrypted
|
||||
plaintext
|
||||
\param in pointer to the input buffer containing the ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des dec;
|
||||
byte cipher[]; // ciphertext to decrypt
|
||||
byte plain[sizeof(cipher)];
|
||||
|
||||
wc_Des_SetKey(&dec, key, iv, DES_DECRYPTION);
|
||||
if (wc_Des_EcbDecrypt(&dec, plain, cipher, sizeof(cipher)) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetKey
|
||||
\sa wc_Des_EcbEncrypt
|
||||
*/
|
||||
int wc_Des_EcbDecrypt(Des* des, byte* out, const byte* in, word32 sz);
|
||||
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
\brief This function decrypts the input ciphertext and stores the
|
||||
resulting plaintext in the output buffer. It uses Triple DES (3DES)
|
||||
encryption with Electronic Codebook (ECB) mode. Warning: In nearly
|
||||
all use cases ECB mode is considered to be less secure. Please
|
||||
avoid using ECB APIs directly whenever possible.
|
||||
|
||||
\return 0 On successfully decrypting the given ciphertext
|
||||
|
||||
\param des pointer to the Des3 structure to use for decryption
|
||||
\param out pointer to the buffer in which to store the decrypted
|
||||
plaintext
|
||||
\param in pointer to the input buffer containing the ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 dec;
|
||||
byte cipher[]; // ciphertext to decrypt
|
||||
byte plain[sizeof(cipher)];
|
||||
|
||||
wc_Des3_SetKey(&dec, key, iv, DES_DECRYPTION);
|
||||
if (wc_Des3_EcbDecrypt(&dec, plain, cipher, sizeof(cipher)) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
\sa wc_Des3_EcbEncrypt
|
||||
*/
|
||||
int wc_Des3_EcbDecrypt(Des3* des, byte* out, const byte* in, word32 sz);
|
||||
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
\brief This function initializes a Des3 structure for use with
|
||||
hardware acceleration and custom memory management. This is an
|
||||
extended version of the standard initialization that allows
|
||||
specification of heap hints and device IDs.
|
||||
|
||||
\return 0 On successfully initializing the Des3 structure
|
||||
\return BAD_FUNC_ARG If des3 is NULL
|
||||
|
||||
\param des3 pointer to the Des3 structure to initialize
|
||||
\param heap pointer to heap hint for memory allocation (can be NULL)
|
||||
\param devId device ID for hardware acceleration (use INVALID_DEVID
|
||||
for software only)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 des;
|
||||
void* heap = NULL;
|
||||
int devId = INVALID_DEVID;
|
||||
|
||||
if (wc_Des3Init(&des, heap, devId) != 0) {
|
||||
// error initializing Des3 structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
\sa wc_Des3Free
|
||||
*/
|
||||
int wc_Des3Init(Des3* des3, void* heap, int devId);
|
||||
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
\brief This function frees a Des3 structure and releases any
|
||||
resources allocated for it. This should be called when finished
|
||||
using the Des3 structure to prevent memory leaks.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param des3 pointer to the Des3 structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 des;
|
||||
wc_Des3Init(&des, NULL, INVALID_DEVID);
|
||||
wc_Des3_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
// use des for encryption/decryption
|
||||
wc_Des3Free(&des);
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3Init
|
||||
\sa wc_Des3_SetKey
|
||||
*/
|
||||
void wc_Des3Free(Des3* des3);
|
||||
|
||||
@@ -274,9 +274,348 @@ int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Encodes DH parameters to DER format for OpenSSL compatibility.
|
||||
|
||||
\brief This function returns ... and requires that HAVE_FFDHE_2048 be
|
||||
defined.
|
||||
\return Length of DER encoding on success
|
||||
\return Negative on error
|
||||
|
||||
\param dh DH parameters to encode
|
||||
\param out Output buffer pointer (if *out is NULL, allocates buffer)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
unsigned char* der = NULL;
|
||||
int derSz = wolfSSL_i2d_DHparams(dh, &der);
|
||||
if (derSz > 0) {
|
||||
// use der buffer
|
||||
XFREE(der, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
int wolfSSL_i2d_DHparams(const WOLFSSL_DH *dh, unsigned char **out);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Allocates and initializes a new DH structure for OpenSSL
|
||||
compatibility.
|
||||
|
||||
\return Pointer to WOLFSSL_DH on success
|
||||
\return NULL on failure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
if (dh == NULL) {
|
||||
// error allocating DH
|
||||
}
|
||||
// use dh
|
||||
wolfSSL_DH_free(dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_free
|
||||
\sa wolfSSL_DH_generate_key
|
||||
*/
|
||||
WOLFSSL_DH* wolfSSL_DH_new(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Creates a new DH structure with named group parameters.
|
||||
|
||||
\return Pointer to WOLFSSL_DH on success
|
||||
\return NULL on failure
|
||||
|
||||
\param nid Named group identifier (e.g., NID_ffdhe2048)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new_by_nid(NID_ffdhe2048);
|
||||
if (dh == NULL) {
|
||||
// error creating DH with named group
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
WOLFSSL_DH* wolfSSL_DH_new_by_nid(int nid);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Frees a DH structure.
|
||||
|
||||
\param dh DH structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
// use dh
|
||||
wolfSSL_DH_free(dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
void wolfSSL_DH_free(WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Duplicates a DH structure.
|
||||
|
||||
\return Pointer to new WOLFSSL_DH on success
|
||||
\return NULL on failure
|
||||
|
||||
\param dh DH structure to duplicate
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
WOLFSSL_DH* dhCopy = wolfSSL_DH_dup(dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
WOLFSSL_DH* wolfSSL_DH_dup(WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Increments reference count for DH structure.
|
||||
|
||||
\return 1 on success
|
||||
\return 0 on failure
|
||||
|
||||
\param dh DH structure to increment reference
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
int ret = wolfSSL_DH_up_ref(dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_free
|
||||
*/
|
||||
int wolfSSL_DH_up_ref(WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Validates DH parameters.
|
||||
|
||||
\return 1 on success
|
||||
\return 0 on failure
|
||||
|
||||
\param dh DH parameters to check
|
||||
\param codes Output for validation error codes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
int codes;
|
||||
int ret = wolfSSL_DH_check(dh, &codes);
|
||||
if (ret != 1 || codes != 0) {
|
||||
// validation failed
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_generate_key
|
||||
*/
|
||||
int wolfSSL_DH_check(const WOLFSSL_DH *dh, int *codes);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns size of DH key in bytes.
|
||||
|
||||
\return Key size in bytes on success
|
||||
\return -1 on failure
|
||||
|
||||
\param dh DH structure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
int size = wolfSSL_DH_size(dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
int wolfSSL_DH_size(WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Generates DH public/private key pair.
|
||||
|
||||
\return 1 on success
|
||||
\return 0 on failure
|
||||
|
||||
\param dh DH structure with parameters set
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
// set p and g parameters
|
||||
int ret = wolfSSL_DH_generate_key(dh);
|
||||
if (ret != 1) {
|
||||
// key generation failed
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_compute_key
|
||||
*/
|
||||
int wolfSSL_DH_generate_key(WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Computes shared secret from peer's public key.
|
||||
|
||||
\return Length of shared secret on success
|
||||
\return -1 on failure
|
||||
|
||||
\param key Output buffer for shared secret
|
||||
\param pub Peer's public key
|
||||
\param dh DH structure with private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
wolfSSL_DH_generate_key(dh);
|
||||
byte secret[256];
|
||||
WOLFSSL_BIGNUM* peerPub = NULL; // peer's public key
|
||||
int secretSz = wolfSSL_DH_compute_key(secret, peerPub, dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_generate_key
|
||||
*/
|
||||
int wolfSSL_DH_compute_key(unsigned char* key,
|
||||
const WOLFSSL_BIGNUM* pub, WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Computes shared secret with zero-padding to DH size.
|
||||
|
||||
\return Length of shared secret on success
|
||||
\return -1 on failure
|
||||
|
||||
\param key Output buffer for shared secret
|
||||
\param otherPub Peer's public key
|
||||
\param dh DH structure with private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
wolfSSL_DH_generate_key(dh);
|
||||
byte secret[256];
|
||||
WOLFSSL_BIGNUM* peerPub = NULL;
|
||||
int secretSz = wolfSSL_DH_compute_key_padded(secret, peerPub, dh);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_compute_key
|
||||
*/
|
||||
int wolfSSL_DH_compute_key_padded(unsigned char* key,
|
||||
const WOLFSSL_BIGNUM* otherPub,
|
||||
WOLFSSL_DH* dh);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Loads DH parameters from DER buffer.
|
||||
|
||||
\return WOLFSSL_SUCCESS on success
|
||||
\return WOLFSSL_FAILURE on failure
|
||||
|
||||
\param dh DH structure to load into
|
||||
\param derBuf DER-encoded DH parameters
|
||||
\param derSz Size of DER buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
byte derBuf[256];
|
||||
int ret = wolfSSL_DH_LoadDer(dh, derBuf, sizeof(derBuf));
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new
|
||||
*/
|
||||
int wolfSSL_DH_LoadDer(WOLFSSL_DH* dh, const unsigned char* derBuf,
|
||||
int derSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Sets optional private key length.
|
||||
|
||||
\return 1 on success
|
||||
\return 0 on failure
|
||||
|
||||
\param dh DH structure
|
||||
\param len Private key length in bits
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
int ret = wolfSSL_DH_set_length(dh, 256);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_generate_key
|
||||
*/
|
||||
int wolfSSL_DH_set_length(WOLFSSL_DH* dh, long len);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Sets DH parameters p, q, and g.
|
||||
|
||||
\return 1 on success
|
||||
\return 0 on failure
|
||||
|
||||
\param dh DH structure
|
||||
\param p Prime modulus (takes ownership)
|
||||
\param q Subgroup order (takes ownership, can be NULL)
|
||||
\param g Generator (takes ownership)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_new();
|
||||
WOLFSSL_BIGNUM *p = wolfSSL_BN_new();
|
||||
WOLFSSL_BIGNUM *g = wolfSSL_BN_new();
|
||||
// set p and g values
|
||||
int ret = wolfSSL_DH_set0_pqg(dh, p, NULL, g);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_generate_key
|
||||
*/
|
||||
int wolfSSL_DH_set0_pqg(WOLFSSL_DH *dh, WOLFSSL_BIGNUM *p,
|
||||
WOLFSSL_BIGNUM *q, WOLFSSL_BIGNUM *g);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns DH parameters for 2048-bit MODP group with 256-bit
|
||||
subgroup.
|
||||
|
||||
\return Pointer to WOLFSSL_DH on success
|
||||
\return NULL on failure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_DH* dh = wolfSSL_DH_get_2048_256();
|
||||
if (dh == NULL) {
|
||||
// error getting standard group
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_DH_new_by_nid
|
||||
*/
|
||||
WOLFSSL_DH* wolfSSL_DH_get_2048_256(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns FFDHE 2048-bit group parameters.
|
||||
|
||||
\return Pointer to DhParams structure
|
||||
\return NULL if not compiled with HAVE_FFDHE_2048
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const DhParams* params = wc_Dh_ffdhe2048_Get();
|
||||
if (params != NULL) {
|
||||
// use params
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Dh_ffdhe3072_Get
|
||||
\sa wc_Dh_ffdhe4096_Get
|
||||
@@ -287,9 +626,18 @@ const DhParams* wc_Dh_ffdhe2048_Get(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns FFDHE 3072-bit group parameters.
|
||||
|
||||
\brief This function returns ... and requires that HAVE_FFDHE_3072 be
|
||||
defined.
|
||||
\return Pointer to DhParams structure
|
||||
\return NULL if not compiled with HAVE_FFDHE_3072
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const DhParams* params = wc_Dh_ffdhe3072_Get();
|
||||
if (params != NULL) {
|
||||
// use params
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Dh_ffdhe2048_Get
|
||||
\sa wc_Dh_ffdhe4096_Get
|
||||
@@ -300,9 +648,18 @@ const DhParams* wc_Dh_ffdhe3072_Get(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns FFDHE 4096-bit group parameters.
|
||||
|
||||
\brief This function returns ... and requires that HAVE_FFDHE_4096 be
|
||||
defined.
|
||||
\return Pointer to DhParams structure
|
||||
\return NULL if not compiled with HAVE_FFDHE_4096
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const DhParams* params = wc_Dh_ffdhe4096_Get();
|
||||
if (params != NULL) {
|
||||
// use params
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Dh_ffdhe2048_Get
|
||||
\sa wc_Dh_ffdhe3072_Get
|
||||
@@ -313,9 +670,18 @@ const DhParams* wc_Dh_ffdhe4096_Get(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns FFDHE 6144-bit group parameters.
|
||||
|
||||
\brief This function returns ... and requires that HAVE_FFDHE_6144 be
|
||||
defined.
|
||||
\return Pointer to DhParams structure
|
||||
\return NULL if not compiled with HAVE_FFDHE_6144
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const DhParams* params = wc_Dh_ffdhe6144_Get();
|
||||
if (params != NULL) {
|
||||
// use params
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Dh_ffdhe2048_Get
|
||||
\sa wc_Dh_ffdhe3072_Get
|
||||
@@ -326,9 +692,18 @@ const DhParams* wc_Dh_ffdhe6144_Get(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Returns FFDHE 8192-bit group parameters.
|
||||
|
||||
\brief This function returns ... and requires that HAVE_FFDHE_8192 be
|
||||
defined.
|
||||
\return Pointer to DhParams structure
|
||||
\return NULL if not compiled with HAVE_FFDHE_8192
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const DhParams* params = wc_Dh_ffdhe8192_Get();
|
||||
if (params != NULL) {
|
||||
// use params
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Dh_ffdhe2048_Get
|
||||
\sa wc_Dh_ffdhe3072_Get
|
||||
@@ -337,6 +712,291 @@ const DhParams* wc_Dh_ffdhe6144_Get(void);
|
||||
*/
|
||||
const DhParams* wc_Dh_ffdhe8192_Get(void);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Initializes DH key with heap hint and device ID.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if key is NULL
|
||||
|
||||
\param key DH key to initialize
|
||||
\param heap Heap hint for memory allocation
|
||||
\param devId Device ID for hardware acceleration
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
int ret = wc_InitDhKey_ex(&key, NULL, INVALID_DEVID);
|
||||
if (ret != 0) {
|
||||
// error initializing key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDhKey
|
||||
\sa wc_FreeDhKey
|
||||
*/
|
||||
int wc_InitDhKey_ex(DhKey* key, void* heap, int devId);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Computes shared secret with constant-time operations.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
\return BUFFER_E if output buffer too small
|
||||
|
||||
\param key DH key with parameters
|
||||
\param agree Output buffer for shared secret
|
||||
\param agreeSz Input: buffer size, Output: secret size
|
||||
\param priv Private key
|
||||
\param privSz Private key size
|
||||
\param otherPub Peer's public key
|
||||
\param pubSz Peer's public key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
byte agree[256], priv[256], pub[256];
|
||||
word32 agreeSz = sizeof(agree);
|
||||
int ret = wc_DhAgree_ct(&key, agree, &agreeSz, priv,
|
||||
sizeof(priv), pub, sizeof(pub));
|
||||
\endcode
|
||||
|
||||
\sa wc_DhAgree
|
||||
*/
|
||||
int wc_DhAgree_ct(DhKey* key, byte* agree, word32 *agreeSz,
|
||||
const byte* priv, word32 privSz,
|
||||
const byte* otherPub, word32 pubSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Sets DH key to use named group parameters.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
|
||||
\param key DH key to configure
|
||||
\param name Named group identifier
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
wc_InitDhKey(&key);
|
||||
int ret = wc_DhSetNamedKey(&key, WC_FFDHE_2048);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhGetNamedKeyParamSize
|
||||
*/
|
||||
int wc_DhSetNamedKey(DhKey* key, int name);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Gets parameter sizes for named group.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
|
||||
\param name Named group identifier
|
||||
\param p Output for prime size
|
||||
\param g Output for generator size
|
||||
\param q Output for subgroup order size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
word32 pSz, gSz, qSz;
|
||||
int ret = wc_DhGetNamedKeyParamSize(WC_FFDHE_2048, &pSz, &gSz,
|
||||
&qSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetNamedKey
|
||||
*/
|
||||
int wc_DhGetNamedKeyParamSize(int name, word32* p, word32* g,
|
||||
word32* q);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Gets minimum key size for named group.
|
||||
|
||||
\return Minimum key size in bits
|
||||
\return 0 if invalid name
|
||||
|
||||
\param name Named group identifier
|
||||
|
||||
_Example_
|
||||
\code
|
||||
word32 minSize = wc_DhGetNamedKeyMinSize(WC_FFDHE_2048);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetNamedKey
|
||||
*/
|
||||
word32 wc_DhGetNamedKeyMinSize(int name);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Compares parameters against named group.
|
||||
|
||||
\return 0 if parameters match named group
|
||||
\return Non-zero if parameters don't match
|
||||
|
||||
\param name Named group identifier
|
||||
\param noQ 1 to skip q comparison
|
||||
\param p Prime modulus
|
||||
\param pSz Prime size
|
||||
\param g Generator
|
||||
\param gSz Generator size
|
||||
\param q Subgroup order
|
||||
\param qSz Subgroup order size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte p[256], g[256];
|
||||
int ret = wc_DhCmpNamedKey(WC_FFDHE_2048, 1, p, sizeof(p),
|
||||
g, sizeof(g), NULL, 0);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetNamedKey
|
||||
*/
|
||||
int wc_DhCmpNamedKey(int name, int noQ, const byte* p, word32 pSz,
|
||||
const byte* g, word32 gSz, const byte* q,
|
||||
word32 qSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Copies named group parameters to buffers.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
\return BUFFER_E if buffers too small
|
||||
|
||||
\param name Named group identifier
|
||||
\param p Output buffer for prime
|
||||
\param pSz Input: buffer size, Output: prime size
|
||||
\param g Output buffer for generator
|
||||
\param gSz Input: buffer size, Output: generator size
|
||||
\param q Output buffer for subgroup order
|
||||
\param qSz Input: buffer size, Output: subgroup order size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte p[512], g[512], q[512];
|
||||
word32 pSz = sizeof(p), gSz = sizeof(g), qSz = sizeof(q);
|
||||
int ret = wc_DhCopyNamedKey(WC_FFDHE_2048, p, &pSz, g, &gSz,
|
||||
q, &qSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetNamedKey
|
||||
*/
|
||||
int wc_DhCopyNamedKey(int name, byte* p, word32* pSz, byte* g,
|
||||
word32* gSz, byte* q, word32* qSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Generates public key from private key.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
|
||||
\param key DH key with parameters set
|
||||
\param priv Private key
|
||||
\param privSz Private key size
|
||||
\param pub Output buffer for public key
|
||||
\param pubSz Input: buffer size, Output: public key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
byte priv[256], pub[256];
|
||||
word32 pubSz = sizeof(pub);
|
||||
int ret = wc_DhGeneratePublic(&key, priv, sizeof(priv), pub,
|
||||
&pubSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhGenerateKeyPair
|
||||
*/
|
||||
int wc_DhGeneratePublic(DhKey* key, byte* priv, word32 privSz,
|
||||
byte* pub, word32* pubSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Imports private and/or public key into DH key.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
|
||||
\param key DH key to import into
|
||||
\param priv Private key (can be NULL)
|
||||
\param privSz Private key size
|
||||
\param pub Public key (can be NULL)
|
||||
\param pubSz Public key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
byte priv[256], pub[256];
|
||||
int ret = wc_DhImportKeyPair(&key, priv, sizeof(priv), pub,
|
||||
sizeof(pub));
|
||||
\endcode
|
||||
|
||||
\sa wc_DhExportKeyPair
|
||||
*/
|
||||
int wc_DhImportKeyPair(DhKey* key, const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Exports private and public key from DH key.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
\return BUFFER_E if buffers too small
|
||||
|
||||
\param key DH key to export from
|
||||
\param priv Output buffer for private key
|
||||
\param pPrivSz Input: buffer size, Output: private key size
|
||||
\param pub Output buffer for public key
|
||||
\param pPubSz Input: buffer size, Output: public key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
byte priv[256], pub[256];
|
||||
word32 privSz = sizeof(priv), pubSz = sizeof(pub);
|
||||
int ret = wc_DhExportKeyPair(&key, priv, &privSz, pub, &pubSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DhImportKeyPair
|
||||
*/
|
||||
int wc_DhExportKeyPair(DhKey* key, byte* priv, word32* pPrivSz,
|
||||
byte* pub, word32* pPubSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
\brief Validates public key value.
|
||||
|
||||
\return 0 if public key is valid
|
||||
\return BAD_FUNC_ARG if parameters are invalid
|
||||
\return MP_VAL if public key is invalid
|
||||
|
||||
\param prime Prime modulus
|
||||
\param primeSz Prime size
|
||||
\param pub Public key to validate
|
||||
\param pubSz Public key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte prime[256], pub[256];
|
||||
int ret = wc_DhCheckPubValue(prime, sizeof(prime), pub,
|
||||
sizeof(pub));
|
||||
if (ret != 0) {
|
||||
// invalid public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DhCheckPubKey
|
||||
*/
|
||||
int wc_DhCheckPubValue(const byte* prime, word32 primeSz,
|
||||
const byte* pub, word32 pubSz);
|
||||
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
|
||||
@@ -340,3 +340,298 @@ int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa);
|
||||
\sa wc_InitDsaKey
|
||||
*/
|
||||
int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Initializes DSA key with heap hint.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param key DSA key structure
|
||||
\param h Heap hint for memory allocation
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
int ret = wc_InitDsaKey_h(&key, NULL);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDsaKey
|
||||
*/
|
||||
int wc_InitDsaKey_h(DsaKey* key, void* h);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Signs digest with extended parameters.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param digest Digest to sign
|
||||
\param digestSz Digest size
|
||||
\param out Output signature buffer
|
||||
\param key DSA key
|
||||
\param rng Random number generator
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte digest[WC_SHA_DIGEST_SIZE];
|
||||
byte sig[40];
|
||||
WC_RNG rng;
|
||||
int ret = wc_DsaSign_ex(digest, sizeof(digest), sig, &key,
|
||||
&rng);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaSign
|
||||
*/
|
||||
int wc_DsaSign_ex(const byte* digest, word32 digestSz, byte* out,
|
||||
DsaKey* key, WC_RNG* rng);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Verifies signature with extended parameters.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param digest Digest
|
||||
\param digestSz Digest size
|
||||
\param sig Signature buffer
|
||||
\param key DSA key
|
||||
\param answer Verification result
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte digest[WC_SHA_DIGEST_SIZE];
|
||||
byte sig[40];
|
||||
int answer;
|
||||
int ret = wc_DsaVerify_ex(digest, sizeof(digest), sig, &key,
|
||||
&answer);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaVerify
|
||||
*/
|
||||
int wc_DsaVerify_ex(const byte* digest, word32 digestSz,
|
||||
const byte* sig, DsaKey* key, int* answer);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Sets DSA public key in output buffer.
|
||||
|
||||
\return Size on success
|
||||
\return negative on failure
|
||||
|
||||
\param output Output buffer
|
||||
\param key DSA key
|
||||
\param outLen Output buffer length
|
||||
\param with_header Include header flag
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte output[256];
|
||||
int ret = wc_SetDsaPublicKey(output, &key, sizeof(output), 1);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaKeyToPublicDer
|
||||
*/
|
||||
int wc_SetDsaPublicKey(byte* output, DsaKey* key, int outLen,
|
||||
int with_header);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Converts DSA key to public DER format.
|
||||
|
||||
\return Size on success
|
||||
\return negative on failure
|
||||
|
||||
\param key DSA key
|
||||
\param output Output buffer
|
||||
\param inLen Output buffer length
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
WC_RNG rng;
|
||||
byte output[256];
|
||||
|
||||
// Initialize key and RNG
|
||||
wc_InitDsaKey(&key);
|
||||
wc_InitRng(&rng);
|
||||
|
||||
// Generate DSA key or import existing key
|
||||
wc_MakeDsaKey(&rng, &key);
|
||||
|
||||
// Convert to public DER format
|
||||
int ret = wc_DsaKeyToPublicDer(&key, output, sizeof(output));
|
||||
if (ret > 0) {
|
||||
// output contains DER encoded public key of size ret
|
||||
}
|
||||
|
||||
wc_FreeDsaKey(&key);
|
||||
wc_FreeRng(&rng);
|
||||
\endcode
|
||||
|
||||
\sa wc_SetDsaPublicKey
|
||||
*/
|
||||
int wc_DsaKeyToPublicDer(DsaKey* key, byte* output, word32 inLen);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Imports DSA parameters from raw format. The parameters p, q, and
|
||||
g must be provided as ASCII hexadecimal strings (without 0x prefix).
|
||||
These represent the DSA domain parameters: p is the prime modulus, q is
|
||||
the prime divisor (subgroup order), and g is the generator.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param dsa DSA key structure (must be initialized)
|
||||
\param p P parameter as ASCII hex string (prime modulus)
|
||||
\param q Q parameter as ASCII hex string (prime divisor/subgroup order)
|
||||
\param g G parameter as ASCII hex string (generator)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey dsa;
|
||||
wc_InitDsaKey(&dsa);
|
||||
|
||||
// DSA parameters as ASCII hexadecimal strings (example values)
|
||||
const char* pStr = "E0A67598CD1B763BC98C8ABB333E5DDA0CD3AA0E5E1F"
|
||||
"B5BA8A7B4EABC10BA338FAE06DD4B90FDA70D7CF0CB0"
|
||||
"C638BE3341BEC0AF8A7330A3307DED2299A0EE606DF0"
|
||||
"35177A239C34A912C202AA5F83B9C4A7CF0235B5316B"
|
||||
"FC6EFB9A248411258B30B839AF172440F32563056CB6"
|
||||
"7A861158DDD90E6A894C72A5BBEF9E286C6B";
|
||||
const char* qStr = "E950511EAB424B9A19A2AEB4E159B7844C589C4F";
|
||||
const char* gStr = "D29D5121B0423C2769AB21843E5A3240FF19CACC792D"
|
||||
"C6E7925E6D1A4E6E4E3D119A3D133C8D3C8C8C8C8C8C"
|
||||
"8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C"
|
||||
"8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C";
|
||||
|
||||
int ret = wc_DsaImportParamsRaw(&dsa, pStr, qStr, gStr);
|
||||
if (ret == 0) {
|
||||
// DSA parameters successfully imported
|
||||
// Can now use dsa for key generation or signing
|
||||
}
|
||||
wc_FreeDsaKey(&dsa);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaImportParamsRawCheck
|
||||
\sa wc_InitDsaKey
|
||||
*/
|
||||
int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p, const char* q,
|
||||
const char* g);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Imports DSA parameters from raw format with optional validation.
|
||||
The parameters p, q, and g must be provided as ASCII hexadecimal strings
|
||||
(without 0x prefix). The trusted parameter controls whether the prime p
|
||||
is validated: when trusted=1, prime checking is skipped (use when
|
||||
parameters come from a trusted source); when trusted=0, performs full
|
||||
primality testing on p (recommended for untrusted sources).
|
||||
|
||||
\return 0 on success
|
||||
\return DH_CHECK_PUB_E if p fails primality test (when trusted=0)
|
||||
\return negative on other failures
|
||||
|
||||
\param dsa DSA key structure (must be initialized)
|
||||
\param p P parameter as ASCII hex string (prime modulus)
|
||||
\param q Q parameter as ASCII hex string (prime divisor/subgroup order)
|
||||
\param g G parameter as ASCII hex string (generator)
|
||||
\param trusted If 1, skip prime validation (trusted source); if 0,
|
||||
perform full primality test on p
|
||||
\param rng Random number generator (required when trusted=0 for
|
||||
primality testing)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey dsa;
|
||||
WC_RNG rng;
|
||||
|
||||
// Initialize DSA key and RNG
|
||||
wc_InitDsaKey(&dsa);
|
||||
wc_InitRng(&rng);
|
||||
|
||||
// DSA parameters as ASCII hexadecimal strings
|
||||
const char* pStr = "E0A67598CD1B763BC98C8ABB333E5DDA0CD3AA0E5E1F"
|
||||
"B5BA8A7B4EABC10BA338FAE06DD4B90FDA70D7CF0CB0"
|
||||
"C638BE3341BEC0AF8A7330A3307DED2299A0EE606DF0"
|
||||
"35177A239C34A912C202AA5F83B9C4A7CF0235B5316B"
|
||||
"FC6EFB9A248411258B30B839AF172440F32563056CB6"
|
||||
"7A861158DDD90E6A894C72A5BBEF9E286C6B";
|
||||
const char* qStr = "E950511EAB424B9A19A2AEB4E159B7844C589C4F";
|
||||
const char* gStr = "D29D5121B0423C2769AB21843E5A3240FF19CACC792D"
|
||||
"C6E7925E6D1A4E6E4E3D119A3D133C8D3C8C8C8C8C8C"
|
||||
"8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C"
|
||||
"8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C8C";
|
||||
|
||||
// Import with validation (trusted=0 performs primality test on p)
|
||||
int ret = wc_DsaImportParamsRawCheck(&dsa, pStr, qStr, gStr, 0,
|
||||
&rng);
|
||||
if (ret == 0) {
|
||||
// Parameters imported and validated successfully
|
||||
}
|
||||
|
||||
wc_FreeDsaKey(&dsa);
|
||||
wc_FreeRng(&rng);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaImportParamsRaw
|
||||
\sa wc_InitDsaKey
|
||||
*/
|
||||
int wc_DsaImportParamsRawCheck(DsaKey* dsa, const char* p,
|
||||
const char* q, const char* g, int trusted, WC_RNG* rng);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Exports DSA parameters to raw format.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param dsa DSA key structure
|
||||
\param p P parameter buffer
|
||||
\param pSz P parameter size (in/out)
|
||||
\param q Q parameter buffer
|
||||
\param qSz Q parameter size (in/out)
|
||||
\param g G parameter buffer
|
||||
\param gSz G parameter size (in/out)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte p[256], q[32], g[256];
|
||||
word32 pSz = sizeof(p), qSz = sizeof(q), gSz = sizeof(g);
|
||||
int ret = wc_DsaExportParamsRaw(&dsa, p, &pSz, q, &qSz, g,
|
||||
&gSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaImportParamsRaw
|
||||
*/
|
||||
int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz, byte* q,
|
||||
word32* qSz, byte* g, word32* gSz);
|
||||
|
||||
/*!
|
||||
\ingroup DSA
|
||||
\brief Exports DSA key to raw format.
|
||||
|
||||
\return 0 on success
|
||||
\return negative on failure
|
||||
|
||||
\param dsa DSA key structure
|
||||
\param x Private key buffer
|
||||
\param xSz Private key size (in/out)
|
||||
\param y Public key buffer
|
||||
\param ySz Public key size (in/out)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte x[32], y[256];
|
||||
word32 xSz = sizeof(x), ySz = sizeof(y);
|
||||
int ret = wc_DsaExportKeyRaw(&dsa, x, &xSz, y, &ySz);
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaImportParamsRaw
|
||||
*/
|
||||
int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y,
|
||||
word32* ySz);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user