Skip to content

SDK Reference

The EmbSec SDK provides a simplified abstraction layer over TivaWare for embedded security lab development. It includes essential functions for UART communication, GPIO control, timing, cryptography, and secure flag generation.

Overview

The SDK is designed to make embedded programming more accessible while teaching fundamental security concepts. It provides:

  • Simple APIs - Clean, well-documented functions that abstract complex hardware details
  • Security Features - Built-in cryptographic functions and secure flag generation
  • Educational Focus - Functions designed to support security lab scenarios
  • Cross-platform - Supports both hardware (TM4C123GH6PM) and QEMU emulation

Key Components

Core Functions

The Core API provides system initialization, interrupt control, and basic utilities.

UART Communication

The UART API handles console I/O with functions for character and string operations.

GPIO Control

The GPIO API manages digital I/O including LEDs and switches.

Timing Functions

The Timer API provides delays, timeouts, and performance measurement.

Cryptography

The Crypto API includes SHA-256 hashing, HMAC, and secure random generation.

Flag Generation

The Flag API generates unique, cryptographically secure flags for CTF challenges.

Getting Started

Every program using the EmbSec SDK should start with:

#include <embsec/embsec.h>
#include <embsec/uart.h>
// Include other headers as needed

int main(void) {
    // Initialize the SDK
    embsec_init();

    // Your code here
    embsec_printf("Hello, EmbSec!\n");

    while (1) {
        // Main loop
    }
}

Version Information

The SDK version can be checked at compile time:

#include <embsec/version.h>

#if !EMBSEC_VERSION_CHECK(1, 0, 0)
#error "EmbSec SDK 1.0.0 or later required"
#endif

Or at runtime:

const char *version = embsec_get_version();
embsec_printf("SDK Version: %s\n", version);

Header Files

All SDK headers are located in sdk/include/embsec/:

  • embsec.h - Main SDK header with core functions
  • uart.h - UART communication functions
  • gpio.h - GPIO control functions
  • timer.h - Timing and delay functions
  • crypto.h - Cryptographic functions
  • flag.h - Flag generation functions
  • version.h - Version information

Building with the SDK

The SDK is automatically included when building labs with CMake:

# In your lab's CMakeLists.txt
embsec_add_lab(
    NAME my_lab
    SOURCES src/main.c
)

This automatically:

  • Links the EmbSec SDK library
  • Includes SDK headers
  • Configures for the target platform
  • Sets up proper compiler flags

Platform Support

The SDK supports two platforms:

Hardware (TM4C123GH6PM)

  • Texas Instruments Tiva C Series LaunchPad
  • 80MHz ARM Cortex-M4F
  • Hardware peripherals (UART, GPIO, timers)

Emulation (QEMU)

  • QEMU emulation of LM3S6965
  • Same API, adapted for emulation
  • Ideal for development and testing

Memory Considerations

The SDK is designed for constrained embedded systems:

  • Minimal RAM usage
  • Efficient stack usage
  • No dynamic memory allocation
  • Compile-time configuration where possible

Security Considerations

When using the SDK for security labs:

  1. Flag Generation - Always use the provided flag generation functions
  2. Crypto Functions - Use constant-time comparison for sensitive data
  3. Memory Clearing - Use embsec_secure_zero() for sensitive data
  4. Random Numbers - Use embsec_random_bytes() for cryptographic randomness

Examples

See the Examples page for complete code examples demonstrating:

  • Basic I/O operations
  • LED and switch control
  • Timer usage
  • Flag generation
  • Cryptographic operations

API Reference

For detailed function documentation, see:

Support

For issues or questions:

  • Check the Examples page
  • Review lab implementations in labs/
  • Consult the TivaWare documentation for hardware details