Explorar el Código

fix indentation

Francois Perrad hace 9 años
padre
commit
7b48f4d5f7
Se han modificado 37 ficheros con 334 adiciones y 333 borrados
  1. 11 11
      src/ciphers/aes/aes.c
  2. 5 5
      src/ciphers/anubis.c
  3. 2 2
      src/ciphers/camellia.c
  4. 6 6
      src/ciphers/des.c
  5. 26 26
      src/ciphers/kseed.c
  6. 5 5
      src/ciphers/noekeon.c
  7. 21 21
      src/ciphers/rc2.c
  8. 12 11
      src/ciphers/safer/safer.c
  9. 13 13
      src/ciphers/twofish/twofish.c
  10. 2 2
      src/encauth/ccm/ccm_memory.c
  11. 3 3
      src/encauth/ccm/ccm_test.c
  12. 2 2
      src/encauth/eax/eax_test.c
  13. 2 2
      src/encauth/gcm/gcm_add_aad.c
  14. 1 1
      src/encauth/gcm/gcm_add_iv.c
  15. 2 2
      src/encauth/gcm/gcm_init.c
  16. 1 1
      src/encauth/gcm/gcm_process.c
  17. 20 20
      src/encauth/ocb/ocb_init.c
  18. 28 28
      src/encauth/ocb3/ocb3_init.c
  19. 10 10
      src/hashes/sha2/sha512.c
  20. 7 7
      src/mac/f9/f9_process.c
  21. 23 23
      src/mac/pmac/pmac_init.c
  22. 2 2
      src/mac/pmac/pmac_test.c
  23. 7 7
      src/mac/xcbc/xcbc_process.c
  24. 9 9
      src/modes/cbc/cbc_decrypt.c
  25. 15 15
      src/modes/cbc/cbc_encrypt.c
  26. 6 6
      src/modes/lrw/lrw_start.c
  27. 2 2
      src/modes/lrw/lrw_test.c
  28. 2 2
      src/pk/asn1/der/bit/der_decode_bit_string.c
  29. 2 2
      src/pk/asn1/der/bit/der_decode_raw_bit_string.c
  30. 22 22
      src/pk/asn1/der/object_identifier/der_decode_object_identifier.c
  31. 26 26
      src/pk/asn1/der/object_identifier/der_encode_object_identifier.c
  32. 8 8
      src/pk/asn1/der/sequence/der_decode_sequence_ex.c
  33. 8 8
      src/pk/asn1/der/set/der_encode_setof.c
  34. 3 3
      src/pk/dsa/dsa_import.c
  35. 7 7
      src/pk/ecc/ltc_ecc_mul2add.c
  36. 3 3
      src/pk/ecc/ltc_ecc_mulmod_timing.c
  37. 10 10
      src/prngs/sober128.c

+ 11 - 11
src/ciphers/aes/aes.c

@@ -675,11 +675,11 @@ int ECB_TEST(void)
     }
     }
  };
  };
 
 
- symmetric_key key;
- unsigned char tmp[2][16];
- int i, y;
+  symmetric_key key;
+  unsigned char tmp[2][16];
+  int i, y;
 
 
- for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
+  for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
     zeromem(&key, sizeof(key));
     zeromem(&key, sizeof(key));
     if ((err = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
     if ((err = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
        return err;
        return err;
@@ -707,13 +707,13 @@ int ECB_TEST(void)
         return CRYPT_FAIL_TESTVECTOR;
         return CRYPT_FAIL_TESTVECTOR;
     }
     }
 
 
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 16; y++) tmp[0][y] = 0;
-      for (y = 0; y < 1000; y++) rijndael_ecb_encrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 1000; y++) rijndael_ecb_decrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
- }
- return CRYPT_OK;
+    /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+    for (y = 0; y < 16; y++) tmp[0][y] = 0;
+    for (y = 0; y < 1000; y++) rijndael_ecb_encrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 1000; y++) rijndael_ecb_decrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
+  }
+  return CRYPT_OK;
  #endif
  #endif
 }
 }
 
 

+ 5 - 5
src/ciphers/anubis.c

@@ -926,16 +926,16 @@ int  anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetri
       return CRYPT_INVALID_ROUNDS;
       return CRYPT_INVALID_ROUNDS;
    }
    }
 
 
-    /*
-    * map cipher key to initial key state (mu):
-    */
-    for (i = 0, pos = 0; i < N; i++, pos += 4) {
+   /*
+   * map cipher key to initial key state (mu):
+   */
+   for (i = 0, pos = 0; i < N; i++, pos += 4) {
       kappa[i] =
       kappa[i] =
          (((ulong32)key[pos    ]) << 24) ^
          (((ulong32)key[pos    ]) << 24) ^
          (((ulong32)key[pos + 1]) << 16) ^
          (((ulong32)key[pos + 1]) << 16) ^
          (((ulong32)key[pos + 2]) <<  8) ^
          (((ulong32)key[pos + 2]) <<  8) ^
          (((ulong32)key[pos + 3])      );
          (((ulong32)key[pos + 3])      );
-    }
+   }
 
 
    /*
    /*
     * generate R + 1 round keys:
     * generate R + 1 round keys:

+ 2 - 2
src/ciphers/camellia.c

@@ -686,8 +686,8 @@ int camellia_test(void)
    unsigned int x;
    unsigned int x;
 
 
    for (x = 0; x < sizeof(tests)/sizeof(tests[0]); x++) {
    for (x = 0; x < sizeof(tests)/sizeof(tests[0]); x++) {
-     zeromem(&skey, sizeof(skey));
-     if ((err = camellia_setup(tests[x].key, tests[x].keylen, 0, &skey)) != CRYPT_OK) {
+      zeromem(&skey, sizeof(skey));
+      if ((err = camellia_setup(tests[x].key, tests[x].keylen, 0, &skey)) != CRYPT_OK) {
          return err;
          return err;
       }
       }
       if ((err = camellia_ecb_encrypt(tests[x].pt, buf[0], &skey)) != CRYPT_OK) {
       if ((err = camellia_ecb_encrypt(tests[x].pt, buf[0], &skey)) != CRYPT_OK) {

+ 6 - 6
src/ciphers/des.c

@@ -1983,12 +1983,12 @@ int des_test(void)
            return CRYPT_FAIL_TESTVECTOR;
            return CRYPT_FAIL_TESTVECTOR;
         }
         }
 
 
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 8; y++) tmp[y] = 0;
-      for (y = 0; y < 1000; y++) des_ecb_encrypt(tmp, tmp, &des);
-      for (y = 0; y < 1000; y++) des_ecb_decrypt(tmp, tmp, &des);
-      for (y = 0; y < 8; y++) if (tmp[y] != 0) return CRYPT_FAIL_TESTVECTOR;
-}
+        /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+        for (y = 0; y < 8; y++) tmp[y] = 0;
+        for (y = 0; y < 1000; y++) des_ecb_encrypt(tmp, tmp, &des);
+        for (y = 0; y < 1000; y++) des_ecb_decrypt(tmp, tmp, &des);
+        for (y = 0; y < 8; y++) if (tmp[y] != 0) return CRYPT_FAIL_TESTVECTOR;
+    }
 
 
     return CRYPT_OK;
     return CRYPT_OK;
   #endif
   #endif

+ 26 - 26
src/ciphers/kseed.c

@@ -201,41 +201,41 @@ static const ulong32 KCi[16] = {
  */
  */
 int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
 int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
 {
 {
-    int     i;
-    ulong32 tmp, k1, k2, k3, k4;
+   int     i;
+   ulong32 tmp, k1, k2, k3, k4;
 
 
-    if (keylen != 16) {
-       return CRYPT_INVALID_KEYSIZE;
-    }
+   if (keylen != 16) {
+      return CRYPT_INVALID_KEYSIZE;
+   }
 
 
-    if (num_rounds != 16 && num_rounds != 0) {
-       return CRYPT_INVALID_ROUNDS;
-    }
+   if (num_rounds != 16 && num_rounds != 0) {
+      return CRYPT_INVALID_ROUNDS;
+   }
 
 
-    /* load key */
-    LOAD32H(k1, key);
-    LOAD32H(k2, key+4);
-    LOAD32H(k3, key+8);
-    LOAD32H(k4, key+12);
+   /* load key */
+   LOAD32H(k1, key);
+   LOAD32H(k2, key+4);
+   LOAD32H(k3, key+8);
+   LOAD32H(k4, key+12);
 
 
-    for (i = 0; i < 16; i++) {
-       skey->kseed.K[2*i+0] = G(k1 + k3 - KCi[i]);
-       skey->kseed.K[2*i+1] = G(k2 - k4 + KCi[i]);
-       if (i&1) {
-          tmp = k3;
-          k3 = ((k3 << 8) | (k4 >> 24)) & 0xFFFFFFFF;
-          k4 = ((k4 << 8) | (tmp >> 24)) & 0xFFFFFFFF;
-       } else {
-          tmp = k1;
-          k1 = ((k1 >> 8) | (k2 << 24)) & 0xFFFFFFFF;
-          k2 = ((k2 >> 8) | (tmp << 24)) & 0xFFFFFFFF;
+   for (i = 0; i < 16; i++) {
+      skey->kseed.K[2*i+0] = G(k1 + k3 - KCi[i]);
+      skey->kseed.K[2*i+1] = G(k2 - k4 + KCi[i]);
+      if (i&1) {
+         tmp = k3;
+         k3 = ((k3 << 8) | (k4 >> 24)) & 0xFFFFFFFF;
+         k4 = ((k4 << 8) | (tmp >> 24)) & 0xFFFFFFFF;
+      } else {
+         tmp = k1;
+         k1 = ((k1 >> 8) | (k2 << 24)) & 0xFFFFFFFF;
+         k2 = ((k2 >> 8) | (tmp << 24)) & 0xFFFFFFFF;
       }
       }
       /* reverse keys for decrypt */
       /* reverse keys for decrypt */
       skey->kseed.dK[2*(15-i)+0] = skey->kseed.K[2*i+0];
       skey->kseed.dK[2*(15-i)+0] = skey->kseed.K[2*i+0];
       skey->kseed.dK[2*(15-i)+1] = skey->kseed.K[2*i+1];
       skey->kseed.dK[2*(15-i)+1] = skey->kseed.K[2*i+1];
-    }
+   }
 
 
-    return CRYPT_OK;
+   return CRYPT_OK;
 }
 }
 
 
 static void rounds(ulong32 *P, ulong32 *K)
 static void rounds(ulong32 *P, ulong32 *K)

+ 5 - 5
src/ciphers/noekeon.c

@@ -303,11 +303,11 @@ int noekeon_test(void)
         return CRYPT_FAIL_TESTVECTOR;
         return CRYPT_FAIL_TESTVECTOR;
     }
     }
 
 
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 16; y++) tmp[0][y] = 0;
-      for (y = 0; y < 1000; y++) noekeon_ecb_encrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 1000; y++) noekeon_ecb_decrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
+    /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+    for (y = 0; y < 16; y++) tmp[0][y] = 0;
+    for (y = 0; y < 1000; y++) noekeon_ecb_encrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 1000; y++) noekeon_ecb_decrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
  }
  }
  return CRYPT_OK;
  return CRYPT_OK;
  #endif
  #endif

+ 21 - 21
src/ciphers/rc2.c

@@ -86,35 +86,35 @@ int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_ke
    }
    }
 
 
    for (i = 0; i < keylen; i++) {
    for (i = 0; i < keylen; i++) {
-       tmp[i] = key[i] & 255;
+      tmp[i] = key[i] & 255;
    }
    }
 
 
-    /* Phase 1: Expand input key to 128 bytes */
-    if (keylen < 128) {
-        for (i = keylen; i < 128; i++) {
-            tmp[i] = permute[(tmp[i - 1] + tmp[i - keylen]) & 255];
-        }
-    }
+   /* Phase 1: Expand input key to 128 bytes */
+   if (keylen < 128) {
+      for (i = keylen; i < 128; i++) {
+         tmp[i] = permute[(tmp[i - 1] + tmp[i - keylen]) & 255];
+      }
+   }
 
 
-    /* Phase 2 - reduce effective key size to "bits" */
-    bits = keylen<<3;
-    T8   = (unsigned)(bits+7)>>3;
-    TM   = (255 >> (unsigned)(7 & -bits));
-    tmp[128 - T8] = permute[tmp[128 - T8] & TM];
-    for (i = 127 - T8; i >= 0; i--) {
-        tmp[i] = permute[tmp[i + 1] ^ tmp[i + T8]];
-    }
+   /* Phase 2 - reduce effective key size to "bits" */
+   bits = keylen<<3;
+   T8   = (unsigned)(bits+7)>>3;
+   TM   = (255 >> (unsigned)(7 & -bits));
+   tmp[128 - T8] = permute[tmp[128 - T8] & TM];
+   for (i = 127 - T8; i >= 0; i--) {
+      tmp[i] = permute[tmp[i + 1] ^ tmp[i + T8]];
+   }
 
 
-    /* Phase 3 - copy to xkey in little-endian order */
-    for (i = 0; i < 64; i++) {
-        xkey[i] =  (unsigned)tmp[2*i] + ((unsigned)tmp[2*i+1] << 8);
-    }
+   /* Phase 3 - copy to xkey in little-endian order */
+   for (i = 0; i < 64; i++) {
+      xkey[i] =  (unsigned)tmp[2*i] + ((unsigned)tmp[2*i+1] << 8);
+   }
 
 
 #ifdef LTC_CLEAN_STACK
 #ifdef LTC_CLEAN_STACK
-    zeromem(tmp, sizeof(tmp));
+   zeromem(tmp, sizeof(tmp));
 #endif
 #endif
 
 
-    return CRYPT_OK;
+   return CRYPT_OK;
 }
 }
 
 
 /**********************************************************************\
 /**********************************************************************\

+ 12 - 11
src/ciphers/safer/safer.c

@@ -432,11 +432,11 @@ int safer_sk64_test(void)
       return CRYPT_FAIL_TESTVECTOR;
       return CRYPT_FAIL_TESTVECTOR;
    }
    }
 
 
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 8; y++) buf[0][y] = 0;
-      for (y = 0; y < 1000; y++) safer_ecb_encrypt(buf[0], buf[0], &skey);
-      for (y = 0; y < 1000; y++) safer_ecb_decrypt(buf[0], buf[0], &skey);
-      for (y = 0; y < 8; y++) if (buf[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
+   /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+   for (y = 0; y < 8; y++) buf[0][y] = 0;
+   for (y = 0; y < 1000; y++) safer_ecb_encrypt(buf[0], buf[0], &skey);
+   for (y = 0; y < 1000; y++) safer_ecb_decrypt(buf[0], buf[0], &skey);
+   for (y = 0; y < 8; y++) if (buf[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
 
 
    return CRYPT_OK;
    return CRYPT_OK;
   #endif
   #endif
@@ -475,12 +475,13 @@ int safer_sk128_test(void)
       return CRYPT_FAIL_TESTVECTOR;
       return CRYPT_FAIL_TESTVECTOR;
    }
    }
 
 
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 8; y++) buf[0][y] = 0;
-      for (y = 0; y < 1000; y++) safer_ecb_encrypt(buf[0], buf[0], &skey);
-      for (y = 0; y < 1000; y++) safer_ecb_decrypt(buf[0], buf[0], &skey);
-      for (y = 0; y < 8; y++) if (buf[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
-  return CRYPT_OK;
+   /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+   for (y = 0; y < 8; y++) buf[0][y] = 0;
+   for (y = 0; y < 1000; y++) safer_ecb_encrypt(buf[0], buf[0], &skey);
+   for (y = 0; y < 1000; y++) safer_ecb_decrypt(buf[0], buf[0], &skey);
+   for (y = 0; y < 8; y++) if (buf[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
+
+   return CRYPT_OK;
  #endif
  #endif
 }
 }
 
 

+ 13 - 13
src/ciphers/twofish/twofish.c

@@ -245,7 +245,7 @@ static void h_func(const unsigned char *in, unsigned char *out, unsigned char *M
   unsigned char y[4];
   unsigned char y[4];
   for (x = 0; x < 4; x++) {
   for (x = 0; x < 4; x++) {
       y[x] = in[x];
       y[x] = in[x];
- }
+  }
   switch (k) {
   switch (k) {
      case 4:
      case 4:
             y[0] = (unsigned char)(sbox(1, (ulong32)y[0]) ^ M[4 * (6 + offset) + 0]);
             y[0] = (unsigned char)(sbox(1, (ulong32)y[0]) ^ M[4 * (6 + offset) + 0]);
@@ -504,7 +504,7 @@ int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_ke
         a  = RORc(a ^ (t1 + k[2]), 1);
         a  = RORc(a ^ (t1 + k[2]), 1);
         b  = ROLc(b, 1) ^ (t2 + t1 + k[3]);
         b  = ROLc(b, 1) ^ (t2 + t1 + k[3]);
         k += 4;
         k += 4;
-   }
+    }
 
 
     /* output with "undo last swap" */
     /* output with "undo last swap" */
     ta = c ^ skey->twofish.K[4];
     ta = c ^ skey->twofish.K[4];
@@ -646,11 +646,11 @@ int twofish_test(void)
 };
 };
 
 
 
 
- symmetric_key key;
- unsigned char tmp[2][16];
- int err, i, y;
+  symmetric_key key;
+  unsigned char tmp[2][16];
+  int err, i, y;
 
 
- for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
+  for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
     if ((err = twofish_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
     if ((err = twofish_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
        return err;
        return err;
     }
     }
@@ -662,13 +662,13 @@ int twofish_test(void)
 #endif
 #endif
        return CRYPT_FAIL_TESTVECTOR;
        return CRYPT_FAIL_TESTVECTOR;
     }
     }
-      /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
-      for (y = 0; y < 16; y++) tmp[0][y] = 0;
-      for (y = 0; y < 1000; y++) twofish_ecb_encrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 1000; y++) twofish_ecb_decrypt(tmp[0], tmp[0], &key);
-      for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
- }
- return CRYPT_OK;
+    /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */
+    for (y = 0; y < 16; y++) tmp[0][y] = 0;
+    for (y = 0; y < 1000; y++) twofish_ecb_encrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 1000; y++) twofish_ecb_decrypt(tmp[0], tmp[0], &key);
+    for (y = 0; y < 16; y++) if (tmp[0][y] != 0) return CRYPT_FAIL_TESTVECTOR;
+  }
+  return CRYPT_OK;
 #endif
 #endif
 }
 }
 
 

+ 2 - 2
src/encauth/ccm/ccm_memory.c

@@ -283,8 +283,8 @@ int ccm_memory(int cipher,
                    goto error;
                    goto error;
                 }
                 }
              }
              }
-         }
-     }
+          }
+      }
 #endif
 #endif
 
 
       for (; y < ptlen; y++) {
       for (; y < ptlen; y++) {

+ 3 - 3
src/encauth/ccm/ccm_test.c

@@ -190,9 +190,9 @@ int ccm_test(void)
       }
       }
 
 
       if (y == 0) {
       if (y == 0) {
-          XMEMCPY(tag3, tests[x].tag, tests[x].taglen);
-          taglen = tests[x].taglen;
-          if ((err = ccm_memory(idx,
+         XMEMCPY(tag3, tests[x].tag, tests[x].taglen);
+         taglen = tests[x].taglen;
+         if ((err = ccm_memory(idx,
                                tests[x].key, 16,
                                tests[x].key, 16,
                                NULL,
                                NULL,
                                tests[x].nonce, tests[x].noncelen,
                                tests[x].nonce, tests[x].noncelen,

+ 2 - 2
src/encauth/eax/eax_test.c

@@ -270,8 +270,8 @@ int eax_test(void)
            return CRYPT_FAIL_TESTVECTOR;
            return CRYPT_FAIL_TESTVECTOR;
         }
         }
 
 
-     }
-     return CRYPT_OK;
+    }
+    return CRYPT_OK;
 #endif /* LTC_TEST */
 #endif /* LTC_TEST */
 }
 }
 
 

+ 2 - 2
src/encauth/gcm/gcm_add_aad.c

@@ -104,9 +104,9 @@ int gcm_add_aad(gcm_state *gcm,
 
 
    /* start adding AAD data to the state */
    /* start adding AAD data to the state */
    for (; x < adatalen; x++) {
    for (; x < adatalen; x++) {
-       gcm->X[gcm->buflen++] ^= *adata++;
+      gcm->X[gcm->buflen++] ^= *adata++;
 
 
-       if (gcm->buflen == 16) {
+      if (gcm->buflen == 16) {
          /* GF mult it */
          /* GF mult it */
          gcm_mult_h(gcm, gcm->X);
          gcm_mult_h(gcm, gcm->X);
          gcm->buflen = 0;
          gcm->buflen = 0;

+ 1 - 1
src/encauth/gcm/gcm_add_iv.c

@@ -72,7 +72,7 @@ int gcm_add_iv(gcm_state *gcm,
    for (; x < IVlen; x++) {
    for (; x < IVlen; x++) {
        gcm->buf[gcm->buflen++] = *IV++;
        gcm->buf[gcm->buflen++] = *IV++;
 
 
-       if (gcm->buflen == 16) {
+      if (gcm->buflen == 16) {
          /* GF mult it */
          /* GF mult it */
          for (y = 0; y < 16; y++) {
          for (y = 0; y < 16; y++) {
              gcm->X[y] ^= gcm->buf[y];
              gcm->X[y] ^= gcm->buf[y];

+ 2 - 2
src/encauth/gcm/gcm_init.c

@@ -92,8 +92,8 @@ int gcm_init(gcm_state *gcm, int cipher,
          }
          }
          gcm->PC[x][y][0] = gcm_shift_table[t<<1];
          gcm->PC[x][y][0] = gcm_shift_table[t<<1];
          gcm->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
          gcm->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
-     }
-  }
+      }
+   }
 
 
 #endif
 #endif
 
 

+ 1 - 1
src/encauth/gcm/gcm_process.c

@@ -118,7 +118,7 @@ int gcm_process(gcm_state *gcm,
                 return err;
                 return err;
              }
              }
          }
          }
-     }
+      }
    }
    }
 #endif
 #endif
 
 

+ 20 - 20
src/encauth/ocb/ocb_init.c

@@ -106,32 +106,32 @@ int ocb_init(ocb_state *ocb, int cipher,
               ocb->Ls[x][y] ^= polys[poly].poly_mul[y];
               ocb->Ls[x][y] ^= polys[poly].poly_mul[y];
           }
           }
        }
        }
-    }
+   }
 
 
-    /* find Lr = L / x */
-    m = ocb->L[ocb->block_len-1] & 1;
+   /* find Lr = L / x */
+   m = ocb->L[ocb->block_len-1] & 1;
 
 
-    /* shift right */
-    for (x = ocb->block_len - 1; x > 0; x--) {
-        ocb->Lr[x] = ((ocb->L[x] >> 1) | (ocb->L[x-1] << 7)) & 255;
-    }
-    ocb->Lr[0] = ocb->L[0] >> 1;
+   /* shift right */
+   for (x = ocb->block_len - 1; x > 0; x--) {
+      ocb->Lr[x] = ((ocb->L[x] >> 1) | (ocb->L[x-1] << 7)) & 255;
+   }
+   ocb->Lr[0] = ocb->L[0] >> 1;
 
 
-    if (m == 1) {
-       for (x = 0; x < ocb->block_len; x++) {
-           ocb->Lr[x] ^= polys[poly].poly_div[x];
-       }
-    }
+   if (m == 1) {
+      for (x = 0; x < ocb->block_len; x++) {
+         ocb->Lr[x] ^= polys[poly].poly_div[x];
+      }
+   }
 
 
-    /* set Li, checksum */
-    zeromem(ocb->Li,       ocb->block_len);
-    zeromem(ocb->checksum, ocb->block_len);
+   /* set Li, checksum */
+   zeromem(ocb->Li,       ocb->block_len);
+   zeromem(ocb->checksum, ocb->block_len);
 
 
-    /* set other params */
-    ocb->block_index = 1;
-    ocb->cipher      = cipher;
+   /* set other params */
+   ocb->block_index = 1;
+   ocb->cipher      = cipher;
 
 
-    return CRYPT_OK;
+   return CRYPT_OK;
 }
 }
 
 
 #endif
 #endif

+ 28 - 28
src/encauth/ocb3/ocb3_init.c

@@ -90,45 +90,45 @@ int ocb3_init(ocb3_state *ocb, int cipher,
 
 
    /* compute L_$, L_0, L_1, ... */
    /* compute L_$, L_0, L_1, ... */
    for (x = -1; x < 32; x++) {
    for (x = -1; x < 32; x++) {
-       if (x == -1) {                /* gonna compute: L_$ = double(L_*) */
+      if (x == -1) {                /* gonna compute: L_$ = double(L_*) */
          current  = ocb->L_dollar;
          current  = ocb->L_dollar;
          previous = ocb->L_star;
          previous = ocb->L_star;
-       }
-       else if (x == 0) {            /* gonna compute: L_0 = double(L_$) */
+      }
+      else if (x == 0) {            /* gonna compute: L_0 = double(L_$) */
          current  = ocb->L_[0];
          current  = ocb->L_[0];
          previous = ocb->L_dollar;
          previous = ocb->L_dollar;
-       }
-       else {                        /* gonna compute: L_i = double(L_{i-1}) for every integer i > 0 */
+      }
+      else {                        /* gonna compute: L_i = double(L_{i-1}) for every integer i > 0 */
          current  = ocb->L_[x];
          current  = ocb->L_[x];
          previous = ocb->L_[x-1];
          previous = ocb->L_[x-1];
-       }
-       m = previous[0] >> 7;
-       for (y = 0; y < ocb->block_len-1; y++) {
-           current[y] = ((previous[y] << 1) | (previous[y+1] >> 7)) & 255;
-       }
-       current[ocb->block_len-1] = (previous[ocb->block_len-1] << 1) & 255;
-       if (m == 1) {
-          /* current[] = current[] XOR polys[poly].poly_mul[]*/
-          ocb3_int_xor_blocks(current, current, polys[poly].poly_mul, ocb->block_len);
-       }
-    }
+      }
+      m = previous[0] >> 7;
+      for (y = 0; y < ocb->block_len-1; y++) {
+         current[y] = ((previous[y] << 1) | (previous[y+1] >> 7)) & 255;
+      }
+      current[ocb->block_len-1] = (previous[ocb->block_len-1] << 1) & 255;
+      if (m == 1) {
+         /* current[] = current[] XOR polys[poly].poly_mul[]*/
+         ocb3_int_xor_blocks(current, current, polys[poly].poly_mul, ocb->block_len);
+      }
+   }
 
 
-    /* initialize ocb->Offset_current = Offset_0 */
-    ocb3_int_calc_offset_zero(ocb, nonce, noncelen);
+   /* initialize ocb->Offset_current = Offset_0 */
+   ocb3_int_calc_offset_zero(ocb, nonce, noncelen);
 
 
-    /* initialize checksum to all zeros */
-    zeromem(ocb->checksum, ocb->block_len);
+   /* initialize checksum to all zeros */
+   zeromem(ocb->checksum, ocb->block_len);
 
 
-    /* set block index */
-    ocb->block_index = 1;
+   /* set block index */
+   ocb->block_index = 1;
 
 
-    /* initialize AAD related stuff */
-    ocb->ablock_index = 1;
-    ocb->adata_buffer_bytes = 0;
-    zeromem(ocb->aOffset_current, ocb->block_len);
-    zeromem(ocb->aSum_current, ocb->block_len);
+   /* initialize AAD related stuff */
+   ocb->ablock_index = 1;
+   ocb->adata_buffer_bytes = 0;
+   zeromem(ocb->aOffset_current, ocb->block_len);
+   zeromem(ocb->aSum_current, ocb->block_len);
 
 
-    return CRYPT_OK;
+   return CRYPT_OK;
 }
 }
 
 
 #endif
 #endif

+ 10 - 10
src/hashes/sha2/sha512.c

@@ -135,16 +135,16 @@ static int  sha512_compress(hash_state * md, unsigned char *buf)
      d += t0;                                        \
      d += t0;                                        \
      h  = t0 + t1;
      h  = t0 + t1;
 
 
-     for (i = 0; i < 80; i += 8) {
-         RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
-         RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
-         RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
-         RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
-         RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
-         RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
-         RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
-         RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
-     }
+    for (i = 0; i < 80; i += 8) {
+        RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
+        RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
+        RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
+        RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
+        RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
+        RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
+        RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
+        RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
+    }
 #endif     
 #endif     
 
 
 
 

+ 7 - 7
src/mac/f9/f9_process.c

@@ -53,21 +53,21 @@ int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen)
            in    += f9->blocksize;
            in    += f9->blocksize;
            inlen -= f9->blocksize;
            inlen -= f9->blocksize;
        }
        }
-  }
+   }
 #endif
 #endif
 
 
    while (inlen) {
    while (inlen) {
-     if (f9->buflen == f9->blocksize) {
+      if (f9->buflen == f9->blocksize) {
          cipher_descriptor[f9->cipher].ecb_encrypt(f9->IV, f9->IV, &f9->key);
          cipher_descriptor[f9->cipher].ecb_encrypt(f9->IV, f9->IV, &f9->key);
          for (x = 0; x < f9->blocksize; x++) {
          for (x = 0; x < f9->blocksize; x++) {
             f9->ACC[x] ^= f9->IV[x];
             f9->ACC[x] ^= f9->IV[x];
          }
          }
          f9->buflen = 0;
          f9->buflen = 0;
-     }
-     f9->IV[f9->buflen++] ^= *in++;
-     --inlen;
-  }
-  return CRYPT_OK;
+      }
+      f9->IV[f9->buflen++] ^= *in++;
+      --inlen;
+   }
+   return CRYPT_OK;
 }
 }
 
 
 #endif
 #endif

+ 23 - 23
src/mac/pmac/pmac_init.c

@@ -110,37 +110,37 @@ int pmac_init(pmac_state *pmac, int cipher, const unsigned char *key, unsigned l
        }
        }
     }
     }
 
 
-    /* find Lr = L / x */
-    m = L[pmac->block_len-1] & 1;
+   /* find Lr = L / x */
+   m = L[pmac->block_len-1] & 1;
 
 
-    /* shift right */
-    for (x = pmac->block_len - 1; x > 0; x--) {
-        pmac->Lr[x] = ((L[x] >> 1) | (L[x-1] << 7)) & 255;
-    }
-    pmac->Lr[0] = L[0] >> 1;
+   /* shift right */
+   for (x = pmac->block_len - 1; x > 0; x--) {
+      pmac->Lr[x] = ((L[x] >> 1) | (L[x-1] << 7)) & 255;
+   }
+   pmac->Lr[0] = L[0] >> 1;
 
 
-    if (m == 1) {
-       for (x = 0; x < pmac->block_len; x++) {
-           pmac->Lr[x] ^= polys[poly].poly_div[x];
-       }
-    }
+   if (m == 1) {
+      for (x = 0; x < pmac->block_len; x++) {
+         pmac->Lr[x] ^= polys[poly].poly_div[x];
+      }
+   }
 
 
-    /* zero buffer, counters, etc... */
-    pmac->block_index = 1;
-    pmac->cipher_idx  = cipher;
-    pmac->buflen      = 0;
-    zeromem(pmac->block,    sizeof(pmac->block));
-    zeromem(pmac->Li,       sizeof(pmac->Li));
-    zeromem(pmac->checksum, sizeof(pmac->checksum));
-    err = CRYPT_OK;
+   /* zero buffer, counters, etc... */
+   pmac->block_index = 1;
+   pmac->cipher_idx  = cipher;
+   pmac->buflen      = 0;
+   zeromem(pmac->block,    sizeof(pmac->block));
+   zeromem(pmac->Li,       sizeof(pmac->Li));
+   zeromem(pmac->checksum, sizeof(pmac->checksum));
+   err = CRYPT_OK;
 error:
 error:
 #ifdef LTC_CLEAN_STACK
 #ifdef LTC_CLEAN_STACK
-    zeromem(L, pmac->block_len);
+   zeromem(L, pmac->block_len);
 #endif
 #endif
 
 
-    XFREE(L);
+   XFREE(L);
 
 
-    return err;
+   return err;
 }
 }
 
 
 #endif
 #endif

+ 2 - 2
src/mac/pmac/pmac_test.c

@@ -150,8 +150,8 @@ int pmac_test(void)
 #endif
 #endif
            return CRYPT_FAIL_TESTVECTOR;
            return CRYPT_FAIL_TESTVECTOR;
         }
         }
-     }
-     return CRYPT_OK;
+    }
+    return CRYPT_OK;
 #endif /* LTC_TEST */
 #endif /* LTC_TEST */
 }
 }
 
 

+ 7 - 7
src/mac/xcbc/xcbc_process.c

@@ -53,18 +53,18 @@ int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen)
            in    += xcbc->blocksize;
            in    += xcbc->blocksize;
            inlen -= xcbc->blocksize;
            inlen -= xcbc->blocksize;
        }
        }
-  }
+   }
 #endif
 #endif
 
 
    while (inlen) {
    while (inlen) {
-     if (xcbc->buflen == xcbc->blocksize) {
+      if (xcbc->buflen == xcbc->blocksize) {
          cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
          cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
          xcbc->buflen = 0;
          xcbc->buflen = 0;
-     }
-     xcbc->IV[xcbc->buflen++] ^= *in++;
-     --inlen;
-  }
-  return CRYPT_OK;
+      }
+      xcbc->IV[xcbc->buflen++] ^= *in++;
+      --inlen;
+   }
+   return CRYPT_OK;
 }
 }
 
 
 #endif
 #endif

+ 9 - 9
src/modes/cbc/cbc_decrypt.c

@@ -69,17 +69,17 @@ int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, s
 
 
          /* xor IV against plaintext */
          /* xor IV against plaintext */
          #if defined(LTC_FAST)
          #if defined(LTC_FAST)
-        for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
+         for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
             tmpy = *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) ^ *((LTC_FAST_TYPE*)((unsigned char *)tmp + x));
             tmpy = *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) ^ *((LTC_FAST_TYPE*)((unsigned char *)tmp + x));
-       *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) = *((LTC_FAST_TYPE*)((unsigned char *)ct + x));
-       *((LTC_FAST_TYPE*)((unsigned char *)pt + x)) = tmpy;
-        }
+            *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) = *((LTC_FAST_TYPE*)((unsigned char *)ct + x));
+            *((LTC_FAST_TYPE*)((unsigned char *)pt + x)) = tmpy;
+         }
     #else
     #else
-            for (x = 0; x < cbc->blocklen; x++) {
-               tmpy       = tmp[x] ^ cbc->IV[x];
-               cbc->IV[x] = ct[x];
-               pt[x]      = tmpy;
-            }
+         for (x = 0; x < cbc->blocklen; x++) {
+            tmpy       = tmp[x] ^ cbc->IV[x];
+            cbc->IV[x] = ct[x];
+            pt[x]      = tmpy;
+         }
     #endif
     #endif
 
 
          ct  += cbc->blocklen;
          ct  += cbc->blocklen;

+ 15 - 15
src/modes/cbc/cbc_encrypt.c

@@ -58,13 +58,13 @@ int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
       while (len) {
       while (len) {
          /* xor IV against plaintext */
          /* xor IV against plaintext */
          #if defined(LTC_FAST)
          #if defined(LTC_FAST)
-        for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
+         for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
             *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) ^= *((LTC_FAST_TYPE*)((unsigned char *)pt + x));
             *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) ^= *((LTC_FAST_TYPE*)((unsigned char *)pt + x));
-        }
+         }
     #else
     #else
-            for (x = 0; x < cbc->blocklen; x++) {
-               cbc->IV[x] ^= pt[x];
-            }
+         for (x = 0; x < cbc->blocklen; x++) {
+            cbc->IV[x] ^= pt[x];
+         }
     #endif
     #endif
 
 
          /* encrypt */
          /* encrypt */
@@ -72,21 +72,21 @@ int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, s
             return err;
             return err;
          }
          }
 
 
-        /* store IV [ciphertext] for a future block */
+         /* store IV [ciphertext] for a future block */
          #if defined(LTC_FAST)
          #if defined(LTC_FAST)
-        for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
+         for (x = 0; x < cbc->blocklen; x += sizeof(LTC_FAST_TYPE)) {
             *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) = *((LTC_FAST_TYPE*)((unsigned char *)ct + x));
             *((LTC_FAST_TYPE*)((unsigned char *)cbc->IV + x)) = *((LTC_FAST_TYPE*)((unsigned char *)ct + x));
-        }
+         }
     #else
     #else
-             for (x = 0; x < cbc->blocklen; x++) {
-                cbc->IV[x] = ct[x];
-             }
+         for (x = 0; x < cbc->blocklen; x++) {
+            cbc->IV[x] = ct[x];
+         }
     #endif
     #endif
 
 
-        ct  += cbc->blocklen;
-        pt  += cbc->blocklen;
-        len -= cbc->blocklen;
-     }
+         ct  += cbc->blocklen;
+         pt  += cbc->blocklen;
+         len -= cbc->blocklen;
+      }
    }
    }
    return CRYPT_OK;
    return CRYPT_OK;
 }
 }

+ 6 - 6
src/modes/lrw/lrw_start.c

@@ -41,10 +41,10 @@ int lrw_start(               int   cipher,
    int           x, y, z, t;
    int           x, y, z, t;
 #endif
 #endif
 
 
-  LTC_ARGCHK(IV    != NULL);
-  LTC_ARGCHK(key   != NULL);
-  LTC_ARGCHK(tweak != NULL);
-  LTC_ARGCHK(lrw   != NULL);
+   LTC_ARGCHK(IV    != NULL);
+   LTC_ARGCHK(key   != NULL);
+   LTC_ARGCHK(tweak != NULL);
+   LTC_ARGCHK(lrw   != NULL);
 
 
 #ifdef LTC_FAST
 #ifdef LTC_FAST
    if (16 % sizeof(LTC_FAST_TYPE)) {
    if (16 % sizeof(LTC_FAST_TYPE)) {
@@ -88,8 +88,8 @@ int lrw_start(               int   cipher,
          }
          }
          lrw->PC[x][y][0]  = gcm_shift_table[t<<1];
          lrw->PC[x][y][0]  = gcm_shift_table[t<<1];
          lrw->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
          lrw->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
-     }
-  }
+      }
+   }
 #endif
 #endif
 
 
    /* generate first pad */
    /* generate first pad */

+ 2 - 2
src/modes/lrw/lrw_test.c

@@ -122,8 +122,8 @@ int lrw_test(void)
      if ((err = lrw_done(&lrw)) != CRYPT_OK) {
      if ((err = lrw_done(&lrw)) != CRYPT_OK) {
         return err;
         return err;
      }
      }
-   }
-   return CRYPT_OK;
+  }
+  return CRYPT_OK;
 #endif
 #endif
 }
 }
 
 

+ 2 - 2
src/pk/asn1/der/bit/der_decode_bit_string.c

@@ -45,8 +45,8 @@ int der_decode_bit_string(const unsigned char *in,  unsigned long inlen,
       return CRYPT_INVALID_PACKET;
       return CRYPT_INVALID_PACKET;
    }
    }
 
 
-    /* offset in the data */
-    x = 1;
+   /* offset in the data */
+   x = 1;
 
 
    /* get the length of the data */
    /* get the length of the data */
    if (in[x] & 0x80) {
    if (in[x] & 0x80) {

+ 2 - 2
src/pk/asn1/der/bit/der_decode_raw_bit_string.c

@@ -47,8 +47,8 @@ int der_decode_raw_bit_string(const unsigned char *in,  unsigned long inlen,
       return CRYPT_INVALID_PACKET;
       return CRYPT_INVALID_PACKET;
    }
    }
 
 
-    /* offset in the data */
-    x = 1;
+   /* offset in the data */
+   x = 1;
 
 
    /* get the length of the data */
    /* get the length of the data */
    if (in[x] & 0x80) {
    if (in[x] & 0x80) {

+ 22 - 22
src/pk/asn1/der/object_identifier/der_decode_object_identifier.c

@@ -53,14 +53,14 @@ int der_decode_object_identifier(const unsigned char *in,    unsigned long  inle
    if (in[x] < 128) {
    if (in[x] < 128) {
       len = in[x++]; 
       len = in[x++]; 
    } else {
    } else {
-       if (in[x] < 0x81 || in[x] > 0x82) {
-          return CRYPT_INVALID_PACKET;
-       }
-       y   = in[x++] & 0x7F;
-       len = 0;
-       while (y--) {
-          len = (len << 8) | (unsigned long)in[x++];
-       }
+      if (in[x] < 0x81 || in[x] > 0x82) {
+         return CRYPT_INVALID_PACKET;
+      }
+      y   = in[x++] & 0x7F;
+      len = 0;
+      while (y--) {
+         len = (len << 8) | (unsigned long)in[x++];
+      }
    }
    }
 
 
    if (len < 1 || (len + x) > inlen) {
    if (len < 1 || (len + x) > inlen) {
@@ -71,21 +71,21 @@ int der_decode_object_identifier(const unsigned char *in,    unsigned long  inle
    y = 0;
    y = 0;
    t = 0;
    t = 0;
    while (len--) {
    while (len--) {
-       t = (t << 7) | (in[x] & 0x7F);
-       if (!(in[x++] & 0x80)) {
-           /* store t */
-           if (y >= *outlen) {
-              return CRYPT_BUFFER_OVERFLOW;
-           }
-      if (y == 0) {
-         words[0] = t / 40;
-         words[1] = t % 40;
-         y = 2;
-      } else {
-              words[y++] = t;
+      t = (t << 7) | (in[x] & 0x7F);
+      if (!(in[x++] & 0x80)) {
+         /* store t */
+         if (y >= *outlen) {
+            return CRYPT_BUFFER_OVERFLOW;
+         }
+         if (y == 0) {
+            words[0] = t / 40;
+            words[1] = t % 40;
+            y = 2;
+         } else {
+            words[y++] = t;
+         }
+            t          = 0;
       }
       }
-           t          = 0;
-       }
    }
    }
        
        
    *outlen = y;
    *outlen = y;

+ 26 - 26
src/pk/asn1/der/object_identifier/der_encode_object_identifier.c

@@ -71,33 +71,33 @@ int der_encode_object_identifier(unsigned long *words, unsigned long  nwords,
    }
    }
 
 
    /* store first byte */
    /* store first byte */
-    wordbuf = words[0] * 40 + words[1];   
-    for (i = 1; i < nwords; i++) {
-        /* store 7 bit words in little endian */
-        t    = wordbuf & 0xFFFFFFFF;
-        if (t) {
-           y    = x;
-           mask = 0;
-           while (t) {
-               out[x++] = (unsigned char)((t & 0x7F) | mask);
-               t    >>= 7;
-               mask  |= 0x80;  /* upper bit is set on all but the last byte */
-           }
-           /* now swap bytes y...x-1 */
-           z = x - 1;
-           while (y < z) {
-               t = out[y]; out[y] = out[z]; out[z] = (unsigned char)t;
-               ++y; 
-               --z;
-           }
-       } else {
-          /* zero word */
-          out[x++] = 0x00;
-       }
+   wordbuf = words[0] * 40 + words[1];   
+   for (i = 1; i < nwords; i++) {
+      /* store 7 bit words in little endian */
+      t    = wordbuf & 0xFFFFFFFF;
+      if (t) {
+         y    = x;
+         mask = 0;
+         while (t) {
+            out[x++] = (unsigned char)((t & 0x7F) | mask);
+            t    >>= 7;
+            mask  |= 0x80;  /* upper bit is set on all but the last byte */
+         }
+         /* now swap bytes y...x-1 */
+         z = x - 1;
+         while (y < z) {
+            t = out[y]; out[y] = out[z]; out[z] = (unsigned char)t;
+            ++y; 
+            --z;
+         }
+      } else {
+         /* zero word */
+         out[x++] = 0x00;
+      }
        
        
-       if (i < nwords - 1) {
-          wordbuf = words[i + 1];
-       }
+      if (i < nwords - 1) {
+         wordbuf = words[i + 1];
+      }
    }
    }
 
 
    *outlen = x;
    *outlen = x;

+ 8 - 8
src/pk/asn1/der/sequence/der_decode_sequence_ex.c

@@ -72,19 +72,19 @@ int der_decode_sequence_ex(const unsigned char *in, unsigned long  inlen,
       while (y--) {
       while (y--) {
           blksize = (blksize << 8) | (unsigned long)in[x++];
           blksize = (blksize << 8) | (unsigned long)in[x++];
       }
       }
-  }
+   }
 
 
-  /* would this blksize overflow? */
-  if (x + blksize > inlen) {
-     return CRYPT_INVALID_PACKET;
-  }
+   /* would this blksize overflow? */
+   if (x + blksize > inlen) {
+      return CRYPT_INVALID_PACKET;
+   }
 
 
    /* mark all as unused */
    /* mark all as unused */
    for (i = 0; i < (int)outlen; i++) {
    for (i = 0; i < (int)outlen; i++) {
        list[i].used = 0;
        list[i].used = 0;
    }
    }
 
 
-  /* ok read data */
+   /* ok read data */
    inlen = blksize;
    inlen = blksize;
    for (i = 0; i < (int)outlen; i++) {
    for (i = 0; i < (int)outlen; i++) {
        z    = 0;
        z    = 0;
@@ -105,8 +105,8 @@ int der_decode_sequence_ex(const unsigned char *in, unsigned long  inlen,
                }
                }
                if ((err = der_length_boolean(&z)) != CRYPT_OK) {
                if ((err = der_length_boolean(&z)) != CRYPT_OK) {
                    goto LBL_ERR;
                    goto LBL_ERR;
-                }
-                break;
+               }
+               break;
 
 
            case LTC_ASN1_INTEGER:
            case LTC_ASN1_INTEGER:
                z = inlen;
                z = inlen;

+ 8 - 8
src/pk/asn1/der/set/der_encode_setof.c

@@ -94,16 +94,16 @@ int der_encode_setof(ltc_asn1_list *list, unsigned long inlen,
    }
    }
 
 
    /* skip header */
    /* skip header */
-      ptr = buf + 1;
+   ptr = buf + 1;
 
 
-      /* now skip length data */
-      x = *ptr++;
-      if (x >= 0x80) {
-         ptr += (x & 0x7F);
-      }
+   /* now skip length data */
+   x = *ptr++;
+   if (x >= 0x80) {
+      ptr += (x & 0x7F);
+   }
 
 
-      /* get the size of the static header */
-      hdrlen = ptr - buf;
+   /* get the size of the static header */
+   hdrlen = ptr - buf;
 
 
 
 
    /* scan for edges */
    /* scan for edges */

+ 3 - 3
src/pk/dsa/dsa_import.c

@@ -95,8 +95,8 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
 
 
       tmpbuf = XCALLOC(1, tmpbuf_len);
       tmpbuf = XCALLOC(1, tmpbuf_len);
       if (tmpbuf == NULL) {
       if (tmpbuf == NULL) {
-          err = CRYPT_MEM;
-          goto LBL_ERR;
+         err = CRYPT_MEM;
+         goto LBL_ERR;
       }
       }
 
 
       err = der_decode_subject_public_key_info(in, inlen,
       err = der_decode_subject_public_key_info(in, inlen,
@@ -112,7 +112,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key)
 
 
       XFREE(tmpbuf);
       XFREE(tmpbuf);
       key->type = PK_PUBLIC;
       key->type = PK_PUBLIC;
-  }
+   }
 
 
 LBL_OK:
 LBL_OK:
   key->qord = mp_unsigned_bin_size(key->q);
   key->qord = mp_unsigned_bin_size(key->q);

+ 7 - 7
src/pk/ecc/ltc_ecc_mul2add.c

@@ -93,16 +93,16 @@ int ltc_ecc_mul2add(ecc_point *A, void *kA,
      }
      }
   }
   }
 
 
-   /* init montgomery reduction */
-   if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) {
+  /* init montgomery reduction */
+  if ((err = mp_montgomery_setup(modulus, &mp)) != CRYPT_OK) {
       goto ERR_P;
       goto ERR_P;
-   }
-   if ((err = mp_init(&mu)) != CRYPT_OK) {
+  }
+  if ((err = mp_init(&mu)) != CRYPT_OK) {
       goto ERR_MP;
       goto ERR_MP;
-   }
-   if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) {
+  }
+  if ((err = mp_montgomery_normalization(mu, modulus)) != CRYPT_OK) {
       goto ERR_MU;
       goto ERR_MU;
-   }
+  }
 
 
   /* copy ones ... */
   /* copy ones ... */
   if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK)                                         { goto ERR_MU; }
   if ((err = mp_mulmod(A->x, mu, modulus, precomp[1]->x)) != CRYPT_OK)                                         { goto ERR_MU; }

+ 3 - 3
src/pk/ecc/ltc_ecc_mulmod_timing.c

@@ -61,8 +61,8 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map)
       return err;
       return err;
    }
    }
 
 
-  /* alloc ram for window temps */
-  for (i = 0; i < 3; i++) {
+   /* alloc ram for window temps */
+   for (i = 0; i < 3; i++) {
       M[i] = ltc_ecc_new_point();
       M[i] = ltc_ecc_new_point();
       if (M[i] == NULL) {
       if (M[i] == NULL) {
          for (j = 0; j < i; j++) {
          for (j = 0; j < i; j++) {
@@ -72,7 +72,7 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map)
          mp_montgomery_free(mp);
          mp_montgomery_free(mp);
          return CRYPT_MEM;
          return CRYPT_MEM;
       }
       }
-  }
+   }
 
 
    /* make a copy of G incase R==G */
    /* make a copy of G incase R==G */
    tG = ltc_ecc_new_point();
    tG = ltc_ecc_new_point();

+ 10 - 10
src/prngs/sober128.c

@@ -311,8 +311,8 @@ unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state
    }
    }
 
 
 #ifndef LTC_SMALL_CODE
 #ifndef LTC_SMALL_CODE
-    /* do lots at a time, if there's enough to do */
-    while (outlen >= N*4) {
+   /* do lots at a time, if there's enough to do */
+   while (outlen >= N*4) {
       SROUND(0);
       SROUND(0);
       SROUND(1);
       SROUND(1);
       SROUND(2);
       SROUND(2);
@@ -332,20 +332,20 @@ unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state
       SROUND(16);
       SROUND(16);
       out    += 4*N;
       out    += 4*N;
       outlen -= 4*N;
       outlen -= 4*N;
-    }
+   }
 #endif
 #endif
 
 
-    /* do small or odd size buffers the slow way */
-    while (4 <= outlen) {
+   /* do small or odd size buffers the slow way */
+   while (4 <= outlen) {
       cycle(c->R);
       cycle(c->R);
       t = nltap(c);
       t = nltap(c);
       XORWORD(t, out);
       XORWORD(t, out);
       out    += 4;
       out    += 4;
       outlen -= 4;
       outlen -= 4;
-    }
+   }
 
 
-    /* handle any trailing bytes */
-    if (outlen != 0) {
+   /* handle any trailing bytes */
+   if (outlen != 0) {
       cycle(c->R);
       cycle(c->R);
       c->sbuf = nltap(c);
       c->sbuf = nltap(c);
       c->nbuf = 32;
       c->nbuf = 32;
@@ -355,9 +355,9 @@ unsigned long sober128_read(unsigned char *out, unsigned long outlen, prng_state
           c->nbuf -= 8;
           c->nbuf -= 8;
           --outlen;
           --outlen;
       }
       }
-    }
+   }
 
 
-    return tlen;
+   return tlen;
 }
 }
 
 
 /**
 /**