aboutsummaryrefslogtreecommitdiff
path: root/openssl/crypto/modes
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-06-17 08:30:55 +0000
committermarha <marha@users.sourceforge.net>2010-06-17 08:30:55 +0000
commiteb8e32daea99b6e3ebf134efeeba184c23817f08 (patch)
treeffbda57952ba3f40612e6409bd9a95f9a0a892dc /openssl/crypto/modes
parented16af1abc515d7cc3ff9c5794aef89551fe7494 (diff)
parentfef0b61e18b9c7475e4d6e67ddfc55db46573f4e (diff)
downloadvcxsrv-eb8e32daea99b6e3ebf134efeeba184c23817f08.tar.gz
vcxsrv-eb8e32daea99b6e3ebf134efeeba184c23817f08.tar.bz2
vcxsrv-eb8e32daea99b6e3ebf134efeeba184c23817f08.zip
svn merge ^/branches/released .
Diffstat (limited to 'openssl/crypto/modes')
-rw-r--r--openssl/crypto/modes/cfb128.c8
-rw-r--r--openssl/crypto/modes/ctr128.c28
-rw-r--r--openssl/crypto/modes/ofb128.c4
3 files changed, 19 insertions, 21 deletions
diff --git a/openssl/crypto/modes/cfb128.c b/openssl/crypto/modes/cfb128.c
index 98f4cf315..e5938c613 100644
--- a/openssl/crypto/modes/cfb128.c
+++ b/openssl/crypto/modes/cfb128.c
@@ -96,15 +96,15 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
#endif
while (len>=16) {
(*block)(ivec, ivec, key);
- for (n=0; n<16; n+=sizeof(size_t)) {
+ for (; n<16; n+=sizeof(size_t)) {
*(size_t*)(out+n) =
*(size_t*)(ivec+n) ^= *(size_t*)(in+n);
}
len -= 16;
out += 16;
in += 16;
+ n = 0;
}
- n = 0;
if (len) {
(*block)(ivec, ivec, key);
while (len--) {
@@ -141,7 +141,7 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
#endif
while (len>=16) {
(*block)(ivec, ivec, key);
- for (n=0; n<16; n+=sizeof(size_t)) {
+ for (; n<16; n+=sizeof(size_t)) {
size_t t = *(size_t*)(in+n);
*(size_t*)(out+n) = *(size_t*)(ivec+n) ^ t;
*(size_t*)(ivec+n) = t;
@@ -149,8 +149,8 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
len -= 16;
out += 16;
in += 16;
+ n = 0;
}
- n = 0;
if (len) {
(*block)(ivec, ivec, key);
while (len--) {
diff --git a/openssl/crypto/modes/ctr128.c b/openssl/crypto/modes/ctr128.c
index bd84f4152..932037f55 100644
--- a/openssl/crypto/modes/ctr128.c
+++ b/openssl/crypto/modes/ctr128.c
@@ -61,14 +61,11 @@
typedef unsigned int u32;
typedef unsigned char u8;
-# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3]))
-# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); }
-
#define STRICT_ALIGNMENT
-#if defined(__i386) || defined(__i386__) || \
- defined(__x86_64) || defined(__x86_64__) || \
- defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(__s390__) || defined(__s390x__)
+#if defined(__i386) || defined(__i386__) || \
+ defined(__x86_64) || defined(__x86_64__) || \
+ defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
+ defined(__s390__) || defined(__s390x__)
# undef STRICT_ALIGNMENT
#endif
@@ -77,18 +74,19 @@ typedef unsigned char u8;
/* increment counter (128-bit int) by 1 */
static void ctr128_inc(unsigned char *counter) {
- u32 c,n=16;
+ u32 n=16;
+ u8 c;
do {
- n -= 4;
- c = GETU32(counter+n);
- ++c; c &= 0xFFFFFFFF;
- PUTU32(counter + n, c);
+ --n;
+ c = counter[n];
+ ++c;
+ counter[n] = c;
if (c) return;
} while (n);
}
-#if !defined(OPENSSL_SMALL_FOORPRINT)
+#if !defined(OPENSSL_SMALL_FOOTPRINT)
static void ctr128_inc_aligned(unsigned char *counter) {
size_t *data,c,n;
const union { long one; char little; } is_endian = {1};
@@ -151,14 +149,14 @@ void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
while (len>=16) {
(*block)(ivec, ecount_buf, key);
ctr128_inc_aligned(ivec);
- for (n=0; n<16; n+=sizeof(size_t))
+ for (; n<16; n+=sizeof(size_t))
*(size_t *)(out+n) =
*(size_t *)(in+n) ^ *(size_t *)(ecount_buf+n);
len -= 16;
out += 16;
in += 16;
+ n = 0;
}
- n = 0;
if (len) {
(*block)(ivec, ecount_buf, key);
ctr128_inc_aligned(ivec);
diff --git a/openssl/crypto/modes/ofb128.c b/openssl/crypto/modes/ofb128.c
index 09b343003..c732e2ec5 100644
--- a/openssl/crypto/modes/ofb128.c
+++ b/openssl/crypto/modes/ofb128.c
@@ -95,14 +95,14 @@ void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
#endif
while (len>=16) {
(*block)(ivec, ivec, key);
- for (n=0; n<16; n+=sizeof(size_t))
+ for (; n<16; n+=sizeof(size_t))
*(size_t*)(out+n) =
*(size_t*)(in+n) ^ *(size_t*)(ivec+n);
len -= 16;
out += 16;
in += 16;
+ n = 0;
}
- n = 0;
if (len) {
(*block)(ivec, ivec, key);
while (len--) {