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


  47 
  48 extern struct mod_ops mod_miscops;
  49 extern struct mod_ops mod_cryptoops;
  50 
  51 /*
  52  * Module linkage information for the kernel.
  53  */
  54 
  55 static struct modlmisc modlmisc = {
  56         &mod_miscops,
  57         "MD5 Message-Digest Algorithm"
  58 };
  59 
  60 static struct modlcrypto modlcrypto = {
  61         &mod_cryptoops,
  62         "MD5 Kernel SW Provider"
  63 };
  64 
  65 static struct modlinkage modlinkage = {
  66         MODREV_1,
  67         (void *)&modlmisc,
  68         (void *)&modlcrypto,
  69         NULL
  70 };
  71 
  72 /*
  73  * CSPI information (entry points, provider info, etc.)
  74  */
  75 
  76 typedef enum md5_mech_type {
  77         MD5_MECH_INFO_TYPE,             /* SUN_CKM_MD5 */
  78         MD5_HMAC_MECH_INFO_TYPE,        /* SUN_CKM_MD5_HMAC */
  79         MD5_HMAC_GEN_MECH_INFO_TYPE     /* SUN_CKM_MD5_HMAC_GENERAL */
  80 } md5_mech_type_t;
  81 
  82 #define MD5_DIGEST_LENGTH       16      /* MD5 digest length in bytes */
  83 #define MD5_HMAC_BLOCK_SIZE     64      /* MD5 block size */
  84 #define MD5_HMAC_MIN_KEY_LEN    1       /* MD5-HMAC min key length in bytes */
  85 #define MD5_HMAC_MAX_KEY_LEN    INT_MAX /* MD5-HMAC max key length in bytes */
  86 #define MD5_HMAC_INTS_PER_BLOCK (MD5_HMAC_BLOCK_SIZE/sizeof (uint32_t))
  87 
  88 /*
  89  * Context for MD5 mechanism.


 189 static crypto_mac_ops_t md5_mac_ops = {
 190         md5_mac_init,
 191         NULL,
 192         md5_mac_update,
 193         md5_mac_final,
 194         md5_mac_atomic,
 195         md5_mac_verify_atomic
 196 };
 197 
 198 static int md5_create_ctx_template(crypto_provider_handle_t,
 199     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 200     size_t *, crypto_req_handle_t);
 201 static int md5_free_context(crypto_ctx_t *);
 202 
 203 static crypto_ctx_ops_t md5_ctx_ops = {
 204         md5_create_ctx_template,
 205         md5_free_context
 206 };
 207 
 208 static crypto_ops_t md5_crypto_ops = {
 209         &md5_control_ops,
 210         &md5_digest_ops,
 211         NULL,
 212         &md5_mac_ops,
 213         NULL,
 214         NULL,
 215         NULL,
 216         NULL,
 217         NULL,
 218         NULL,
 219         NULL,
 220         NULL,
 221         NULL,
 222         &md5_ctx_ops
 223 };
 224 
 225 static crypto_provider_info_t md5_prov_info = {
 226         CRYPTO_SPI_VERSION_1,
 227         "MD5 Software Provider",
 228         CRYPTO_SW_PROVIDER,
 229         {&modlinkage},
 230         NULL,
 231         &md5_crypto_ops,
 232         sizeof (md5_mech_info_tab)/sizeof (crypto_mech_info_t),
 233         md5_mech_info_tab
 234 };
 235 
 236 static crypto_kcf_provider_handle_t md5_prov_handle = NULL;
 237 
 238 int
 239 _init(void)
 240 {
 241         int ret;
 242 
 243         if ((ret = mod_install(&modlinkage)) != 0)
 244                 return (ret);
 245 
 246         /*
 247          * Register with KCF.  If the registration fails, do not uninstall the
 248          * module, since the functionality provided by misc/md5 should still be
 249          * available.
 250          */
 251         (void) crypto_register_provider(&md5_prov_info, &md5_prov_handle);
 252 
 253         return (0);
 254 }




  47 
  48 extern struct mod_ops mod_miscops;
  49 extern struct mod_ops mod_cryptoops;
  50 
  51 /*
  52  * Module linkage information for the kernel.
  53  */
  54 
  55 static struct modlmisc modlmisc = {
  56         &mod_miscops,
  57         "MD5 Message-Digest Algorithm"
  58 };
  59 
  60 static struct modlcrypto modlcrypto = {
  61         &mod_cryptoops,
  62         "MD5 Kernel SW Provider"
  63 };
  64 
  65 static struct modlinkage modlinkage = {
  66         MODREV_1,
  67         {   (void *)&modlmisc,
  68             (void *)&modlcrypto,
  69             NULL }
  70 };
  71 
  72 /*
  73  * CSPI information (entry points, provider info, etc.)
  74  */
  75 
  76 typedef enum md5_mech_type {
  77         MD5_MECH_INFO_TYPE,             /* SUN_CKM_MD5 */
  78         MD5_HMAC_MECH_INFO_TYPE,        /* SUN_CKM_MD5_HMAC */
  79         MD5_HMAC_GEN_MECH_INFO_TYPE     /* SUN_CKM_MD5_HMAC_GENERAL */
  80 } md5_mech_type_t;
  81 
  82 #define MD5_DIGEST_LENGTH       16      /* MD5 digest length in bytes */
  83 #define MD5_HMAC_BLOCK_SIZE     64      /* MD5 block size */
  84 #define MD5_HMAC_MIN_KEY_LEN    1       /* MD5-HMAC min key length in bytes */
  85 #define MD5_HMAC_MAX_KEY_LEN    INT_MAX /* MD5-HMAC max key length in bytes */
  86 #define MD5_HMAC_INTS_PER_BLOCK (MD5_HMAC_BLOCK_SIZE/sizeof (uint32_t))
  87 
  88 /*
  89  * Context for MD5 mechanism.


 189 static crypto_mac_ops_t md5_mac_ops = {
 190         md5_mac_init,
 191         NULL,
 192         md5_mac_update,
 193         md5_mac_final,
 194         md5_mac_atomic,
 195         md5_mac_verify_atomic
 196 };
 197 
 198 static int md5_create_ctx_template(crypto_provider_handle_t,
 199     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 200     size_t *, crypto_req_handle_t);
 201 static int md5_free_context(crypto_ctx_t *);
 202 
 203 static crypto_ctx_ops_t md5_ctx_ops = {
 204         md5_create_ctx_template,
 205         md5_free_context
 206 };
 207 
 208 static crypto_ops_t md5_crypto_ops = {
 209         .co_control_ops = &md5_control_ops,
 210         .co_digest_ops = &md5_digest_ops,
 211         .co_cipher_ops = NULL,
 212         .co_mac_ops = &md5_mac_ops,
 213         .co_sign_ops = NULL,
 214         .co_verify_ops = NULL,
 215         .co_dual_ops = NULL,
 216         .co_dual_cipher_mac_ops = NULL,
 217         .co_random_ops = NULL,
 218         .co_session_ops = NULL,
 219         .co_object_ops = NULL,
 220         .co_key_ops = NULL,
 221         .co_provider_ops = NULL,
 222         .co_ctx_ops = &md5_ctx_ops
 223 };
 224 
 225 static crypto_provider_info_t md5_prov_info = {{{{
 226         CRYPTO_SPI_VERSION_1,
 227         "MD5 Software Provider",
 228         CRYPTO_SW_PROVIDER,
 229         {&modlinkage},
 230         NULL,
 231         &md5_crypto_ops,
 232         sizeof (md5_mech_info_tab)/sizeof (crypto_mech_info_t),
 233         md5_mech_info_tab
 234 }}}};
 235 
 236 static crypto_kcf_provider_handle_t md5_prov_handle = NULL;
 237 
 238 int
 239 _init(void)
 240 {
 241         int ret;
 242 
 243         if ((ret = mod_install(&modlinkage)) != 0)
 244                 return (ret);
 245 
 246         /*
 247          * Register with KCF.  If the registration fails, do not uninstall the
 248          * module, since the functionality provided by misc/md5 should still be
 249          * available.
 250          */
 251         (void) crypto_register_provider(&md5_prov_info, &md5_prov_handle);
 252 
 253         return (0);
 254 }