我试图将NSA SPECK的实现安装在8位PIC微控制器中。他们的编译器的免费版本(基于CLANG)将无法进行优化,因此我的内存不足。我尝试了启用-O2,-O3和-Os(针对大小进行优化)的“试用版”。使用-Os可以使我的代码适合2K程序存储空间。
这是代码:
#include <stdint.h>
#include <string.h>
#define ROR(x, r) ((x >> r) | (x << (32 - r)))
#define ROL(x, r) ((x << r) | (x >> (32 - r)))
#define R(x, y, k) (x = ROR(x, 8), x += y, x ^= k, y = ROL(y, 3), y ^= x)
#define ROUNDS 27
void encrypt_block(uint32_t ct[2],
uint32_t const pt[2],
uint32_t const K[4]) {
uint32_t x = pt[0], y = pt[1];
uint32_t a = K[0], b = K[1], …
Run Code Online (Sandbox Code Playgroud)