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


  31 #include <sys/systm.h>
  32 #define SKEIN_MODULE_IMPL
  33 #include <sys/skein.h>
  34 
  35 /*
  36  * Like the sha2 module, we create the skein module with two modlinkages:
  37  * - modlmisc to allow direct calls to Skein_* API functions.
  38  * - modlcrypto to integrate well into the Kernel Crypto Framework (KCF).
  39  */
  40 static struct modlmisc modlmisc = {
  41         &mod_miscops,
  42         "Skein Message-Digest Algorithm"
  43 };
  44 
  45 static struct modlcrypto modlcrypto = {
  46         &mod_cryptoops,
  47         "Skein Kernel SW Provider"
  48 };
  49 
  50 static struct modlinkage modlinkage = {
  51         MODREV_1, &modlmisc, &modlcrypto, NULL
  52 };
  53 
  54 static crypto_mech_info_t skein_mech_info_tab[] = {
  55         {CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE,
  56             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  57             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  58         {CKM_SKEIN_256_MAC, SKEIN_256_MAC_MECH_INFO_TYPE,
  59             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,
  60             CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  61         {CKM_SKEIN_512, SKEIN_512_MECH_INFO_TYPE,
  62             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  63             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  64         {CKM_SKEIN_512_MAC, SKEIN_512_MAC_MECH_INFO_TYPE,
  65             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,
  66             CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  67         {CKM_SKEIN1024, SKEIN1024_MECH_INFO_TYPE,
  68             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  69             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  70         {CKM_SKEIN1024_MAC, SKEIN1024_MAC_MECH_INFO_TYPE,
  71             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,


 105 
 106 static crypto_mac_ops_t skein_mac_ops = {
 107         skein_mac_init,
 108         NULL,
 109         skein_update,   /* using regular digest update is OK here */
 110         skein_final,    /* using regular digest final is OK here */
 111         skein_mac_atomic,
 112         NULL
 113 };
 114 
 115 static int skein_create_ctx_template(crypto_provider_handle_t,
 116     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 117     size_t *, crypto_req_handle_t);
 118 static int skein_free_context(crypto_ctx_t *);
 119 
 120 static crypto_ctx_ops_t skein_ctx_ops = {
 121         skein_create_ctx_template,
 122         skein_free_context
 123 };
 124 
 125 static crypto_ops_t skein_crypto_ops = {
 126         &skein_control_ops,
 127         &skein_digest_ops,
 128         NULL,
 129         &skein_mac_ops,
 130         NULL,
 131         NULL,
 132         NULL,
 133         NULL,
 134         NULL,
 135         NULL,
 136         NULL,
 137         NULL,
 138         NULL,
 139         &skein_ctx_ops,
 140         NULL,
 141         NULL,
 142         NULL
 143 };
 144 
 145 static crypto_provider_info_t skein_prov_info = {
 146         CRYPTO_SPI_VERSION_4,
 147         "Skein Software Provider",
 148         CRYPTO_SW_PROVIDER,
 149         {&modlinkage},
 150         NULL,
 151         &skein_crypto_ops,
 152         sizeof (skein_mech_info_tab) / sizeof (crypto_mech_info_t),
 153         skein_mech_info_tab
 154 };
 155 
 156 static crypto_kcf_provider_handle_t skein_prov_handle = 0;
 157 
 158 typedef struct skein_ctx {
 159         skein_mech_type_t               sc_mech_type;
 160         size_t                          sc_digest_bitlen;
 161         union {
 162                 Skein_256_Ctxt_t        sc_256;
 163                 Skein_512_Ctxt_t        sc_512;
 164                 Skein1024_Ctxt_t        sc_1024;
 165         } sc_u;
 166 } skein_ctx_t;
 167 #define SKEIN_CTX(_ctx_)        ((skein_ctx_t *)((_ctx_)->cc_provider_private))
 168 #define SKEIN_CTX_LVALUE(_ctx_) (_ctx_)->cc_provider_private
 169 #define SKEIN_OP(_skein_ctx, _op, ...)                                  \
 170         do {                                                            \
 171                 skein_ctx_t     *sc = (_skein_ctx);                     \
 172                 switch (sc->sc_mech_type) {                          \
 173                 case SKEIN_256_MECH_INFO_TYPE:                          \
 174                 case SKEIN_256_MAC_MECH_INFO_TYPE:                      \




  31 #include <sys/systm.h>
  32 #define SKEIN_MODULE_IMPL
  33 #include <sys/skein.h>
  34 
  35 /*
  36  * Like the sha2 module, we create the skein module with two modlinkages:
  37  * - modlmisc to allow direct calls to Skein_* API functions.
  38  * - modlcrypto to integrate well into the Kernel Crypto Framework (KCF).
  39  */
  40 static struct modlmisc modlmisc = {
  41         &mod_miscops,
  42         "Skein Message-Digest Algorithm"
  43 };
  44 
  45 static struct modlcrypto modlcrypto = {
  46         &mod_cryptoops,
  47         "Skein Kernel SW Provider"
  48 };
  49 
  50 static struct modlinkage modlinkage = {
  51         MODREV_1, { &modlmisc, &modlcrypto, NULL }
  52 };
  53 
  54 static crypto_mech_info_t skein_mech_info_tab[] = {
  55         {CKM_SKEIN_256, SKEIN_256_MECH_INFO_TYPE,
  56             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  57             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  58         {CKM_SKEIN_256_MAC, SKEIN_256_MAC_MECH_INFO_TYPE,
  59             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,
  60             CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  61         {CKM_SKEIN_512, SKEIN_512_MECH_INFO_TYPE,
  62             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  63             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  64         {CKM_SKEIN_512_MAC, SKEIN_512_MAC_MECH_INFO_TYPE,
  65             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,
  66             CRYPTO_KEYSIZE_UNIT_IN_BYTES},
  67         {CKM_SKEIN1024, SKEIN1024_MECH_INFO_TYPE,
  68             CRYPTO_FG_DIGEST | CRYPTO_FG_DIGEST_ATOMIC,
  69             0, 0, CRYPTO_KEYSIZE_UNIT_IN_BITS},
  70         {CKM_SKEIN1024_MAC, SKEIN1024_MAC_MECH_INFO_TYPE,
  71             CRYPTO_FG_MAC | CRYPTO_FG_MAC_ATOMIC, 1, INT_MAX,


 105 
 106 static crypto_mac_ops_t skein_mac_ops = {
 107         skein_mac_init,
 108         NULL,
 109         skein_update,   /* using regular digest update is OK here */
 110         skein_final,    /* using regular digest final is OK here */
 111         skein_mac_atomic,
 112         NULL
 113 };
 114 
 115 static int skein_create_ctx_template(crypto_provider_handle_t,
 116     crypto_mechanism_t *, crypto_key_t *, crypto_spi_ctx_template_t *,
 117     size_t *, crypto_req_handle_t);
 118 static int skein_free_context(crypto_ctx_t *);
 119 
 120 static crypto_ctx_ops_t skein_ctx_ops = {
 121         skein_create_ctx_template,
 122         skein_free_context
 123 };
 124 
 125 static crypto_ops_t skein_crypto_ops = {{{{{{
 126                                 &skein_control_ops,
 127                                 &skein_digest_ops,
 128                                 NULL,
 129                                 &skein_mac_ops,
 130                                 NULL,
 131                                 NULL,
 132                                 NULL,
 133                                 NULL,
 134                                 NULL,
 135                                 NULL,
 136                                 NULL,
 137                                 NULL,
 138                                 NULL,
 139                                 &skein_ctx_ops },   /* cou_v1 */
 140                         NULL },                         /* cou_v2 */
 141                 NULL },                                 /* cou_v3 */
 142         NULL }                                          /* cou_v4 */
 143 }};
 144 
 145 static crypto_provider_info_t skein_prov_info = {{{{
 146         CRYPTO_SPI_VERSION_4,
 147         "Skein Software Provider",
 148         CRYPTO_SW_PROVIDER,
 149         {&modlinkage},
 150         NULL,
 151         &skein_crypto_ops,
 152         sizeof (skein_mech_info_tab) / sizeof (crypto_mech_info_t),
 153         skein_mech_info_tab
 154 }}}};
 155 
 156 static crypto_kcf_provider_handle_t skein_prov_handle = 0;
 157 
 158 typedef struct skein_ctx {
 159         skein_mech_type_t               sc_mech_type;
 160         size_t                          sc_digest_bitlen;
 161         union {
 162                 Skein_256_Ctxt_t        sc_256;
 163                 Skein_512_Ctxt_t        sc_512;
 164                 Skein1024_Ctxt_t        sc_1024;
 165         } sc_u;
 166 } skein_ctx_t;
 167 #define SKEIN_CTX(_ctx_)        ((skein_ctx_t *)((_ctx_)->cc_provider_private))
 168 #define SKEIN_CTX_LVALUE(_ctx_) (_ctx_)->cc_provider_private
 169 #define SKEIN_OP(_skein_ctx, _op, ...)                                  \
 170         do {                                                            \
 171                 skein_ctx_t     *sc = (_skein_ctx);                     \
 172                 switch (sc->sc_mech_type) {                          \
 173                 case SKEIN_256_MECH_INFO_TYPE:                          \
 174                 case SKEIN_256_MAC_MECH_INFO_TYPE:                      \