Print this page
4896 Performance improvements for KCF AES modes

@@ -20,10 +20,13 @@
  */
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
+/*
+ * Copyright 2015 by Saso Kiselkov. All rights reserved.
+ */
 
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/ddi.h>
 #include <sys/sysmacros.h>

@@ -984,11 +987,11 @@
         *keyp ^= (k & 0x0101010101010101ULL);
         *keyp ^= 0x0101010101010101ULL;
 }
 
 void
-des_copy_block(uint8_t *in, uint8_t *out)
+des_copy_block(const uint8_t *in, uint8_t *out)
 {
         if (IS_P2ALIGNED(in, sizeof (uint32_t)) &&
             IS_P2ALIGNED(out, sizeof (uint32_t))) {
                 /* LINTED: pointer alignment */
                 *(uint32_t *)&out[0] = *(uint32_t *)&in[0];

@@ -999,11 +1002,11 @@
         }
 }
 
 /* XOR block of data into dest */
 void
-des_xor_block(uint8_t *data, uint8_t *dst)
+des_xor_block(const uint8_t *data, uint8_t *dst)
 {
         if (IS_P2ALIGNED(dst, sizeof (uint32_t)) &&
             IS_P2ALIGNED(data, sizeof (uint32_t))) {
                 /* LINTED: pointer alignment */
                 *(uint32_t *)&dst[0] ^=

@@ -1054,23 +1057,23 @@
 
         if (des_ctx->dc_flags & DES3_STRENGTH) {
                 if (des_ctx->dc_flags & CBC_MODE) {
                         rv = cbc_encrypt_contiguous_blocks(ctx, data,
                             length, out, DES_BLOCK_LEN, des3_encrypt_block,
-                            des_copy_block, des_xor_block);
+                            des_copy_block, des_xor_block, NULL);
                 } else {
                         rv = ecb_cipher_contiguous_blocks(ctx, data, length,
-                            out, DES_BLOCK_LEN, des3_encrypt_block);
+                            out, DES_BLOCK_LEN, des3_encrypt_block, NULL);
                 }
         } else {
                 if (des_ctx->dc_flags & CBC_MODE) {
                         rv = cbc_encrypt_contiguous_blocks(ctx, data,
                             length, out, DES_BLOCK_LEN, des_encrypt_block,
-                            des_copy_block, des_xor_block);
+                            des_copy_block, des_xor_block, NULL);
                 } else {
                         rv = ecb_cipher_contiguous_blocks(ctx, data, length,
-                            out, DES_BLOCK_LEN, des_encrypt_block);
+                            out, DES_BLOCK_LEN, des_encrypt_block, NULL);
                 }
         }
         return (rv);
 }
 

@@ -1086,25 +1089,25 @@
 
         if (des_ctx->dc_flags & DES3_STRENGTH) {
                 if (des_ctx->dc_flags & CBC_MODE) {
                         rv = cbc_decrypt_contiguous_blocks(ctx, data,
                             length, out, DES_BLOCK_LEN, des3_decrypt_block,
-                            des_copy_block, des_xor_block);
+                            des_copy_block, des_xor_block, NULL, NULL);
                 } else {
                         rv = ecb_cipher_contiguous_blocks(ctx, data, length,
-                            out, DES_BLOCK_LEN, des3_decrypt_block);
+                            out, DES_BLOCK_LEN, des3_decrypt_block, NULL);
                         if (rv == CRYPTO_DATA_LEN_RANGE)
                                 rv = CRYPTO_ENCRYPTED_DATA_LEN_RANGE;
                 }
         } else {
                 if (des_ctx->dc_flags & CBC_MODE) {
                         rv = cbc_decrypt_contiguous_blocks(ctx, data,
                             length, out, DES_BLOCK_LEN, des_decrypt_block,
-                            des_copy_block, des_xor_block);
+                            des_copy_block, des_xor_block, NULL, NULL);
                 } else {
                         rv = ecb_cipher_contiguous_blocks(ctx, data, length,
-                            out, DES_BLOCK_LEN, des_decrypt_block);
+                            out, DES_BLOCK_LEN, des_decrypt_block, NULL);
                         if (rv == CRYPTO_DATA_LEN_RANGE)
                                 rv = CRYPTO_ENCRYPTED_DATA_LEN_RANGE;
                 }
         }
         return (rv);