Print this page
fixup .text where possible
7127  remove -Wno-missing-braces from Makefile.uts


  45 #include <sys/kmem.h>
  46 #include <sys/kstat.h>
  47 
  48 #include <des/des_impl.h>
  49 #include <ecc/ecc_impl.h>
  50 
  51 #define CKD_NULL                0x00000001
  52 
  53 extern struct mod_ops mod_cryptoops;
  54 
  55 /*
  56  * Module linkage information for the kernel.
  57  */
  58 static struct modlcrypto modlcrypto = {
  59         &mod_cryptoops,
  60         "EC Kernel SW Provider"
  61 };
  62 
  63 static struct modlinkage modlinkage = {
  64         MODREV_1,
  65         (void *)&modlcrypto,
  66         NULL
  67 };
  68 
  69 /*
  70  * CSPI information (entry points, provider info, etc.)
  71  */
  72 typedef enum ecc_mech_type {
  73         EC_KEY_PAIR_GEN_MECH_INFO_TYPE, /* SUN_CKM_EC_KEY_PAIR_GEN */
  74         ECDSA_MECH_INFO_TYPE,           /* SUN_CKM_ECDSA */
  75         ECDSA_SHA1_MECH_INFO_TYPE,      /* SUN_CKM_ECDSA_SHA1 */
  76         ECDH1_DERIVE_MECH_INFO_TYPE     /* SUN_CKM_ECDH1_DERIVE */
  77 } ecc_mech_type_t;
  78 
  79 /*
  80  * Context for ECDSA mechanism.
  81  */
  82 typedef struct ecc_ctx {
  83         ecc_mech_type_t mech_type;
  84         crypto_key_t *key;
  85         size_t keychunk_size;
  86         ECParams ecparams;


 174         NULL,
 175         NULL,
 176         NULL
 177 };
 178 
 179 static int ecc_nostore_key_generate_pair(crypto_provider_handle_t,
 180     crypto_session_id_t, crypto_mechanism_t *, crypto_object_attribute_t *,
 181     uint_t, crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
 182     uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
 183 static int ecc_nostore_key_derive(crypto_provider_handle_t,
 184     crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
 185     crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
 186     uint_t, crypto_req_handle_t);
 187 
 188 static crypto_nostore_key_ops_t ecc_nostore_key_ops = {
 189         NULL,
 190         ecc_nostore_key_generate_pair,
 191         ecc_nostore_key_derive
 192 };
 193 
 194 static crypto_ops_t ecc_crypto_ops = {
 195         &ecc_control_ops,
 196         NULL,
 197         NULL,
 198         NULL,
 199         &ecc_sign_ops,
 200         &ecc_verify_ops,
 201         NULL,
 202         NULL,
 203         NULL,
 204         NULL,
 205         NULL,
 206         NULL,
 207         NULL,
 208         NULL,
 209         NULL,
 210         &ecc_nostore_key_ops,
 211         NULL,
 212 };
 213 
 214 static crypto_provider_info_t ecc_prov_info = {
 215         CRYPTO_SPI_VERSION_4,
 216         "EC Software Provider",
 217         CRYPTO_SW_PROVIDER,
 218         {&modlinkage},
 219         NULL,
 220         &ecc_crypto_ops,
 221         sizeof (ecc_mech_info_tab)/sizeof (crypto_mech_info_t),
 222         ecc_mech_info_tab
 223 };
 224 
 225 static crypto_kcf_provider_handle_t ecc_prov_handle = NULL;
 226 
 227 static int ecc_sign_common(ecc_ctx_t *, crypto_data_t *, crypto_data_t *,
 228     crypto_req_handle_t);
 229 static int ecc_verify_common(ecc_ctx_t *, crypto_data_t *, crypto_data_t *,
 230     crypto_req_handle_t);
 231 static int find_attr(crypto_object_attribute_t *, uint_t, uint64_t);
 232 static int get_template_attr_ulong(crypto_object_attribute_t *,
 233     uint_t, uint64_t, ulong_t *);
 234 static void ecc_free_context(crypto_ctx_t *);
 235 static void free_ecparams(ECParams *, boolean_t);
 236 static void free_ecprivkey(ECPrivateKey *);
 237 
 238 int
 239 _init(void)
 240 {
 241         int ret;
 242 
 243         if ((ret = mod_install(&modlinkage)) != 0)




  45 #include <sys/kmem.h>
  46 #include <sys/kstat.h>
  47 
  48 #include <des/des_impl.h>
  49 #include <ecc/ecc_impl.h>
  50 
  51 #define CKD_NULL                0x00000001
  52 
  53 extern struct mod_ops mod_cryptoops;
  54 
  55 /*
  56  * Module linkage information for the kernel.
  57  */
  58 static struct modlcrypto modlcrypto = {
  59         &mod_cryptoops,
  60         "EC Kernel SW Provider"
  61 };
  62 
  63 static struct modlinkage modlinkage = {
  64         MODREV_1,
  65         {   (void *)&modlcrypto,
  66             NULL }
  67 };
  68 
  69 /*
  70  * CSPI information (entry points, provider info, etc.)
  71  */
  72 typedef enum ecc_mech_type {
  73         EC_KEY_PAIR_GEN_MECH_INFO_TYPE, /* SUN_CKM_EC_KEY_PAIR_GEN */
  74         ECDSA_MECH_INFO_TYPE,           /* SUN_CKM_ECDSA */
  75         ECDSA_SHA1_MECH_INFO_TYPE,      /* SUN_CKM_ECDSA_SHA1 */
  76         ECDH1_DERIVE_MECH_INFO_TYPE     /* SUN_CKM_ECDH1_DERIVE */
  77 } ecc_mech_type_t;
  78 
  79 /*
  80  * Context for ECDSA mechanism.
  81  */
  82 typedef struct ecc_ctx {
  83         ecc_mech_type_t mech_type;
  84         crypto_key_t *key;
  85         size_t keychunk_size;
  86         ECParams ecparams;


 174         NULL,
 175         NULL,
 176         NULL
 177 };
 178 
 179 static int ecc_nostore_key_generate_pair(crypto_provider_handle_t,
 180     crypto_session_id_t, crypto_mechanism_t *, crypto_object_attribute_t *,
 181     uint_t, crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
 182     uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
 183 static int ecc_nostore_key_derive(crypto_provider_handle_t,
 184     crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
 185     crypto_object_attribute_t *, uint_t, crypto_object_attribute_t *,
 186     uint_t, crypto_req_handle_t);
 187 
 188 static crypto_nostore_key_ops_t ecc_nostore_key_ops = {
 189         NULL,
 190         ecc_nostore_key_generate_pair,
 191         ecc_nostore_key_derive
 192 };
 193 
 194 static crypto_ops_t ecc_crypto_ops = {{{{{{
 195                                 &ecc_control_ops,
 196                                 NULL,
 197                                 NULL,
 198                                 NULL,
 199                                 &ecc_sign_ops,
 200                                 &ecc_verify_ops,
 201                                 NULL,
 202                                 NULL,
 203                                 NULL,
 204                                 NULL,
 205                                 NULL,
 206                                 NULL,
 207                                 NULL,
 208                                 NULL }, /* cou_v1 */
 209                         NULL },         /* cou_v2 */
 210                 &ecc_nostore_key_ops },     /* cou_v3 */
 211         NULL },                         /* cou_v4 */
 212 }};
 213 
 214 static crypto_provider_info_t ecc_prov_info = {{{{
 215         CRYPTO_SPI_VERSION_4,
 216         "EC Software Provider",
 217         CRYPTO_SW_PROVIDER,
 218         {&modlinkage},
 219         NULL,
 220         &ecc_crypto_ops,
 221         sizeof (ecc_mech_info_tab)/sizeof (crypto_mech_info_t),
 222         ecc_mech_info_tab
 223 }}}};
 224 
 225 static crypto_kcf_provider_handle_t ecc_prov_handle = NULL;
 226 
 227 static int ecc_sign_common(ecc_ctx_t *, crypto_data_t *, crypto_data_t *,
 228     crypto_req_handle_t);
 229 static int ecc_verify_common(ecc_ctx_t *, crypto_data_t *, crypto_data_t *,
 230     crypto_req_handle_t);
 231 static int find_attr(crypto_object_attribute_t *, uint_t, uint64_t);
 232 static int get_template_attr_ulong(crypto_object_attribute_t *,
 233     uint_t, uint64_t, ulong_t *);
 234 static void ecc_free_context(crypto_ctx_t *);
 235 static void free_ecparams(ECParams *, boolean_t);
 236 static void free_ecprivkey(ECPrivateKey *);
 237 
 238 int
 239 _init(void)
 240 {
 241         int ret;
 242 
 243         if ((ret = mod_install(&modlinkage)) != 0)