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


  39 /*
  40  * The sha1 module is created with two modlinkages:
  41  * - a modlmisc that allows consumers to directly call the entry points
  42  *   SHA1Init, SHA1Update, and SHA1Final.
  43  * - a modlcrypto that allows the module to register with the Kernel
  44  *   Cryptographic Framework (KCF) as a software provider for the SHA1
  45  *   mechanisms.
  46  */
  47 
  48 static struct modlmisc modlmisc = {
  49         &mod_miscops,
  50         "SHA1 Message-Digest Algorithm"
  51 };
  52 
  53 static struct modlcrypto modlcrypto = {
  54         &mod_cryptoops,
  55         "SHA1 Kernel SW Provider 1.1"
  56 };
  57 
  58 static struct modlinkage modlinkage = {
  59         MODREV_1, &modlmisc, &modlcrypto, NULL
  60 };
  61 
  62 
  63 /*
  64  * Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
  65  * by KCF to one of the entry points.
  66  */
  67 
  68 #define PROV_SHA1_CTX(ctx)      ((sha1_ctx_t *)(ctx)->cc_provider_private)
  69 #define PROV_SHA1_HMAC_CTX(ctx) ((sha1_hmac_ctx_t *)(ctx)->cc_provider_private)
  70 
  71 /* to extract the digest length passed as mechanism parameter */
  72 #define PROV_SHA1_GET_DIGEST_LEN(m, len) {                              \
  73         if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))           \
  74                 (len) = (uint32_t)*((ulong_t *)(void *)mechanism->cm_param); \
  75         else {                                                          \
  76                 ulong_t tmp_ulong;                                      \
  77                 bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));      \
  78                 (len) = (uint32_t)tmp_ulong;                            \
  79         }                                                               \


 147 static crypto_mac_ops_t sha1_mac_ops = {
 148         sha1_mac_init,
 149         NULL,
 150         sha1_mac_update,
 151         sha1_mac_final,
 152         sha1_mac_atomic,
 153         sha1_mac_verify_atomic
 154 };
 155 
 156 static int sha1_create_ctx_template(crypto_provider_handle_t,
 157     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 158     size_t *, crypto_req_handle_t);
 159 static int sha1_free_context(crypto_ctx_t *);
 160 
 161 static crypto_ctx_ops_t sha1_ctx_ops = {
 162         sha1_create_ctx_template,
 163         sha1_free_context
 164 };
 165 
 166 static crypto_ops_t sha1_crypto_ops = {
 167         &sha1_control_ops,
 168         &sha1_digest_ops,
 169         NULL,
 170         &sha1_mac_ops,
 171         NULL,
 172         NULL,
 173         NULL,
 174         NULL,
 175         NULL,
 176         NULL,
 177         NULL,
 178         NULL,
 179         NULL,
 180         &sha1_ctx_ops,
 181         NULL,
 182         NULL,
 183         NULL,
 184 };
 185 
 186 static crypto_provider_info_t sha1_prov_info = {
 187         CRYPTO_SPI_VERSION_4,
 188         "SHA1 Software Provider",
 189         CRYPTO_SW_PROVIDER,
 190         {&modlinkage},
 191         NULL,
 192         &sha1_crypto_ops,
 193         sizeof (sha1_mech_info_tab)/sizeof (crypto_mech_info_t),
 194         sha1_mech_info_tab
 195 };
 196 
 197 static crypto_kcf_provider_handle_t sha1_prov_handle = NULL;
 198 
 199 int
 200 _init()
 201 {
 202         int ret;
 203 
 204         if ((ret = mod_install(&modlinkage)) != 0)
 205                 return (ret);
 206 
 207         /*
 208          * Register with KCF. If the registration fails, log do not uninstall
 209          * the module, since the functionality provided by misc/sha1 should
 210          * still be available.
 211          */
 212         (void) crypto_register_provider(&sha1_prov_info, &sha1_prov_handle);
 213 
 214         return (0);
 215 }




  39 /*
  40  * The sha1 module is created with two modlinkages:
  41  * - a modlmisc that allows consumers to directly call the entry points
  42  *   SHA1Init, SHA1Update, and SHA1Final.
  43  * - a modlcrypto that allows the module to register with the Kernel
  44  *   Cryptographic Framework (KCF) as a software provider for the SHA1
  45  *   mechanisms.
  46  */
  47 
  48 static struct modlmisc modlmisc = {
  49         &mod_miscops,
  50         "SHA1 Message-Digest Algorithm"
  51 };
  52 
  53 static struct modlcrypto modlcrypto = {
  54         &mod_cryptoops,
  55         "SHA1 Kernel SW Provider 1.1"
  56 };
  57 
  58 static struct modlinkage modlinkage = {
  59         MODREV_1, { &modlmisc, &modlcrypto, NULL }
  60 };
  61 
  62 
  63 /*
  64  * Macros to access the SHA1 or SHA1-HMAC contexts from a context passed
  65  * by KCF to one of the entry points.
  66  */
  67 
  68 #define PROV_SHA1_CTX(ctx)      ((sha1_ctx_t *)(ctx)->cc_provider_private)
  69 #define PROV_SHA1_HMAC_CTX(ctx) ((sha1_hmac_ctx_t *)(ctx)->cc_provider_private)
  70 
  71 /* to extract the digest length passed as mechanism parameter */
  72 #define PROV_SHA1_GET_DIGEST_LEN(m, len) {                              \
  73         if (IS_P2ALIGNED((m)->cm_param, sizeof (ulong_t)))           \
  74                 (len) = (uint32_t)*((ulong_t *)(void *)mechanism->cm_param); \
  75         else {                                                          \
  76                 ulong_t tmp_ulong;                                      \
  77                 bcopy((m)->cm_param, &tmp_ulong, sizeof (ulong_t));      \
  78                 (len) = (uint32_t)tmp_ulong;                            \
  79         }                                                               \


 147 static crypto_mac_ops_t sha1_mac_ops = {
 148         sha1_mac_init,
 149         NULL,
 150         sha1_mac_update,
 151         sha1_mac_final,
 152         sha1_mac_atomic,
 153         sha1_mac_verify_atomic
 154 };
 155 
 156 static int sha1_create_ctx_template(crypto_provider_handle_t,
 157     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 158     size_t *, crypto_req_handle_t);
 159 static int sha1_free_context(crypto_ctx_t *);
 160 
 161 static crypto_ctx_ops_t sha1_ctx_ops = {
 162         sha1_create_ctx_template,
 163         sha1_free_context
 164 };
 165 
 166 static crypto_ops_t sha1_crypto_ops = {
 167         .co_control_ops = &sha1_control_ops,
 168         .co_digest_ops = &sha1_digest_ops,
 169         .co_mac_ops = &sha1_mac_ops,
 170         .co_ctx_ops = &sha1_ctx_ops













 171 };
 172 
 173 static crypto_provider_info_t sha1_prov_info = {{{{
 174         CRYPTO_SPI_VERSION_4,
 175         "SHA1 Software Provider",
 176         CRYPTO_SW_PROVIDER,
 177         {&modlinkage},
 178         NULL,
 179         &sha1_crypto_ops,
 180         sizeof (sha1_mech_info_tab)/sizeof (crypto_mech_info_t),
 181         sha1_mech_info_tab
 182 }}}};
 183 
 184 static crypto_kcf_provider_handle_t sha1_prov_handle = NULL;
 185 
 186 int
 187 _init()
 188 {
 189         int ret;
 190 
 191         if ((ret = mod_install(&modlinkage)) != 0)
 192                 return (ret);
 193 
 194         /*
 195          * Register with KCF. If the registration fails, log do not uninstall
 196          * the module, since the functionality provided by misc/sha1 should
 197          * still be available.
 198          */
 199         (void) crypto_register_provider(&sha1_prov_info, &sha1_prov_handle);
 200 
 201         return (0);
 202 }