cbc128.c (9eac5592) | cbc128.c (d57444e6) |
---|---|
1/* ==================================================================== 2 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 45 unchanged lines hidden (view full) --- 54 55#ifndef MODES_DEBUG 56# ifndef NDEBUG 57# define NDEBUG 58# endif 59#endif 60#include <assert.h> 61 | 1/* ==================================================================== 2 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 45 unchanged lines hidden (view full) --- 54 55#ifndef MODES_DEBUG 56# ifndef NDEBUG 57# define NDEBUG 58# endif 59#endif 60#include <assert.h> 61 |
62#ifndef STRICT_ALIGNMENT 63# define STRICT_ALIGNMENT 0 | 62#undef STRICT_ALIGNMENT 63#ifdef __STRICT_ALIGNMENT 64#define STRICT_ALIGNMENT 1 65#else 66#define STRICT_ALIGNMENT 0 |
64#endif 65 66void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, 67 size_t len, const void *key, 68 unsigned char ivec[16], block128_f block) 69{ 70 size_t n; 71 const unsigned char *iv = ivec; --- 59 unchanged lines hidden (view full) --- 131 (*block)(in, out, key); 132 for(n=0; n<16; ++n) 133 out[n] ^= iv[n]; 134 iv = in; 135 len -= 16; 136 in += 16; 137 out += 16; 138 } | 67#endif 68 69void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, 70 size_t len, const void *key, 71 unsigned char ivec[16], block128_f block) 72{ 73 size_t n; 74 const unsigned char *iv = ivec; --- 59 unchanged lines hidden (view full) --- 134 (*block)(in, out, key); 135 for(n=0; n<16; ++n) 136 out[n] ^= iv[n]; 137 iv = in; 138 len -= 16; 139 in += 16; 140 out += 16; 141 } |
139 } 140 else if (16%sizeof(size_t) == 0) { /* always true */ | 142 } else if (16%sizeof(size_t) == 0) { /* always true */ |
141 while (len>=16) { 142 size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv; 143 144 (*block)(in, out, key); 145 for(n=0; n<16/sizeof(size_t); n++) 146 out_t[n] ^= iv_t[n]; 147 iv = in; 148 len -= 16; --- 12 unchanged lines hidden (view full) --- 161 c = in[n]; 162 out[n] = tmp.c[n] ^ ivec[n]; 163 ivec[n] = c; 164 } 165 len -= 16; 166 in += 16; 167 out += 16; 168 } | 143 while (len>=16) { 144 size_t *out_t=(size_t *)out, *iv_t=(size_t *)iv; 145 146 (*block)(in, out, key); 147 for(n=0; n<16/sizeof(size_t); n++) 148 out_t[n] ^= iv_t[n]; 149 iv = in; 150 len -= 16; --- 12 unchanged lines hidden (view full) --- 163 c = in[n]; 164 out[n] = tmp.c[n] ^ ivec[n]; 165 ivec[n] = c; 166 } 167 len -= 16; 168 in += 16; 169 out += 16; 170 } |
169 } 170 else if (16%sizeof(size_t) == 0) { /* always true */ | 171 } else if (16%sizeof(size_t) == 0) { /* always true */ |
171 while (len>=16) { 172 size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec; 173 const size_t *in_t=(const size_t *)in; 174 175 (*block)(in, tmp.c, key); 176 for(n=0; n<16/sizeof(size_t); n++) { 177 c = in_t[n]; 178 out_t[n] = tmp.t[n] ^ ivec_t[n]; --- 27 unchanged lines hidden --- | 172 while (len>=16) { 173 size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec; 174 const size_t *in_t=(const size_t *)in; 175 176 (*block)(in, tmp.c, key); 177 for(n=0; n<16/sizeof(size_t); n++) { 178 c = in_t[n]; 179 out_t[n] = tmp.t[n] ^ ivec_t[n]; --- 27 unchanged lines hidden --- |