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.
+ */
 
 #ifndef _KERNEL
 #include <stdlib.h>
 #endif
 

@@ -76,98 +79,11 @@
 
         }
         } /* end switch */
 }
 
-/*
- * Get pointers for where in the output to copy a block of encrypted or
- * decrypted data.  The iov_or_mp argument stores a pointer to the current
- * iovec or mp, and offset stores an offset into the current iovec or mp.
- */
 void
-crypto_get_ptrs(crypto_data_t *out, void **iov_or_mp, offset_t *current_offset,
-    uint8_t **out_data_1, size_t *out_data_1_len, uint8_t **out_data_2,
-    size_t amt)
-{
-        offset_t offset;
-
-        switch (out->cd_format) {
-        case CRYPTO_DATA_RAW: {
-                iovec_t *iov;
-
-                offset = *current_offset;
-                iov = &out->cd_raw;
-                if ((offset + amt) <= iov->iov_len) {
-                        /* one block fits */
-                        *out_data_1 = (uint8_t *)iov->iov_base + offset;
-                        *out_data_1_len = amt;
-                        *out_data_2 = NULL;
-                        *current_offset = offset + amt;
-                }
-                break;
-        }
-
-        case CRYPTO_DATA_UIO: {
-                uio_t *uio = out->cd_uio;
-                iovec_t *iov;
-                offset_t offset;
-                uintptr_t vec_idx;
-                uint8_t *p;
-
-                offset = *current_offset;
-                vec_idx = (uintptr_t)(*iov_or_mp);
-                iov = &uio->uio_iov[vec_idx];
-                p = (uint8_t *)iov->iov_base + offset;
-                *out_data_1 = p;
-
-                if (offset + amt <= iov->iov_len) {
-                        /* can fit one block into this iov */
-                        *out_data_1_len = amt;
-                        *out_data_2 = NULL;
-                        *current_offset = offset + amt;
-                } else {
-                        /* one block spans two iovecs */
-                        *out_data_1_len = iov->iov_len - offset;
-                        if (vec_idx == uio->uio_iovcnt)
-                                return;
-                        vec_idx++;
-                        iov = &uio->uio_iov[vec_idx];
-                        *out_data_2 = (uint8_t *)iov->iov_base;
-                        *current_offset = amt - *out_data_1_len;
-                }
-                *iov_or_mp = (void *)vec_idx;
-                break;
-        }
-
-        case CRYPTO_DATA_MBLK: {
-                mblk_t *mp;
-                uint8_t *p;
-
-                offset = *current_offset;
-                mp = (mblk_t *)*iov_or_mp;
-                p = mp->b_rptr + offset;
-                *out_data_1 = p;
-                if ((p + amt) <= mp->b_wptr) {
-                        /* can fit one block into this mblk */
-                        *out_data_1_len = amt;
-                        *out_data_2 = NULL;
-                        *current_offset = offset + amt;
-                } else {
-                        /* one block spans two mblks */
-                        *out_data_1_len = _PTRDIFF(mp->b_wptr, p);
-                        if ((mp = mp->b_cont) == NULL)
-                                return;
-                        *out_data_2 = mp->b_rptr;
-                        *current_offset = (amt - *out_data_1_len);
-                }
-                *iov_or_mp = mp;
-                break;
-        }
-        } /* end switch */
-}
-
-void
 crypto_free_mode_ctx(void *ctx)
 {
         common_ctx_t *common_ctx = (common_ctx_t *)ctx;
 
         switch (common_ctx->cc_flags &

@@ -211,17 +127,11 @@
                 break;
 
         case GCM_MODE:
         case GMAC_MODE:
 #ifdef _KERNEL
-                if (((gcm_ctx_t *)ctx)->gcm_pt_buf != NULL)
-                        kmem_free(((gcm_ctx_t *)ctx)->gcm_pt_buf,
-                            ((gcm_ctx_t *)ctx)->gcm_pt_buf_len);
-
                 kmem_free(ctx, sizeof (gcm_ctx_t));
 #else
-                if (((gcm_ctx_t *)ctx)->gcm_pt_buf != NULL)
-                        free(((gcm_ctx_t *)ctx)->gcm_pt_buf);
                 free(ctx);
 #endif
         }
 }