提交 6a1823b3 编写于 作者: A Andy Polyakov

[co]fb128.c: fix "n=0" bug.

上级 45106caa
...@@ -96,15 +96,15 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, ...@@ -96,15 +96,15 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
#endif #endif
while (len>=16) { while (len>=16) {
(*block)(ivec, ivec, key); (*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*)(out+n) =
*(size_t*)(ivec+n) ^= *(size_t*)(in+n); *(size_t*)(ivec+n) ^= *(size_t*)(in+n);
} }
len -= 16; len -= 16;
out += 16; out += 16;
in += 16; in += 16;
n = 0;
} }
n = 0;
if (len) { if (len) {
(*block)(ivec, ivec, key); (*block)(ivec, ivec, key);
while (len--) { while (len--) {
...@@ -141,7 +141,7 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, ...@@ -141,7 +141,7 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
#endif #endif
while (len>=16) { while (len>=16) {
(*block)(ivec, ivec, key); (*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 t = *(size_t*)(in+n);
*(size_t*)(out+n) = *(size_t*)(ivec+n) ^ t; *(size_t*)(out+n) = *(size_t*)(ivec+n) ^ t;
*(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, ...@@ -149,8 +149,8 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
len -= 16; len -= 16;
out += 16; out += 16;
in += 16; in += 16;
n = 0;
} }
n = 0;
if (len) { if (len) {
(*block)(ivec, ivec, key); (*block)(ivec, ivec, key);
while (len--) { while (len--) {
......
...@@ -95,14 +95,14 @@ void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, ...@@ -95,14 +95,14 @@ void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
#endif #endif
while (len>=16) { while (len>=16) {
(*block)(ivec, ivec, key); (*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*)(out+n) =
*(size_t*)(in+n) ^ *(size_t*)(ivec+n); *(size_t*)(in+n) ^ *(size_t*)(ivec+n);
len -= 16; len -= 16;
out += 16; out += 16;
in += 16; in += 16;
n = 0;
} }
n = 0;
if (len) { if (len) {
(*block)(ivec, ivec, key); (*block)(ivec, ivec, key);
while (len--) { while (len--) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册