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


  35 #include <sys/crypto/common.h>
  36 #include <sys/crypto/spi.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/strsun.h>
  39 #include <sys/note.h>
  40 #include <modes/modes.h>
  41 #include <blowfish/blowfish_impl.h>
  42 
  43 extern struct mod_ops mod_cryptoops;
  44 
  45 /*
  46  * Module linkage information for the kernel.
  47  */
  48 static struct modlcrypto modlcrypto = {
  49         &mod_cryptoops,
  50         "Blowfish Kernel SW Provider"
  51 };
  52 
  53 static struct modlinkage modlinkage = {
  54         MODREV_1,
  55         (void *)&modlcrypto,
  56         NULL
  57 };
  58 
  59 /*
  60  * CSPI information (entry points, provider info, etc.)
  61  */
  62 typedef enum blowfish_mech_type {
  63         BLOWFISH_ECB_MECH_INFO_TYPE,            /* SUN_CKM_BLOWFISH_ECB */
  64         BLOWFISH_CBC_MECH_INFO_TYPE             /* SUN_CKM_BLOWFISH_CBC */
  65 } blowfish_mech_type_t;
  66 
  67 
  68 #define BLOWFISH_COPY_BLOCK(src, dst) \
  69         (dst)[0] = (src)[0]; \
  70         (dst)[1] = (src)[1]; \
  71         (dst)[2] = (src)[2]; \
  72         (dst)[3] = (src)[3]; \
  73         (dst)[4] = (src)[4]; \
  74         (dst)[5] = (src)[5]; \
  75         (dst)[6] = (src)[6]; \
  76         (dst)[7] = (src)[7]


 149         blowfish_encrypt_final,
 150         blowfish_encrypt_atomic,
 151         blowfish_common_init,
 152         blowfish_decrypt,
 153         blowfish_decrypt_update,
 154         blowfish_decrypt_final,
 155         blowfish_decrypt_atomic
 156 };
 157 
 158 static int blowfish_create_ctx_template(crypto_provider_handle_t,
 159     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 160     size_t *, crypto_req_handle_t);
 161 static int blowfish_free_context(crypto_ctx_t *);
 162 
 163 static crypto_ctx_ops_t blowfish_ctx_ops = {
 164         blowfish_create_ctx_template,
 165         blowfish_free_context
 166 };
 167 
 168 static crypto_ops_t blowfish_crypto_ops = {
 169         &blowfish_control_ops,
 170         NULL,
 171         &blowfish_cipher_ops,
 172         NULL,
 173         NULL,
 174         NULL,
 175         NULL,
 176         NULL,
 177         NULL,
 178         NULL,
 179         NULL,
 180         NULL,
 181         NULL,
 182         &blowfish_ctx_ops
 183 };
 184 
 185 static crypto_provider_info_t blowfish_prov_info = {
 186         CRYPTO_SPI_VERSION_1,
 187         "Blowfish Software Provider",
 188         CRYPTO_SW_PROVIDER,
 189         {&modlinkage},
 190         NULL,
 191         &blowfish_crypto_ops,
 192         sizeof (blowfish_mech_info_tab)/sizeof (crypto_mech_info_t),
 193         blowfish_mech_info_tab
 194 };
 195 
 196 
 197 static crypto_kcf_provider_handle_t blowfish_prov_handle = NULL;
 198 
 199 int
 200 _init(void)
 201 {
 202         int ret;
 203 
 204         if ((ret = mod_install(&modlinkage)) != 0)
 205                 return (ret);
 206 
 207         /* Register with KCF.  If the registration fails, remove the module. */
 208         if (crypto_register_provider(&blowfish_prov_info,
 209             &blowfish_prov_handle)) {
 210                 (void) mod_remove(&modlinkage);
 211                 return (EACCES);
 212         }
 213 
 214         return (0);




  35 #include <sys/crypto/common.h>
  36 #include <sys/crypto/spi.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/strsun.h>
  39 #include <sys/note.h>
  40 #include <modes/modes.h>
  41 #include <blowfish/blowfish_impl.h>
  42 
  43 extern struct mod_ops mod_cryptoops;
  44 
  45 /*
  46  * Module linkage information for the kernel.
  47  */
  48 static struct modlcrypto modlcrypto = {
  49         &mod_cryptoops,
  50         "Blowfish Kernel SW Provider"
  51 };
  52 
  53 static struct modlinkage modlinkage = {
  54         MODREV_1,
  55         {   (void *)&modlcrypto,
  56             NULL }
  57 };
  58 
  59 /*
  60  * CSPI information (entry points, provider info, etc.)
  61  */
  62 typedef enum blowfish_mech_type {
  63         BLOWFISH_ECB_MECH_INFO_TYPE,            /* SUN_CKM_BLOWFISH_ECB */
  64         BLOWFISH_CBC_MECH_INFO_TYPE             /* SUN_CKM_BLOWFISH_CBC */
  65 } blowfish_mech_type_t;
  66 
  67 
  68 #define BLOWFISH_COPY_BLOCK(src, dst) \
  69         (dst)[0] = (src)[0]; \
  70         (dst)[1] = (src)[1]; \
  71         (dst)[2] = (src)[2]; \
  72         (dst)[3] = (src)[3]; \
  73         (dst)[4] = (src)[4]; \
  74         (dst)[5] = (src)[5]; \
  75         (dst)[6] = (src)[6]; \
  76         (dst)[7] = (src)[7]


 149         blowfish_encrypt_final,
 150         blowfish_encrypt_atomic,
 151         blowfish_common_init,
 152         blowfish_decrypt,
 153         blowfish_decrypt_update,
 154         blowfish_decrypt_final,
 155         blowfish_decrypt_atomic
 156 };
 157 
 158 static int blowfish_create_ctx_template(crypto_provider_handle_t,
 159     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 160     size_t *, crypto_req_handle_t);
 161 static int blowfish_free_context(crypto_ctx_t *);
 162 
 163 static crypto_ctx_ops_t blowfish_ctx_ops = {
 164         blowfish_create_ctx_template,
 165         blowfish_free_context
 166 };
 167 
 168 static crypto_ops_t blowfish_crypto_ops = {
 169         .co_control_ops = &blowfish_control_ops,
 170         .co_digest_ops = NULL,
 171         .co_cipher_ops = &blowfish_cipher_ops,
 172         .co_mac_ops = NULL,
 173         .co_sign_ops = NULL,
 174         .co_verify_ops = NULL,
 175         .co_dual_ops = NULL,
 176         .co_dual_cipher_mac_ops = NULL,
 177         .co_random_ops = NULL,
 178         .co_session_ops = NULL,
 179         .co_object_ops = NULL,
 180         .co_key_ops = NULL,
 181         .co_provider_ops = NULL,
 182         .co_ctx_ops = &blowfish_ctx_ops
 183 };
 184 
 185 static crypto_provider_info_t blowfish_prov_info = {{{{
 186         CRYPTO_SPI_VERSION_1,
 187         "Blowfish Software Provider",
 188         CRYPTO_SW_PROVIDER,
 189         {&modlinkage},
 190         NULL,
 191         &blowfish_crypto_ops,
 192         sizeof (blowfish_mech_info_tab)/sizeof (crypto_mech_info_t),
 193         blowfish_mech_info_tab
 194 }}}};
 195 
 196 
 197 static crypto_kcf_provider_handle_t blowfish_prov_handle = NULL;
 198 
 199 int
 200 _init(void)
 201 {
 202         int ret;
 203 
 204         if ((ret = mod_install(&modlinkage)) != 0)
 205                 return (ret);
 206 
 207         /* Register with KCF.  If the registration fails, remove the module. */
 208         if (crypto_register_provider(&blowfish_prov_info,
 209             &blowfish_prov_handle)) {
 210                 (void) mod_remove(&modlinkage);
 211                 return (EACCES);
 212         }
 213 
 214         return (0);