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


  35 #include <sys/crypto/impl.h>
  36 #include <sys/crypto/spi.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/strsun.h>
  39 #include <modes/modes.h>
  40 #define _AES_IMPL
  41 #include <aes/aes_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         "AES Kernel SW Provider"
  51 };
  52 
  53 static struct modlinkage modlinkage = {
  54         MODREV_1,
  55         (void *)&modlcrypto,
  56         NULL
  57 };
  58 
  59 /*
  60  * Mechanism info structure passed to KCF during registration.
  61  */
  62 static crypto_mech_info_t aes_mech_info_tab[] = {
  63         /* AES_ECB */
  64         {SUN_CKM_AES_ECB, AES_ECB_MECH_INFO_TYPE,
  65             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  66             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
  67             AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  68         /* AES_CBC */
  69         {SUN_CKM_AES_CBC, AES_CBC_MECH_INFO_TYPE,
  70             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  71             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
  72             AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  73         /* AES_CTR */
  74         {SUN_CKM_AES_CTR, AES_CTR_MECH_INFO_TYPE,
  75             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  76             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,


 157 
 158 static crypto_mac_ops_t aes_mac_ops = {
 159         NULL,
 160         NULL,
 161         NULL,
 162         NULL,
 163         aes_mac_atomic,
 164         aes_mac_verify_atomic
 165 };
 166 
 167 static int aes_create_ctx_template(crypto_provider_handle_t,
 168     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 169     size_t *, crypto_req_handle_t);
 170 static int aes_free_context(crypto_ctx_t *);
 171 
 172 static crypto_ctx_ops_t aes_ctx_ops = {
 173         aes_create_ctx_template,
 174         aes_free_context
 175 };
 176 
 177 static crypto_ops_t aes_crypto_ops = {
 178         &aes_control_ops,
 179         NULL,
 180         &aes_cipher_ops,
 181         &aes_mac_ops,
 182         NULL,
 183         NULL,
 184         NULL,
 185         NULL,
 186         NULL,
 187         NULL,
 188         NULL,
 189         NULL,
 190         NULL,
 191         &aes_ctx_ops,
 192         NULL,
 193         NULL,
 194         NULL,
 195 };
 196 
 197 static crypto_provider_info_t aes_prov_info = {
 198         CRYPTO_SPI_VERSION_4,
 199         "AES Software Provider",
 200         CRYPTO_SW_PROVIDER,
 201         {&modlinkage},
 202         NULL,
 203         &aes_crypto_ops,
 204         sizeof (aes_mech_info_tab)/sizeof (crypto_mech_info_t),
 205         aes_mech_info_tab
 206 };
 207 
 208 static crypto_kcf_provider_handle_t aes_prov_handle = NULL;
 209 static crypto_data_t null_crypto_data = { CRYPTO_DATA_RAW };
 210 
 211 int
 212 _init(void)
 213 {
 214         int ret;
 215 
 216         if ((ret = mod_install(&modlinkage)) != 0)
 217                 return (ret);
 218 
 219         /* Register with KCF.  If the registration fails, remove the module. */
 220         if (crypto_register_provider(&aes_prov_info, &aes_prov_handle)) {
 221                 (void) mod_remove(&modlinkage);
 222                 return (EACCES);
 223         }
 224 
 225         return (0);
 226 }




  35 #include <sys/crypto/impl.h>
  36 #include <sys/crypto/spi.h>
  37 #include <sys/sysmacros.h>
  38 #include <sys/strsun.h>
  39 #include <modes/modes.h>
  40 #define _AES_IMPL
  41 #include <aes/aes_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         "AES Kernel SW Provider"
  51 };
  52 
  53 static struct modlinkage modlinkage = {
  54         MODREV_1,
  55         {   (void *)&modlcrypto,
  56             NULL }
  57 };
  58 
  59 /*
  60  * Mechanism info structure passed to KCF during registration.
  61  */
  62 static crypto_mech_info_t aes_mech_info_tab[] = {
  63         /* AES_ECB */
  64         {SUN_CKM_AES_ECB, AES_ECB_MECH_INFO_TYPE,
  65             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  66             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
  67             AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  68         /* AES_CBC */
  69         {SUN_CKM_AES_CBC, AES_CBC_MECH_INFO_TYPE,
  70             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  71             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,
  72             AES_MIN_KEY_BYTES, AES_MAX_KEY_BYTES, CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  73         /* AES_CTR */
  74         {SUN_CKM_AES_CTR, AES_CTR_MECH_INFO_TYPE,
  75             CRYPTO_FG_ENCRYPT | CRYPTO_FG_ENCRYPT_ATOMIC |
  76             CRYPTO_FG_DECRYPT | CRYPTO_FG_DECRYPT_ATOMIC,


 157 
 158 static crypto_mac_ops_t aes_mac_ops = {
 159         NULL,
 160         NULL,
 161         NULL,
 162         NULL,
 163         aes_mac_atomic,
 164         aes_mac_verify_atomic
 165 };
 166 
 167 static int aes_create_ctx_template(crypto_provider_handle_t,
 168     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 169     size_t *, crypto_req_handle_t);
 170 static int aes_free_context(crypto_ctx_t *);
 171 
 172 static crypto_ctx_ops_t aes_ctx_ops = {
 173         aes_create_ctx_template,
 174         aes_free_context
 175 };
 176 
 177 static crypto_ops_t aes_crypto_ops = {{{{{{
 178                                 &aes_control_ops,
 179                                 NULL,
 180                                 &aes_cipher_ops,
 181                                 &aes_mac_ops,
 182                                 NULL,
 183                                 NULL,
 184                                 NULL,
 185                                 NULL,
 186                                 NULL,
 187                                 NULL,
 188                                 NULL,
 189                                 NULL,
 190                                 NULL,
 191                                 &aes_ctx_ops },     /* cou_v1 */
 192                         NULL },                 /* cou_v2 */
 193                 NULL },                         /* cou_v3 */
 194         NULL }                                  /* cou_v4 */
 195 }};
 196 
 197 static crypto_provider_info_t aes_prov_info = {{{{
 198         CRYPTO_SPI_VERSION_4,
 199         "AES Software Provider",
 200         CRYPTO_SW_PROVIDER,
 201         {&modlinkage},
 202         NULL,
 203         &aes_crypto_ops,
 204         sizeof (aes_mech_info_tab)/sizeof (crypto_mech_info_t),
 205         aes_mech_info_tab
 206 }}}};
 207 
 208 static crypto_kcf_provider_handle_t aes_prov_handle = NULL;
 209 static crypto_data_t null_crypto_data = { CRYPTO_DATA_RAW };
 210 
 211 int
 212 _init(void)
 213 {
 214         int ret;
 215 
 216         if ((ret = mod_install(&modlinkage)) != 0)
 217                 return (ret);
 218 
 219         /* Register with KCF.  If the registration fails, remove the module. */
 220         if (crypto_register_provider(&aes_prov_info, &aes_prov_handle)) {
 221                 (void) mod_remove(&modlinkage);
 222                 return (EACCES);
 223         }
 224 
 225         return (0);
 226 }