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


  43 #include <sys/crypto/spi.h>
  44 #include <sys/sysmacros.h>
  45 #include <sys/strsun.h>
  46 #include <sys/note.h>
  47 #include <sys/md4.h>
  48 
  49 extern struct mod_ops mod_miscops;
  50 extern struct mod_ops mod_cryptoops;
  51 
  52 /*
  53  * Module linkage information for the kernel.
  54  */
  55 
  56 static struct modlcrypto modlcrypto = {
  57         &mod_cryptoops,
  58         "MD4 Kernel SW Provider"
  59 };
  60 
  61 static struct modlinkage modlinkage = {
  62         MODREV_1,
  63         (void *)&modlcrypto,
  64         NULL
  65 };
  66 
  67 /*
  68  * CSPI information (entry points, provider info, etc.)
  69  */
  70 
  71 typedef enum md4_mech_type {
  72         MD4_MECH_INFO_TYPE,             /* SUN_CKM_MD4 */
  73 } md4_mech_type_t;
  74 
  75 #define MD4_DIGEST_LENGTH       16      /* MD4 digest length in bytes */
  76 
  77 /*
  78  * Context for MD4 mechanism.
  79  */
  80 typedef struct md4_ctx {
  81         md4_mech_type_t         mc_mech_type;   /* type of context */
  82         MD4_CTX                 mc_md4_ctx;     /* MD4 context */
  83 } md4_ctx_t;
  84 


 110 static int md4_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
 111     crypto_req_handle_t);
 112 static int md4_digest_update(crypto_ctx_t *, crypto_data_t *,
 113     crypto_req_handle_t);
 114 static int md4_digest_final(crypto_ctx_t *, crypto_data_t *,
 115     crypto_req_handle_t);
 116 static int md4_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
 117     crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
 118     crypto_req_handle_t);
 119 
 120 static crypto_digest_ops_t md4_digest_ops = {
 121         md4_digest_init,
 122         md4_digest,
 123         md4_digest_update,
 124         NULL,
 125         md4_digest_final,
 126         md4_digest_atomic
 127 };
 128 
 129 static crypto_ops_t md4_crypto_ops = {
 130         &md4_control_ops,
 131         &md4_digest_ops,
 132         NULL,
 133         NULL,
 134         NULL,
 135         NULL,
 136         NULL,
 137         NULL,
 138         NULL,
 139         NULL,
 140         NULL,
 141         NULL,
 142         NULL,
 143         NULL,
 144 };
 145 
 146 static crypto_provider_info_t md4_prov_info = {
 147         CRYPTO_SPI_VERSION_1,
 148         "MD4 Software Provider",
 149         CRYPTO_SW_PROVIDER,
 150         {&modlinkage},
 151         NULL,
 152         &md4_crypto_ops,
 153         sizeof (md4_mech_info_tab)/sizeof (crypto_mech_info_t),
 154         md4_mech_info_tab
 155 };
 156 
 157 static crypto_kcf_provider_handle_t md4_prov_handle = NULL;
 158 
 159 int
 160 _init(void)
 161 {
 162         int ret;
 163 
 164         if ((ret = mod_install(&modlinkage)) != 0)
 165                 return (ret);
 166 
 167         /* Register with KCF.  If the registration fails, remove the module. */
 168         if (crypto_register_provider(&md4_prov_info, &md4_prov_handle)) {
 169                 (void) mod_remove(&modlinkage);
 170                 return (EACCES);
 171         }
 172 
 173         return (0);
 174 }
 175 




  43 #include <sys/crypto/spi.h>
  44 #include <sys/sysmacros.h>
  45 #include <sys/strsun.h>
  46 #include <sys/note.h>
  47 #include <sys/md4.h>
  48 
  49 extern struct mod_ops mod_miscops;
  50 extern struct mod_ops mod_cryptoops;
  51 
  52 /*
  53  * Module linkage information for the kernel.
  54  */
  55 
  56 static struct modlcrypto modlcrypto = {
  57         &mod_cryptoops,
  58         "MD4 Kernel SW Provider"
  59 };
  60 
  61 static struct modlinkage modlinkage = {
  62         MODREV_1,
  63         {   (void *)&modlcrypto,
  64             NULL }
  65 };
  66 
  67 /*
  68  * CSPI information (entry points, provider info, etc.)
  69  */
  70 
  71 typedef enum md4_mech_type {
  72         MD4_MECH_INFO_TYPE,             /* SUN_CKM_MD4 */
  73 } md4_mech_type_t;
  74 
  75 #define MD4_DIGEST_LENGTH       16      /* MD4 digest length in bytes */
  76 
  77 /*
  78  * Context for MD4 mechanism.
  79  */
  80 typedef struct md4_ctx {
  81         md4_mech_type_t         mc_mech_type;   /* type of context */
  82         MD4_CTX                 mc_md4_ctx;     /* MD4 context */
  83 } md4_ctx_t;
  84 


 110 static int md4_digest(crypto_ctx_t *, crypto_data_t *, crypto_data_t *,
 111     crypto_req_handle_t);
 112 static int md4_digest_update(crypto_ctx_t *, crypto_data_t *,
 113     crypto_req_handle_t);
 114 static int md4_digest_final(crypto_ctx_t *, crypto_data_t *,
 115     crypto_req_handle_t);
 116 static int md4_digest_atomic(crypto_provider_handle_t, crypto_session_id_t,
 117     crypto_mechanism_t *, crypto_data_t *, crypto_data_t *,
 118     crypto_req_handle_t);
 119 
 120 static crypto_digest_ops_t md4_digest_ops = {
 121         md4_digest_init,
 122         md4_digest,
 123         md4_digest_update,
 124         NULL,
 125         md4_digest_final,
 126         md4_digest_atomic
 127 };
 128 
 129 static crypto_ops_t md4_crypto_ops = {
 130         .co_control_ops = &md4_control_ops,
 131         .co_digest_ops = &md4_digest_ops,
 132         .co_cipher_ops = NULL,
 133         .co_mac_ops = NULL,
 134         .co_sign_ops = NULL,
 135         .co_verify_ops = NULL,
 136         .co_dual_ops = NULL,
 137         .co_dual_cipher_mac_ops = NULL,
 138         .co_random_ops = NULL,
 139         .co_session_ops = NULL,
 140         .co_object_ops = NULL,
 141         .co_key_ops = NULL,
 142         .co_provider_ops = NULL,
 143         .co_ctx_ops = NULL
 144 };
 145 
 146 static crypto_provider_info_t md4_prov_info = {{{{
 147         CRYPTO_SPI_VERSION_1,
 148         "MD4 Software Provider",
 149         CRYPTO_SW_PROVIDER,
 150         {&modlinkage},
 151         NULL,
 152         &md4_crypto_ops,
 153         sizeof (md4_mech_info_tab)/sizeof (crypto_mech_info_t),
 154         md4_mech_info_tab
 155 }}}};
 156 
 157 static crypto_kcf_provider_handle_t md4_prov_handle = NULL;
 158 
 159 int
 160 _init(void)
 161 {
 162         int ret;
 163 
 164         if ((ret = mod_install(&modlinkage)) != 0)
 165                 return (ret);
 166 
 167         /* Register with KCF.  If the registration fails, remove the module. */
 168         if (crypto_register_provider(&md4_prov_info, &md4_prov_handle)) {
 169                 (void) mod_remove(&modlinkage);
 170                 return (EACCES);
 171         }
 172 
 173         return (0);
 174 }
 175