添加了AES128加密算法实现和电机OTA中继相关文件,包括: - ./sys/aes128.h 和 ./sys/aes128.cpp - AES128加密算法头文件和实现 - ./sys/motor_ota_relay.h 和 ./sys/motor_ota_relay.cpp - 电机OTA中继功能 - 更新了项目配置文件包含这些新模块
29 lines
965 B
C++
29 lines
965 B
C++
/**
|
|
* @file aes128.h
|
|
* @brief AES-128 ECB 加解密(纯软件实现,移植自电机 BOOT 工程)。
|
|
* 用于电机 OTA relay 中对固件数据加密及密钥协商。
|
|
*/
|
|
#ifndef SYS_AES128_H
|
|
#define SYS_AES128_H
|
|
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
|
|
static constexpr uint8_t AES128_KEY_LEN = 16U;
|
|
static constexpr uint8_t AES_BLOCK_SIZE = 16U;
|
|
|
|
struct aes128_context {
|
|
uint8_t key[AES128_KEY_LEN];
|
|
uint8_t round_keys[11][16];
|
|
uint8_t state[AES_BLOCK_SIZE];
|
|
};
|
|
|
|
void aes128_set_key(aes128_context *ctx, const uint8_t *key);
|
|
void aes128_encrypt_block(aes128_context *ctx, const uint8_t *input, uint8_t *output);
|
|
void aes128_decrypt_block(aes128_context *ctx, const uint8_t *input, uint8_t *output);
|
|
void aes128_ecb_encrypt_48bytes(aes128_context *ctx, const uint8_t *input, uint8_t *output);
|
|
void aes128_ecb_decrypt_48bytes(aes128_context *ctx, const uint8_t *input, uint8_t *output);
|
|
|
|
#endif /* SYS_AES128_H */
|