Remove all .cvsignore files
[openssl.git] / crypto / modes / cfb128.c
index 0512c3f986c1c634d03cbe96d9633117b0a4149a..4e6f5d35e13ba2925f9556983f618a9d0e57a620 100644 (file)
@@ -48,7 +48,8 @@
  *
  */
 
-#include <stddef.h>
+#include <openssl/crypto.h>
+#include "modes_lcl.h"
 #include <string.h>
 
 #ifndef MODES_DEBUG
 #endif
 #include <assert.h>
 
-#include "modes.h"
-
-#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__)
-#  undef STRICT_ALIGNMENT
-#endif
-
 /* The input and output encrypted as though 128bit cfb mode is being
  * used.  The extra state information to record how much of the
  * 128bit block we have used is contained in *num;
@@ -75,7 +66,7 @@
 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
                        size_t len, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     unsigned int n;
     size_t l = 0;
@@ -98,15 +89,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--) {
@@ -143,7 +134,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;
@@ -151,8 +142,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--) {
@@ -184,7 +175,7 @@ void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
 static void cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
                            int nbits,const void *key,
                            unsigned char ivec[16],int enc,
-                           block_f block)
+                           block128_f block)
 {
     int n,rem,num;
     unsigned char ovec[16*2 + 1];  /* +1 because we dererefence (but don't use) one byte off the end */
@@ -218,7 +209,7 @@ static void cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
                        size_t bits, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     size_t n;
     unsigned char c[1],d[1];
@@ -226,19 +217,19 @@ void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
     assert(in && out && key && ivec && num);
     assert(*num == 0);
 
-    memset(out,0,(bits+7)/8);
     for(n=0 ; n<bits ; ++n)
        {
        c[0]=(in[n/8]&(1 << (7-n%8))) ? 0x80 : 0;
        cfbr_encrypt_block(c,d,1,key,ivec,enc,block);
-       out[n/8]=(out[n/8]&~(1 << (7-n%8)))|((d[0]&0x80) >> (n%8));
+       out[n/8]=(out[n/8]&~(1 << (unsigned int)(7-n%8))) |
+                ((d[0]&0x80) >> (unsigned int)(n%8));
        }
 }
 
 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
                        size_t length, const void *key,
                        unsigned char ivec[16], int *num,
-                       int enc, block_f block)
+                       int enc, block128_f block)
 {
     size_t n;