2025-12-25 12:07:06 +08:00
|
|
|
#include "initial.h"
|
2026-01-12 01:06:05 +08:00
|
|
|
#include "OTA.h"
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "core_cmFunc.h"
|
2025-12-25 12:07:06 +08:00
|
|
|
#include "gd32c10x.h"
|
|
|
|
|
#include "gd32c10x_gpio.h"
|
|
|
|
|
#include "gd32c10x_rcu.h"
|
2026-01-12 01:06:05 +08:00
|
|
|
#include "main.h"
|
|
|
|
|
#include "systick.h"
|
2025-12-25 12:07:06 +08:00
|
|
|
#include <cstdio>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdio.h>
|
2026-01-12 01:06:05 +08:00
|
|
|
|
|
|
|
|
extern BootloaderSystem sys;
|
2025-12-25 12:07:06 +08:00
|
|
|
|
|
|
|
|
/* retarget the C library printf function to the USART */
|
|
|
|
|
u8 USART0_init() {
|
|
|
|
|
gd_eval_com_init(EVAL_COM0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int fputc(int ch, FILE *f) throw() {
|
|
|
|
|
usart_data_transmit(EVAL_COM0, (uint8_t)ch);
|
|
|
|
|
while (RESET == usart_flag_get(EVAL_COM0, USART_FLAG_TBE))
|
|
|
|
|
;
|
|
|
|
|
return ch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void unused_pin_init() {
|
|
|
|
|
rcu_periph_clock_enable(RCU_GPIOA); // 使能GPIOA时钟
|
|
|
|
|
rcu_periph_clock_enable(RCU_GPIOB); // 使能GPIOB时钟
|
|
|
|
|
rcu_periph_clock_enable(RCU_GPIOC); // 使能GPIOC时钟
|
|
|
|
|
gpio_init(GPIOA, GPIO_MODE_IPU, GPIO_OSPEED_2MHZ,
|
|
|
|
|
GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_12);
|
|
|
|
|
gpio_init(GPIOB, GPIO_MODE_IPU, GPIO_OSPEED_2MHZ,
|
|
|
|
|
GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_15);
|
|
|
|
|
gpio_init(GPIOC, GPIO_MODE_IPU, GPIO_OSPEED_2MHZ,
|
|
|
|
|
GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);
|
|
|
|
|
gpio_bit_reset(GPIOA, GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_12);
|
|
|
|
|
gpio_bit_reset(GPIOB, GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_15);
|
|
|
|
|
gpio_bit_reset(GPIOC, GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);
|
2026-01-03 18:00:28 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-05 00:52:20 +08:00
|
|
|
/**
|
|
|
|
|
* @brief 扫描APP地址范围内的Flash内容
|
|
|
|
|
* @param print_content 是否打印Flash内容,默认为true
|
|
|
|
|
* @param page_count 扫描的页数,默认为0表示扫描整个APP区域
|
|
|
|
|
* @retval 无
|
|
|
|
|
*/
|
|
|
|
|
void scanAppFlashContent(bool print_content = true, u32 page_count = 0) {
|
|
|
|
|
u32 start_addr = APPLATEST_START_ADDR;
|
|
|
|
|
u32 total_size = 0xC000;
|
|
|
|
|
|
|
|
|
|
// 如果指定了页数,则按页数计算大小
|
|
|
|
|
if (page_count > 0) {
|
|
|
|
|
total_size = page_count * FMC_PAGE_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u32 end_addr = start_addr + total_size;
|
|
|
|
|
|
|
|
|
|
#if DEBUG_OTA
|
|
|
|
|
printf("Scanning Flash from 0x%08X to 0x%08X (%d bytes)\r\n", start_addr,
|
|
|
|
|
end_addr, total_size);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
u32 page_count_scanned = 0;
|
|
|
|
|
u32 empty_pages = 0;
|
|
|
|
|
u32 data_pages = 0;
|
|
|
|
|
|
|
|
|
|
for (u32 addr = start_addr; addr < end_addr; addr += FMC_PAGE_SIZE) {
|
|
|
|
|
bool page_empty = true;
|
|
|
|
|
|
|
|
|
|
// 检查当前页是否全为0xFF(空页)
|
|
|
|
|
for (u32 offset = 0; offset < FMC_PAGE_SIZE; offset += 4) {
|
|
|
|
|
u32 data = *(u32 *)(addr + offset);
|
|
|
|
|
|
|
|
|
|
if (data != 0xFFFFFFFF) {
|
|
|
|
|
page_empty = false;
|
|
|
|
|
break; // 找到非空数据,立即退出检查
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (page_empty) {
|
|
|
|
|
empty_pages++;
|
|
|
|
|
} else {
|
|
|
|
|
data_pages++;
|
|
|
|
|
|
|
|
|
|
// 只有在非空页面且需要打印时才输出内容
|
|
|
|
|
if (print_content) {
|
|
|
|
|
printf("Page 0x%08X: \r\n", addr);
|
|
|
|
|
|
|
|
|
|
// 打印所有内容
|
|
|
|
|
for (u32 offset = 0; offset < FMC_PAGE_SIZE;
|
|
|
|
|
offset += 16) { // 每行打印16字节
|
|
|
|
|
// 打印地址偏移
|
|
|
|
|
printf(" +%03X: ", offset);
|
|
|
|
|
|
|
|
|
|
// 打印十六进制数据
|
|
|
|
|
for (u32 byte_idx = 0; byte_idx < 16; byte_idx++) {
|
|
|
|
|
if ((offset + byte_idx) < FMC_PAGE_SIZE) {
|
|
|
|
|
u8 data = *(__IO u8 *)(addr + offset + byte_idx);
|
|
|
|
|
printf("%02X ", data);
|
|
|
|
|
} else {
|
|
|
|
|
printf(" "); // 空白填充
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 每8字节加个小空格,便于阅读
|
|
|
|
|
if (byte_idx == 7) {
|
|
|
|
|
printf(" ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打印可打印字符
|
|
|
|
|
printf("|");
|
|
|
|
|
for (u32 byte_idx = 0; byte_idx < 16; byte_idx++) {
|
|
|
|
|
if ((offset + byte_idx) < FMC_PAGE_SIZE) {
|
|
|
|
|
u8 data = *(__IO u8 *)(addr + offset + byte_idx);
|
|
|
|
|
if (data >= 32 && data <= 126) { // 可打印字符范围
|
|
|
|
|
printf("%c", data);
|
|
|
|
|
} else {
|
|
|
|
|
printf(".");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
printf(" "); // 空白填充
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("|\r\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
page_count_scanned++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if DEBUG_OTA
|
|
|
|
|
printf("Scan complete: %d pages scanned, %d empty pages, %d data pages\r\n",
|
|
|
|
|
page_count_scanned, empty_pages, data_pages);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2026-01-03 18:00:28 +08:00
|
|
|
|
2026-01-12 01:06:05 +08:00
|
|
|
/*!
|
|
|
|
|
\brief prepare system to enter deep sleep mode
|
|
|
|
|
\param[in] none
|
|
|
|
|
\param[out] none
|
|
|
|
|
\retval none
|
|
|
|
|
*/
|
|
|
|
|
void enter_deep_sleep() {
|
|
|
|
|
// 关闭不必要的外设时钟
|
|
|
|
|
rcu_periph_clock_disable(RCU_TIMER0); // 关闭定时器时钟
|
|
|
|
|
rcu_periph_clock_disable(RCU_TIMER1);
|
|
|
|
|
rcu_periph_clock_disable(RCU_SPI0); // 关闭SPI时钟
|
|
|
|
|
rcu_periph_clock_disable(RCU_I2C0); // 关闭I2C时钟
|
|
|
|
|
rcu_periph_clock_disable(RCU_ADC0); // 关闭ADC时钟
|
|
|
|
|
// 注意不要关闭GPIOB和AF的时钟,因为需要它们来处理唤醒中断
|
|
|
|
|
|
|
|
|
|
// 设置深睡眠模式下的电压以进一步降低功耗
|
|
|
|
|
rcu_deepsleep_voltage_set(RCU_DEEPSLEEP_V_0_8); // 设置最低电压
|
|
|
|
|
|
|
|
|
|
// 配置PB8为输入模式,用于外部中断
|
|
|
|
|
rcu_periph_clock_enable(RCU_GPIOB);
|
|
|
|
|
rcu_periph_clock_enable(RCU_AF);
|
|
|
|
|
gpio_init(GPIOB, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_50MHZ, GPIO_PIN_8);
|
|
|
|
|
|
|
|
|
|
// 配置EXTI中断(连接到PB8引脚)
|
|
|
|
|
gpio_exti_source_select(GPIO_PORT_SOURCE_GPIOB,
|
|
|
|
|
GPIO_PIN_SOURCE_8); // 配置GPIOB的PIN8作为EXTI8的源
|
|
|
|
|
exti_init(EXTI_8, EXTI_INTERRUPT, EXTI_TRIG_RISING); // 边沿触发
|
|
|
|
|
exti_interrupt_enable(EXTI_8);
|
|
|
|
|
nvic_irq_enable(EXTI5_9_IRQn, 0, 0); //
|
|
|
|
|
|
|
|
|
|
// 确保中断标志已被清除
|
|
|
|
|
exti_interrupt_flag_clear(EXTI_8);
|
|
|
|
|
__enable_irq();
|
|
|
|
|
delay_1ms(10);
|
|
|
|
|
// 进入深度睡眠
|
|
|
|
|
pmu_to_deepsleepmode(PMU_LDO_LOWPOWER, WFI_CMD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 写地址
|
|
|
|
|
* @return fmc_state_enum
|
|
|
|
|
*/
|
|
|
|
|
fmc_state_enum write_ADDRESS(u32 address, u32 data) {
|
|
|
|
|
fmc_unlock();
|
|
|
|
|
fmc_flag_clear(FMC_FLAG_PGERR | FMC_FLAG_PGAERR | FMC_FLAG_WPERR);
|
|
|
|
|
|
|
|
|
|
// 确保使用对齐地址
|
|
|
|
|
fmc_state_enum fmc_status = fmc_word_program(address, data);
|
|
|
|
|
|
|
|
|
|
fmc_lock();
|
|
|
|
|
return fmc_status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief EXTI5_9中断处理函数
|
|
|
|
|
* @param 无
|
|
|
|
|
* @retval 无
|
|
|
|
|
*/
|
|
|
|
|
void EXTI5_9_IRQHandler(void) {
|
|
|
|
|
if (exti_interrupt_flag_get(EXTI_8) != RESET) {
|
|
|
|
|
// 清除中断标志
|
|
|
|
|
exti_interrupt_flag_clear(EXTI_8);
|
|
|
|
|
// 禁用EXTI线8的中断,防止重复触发
|
|
|
|
|
exti_interrupt_disable(EXTI_8);
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("MCU wake up\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
OTA_SET(n_APP_LATEST_EN_ADDR, OTA_AVAL); // 设置APP为不激活
|
|
|
|
|
// 遍历睡眠存储区
|
|
|
|
|
for (u32 address = SLEEP_CONFIG_END - SIZE_U32;
|
|
|
|
|
address >= SLEEP_CONFIG_START; address -= SIZE_U32) {
|
|
|
|
|
volatile u32 *flash_ptr = (volatile u32 *)address;
|
|
|
|
|
u32 sleep_check = *flash_ptr;
|
|
|
|
|
if (sleep_check == FLASH_EMPTY and
|
|
|
|
|
address > SLEEP_CONFIG_START) { // 空则跳过该次循环
|
|
|
|
|
continue;
|
|
|
|
|
} else if (
|
|
|
|
|
sleep_check == SLEEP_ENABLE and
|
|
|
|
|
address >
|
|
|
|
|
SLEEP_CONFIG_START) { // 如果检查到睡眠启用,写入非启用
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("boot sleep found %08x at %08x\r\n", sleep_check,
|
|
|
|
|
address);
|
|
|
|
|
#endif
|
|
|
|
|
if (address == SLEEP_CONFIG_END - SIZE_U32) {
|
|
|
|
|
fmc_unlock();
|
|
|
|
|
fmc_state_enum fmc_status =
|
|
|
|
|
fmc_page_erase(SLEEP_CONFIG_START); // 擦除已满的页
|
|
|
|
|
if (fmc_status != FMC_READY) { // 擦除失败报错
|
|
|
|
|
fmc_lock();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
address = SLEEP_CONFIG_START - SIZE_U32; // 重新开始写入
|
|
|
|
|
}
|
|
|
|
|
fmc_state_enum fmc_status =
|
|
|
|
|
write_ADDRESS(address + SIZE_U32, SLEEP_DISABLE);
|
|
|
|
|
if (fmc_status != FMC_READY) { // 写入失败报错
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
break; // 完成,跳出遍历
|
|
|
|
|
} else if (sleep_check == SLEEP_DISABLE) { // 已经是非休眠则跳出遍历
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
fmc_state_enum fmc_status =
|
|
|
|
|
write_ADDRESS(address, SLEEP_DISABLE);
|
|
|
|
|
if (fmc_status != FMC_READY) { // 写入失败报错
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 唤醒后软重启,确保正常初始化
|
|
|
|
|
system_soft_reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int check_sleep() {
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("sleep check\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
for (u32 address = SLEEP_CONFIG_END - SIZE_U32;
|
|
|
|
|
address >= SLEEP_CONFIG_START; address -= SIZE_U32) { // 遍历睡眠存储区
|
|
|
|
|
volatile u32 *flash_ptr = (volatile u32 *)address;
|
|
|
|
|
u32 sleep_check = *flash_ptr;
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("sleep check %8x-----%x\r\n", address, sleep_check);
|
|
|
|
|
#endif
|
|
|
|
|
if (sleep_check == FLASH_EMPTY) { // 空则跳过
|
|
|
|
|
continue;
|
|
|
|
|
} else if (sleep_check == SLEEP_ENABLE) { // 睡眠使能则继续休眠
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("sleep enable\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
enter_deep_sleep();
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (sleep_check == SLEEP_DISABLE) { // 禁用睡眠则跳出
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("sleep disable\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 遍历到头都未找到,写入第一次的数据
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("boot sleep not found\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
fmc_state_enum fmc_status =
|
|
|
|
|
write_ADDRESS(SLEEP_CONFIG_START, SLEEP_DISABLE);
|
|
|
|
|
if (fmc_status != FMC_READY) { // 写入失败报错
|
|
|
|
|
#if SLEEP_DEBUG
|
|
|
|
|
printf("boot sleep write error\r\n");
|
|
|
|
|
#endif
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 2; // 第一次启动
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-03 18:00:28 +08:00
|
|
|
// // 发送单个字节到串口 (用于调试)
|
|
|
|
|
// void uart_send_byte(uint8_t data) {
|
|
|
|
|
// // 实际的串口发送代码
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, data);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // 以十六进制格式打印数据
|
|
|
|
|
// // 安全的十六进制打印函数,不使用sprintf,不使用大缓冲区
|
|
|
|
|
// void safe_print_hex(const char *prefix, const uint8_t *data, size_t length) {
|
|
|
|
|
// // 1. 先打印前缀
|
|
|
|
|
// const char *p = prefix;
|
|
|
|
|
// while (*p) {
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, *p++);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, ':');
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, ' ');
|
|
|
|
|
|
|
|
|
|
// // 2. 逐字节打印数据,每16字节换行
|
|
|
|
|
// for (size_t i = 0; i < length; i++) {
|
|
|
|
|
// uint8_t byte = data[i];
|
|
|
|
|
|
|
|
|
|
// // 打印高4位
|
|
|
|
|
// uint8_t high = (byte >> 4) & 0x0F;
|
|
|
|
|
// char high_char = (high < 10) ? ('0' + high) : ('A' + high - 10);
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, high_char);
|
|
|
|
|
|
|
|
|
|
// // 打印低4位
|
|
|
|
|
// uint8_t low = byte & 0x0F;
|
|
|
|
|
// char low_char = (low < 10) ? ('0' + low) : ('A' + low - 10);
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, low_char);
|
|
|
|
|
|
|
|
|
|
// // 打印空格
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, ' ');
|
|
|
|
|
|
|
|
|
|
// // 每16字节换行
|
|
|
|
|
// if ((i + 1) % 16 == 0 && i < length - 1) {
|
|
|
|
|
// // 换行
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, '\r');
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, '\n');
|
|
|
|
|
|
|
|
|
|
// // 缩进(4个空格)
|
|
|
|
|
// for (int j = 0; j < 4; j++) {
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, ' ');
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // 3. 打印换行
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, '\r');
|
|
|
|
|
// while (RESET == usart_flag_get(USART0, USART_FLAG_TBE))
|
|
|
|
|
// ;
|
|
|
|
|
// usart_data_transmit(USART0, '\n');
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// void test_decrypt() {
|
|
|
|
|
// printf("AES Encryption Verification Starting...\r\n");
|
|
|
|
|
|
|
|
|
|
// // 定义48字节测试数据
|
|
|
|
|
// uint8_t plaintext[48] = {
|
|
|
|
|
// 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
|
|
|
|
// 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
|
|
|
|
// 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
|
|
|
|
|
// 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F};
|
|
|
|
|
|
|
|
|
|
// // 定义128位密钥 (16字节)
|
|
|
|
|
// uint8_t key[16] = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
|
|
|
|
|
// 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c};
|
|
|
|
|
|
|
|
|
|
// // 创建AES上下文
|
|
|
|
|
// aes128_context ctx;
|
|
|
|
|
|
|
|
|
|
// // 设置密钥
|
|
|
|
|
// aes128_set_key(&ctx, key);
|
|
|
|
|
|
|
|
|
|
// // 打印原始数据
|
|
|
|
|
// safe_print_hex("Original Data", plaintext, 48);
|
|
|
|
|
|
|
|
|
|
// uint8_t ciphertext[48];
|
|
|
|
|
// uint8_t decrypted[48];
|
|
|
|
|
|
|
|
|
|
// // 加密
|
|
|
|
|
// aes128_ecb_encrypt_48bytes(&ctx, plaintext, ciphertext);
|
|
|
|
|
// safe_print_hex("Encrypted Data", ciphertext, 48);
|
|
|
|
|
|
|
|
|
|
// // 解密
|
|
|
|
|
// aes128_ecb_decrypt_48bytes(&ctx, ciphertext, decrypted);
|
|
|
|
|
// safe_print_hex("Decrypted Data", decrypted, 48);
|
|
|
|
|
// }
|