57 #define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
63 #if defined(__i386__) || defined(__x86_64__)
64 #define UNALIGNED_MEMOPS_ARE_FAST 1
66 #define UNALIGNED_MEMOPS_ARE_FAST 0
69 #if UNALIGNED_MEMOPS_ARE_FAST
70 #define load_block(d, s) (d) = *(const aes_block_t *)(s)
71 #define store_block(d, s) *(aes_block_t *)(d) = (s)
73 #define load_block(d, s) memcpy((d).data, (s), AES_BLOCK_SIZE)
74 #define store_block(d, s) memcpy((d), (s).data, AES_BLOCK_SIZE)
81 unsigned char *ivec,
const int enc)
113 in += AES_BLOCK_SIZE;
114 out += AES_BLOCK_SIZE;
116 memcpy(ivec, ivp->
data, AES_BLOCK_SIZE);
117 memcpy(ivec + AES_BLOCK_SIZE, iv2p->
data, AES_BLOCK_SIZE);
143 memcpy(ivec, iv.
data, AES_BLOCK_SIZE);
144 memcpy(ivec + AES_BLOCK_SIZE, iv2.
data, AES_BLOCK_SIZE);
169 in += AES_BLOCK_SIZE;
170 out += AES_BLOCK_SIZE;
172 memcpy(ivec, ivp->
data, AES_BLOCK_SIZE);
173 memcpy(ivec + AES_BLOCK_SIZE, iv2p->
data, AES_BLOCK_SIZE);
200 memcpy(ivec, iv.
data, AES_BLOCK_SIZE);
201 memcpy(ivec + AES_BLOCK_SIZE, iv2.
data, AES_BLOCK_SIZE);
215 const AES_KEY *key2,
const unsigned char *ivec,
224 const unsigned char *iv;
225 const unsigned char *iv2;
239 while (len >= AES_BLOCK_SIZE)
242 out[n] = in[n] ^ iv[n];
247 memcpy(prev, in, AES_BLOCK_SIZE);
255 iv = ivec + AES_BLOCK_SIZE*2;
256 iv2 = ivec + AES_BLOCK_SIZE*3;
258 while(len >= AES_BLOCK_SIZE)
262 memcpy(tmp, out, AES_BLOCK_SIZE);
273 memcpy(prev, tmp, AES_BLOCK_SIZE);
281 iv = ivec + AES_BLOCK_SIZE*2;
282 iv2 = ivec + AES_BLOCK_SIZE*3;
285 while (len >= AES_BLOCK_SIZE)
289 memcpy(tmp, in, AES_BLOCK_SIZE);
290 memcpy(tmp2, in, AES_BLOCK_SIZE);
296 memcpy(tmp3, tmp2, AES_BLOCK_SIZE);
306 while (len >= AES_BLOCK_SIZE)
308 memcpy(tmp, out, AES_BLOCK_SIZE);
309 memcpy(tmp2, out, AES_BLOCK_SIZE);
315 memcpy(tmp3, tmp2, AES_BLOCK_SIZE);