我需要一个小的,像两个分段的,版本的AES加密。我搜索并找到了 (源代码),但是这些代码似乎是为Windows编写的,我需要一个多平台的。
对于Linux上似乎未知的已使用函数,还有其他已知的AES加密版本或修复吗?
我的编译器说,这些是未知的函数:
./aes/AES.cpp:198:17: error: ‘_rotl’ was not declared in this scope
./aes/AES.cpp:608:20: error: ‘_rotr’ was not declared in this scope我还得到了:
./aes/AES.cpp:764:34: error: ‘memset’ was not declared in this scope
./aes/AES.cpp:770:36: error: ‘memcpy’ was not declared in this scope如所知,考虑到这些因素包括:
#include "AES.hpp"
#include <assert.h>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>发布于 2011-09-29 17:08:08
AES的参考实现可以在这里找到:http://www.efgh.com/software/rijndael.htm。主源文件只包含<stdio.h>,但它甚至不依赖于此;在任何平台上使用它都应该没有问题。
发布于 2011-09-29 16:45:12
使用一个经过良好测试的密码库,比如密码库或OpenSSL,而不是在搜索结果的第40页上找到一些随机片段。根据您正在做的事情,您可能还应该使用更高级别的构造,而不是直接使用AES。
发布于 2013-07-03 07:32:13
由于这在google搜索中出现了很高的错误,所以我的程序拒绝在缺少ia32in.h的x64 CentOS系统上编译。
#if !defined(_rotr) && (defined(__i386__) || defined(__x86_64__))
static inline unsigned int _rotr(unsigned int n, const int count) {
asm volatile (
"rorl %1, %0;"
: "=r" (n)
: "nI" (count), "0" (n)
);
return n;
}
#endif正如avakar所提到的那样,您需要包含cstring,或者是cstring.h,才能获得memset和memcpy。
_rotl的代码将是相同的,但操作码助记符除外,这将是roll。
https://stackoverflow.com/questions/7600557
复制相似问题