-#if !defined(OPENSSL_SMALL_FOOTPRINT)
- if (AES_BLOCK_SIZE%sizeof(size_t) == 0) { /* always true actually */
- if (enc) {
- if (n) {
- while (length) {
- *(out++) = ivec[n] ^= *(in++);
- length--;
- if(!(n = (n + 1) % AES_BLOCK_SIZE))
- break;
- }
- }
-#if defined(STRICT_ALIGNMENT)
- if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
- goto enc_unaligned;
-#endif
- while ((l + AES_BLOCK_SIZE) <= length) {
- unsigned int i;
- AES_encrypt(ivec, ivec, key);
- for (i=0;i<AES_BLOCK_SIZE;i+=sizeof(size_t)) {
- *(size_t*)(out+l+i) =
- *(size_t*)(ivec+i) ^= *(size_t*)(in+l+i);
- }
- l += AES_BLOCK_SIZE;
- }
-
- if (l < length) {
- AES_encrypt(ivec, ivec, key);
- do { out[l] = ivec[n] ^= in[l];
- l++; n++;
- } while (l < length);
- }
- } else {
- if (n) {
- while (length) {
- unsigned char c;
- *(out++) = ivec[n] ^ (c = *(in++)); ivec[n] = c;
- length--;
- if(!(n = (n + 1) % AES_BLOCK_SIZE))
- break;
- }
- }
-#if defined(STRICT_ALIGNMENT)
- if (((size_t)in|(size_t)out|(size_t)ivec)%sizeof(size_t) != 0)
- goto dec_unaligned;
-#endif
- while (l + AES_BLOCK_SIZE <= length) {
- unsigned int i;
- AES_encrypt(ivec, ivec, key);
- for (i=0;i<AES_BLOCK_SIZE;i+=sizeof(size_t)) {
- size_t t = *(size_t*)(in+l+i);
- *(size_t*)(out+l+i) = *(size_t*)(ivec+i) ^ t;
- *(size_t*)(ivec+i) = t;
- }
- l += AES_BLOCK_SIZE;
- }
-
- if (l < length) {
- AES_encrypt(ivec, ivec, key);
- do { unsigned char c;
- out[l] = ivec[n] ^ (c = in[l]); ivec[n] = c;
- l++; n++;
- } while (l < length);
- }
- }
- *num = n;
- return;
- }
-#endif
-
- /* this code would be commonly eliminated by x86* compiler */
- if (enc) {
-#if defined(STRICT_ALIGNMENT) && !defined(OPENSSL_SMALL_FOOTPRINT)
- enc_unaligned:
-#endif
- while (l<length) {
- if (n == 0) {
- AES_encrypt(ivec, ivec, key);
- }
- out[l] = ivec[n] ^= in[l];
- l++;
- n = (n+1) % AES_BLOCK_SIZE;
- }
- } else {
-#if defined(STRICT_ALIGNMENT) && !defined(OPENSSL_SMALL_FOOTPRINT)
- dec_unaligned:
-#endif
- while (l<length) {
- unsigned char c;
- if (n == 0) {
- AES_encrypt(ivec, ivec, key);
- }
- out[l] = ivec[n] ^ (c = in[l]); ivec[n] = c;
- l++;
- n = (n+1) % AES_BLOCK_SIZE;
- }
- }
-
- *num=n;