svn rev #24228: branches/camellia-ccm/src/lib/crypto/ builtin/enc_provider/ krb/ ...

ghudson@MIT.EDU ghudson at MIT.EDU
Tue Aug 3 05:26:41 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24228
Commit By: ghudson
Log Message:
General style pass over camellia-ccm branch changes.



Changed Files:
U   branches/camellia-ccm/src/lib/crypto/builtin/enc_provider/camellia_ctr.c
U   branches/camellia-ccm/src/lib/crypto/krb/aead.h
U   branches/camellia-ccm/src/lib/crypto/krb/checksum/cmac.c
U   branches/camellia-ccm/src/lib/crypto/krb/dk/checksum_hmac.c
U   branches/camellia-ccm/src/lib/crypto/openssl/enc_provider/camellia_ctr.c
Modified: branches/camellia-ccm/src/lib/crypto/builtin/enc_provider/camellia_ctr.c
===================================================================
--- branches/camellia-ccm/src/lib/crypto/builtin/enc_provider/camellia_ctr.c	2010-08-03 09:25:02 UTC (rev 24227)
+++ branches/camellia-ccm/src/lib/crypto/builtin/enc_provider/camellia_ctr.c	2010-08-03 09:26:41 UTC (rev 24228)
@@ -34,9 +34,9 @@
 xorblock(unsigned char *out, const unsigned char *in)
 {
     int z;
-    for (z = 0; z < BLOCK_SIZE/4; z++) {
-        unsigned char *outptr = &out[z*4];
-        unsigned char *inptr = (unsigned char *)&in[z*4];
+    for (z = 0; z < BLOCK_SIZE / 4; z++) {
+        unsigned char *outptr = &out[z * 4];
+        unsigned char *inptr = (unsigned char *)&in[z * 4];
         /*
          * Use unaligned accesses.  On x86, this will probably still be faster
          * than multiple byte accesses for unaligned data, and for aligned data
@@ -51,7 +51,7 @@
          * conditionalize on CPU type, as that may be hard to determine
          * automatically.
          */
-        store_32_n (load_32_n(outptr) ^ load_32_n(inptr), outptr);
+        store_32_n(load_32_n(outptr) ^ load_32_n(inptr), outptr);
     }
 }
 
@@ -70,13 +70,11 @@
 }
 
 /*
- * ivec must be a correctly formatted counter block per SP800-38C A.3
+ * ivec must be a correctly formatted counter block per NIST SP800-38C A.3.
  */
 static krb5_error_code
-krb5int_camellia_encrypt_ctr(krb5_key key,
-                             const krb5_data *ivec,
-                             krb5_crypto_iov *data,
-                             size_t num_data)
+krb5int_camellia_encrypt_ctr(krb5_key key, const krb5_data *ivec,
+                             krb5_crypto_iov *data, size_t num_data)
 {
     camellia_ctx ctx;
     unsigned char ctr[BLOCK_SIZE];
@@ -90,7 +88,7 @@
     IOV_BLOCK_STATE_INIT(&input_pos);
     IOV_BLOCK_STATE_INIT(&output_pos);
 
-    /* Don't encrypt the header (B0), and use zero instead of IOV padding */
+    /* Don't encrypt the header (B0), and use zero instead of IOV padding. */
     input_pos.ignore_header = output_pos.ignore_header = 1;
     input_pos.pad_to_boundary = output_pos.pad_to_boundary = 1;
 
@@ -107,8 +105,8 @@
         unsigned char storage[BLOCK_SIZE], *block;
         unsigned char ectr[BLOCK_SIZE];
 
-        if (!krb5int_c_iov_get_block_nocopy(storage, BLOCK_SIZE,
-                                            data, num_data, &input_pos, &block))
+        if (!krb5int_c_iov_get_block_nocopy(storage, BLOCK_SIZE, data,
+					    num_data, &input_pos, &block))
             break;
 
         if (camellia_enc_blk(ctr, ectr, &ctx) != camellia_good)
@@ -127,11 +125,9 @@
 }
 
 krb5_error_code
-krb5int_camellia_cbc_mac(krb5_key key,
-                         const krb5_crypto_iov *data,
-                         size_t num_data,
-                         const krb5_data *iv,
-                         krb5_data *output)
+krb5int_camellia_cbc_mac(krb5_key key, const krb5_crypto_iov *data,
+                         size_t num_data, const krb5_data *iv,
+			 krb5_data *output)
 {
     camellia_ctx ctx;
     unsigned char blockY[BLOCK_SIZE];
@@ -153,7 +149,7 @@
 
     /*
      * The CCM header may not fit in a block, because it includes a variable
-     * length encoding of the associated data length. This encoding plus the
+     * length encoding of the associated data length.  This encoding plus the
      * associated data itself is padded to the block size.
      */
     iov_state.include_sign_only = 1;
@@ -162,7 +158,8 @@
     for (;;) {
         unsigned char blockB[BLOCK_SIZE];
 
-        if (!krb5int_c_iov_get_block(blockB, BLOCK_SIZE, data, num_data, &iov_state))
+        if (!krb5int_c_iov_get_block(blockB, BLOCK_SIZE, data, num_data,
+				     &iov_state))
             break;
 
         xorblock(blockB, blockY);
@@ -178,8 +175,8 @@
 }
 
 static krb5_error_code
-krb5int_camellia_init_state_ctr (const krb5_keyblock *key, krb5_keyusage usage,
-                                 krb5_data *state)
+krb5int_camellia_init_state_ctr(const krb5_keyblock *key, krb5_keyusage usage,
+				krb5_data *state)
 {
     return alloc_data(state, 16);
 }

Modified: branches/camellia-ccm/src/lib/crypto/krb/aead.h
===================================================================
--- branches/camellia-ccm/src/lib/crypto/krb/aead.h	2010-08-03 09:25:02 UTC (rev 24227)
+++ branches/camellia-ccm/src/lib/crypto/krb/aead.h	2010-08-03 09:26:41 UTC (rev 24228)
@@ -256,7 +256,7 @@
         if (p == storage) {
             memcpy(iov->data.data + iov_state->data_pos, storage + j, nbytes);
         } else {
-            /* Validate we correctly paired with a call to get_block_nocopy() */
+            /* Ensure correctly paired with a call to get_block_nocopy(). */
             assert(j == 0);
             assert(nbytes == 0 || nbytes == block_size);
         }

Modified: branches/camellia-ccm/src/lib/crypto/krb/checksum/cmac.c
===================================================================
--- branches/camellia-ccm/src/lib/crypto/krb/checksum/cmac.c	2010-08-03 09:25:02 UTC (rev 24227)
+++ branches/camellia-ccm/src/lib/crypto/krb/checksum/cmac.c	2010-08-03 09:26:41 UTC (rev 24228)
@@ -223,4 +223,3 @@
 
     return 0;
 }
-

Modified: branches/camellia-ccm/src/lib/crypto/krb/dk/checksum_hmac.c
===================================================================
--- branches/camellia-ccm/src/lib/crypto/krb/dk/checksum_hmac.c	2010-08-03 09:25:02 UTC (rev 24227)
+++ branches/camellia-ccm/src/lib/crypto/krb/dk/checksum_hmac.c	2010-08-03 09:26:41 UTC (rev 24228)
@@ -69,4 +69,3 @@
     krb5_k_free_key(NULL, kc);
     return ret;
 }
-

Modified: branches/camellia-ccm/src/lib/crypto/openssl/enc_provider/camellia_ctr.c
===================================================================
--- branches/camellia-ccm/src/lib/crypto/openssl/enc_provider/camellia_ctr.c	2010-08-03 09:25:02 UTC (rev 24227)
+++ branches/camellia-ccm/src/lib/crypto/openssl/enc_provider/camellia_ctr.c	2010-08-03 09:26:41 UTC (rev 24228)
@@ -39,9 +39,9 @@
 xorblock(unsigned char *out, const unsigned char *in)
 {
     int z;
-    for (z = 0; z < CAMELLIA_BLOCK_SIZE/4; z++) {
-        unsigned char *outptr = &out[z*4];
-        unsigned char *inptr = (unsigned char *)&in[z*4];
+    for (z = 0; z < CAMELLIA_BLOCK_SIZE / 4; z++) {
+        unsigned char *outptr = &out[z * 4];
+        unsigned char *inptr = (unsigned char *)&in[z * 4];
         /*
          * Use unaligned accesses.  On x86, this will probably still be faster
          * than multiple byte accesses for unaligned data, and for aligned data
@@ -56,7 +56,7 @@
          * conditionalize on CPU type, as that may be hard to determine
          * automatically.
          */
-        store_32_n (load_32_n(outptr) ^ load_32_n(inptr), outptr);
+        store_32_n(load_32_n(outptr) ^ load_32_n(inptr), outptr);
     }
 }
 
@@ -64,10 +64,8 @@
  * ivec must be a correctly formatted counter block per SP800-38C A.3
  */
 static krb5_error_code
-krb5int_camellia_encrypt_ctr(krb5_key key,
-                             const krb5_data *ivec,
-                             krb5_crypto_iov *data,
-                             size_t num_data)
+krb5int_camellia_encrypt_ctr(krb5_key key, const krb5_data *ivec,
+                             krb5_crypto_iov *data, size_t num_data)
 {
     CAMELLIA_KEY enck;
     unsigned char ctr[CAMELLIA_BLOCK_SIZE];
@@ -97,14 +95,18 @@
         unsigned int num = 0;
 
         if (!krb5int_c_iov_get_block_nocopy(storage, CAMELLIA_BLOCK_SIZE,
-                                            data, num_data, &input_pos, &block))
+                                            data, num_data, &input_pos,
+					    &block))
             break;
 
-        /* We should not need to initialise ectr because we're on a block boundary. */
-        Camellia_ctr128_encrypt(block, block, CAMELLIA_BLOCK_SIZE, &enck, ctr, ectr, &num);
+        /* We should not need to initialise ectr because we're on a block
+	 * boundary. */
+        Camellia_ctr128_encrypt(block, block, CAMELLIA_BLOCK_SIZE, &enck, ctr,
+				ectr, &num);
         assert(num == 0);
         krb5int_c_iov_put_block_nocopy(data, num_data, storage,
-                                       CAMELLIA_BLOCK_SIZE, &output_pos, block);
+				       CAMELLIA_BLOCK_SIZE, &output_pos,
+				       block);
     }
 
     if (ivec != NULL)
@@ -114,11 +116,9 @@
 }
 
 static krb5_error_code
-krb5int_camellia_cbc_mac(krb5_key key,
-                         const krb5_crypto_iov *data,
-                         size_t num_data,
-                         const krb5_data *iv,
-                         krb5_data *output)
+krb5int_camellia_cbc_mac(krb5_key key, const krb5_crypto_iov *data,
+                         size_t num_data, const krb5_data *iv,
+			 krb5_data *output)
 {
     CAMELLIA_KEY enck;
     unsigned char blockY[CAMELLIA_BLOCK_SIZE];
@@ -148,7 +148,8 @@
     for (;;) {
         unsigned char blockB[CAMELLIA_BLOCK_SIZE];
 
-        if (!krb5int_c_iov_get_block(blockB, CAMELLIA_BLOCK_SIZE, data, num_data, &iov_state))
+        if (!krb5int_c_iov_get_block(blockB, CAMELLIA_BLOCK_SIZE, data,
+				     num_data, &iov_state))
             break;
 
         xorblock(blockB, blockY);




More information about the cvs-krb5 mailing list