Run util/openssl-format-source -v -c .
[openssl.git] / crypto / camellia / cmll_misc.c
index 2cd7aba9bbd41c455e1899a674064d62090578f8..a27ed6b8dd53791476341577b212e4216ca252a8 100644 (file)
@@ -7,7 +7,7 @@
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
+ *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  * ====================================================================
  *
  */
+
 #include <openssl/opensslv.h>
 #include <openssl/camellia.h>
 #include "cmll_locl.h"
 #include <openssl/crypto.h>
 #ifdef OPENSSL_FIPS
-#include <openssl/fips.h>
+# include <openssl/fips.h>
 #endif
 
-const char CAMELLIA_version[]="CAMELLIA" OPENSSL_VERSION_PTEXT;
+const char CAMELLIA_version[] = "CAMELLIA" OPENSSL_VERSION_PTEXT;
 
 int Camellia_set_key(const unsigned char *userKey, const int bits,
-       CAMELLIA_KEY *key)
+                     CAMELLIA_KEY *key)
 #ifdef OPENSSL_FIPS
-       {
-       if (FIPS_mode())
-               FIPS_BAD_ABORT(CAMELLIA)
-       return private_Camellia_set_key(userKey, bits, key);
-       }
+{
+    if (FIPS_mode())
+        FIPS_BAD_ABORT(CAMELLIA)
+            return private_Camellia_set_key(userKey, bits, key);
+}
+
 int private_Camellia_set_key(const unsigned char *userKey, const int bits,
-       CAMELLIA_KEY *key)
+                             CAMELLIA_KEY *key)
 #endif
-       {
-       if (!userKey || !key)
-               {
-               return -1;
-               }
-       
-       switch(bits)
-               {
-       case 128:
-               camellia_setup128(userKey, (unsigned int *)key->rd_key);
-               key->enc = camellia_encrypt128;
-               key->dec = camellia_decrypt128;
-               break;
-       case 192:
-               camellia_setup192(userKey, (unsigned int *)key->rd_key);
-               key->enc = camellia_encrypt256;
-               key->dec = camellia_decrypt256;
-               break;
-       case 256:
-               camellia_setup256(userKey, (unsigned int *)key->rd_key);
-               key->enc = camellia_encrypt256;
-               key->dec = camellia_decrypt256;
-               break;
-       default:
-               return -2;
-               }
-       
-       key->bitLength = bits;
-       return 0;
-       }
+{
+    if (!userKey || !key) {
+        return -1;
+    }
+
+    switch (bits) {
+    case 128:
+        camellia_setup128(userKey, (unsigned int *)key->rd_key);
+        key->enc = camellia_encrypt128;
+        key->dec = camellia_decrypt128;
+        break;
+    case 192:
+        camellia_setup192(userKey, (unsigned int *)key->rd_key);
+        key->enc = camellia_encrypt256;
+        key->dec = camellia_decrypt256;
+        break;
+    case 256:
+        camellia_setup256(userKey, (unsigned int *)key->rd_key);
+        key->enc = camellia_encrypt256;
+        key->dec = camellia_decrypt256;
+        break;
+    default:
+        return -2;
+    }
+
+    key->bitLength = bits;
+    return 0;
+}
 
 void Camellia_encrypt(const unsigned char *in, unsigned char *out,
-       const CAMELLIA_KEY *key)
-       {
-       u32 tmp[CAMELLIA_BLOCK_SIZE/sizeof(u32)];
-       const union { long one; char little; } camellia_endian = {1};
+                      const CAMELLIA_KEY *key)
+{
+    u32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(u32)];
+    const union {
+        long one;
+        char little;
+    } camellia_endian = {
+        1
+    };
 
-       memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
-       if (camellia_endian.little) SWAP4WORD(tmp);
-       key->enc(key->rd_key, tmp);
-       if (camellia_endian.little) SWAP4WORD(tmp);
-       memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
-       }
+    memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
+    if (camellia_endian.little)
+        SWAP4WORD(tmp);
+    key->enc(key->rd_key, tmp);
+    if (camellia_endian.little)
+        SWAP4WORD(tmp);
+    memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
+}
 
 void Camellia_decrypt(const unsigned char *in, unsigned char *out,
-       const CAMELLIA_KEY *key)
-       {
-       u32 tmp[CAMELLIA_BLOCK_SIZE/sizeof(u32)];
-       const union { long one; char little; } camellia_endian = {1};
-
-       memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
-       if (camellia_endian.little) SWAP4WORD(tmp);
-       key->dec(key->rd_key, tmp);
-       if (camellia_endian.little) SWAP4WORD(tmp);
-       memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
-       }
+                      const CAMELLIA_KEY *key)
+{
+    u32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(u32)];
+    const union {
+        long one;
+        char little;
+    } camellia_endian = {
+        1
+    };
 
+    memcpy(tmp, in, CAMELLIA_BLOCK_SIZE);
+    if (camellia_endian.little)
+        SWAP4WORD(tmp);
+    key->dec(key->rd_key, tmp);
+    if (camellia_endian.little)
+        SWAP4WORD(tmp);
+    memcpy(out, tmp, CAMELLIA_BLOCK_SIZE);
+}