/** * @file aes128.h * @brief AES-128 ECB 加解密(纯软件实现,移植自电机 BOOT 工程)。 * 用于电机 OTA relay 中对固件数据加密及密钥协商。 */ #ifndef SYS_AES128_H #define SYS_AES128_H #include #include #include 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 */