Print this page
4896 Performance improvements for KCF AES modes
*** 18,27 ****
--- 18,28 ----
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2015 by Saso Kiselkov. All rights reserved.
*/
#ifndef _KERNEL
#include <strings.h>
#include <limits.h>
*** 29,38 ****
--- 30,40 ----
#include <security/cryptoki.h>
#endif
#include <sys/types.h>
#include <sys/kmem.h>
+ #define INLINE_CRYPTO_GET_PTRS
#include <modes/modes.h>
#include <sys/crypto/common.h>
#include <sys/crypto/impl.h>
#include <sys/byteorder.h>
*** 46,57 ****
*/
int
ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
size_t remainder = length;
size_t need;
uint8_t *datap = (uint8_t *)data;
uint8_t *blockp;
--- 48,59 ----
*/
int
ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
size_t remainder = length;
size_t need;
uint8_t *datap = (uint8_t *)data;
uint8_t *blockp;
*** 204,214 ****
/* ARGSUSED */
int
ccm_encrypt_final(ccm_ctx_t *ctx, crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
uint8_t *lastp, *mac_buf, *ccm_mac_p, *macp;
void *iov_or_mp;
offset_t offset;
uint8_t *out_data_1;
--- 206,216 ----
/* ARGSUSED */
int
ccm_encrypt_final(ccm_ctx_t *ctx, crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
uint8_t *lastp, *mac_buf, *ccm_mac_p, *macp;
void *iov_or_mp;
offset_t offset;
uint8_t *out_data_1;
*** 357,368 ****
/* ARGSUSED */
int
ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
size_t remainder = length;
size_t need;
uint8_t *datap = (uint8_t *)data;
uint8_t *blockp;
--- 359,370 ----
/* ARGSUSED */
int
ccm_mode_decrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
size_t remainder = length;
size_t need;
uint8_t *datap = (uint8_t *)data;
uint8_t *blockp;
*** 524,535 ****
}
int
ccm_decrypt_final(ccm_ctx_t *ctx, crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
size_t mac_remain, pt_len;
uint8_t *pt, *mac_buf, *macp, *ccm_mac_p;
int rv;
--- 526,537 ----
}
int
ccm_decrypt_final(ccm_ctx_t *ctx, crypto_data_t *out, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*copy_block)(const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
size_t mac_remain, pt_len;
uint8_t *pt, *mac_buf, *macp, *ccm_mac_p;
int rv;
*** 768,778 ****
*/
int
ccm_init(ccm_ctx_t *ctx, unsigned char *nonce, size_t nonce_len,
unsigned char *auth_data, size_t auth_data_len, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
uint8_t *mac_buf, *datap, *ivp, *authp;
size_t remainder, processed;
uint8_t encoded_a[10]; /* max encoded auth data length is 10 octets */
size_t encoded_a_len = 0;
--- 770,780 ----
*/
int
ccm_init(ccm_ctx_t *ctx, unsigned char *nonce, size_t nonce_len,
unsigned char *auth_data, size_t auth_data_len, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
uint8_t *mac_buf, *datap, *ivp, *authp;
size_t remainder, processed;
uint8_t encoded_a[10]; /* max encoded auth data length is 10 octets */
size_t encoded_a_len = 0;
*** 852,862 ****
int
ccm_init_ctx(ccm_ctx_t *ccm_ctx, char *param, int kmflag,
boolean_t is_encrypt_init, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(uint8_t *, uint8_t *))
{
int rv;
CK_AES_CCM_PARAMS *ccm_param;
if (param != NULL) {
--- 854,864 ----
int
ccm_init_ctx(ccm_ctx_t *ccm_ctx, char *param, int kmflag,
boolean_t is_encrypt_init, size_t block_size,
int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
! void (*xor_block)(const uint8_t *, uint8_t *))
{
int rv;
CK_AES_CCM_PARAMS *ccm_param;
if (param != NULL) {