Print this page
4896 Performance improvements for KCF AES modes


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */



  25 
  26 #ifndef _DES_IMPL_H
  27 #define _DES_IMPL_H
  28 
  29 /*
  30  * Common definitions used by DES
  31  */
  32 
  33 #ifdef  __cplusplus
  34 extern "C" {
  35 #endif
  36 
  37 #define DES_BLOCK_LEN   8
  38 
  39 #define DES_COPY_BLOCK(src, dst) \
  40         (dst)[0] = (src)[0]; \
  41         (dst)[1] = (src)[1]; \
  42         (dst)[2] = (src)[2]; \
  43         (dst)[3] = (src)[3]; \
  44         (dst)[4] = (src)[4]; \


  80 #define DES3_KEYSIZE    (3 * DES_KEYSIZE)
  81 #define DES3_MINBITS    (2 * DES_MINBITS)       /* DES3 handles CKK_DES2 keys */
  82 #define DES3_MAXBITS    (3 * DES_MAXBITS)
  83 #define DES3_MINBYTES   (DES3_MINBITS / 8)
  84 #define DES3_MAXBYTES   (DES3_MAXBITS / 8)
  85 
  86 extern int des_encrypt_contiguous_blocks(void *, char *, size_t,
  87     crypto_data_t *);
  88 extern int des_decrypt_contiguous_blocks(void *, char *, size_t,
  89     crypto_data_t *);
  90 extern uint64_t des_crypt_impl(uint64_t *, uint64_t, int);
  91 extern void des_ks(uint64_t *, uint64_t);
  92 extern int des_crunch_block(const void *, const uint8_t *, uint8_t *,
  93     boolean_t);
  94 extern int des3_crunch_block(const void *, const uint8_t *, uint8_t *,
  95     boolean_t);
  96 extern void des_init_keysched(uint8_t *, des_strength_t, void *);
  97 extern void *des_alloc_keysched(size_t *, des_strength_t, int);
  98 extern boolean_t des_keycheck(uint8_t *, des_strength_t, uint8_t *);
  99 extern void des_parity_fix(uint8_t *, des_strength_t, uint8_t *);
 100 extern void des_copy_block(uint8_t *, uint8_t *);
 101 extern void des_xor_block(uint8_t *, uint8_t *);
 102 extern int des_encrypt_block(const void *, const uint8_t *, uint8_t *);
 103 extern int des3_encrypt_block(const void *, const uint8_t *, uint8_t *);
 104 extern int des_decrypt_block(const void *, const uint8_t *, uint8_t *);
 105 extern int des3_decrypt_block(const void *, const uint8_t *, uint8_t *);
 106 
 107 #ifdef _DES_IMPL
 108 
 109 #ifdef _KERNEL
 110 typedef enum des_mech_type {
 111         DES_ECB_MECH_INFO_TYPE,         /* SUN_CKM_DES_ECB */
 112         DES_CBC_MECH_INFO_TYPE,         /* SUN_CKM_DES_CBC */
 113         DES_CFB_MECH_INFO_TYPE,         /* SUN_CKM_DES_CFB */
 114         DES3_ECB_MECH_INFO_TYPE,        /* SUN_CKM_DES3_ECB */
 115         DES3_CBC_MECH_INFO_TYPE,        /* SUN_CKM_DES3_CBC */
 116         DES3_CFB_MECH_INFO_TYPE         /* SUN_CKM_DES3_CFB */
 117 } des_mech_type_t;
 118 
 119 #endif  /* _KERNEL */
 120 #endif  /* _DES_IMPL */
 121 


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2015 by Saso Kiselkov. All rights reserved.
  27  */
  28 
  29 #ifndef _DES_IMPL_H
  30 #define _DES_IMPL_H
  31 
  32 /*
  33  * Common definitions used by DES
  34  */
  35 
  36 #ifdef  __cplusplus
  37 extern "C" {
  38 #endif
  39 
  40 #define DES_BLOCK_LEN   8
  41 
  42 #define DES_COPY_BLOCK(src, dst) \
  43         (dst)[0] = (src)[0]; \
  44         (dst)[1] = (src)[1]; \
  45         (dst)[2] = (src)[2]; \
  46         (dst)[3] = (src)[3]; \
  47         (dst)[4] = (src)[4]; \


  83 #define DES3_KEYSIZE    (3 * DES_KEYSIZE)
  84 #define DES3_MINBITS    (2 * DES_MINBITS)       /* DES3 handles CKK_DES2 keys */
  85 #define DES3_MAXBITS    (3 * DES_MAXBITS)
  86 #define DES3_MINBYTES   (DES3_MINBITS / 8)
  87 #define DES3_MAXBYTES   (DES3_MAXBITS / 8)
  88 
  89 extern int des_encrypt_contiguous_blocks(void *, char *, size_t,
  90     crypto_data_t *);
  91 extern int des_decrypt_contiguous_blocks(void *, char *, size_t,
  92     crypto_data_t *);
  93 extern uint64_t des_crypt_impl(uint64_t *, uint64_t, int);
  94 extern void des_ks(uint64_t *, uint64_t);
  95 extern int des_crunch_block(const void *, const uint8_t *, uint8_t *,
  96     boolean_t);
  97 extern int des3_crunch_block(const void *, const uint8_t *, uint8_t *,
  98     boolean_t);
  99 extern void des_init_keysched(uint8_t *, des_strength_t, void *);
 100 extern void *des_alloc_keysched(size_t *, des_strength_t, int);
 101 extern boolean_t des_keycheck(uint8_t *, des_strength_t, uint8_t *);
 102 extern void des_parity_fix(uint8_t *, des_strength_t, uint8_t *);
 103 extern void des_copy_block(const uint8_t *, uint8_t *);
 104 extern void des_xor_block(const uint8_t *, uint8_t *);
 105 extern int des_encrypt_block(const void *, const uint8_t *, uint8_t *);
 106 extern int des3_encrypt_block(const void *, const uint8_t *, uint8_t *);
 107 extern int des_decrypt_block(const void *, const uint8_t *, uint8_t *);
 108 extern int des3_decrypt_block(const void *, const uint8_t *, uint8_t *);
 109 
 110 #ifdef _DES_IMPL
 111 
 112 #ifdef _KERNEL
 113 typedef enum des_mech_type {
 114         DES_ECB_MECH_INFO_TYPE,         /* SUN_CKM_DES_ECB */
 115         DES_CBC_MECH_INFO_TYPE,         /* SUN_CKM_DES_CBC */
 116         DES_CFB_MECH_INFO_TYPE,         /* SUN_CKM_DES_CFB */
 117         DES3_ECB_MECH_INFO_TYPE,        /* SUN_CKM_DES3_ECB */
 118         DES3_CBC_MECH_INFO_TYPE,        /* SUN_CKM_DES3_CBC */
 119         DES3_CFB_MECH_INFO_TYPE         /* SUN_CKM_DES3_CFB */
 120 } des_mech_type_t;
 121 
 122 #endif  /* _KERNEL */
 123 #endif  /* _DES_IMPL */
 124