mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-10-22 07:18:47 +02:00
Add 0x0026a custom AES-128-CMAC secure bootloader, Week 11a notebook, and README links
This commit is contained in:
1 parent
b85aaf72d6
commit
bec685d573
33 files changed
+3451
No files matched your search
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file ir.h
|
||||
* @brief Header for NEC IR receiver (decoder) API
|
||||
* @author Kevin Thomas
|
||||
* @date 2025
|
||||
*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2025 Kevin Thomas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef IR_H
|
||||
#define IR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the IR receiver GPIO
|
||||
*
|
||||
* Configures the given `pin` as an input with pull-up for the NEC IR receiver.
|
||||
* Call this once during board initialization before calling `ir_getkey()`.
|
||||
*
|
||||
* @param pin GPIO pin number connected to IR receiver output
|
||||
*/
|
||||
void ir_init(uint8_t pin);
|
||||
|
||||
/**
|
||||
* @brief Blocking NEC IR decoder
|
||||
*
|
||||
* Blocks while waiting for a complete NEC frame. On success returns the
|
||||
* decoded command byte (0..255). On timeout or protocol error returns -1.
|
||||
*
|
||||
* @return decoded command byte (0..255) or -1 on failure
|
||||
*/
|
||||
int ir_getkey(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // IR_H
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @file led.h
|
||||
* @brief LED controller driven by decoded NEC IR commands.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* MIT License
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*/
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief LED controller state for the three IR-controlled LEDs.
|
||||
*
|
||||
* Maps each logical LED (1-3) to its GPIO pin and remembers whether the
|
||||
* LED is currently on. Build a default instance with led_default() and
|
||||
* drive it with led_init() and led_handle_ir().
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t led1_pin;
|
||||
uint8_t led2_pin;
|
||||
uint8_t led3_pin;
|
||||
bool led1_state;
|
||||
bool led2_state;
|
||||
bool led3_state;
|
||||
} simple_led_ctrl_t;
|
||||
|
||||
/**
|
||||
* @brief Build the default three-LED configuration (pins 16-18, all off).
|
||||
* @param void No parameters.
|
||||
* @return simple_led_ctrl_t Default LED controller state.
|
||||
*/
|
||||
simple_led_ctrl_t led_default(void);
|
||||
|
||||
/**
|
||||
* @brief Configure the three LED GPIO pins as outputs.
|
||||
* @param leds Pointer to the LED controller to initialize.
|
||||
* @return void No return value.
|
||||
*/
|
||||
void led_init(simple_led_ctrl_t *leds);
|
||||
|
||||
/**
|
||||
* @brief Dispatch a decoded NEC command to the matching LED.
|
||||
* @param leds Pointer to the LED controller to drive.
|
||||
* @param key Decoded NEC command byte, or a negative value to ignore.
|
||||
* @return void No return value.
|
||||
*/
|
||||
void led_handle_ir(simple_led_ctrl_t *leds, int key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LED_H
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file secret.h
|
||||
* @brief AES-128-CBC protected runtime banner for the application.
|
||||
* @author Kevin Thomas
|
||||
* @date 2026
|
||||
*
|
||||
* MIT License
|
||||
* Copyright (c) 2026 Kevin Thomas
|
||||
*/
|
||||
|
||||
#ifndef SECRET_H
|
||||
#define SECRET_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @brief AES block size in bytes used by the runtime banner. */
|
||||
#define APP_AES_BLOCK 16U
|
||||
|
||||
/** @brief Length in bytes of the encrypted runtime banner. */
|
||||
#define APP_BANNER_LEN 32U
|
||||
|
||||
/**
|
||||
* @brief Decrypt the embedded AES-128-CBC banner and print it.
|
||||
* @param void No parameters.
|
||||
* @return int Zero on success, non-zero when decryption fails.
|
||||
*/
|
||||
int secret_print_banner(void);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user