Print this page
6189743 Need an ARCFOUR implementation optimized for AMD64


   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   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 2007 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _SYS_CRYPTO_COMMON_H
  27 #define _SYS_CRYPTO_COMMON_H
  28 
  29 #pragma ident   "@(#)common.h   1.24    07/12/10 SMI"
  30 
  31 /*
  32  * Header file for the common data structures of the cryptographic framework
  33  */
  34 
  35 #ifdef __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 #include <sys/types.h>
  40 #include <sys/uio.h>
  41 #include <sys/stream.h>
  42 #include <sys/mutex.h>
  43 #include <sys/condvar.h>
  44 
  45 
  46 /* Cryptographic Mechanisms */
  47 
  48 #define CRYPTO_MAX_MECH_NAME 32
  49 typedef char crypto_mech_name_t[CRYPTO_MAX_MECH_NAME];


 168 #define SUN_CKM_BLOWFISH_CBC            "CKM_BLOWFISH_CBC"
 169 #define SUN_CKM_BLOWFISH_ECB            "CKM_BLOWFISH_ECB"
 170 #define SUN_CKM_AES_CBC                 "CKM_AES_CBC"
 171 #define SUN_CKM_AES_ECB                 "CKM_AES_ECB"
 172 #define SUN_CKM_AES_CTR                 "CKM_AES_CTR"
 173 #define SUN_CKM_AES_CCM                 "CKM_AES_CCM"
 174 #define SUN_CKM_RC4                     "CKM_RC4"
 175 #define SUN_CKM_RSA_PKCS                "CKM_RSA_PKCS"
 176 #define SUN_CKM_RSA_X_509               "CKM_RSA_X_509"
 177 #define SUN_CKM_MD5_RSA_PKCS            "CKM_MD5_RSA_PKCS"
 178 #define SUN_CKM_SHA1_RSA_PKCS           "CKM_SHA1_RSA_PKCS"
 179 #define SUN_CKM_SHA256_RSA_PKCS         "CKM_SHA256_RSA_PKCS"
 180 #define SUN_CKM_SHA384_RSA_PKCS         "CKM_SHA384_RSA_PKCS"
 181 #define SUN_CKM_SHA512_RSA_PKCS         "CKM_SHA512_RSA_PKCS"
 182 #define SUN_CKM_EC_KEY_PAIR_GEN         "CKM_EC_KEY_PAIR_GEN"
 183 #define SUN_CKM_ECDH1_DERIVE            "CKM_ECDH1_DERIVE"
 184 #define SUN_CKM_ECDSA_SHA1              "CKM_ECDSA_SHA1"
 185 #define SUN_CKM_ECDSA                   "CKM_ECDSA"
 186 
 187 /* Shared operation context format for CKM_RC4 */






 188 typedef struct {
 189         uchar_t arr[256];
 190         uchar_t i, j;
 191         uint64_t pad;           /* For 64-bit alignment */
 192 } arcfour_state_t;
 193 
 194 
 195 /* Data arguments of cryptographic operations */
 196 
 197 typedef enum crypto_data_format {
 198         CRYPTO_DATA_RAW = 1,
 199         CRYPTO_DATA_UIO,
 200         CRYPTO_DATA_MBLK
 201 } crypto_data_format_t;
 202 
 203 typedef struct crypto_data {
 204         crypto_data_format_t    cd_format;      /* Format identifier    */
 205         off_t                   cd_offset;      /* Offset from the beginning */
 206         size_t                  cd_length;      /* # of bytes in use */
 207         caddr_t                 cd_miscdata;    /* ancillary data */
 208         union {
 209                 /* Raw format */
 210                 iovec_t cdu_raw;                /* Pointer and length       */
 211 
 212                 /* uio scatter-gather format */
 213                 uio_t   *cdu_uio;
 214 




   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   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 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _SYS_CRYPTO_COMMON_H
  27 #define _SYS_CRYPTO_COMMON_H
  28 
  29 #pragma ident   "@(#)common.h   1.25    08/01/02 SMI"
  30 
  31 /*
  32  * Header file for the common data structures of the cryptographic framework
  33  */
  34 
  35 #ifdef __cplusplus
  36 extern "C" {
  37 #endif
  38 
  39 #include <sys/types.h>
  40 #include <sys/uio.h>
  41 #include <sys/stream.h>
  42 #include <sys/mutex.h>
  43 #include <sys/condvar.h>
  44 
  45 
  46 /* Cryptographic Mechanisms */
  47 
  48 #define CRYPTO_MAX_MECH_NAME 32
  49 typedef char crypto_mech_name_t[CRYPTO_MAX_MECH_NAME];


 168 #define SUN_CKM_BLOWFISH_CBC            "CKM_BLOWFISH_CBC"
 169 #define SUN_CKM_BLOWFISH_ECB            "CKM_BLOWFISH_ECB"
 170 #define SUN_CKM_AES_CBC                 "CKM_AES_CBC"
 171 #define SUN_CKM_AES_ECB                 "CKM_AES_ECB"
 172 #define SUN_CKM_AES_CTR                 "CKM_AES_CTR"
 173 #define SUN_CKM_AES_CCM                 "CKM_AES_CCM"
 174 #define SUN_CKM_RC4                     "CKM_RC4"
 175 #define SUN_CKM_RSA_PKCS                "CKM_RSA_PKCS"
 176 #define SUN_CKM_RSA_X_509               "CKM_RSA_X_509"
 177 #define SUN_CKM_MD5_RSA_PKCS            "CKM_MD5_RSA_PKCS"
 178 #define SUN_CKM_SHA1_RSA_PKCS           "CKM_SHA1_RSA_PKCS"
 179 #define SUN_CKM_SHA256_RSA_PKCS         "CKM_SHA256_RSA_PKCS"
 180 #define SUN_CKM_SHA384_RSA_PKCS         "CKM_SHA384_RSA_PKCS"
 181 #define SUN_CKM_SHA512_RSA_PKCS         "CKM_SHA512_RSA_PKCS"
 182 #define SUN_CKM_EC_KEY_PAIR_GEN         "CKM_EC_KEY_PAIR_GEN"
 183 #define SUN_CKM_ECDH1_DERIVE            "CKM_ECDH1_DERIVE"
 184 #define SUN_CKM_ECDSA_SHA1              "CKM_ECDSA_SHA1"
 185 #define SUN_CKM_ECDSA                   "CKM_ECDSA"
 186 
 187 /* Shared operation context format for CKM_RC4 */
 188 #if defined(__amd64)
 189 typedef uint64_t arcfour_key_int_t;
 190 #else
 191 typedef uchar_t arcfour_key_int_t;
 192 #endif /* __amd64 */
 193 
 194 typedef struct {
 195         arcfour_key_int_t arr[256];
 196         arcfour_key_int_t i, j;
 197         uint64_t pad;           /* For 64-bit alignment */
 198 } arcfour_state_t;
 199 

 200 /* Data arguments of cryptographic operations */
 201 
 202 typedef enum crypto_data_format {
 203         CRYPTO_DATA_RAW = 1,
 204         CRYPTO_DATA_UIO,
 205         CRYPTO_DATA_MBLK
 206 } crypto_data_format_t;
 207 
 208 typedef struct crypto_data {
 209         crypto_data_format_t    cd_format;      /* Format identifier    */
 210         off_t                   cd_offset;      /* Offset from the beginning */
 211         size_t                  cd_length;      /* # of bytes in use */
 212         caddr_t                 cd_miscdata;    /* ancillary data */
 213         union {
 214                 /* Raw format */
 215                 iovec_t cdu_raw;                /* Pointer and length       */
 216 
 217                 /* uio scatter-gather format */
 218                 uio_t   *cdu_uio;
 219