Lines Matching refs:cd
206 cleanup(struct cipher_data_t *cd) in cleanup() argument
208 if (cd->key != NULL) { in cleanup()
209 bzero(cd->key, cd->keylen); in cleanup()
210 kmem_free(cd->key, cd->keylen); in cleanup()
211 cd->key = NULL; in cleanup()
214 if (cd->ckey != NULL) { in cleanup()
220 kmem_free(cd->ckey, sizeof (crypto_key_t)); in cleanup()
221 cd->ckey = NULL; in cleanup()
224 if (cd->block != NULL) { in cleanup()
225 kmem_free(cd->block, cd->blocklen); in cleanup()
226 cd->block = NULL; in cleanup()
229 if (cd->saveblock != NULL) { in cleanup()
230 kmem_free(cd->saveblock, cd->blocklen); in cleanup()
231 cd->saveblock = NULL; in cleanup()
234 if (cd->ivec != NULL) { in cleanup()
235 kmem_free(cd->ivec, cd->ivlen); in cleanup()
236 cd->ivec = NULL; in cleanup()
239 if (cd->d_encr_key.ck_data != NULL) { in cleanup()
240 bzero(cd->d_encr_key.ck_data, cd->keylen); in cleanup()
241 kmem_free(cd->d_encr_key.ck_data, cd->keylen); in cleanup()
244 if (cd->d_hmac_key.ck_data != NULL) { in cleanup()
245 bzero(cd->d_hmac_key.ck_data, cd->keylen); in cleanup()
246 kmem_free(cd->d_hmac_key.ck_data, cd->keylen); in cleanup()
249 if (cd->enc_tmpl != NULL) in cleanup()
250 (void) crypto_destroy_ctx_template(cd->enc_tmpl); in cleanup()
252 if (cd->hmac_tmpl != NULL) in cleanup()
253 (void) crypto_destroy_ctx_template(cd->hmac_tmpl); in cleanup()
255 if (cd->ctx != NULL) { in cleanup()
256 crypto_cancel_ctx(cd->ctx); in cleanup()
257 cd->ctx = NULL; in cleanup()
329 plaintext_offset(struct cipher_data_t *cd) in plaintext_offset() argument
334 if (ANY_RCMD_MODE(cd->option_mask)) in plaintext_offset()
338 if (cd->option_mask & CRYPTOPT_RCMD_MODE_V2) in plaintext_offset()
342 switch (cd->method) { in plaintext_offset()
376 encrypt_size(struct cipher_data_t *cd, size_t plainlen) in encrypt_size() argument
380 switch (cd->method) { in encrypt_size()
2640 setup_crypto(struct cr_info_t *ci, struct cipher_data_t *cd, int encrypt) in setup_crypto() argument
2665 cd->method = ci->crypto_method; in setup_crypto()
2666 cd->bytes = 0; in setup_crypto()
2669 if (cd->key != NULL) { in setup_crypto()
2670 kmem_free(cd->key, cd->keylen); in setup_crypto()
2671 cd->key = NULL; in setup_crypto()
2672 cd->keylen = 0; in setup_crypto()
2678 cd->key = (char *)kmem_alloc((size_t)ci->keylen, KM_SLEEP); in setup_crypto()
2680 cd->keylen = ci->keylen; in setup_crypto()
2681 bcopy(ci->key, cd->key, (size_t)ci->keylen); in setup_crypto()
2687 switch (cd->method) { in setup_crypto()
2693 cd->mech_type = crypto_mech2id(SUN_CKM_DES_ECB); in setup_crypto()
2699 cd->mech_type = crypto_mech2id(SUN_CKM_DES_CBC); in setup_crypto()
2703 cd->mech_type = crypto_mech2id(SUN_CKM_DES3_CBC); in setup_crypto()
2711 cd->mech_type = crypto_mech2id(SUN_CKM_RC4); in setup_crypto()
2716 cd->mech_type = crypto_mech2id(SUN_CKM_AES_ECB); in setup_crypto()
2721 if (cd->mech_type == CRYPTO_MECH_INVALID) { in setup_crypto()
2729 if (cd->keylen > 0 && IS_RC4_METHOD(cd->method)) { in setup_crypto()
2734 if (cd->ckey == NULL) { in setup_crypto()
2735 cd->ckey = (crypto_key_t *)kmem_zalloc( in setup_crypto()
2739 cd->ckey->ck_format = CRYPTO_KEY_RAW; in setup_crypto()
2740 cd->ckey->ck_data = cd->key; in setup_crypto()
2743 cd->ckey->ck_length = cd->keylen * 8; in setup_crypto()
2751 if (newblocklen != cd->blocklen) { in setup_crypto()
2752 if (cd->block != NULL) { in setup_crypto()
2753 kmem_free(cd->block, cd->blocklen); in setup_crypto()
2754 cd->block = NULL; in setup_crypto()
2757 if (cd->saveblock != NULL) { in setup_crypto()
2758 kmem_free(cd->saveblock, cd->blocklen); in setup_crypto()
2759 cd->saveblock = NULL; in setup_crypto()
2762 cd->blocklen = newblocklen; in setup_crypto()
2763 if (cd->blocklen) { in setup_crypto()
2764 cd->block = (char *)kmem_zalloc((size_t)cd->blocklen, in setup_crypto()
2768 if (cd->method == CRYPT_METHOD_DES_CFB) in setup_crypto()
2769 cd->saveblock = (char *)kmem_zalloc(cd->blocklen, in setup_crypto()
2772 cd->saveblock = NULL; in setup_crypto()
2775 if (ci->iveclen != cd->ivlen) { in setup_crypto()
2776 if (cd->ivec != NULL) { in setup_crypto()
2777 kmem_free(cd->ivec, cd->ivlen); in setup_crypto()
2778 cd->ivec = NULL; in setup_crypto()
2781 cd->ivec = (char *)kmem_zalloc((size_t)ci->iveclen, in setup_crypto()
2783 cd->ivlen = ci->iveclen; in setup_crypto()
2785 cd->ivlen = 0; in setup_crypto()
2786 cd->ivec = NULL; in setup_crypto()
2789 cd->option_mask = ci->option_mask; in setup_crypto()
2795 if (cd->option_mask & CRYPTOPT_RCMD_MODE_V1) { in setup_crypto()
2799 if (cd->ivlen > cd->blocklen) { in setup_crypto()
2808 if (ci->ivec_usage == IVEC_ONETIME && cd->block != NULL) in setup_crypto()
2809 bcopy(ci->ivec, cd->block, (size_t)cd->ivlen); in setup_crypto()
2811 cd->ivec_usage = ci->ivec_usage; in setup_crypto()
2812 if (cd->ivec != NULL) { in setup_crypto()
2814 bcopy(ci->ivec, cd->ivec, (size_t)cd->ivlen); in setup_crypto()
2821 if (cd->method == CRYPT_METHOD_DES3_CBC_SHA1 || in setup_crypto()
2822 IS_AES_METHOD(cd->method)) { in setup_crypto()
2826 if (cd->d_encr_key.ck_data != NULL) { in setup_crypto()
2827 bzero(cd->d_encr_key.ck_data, cd->keylen); in setup_crypto()
2828 kmem_free(cd->d_encr_key.ck_data, cd->keylen); in setup_crypto()
2831 if (cd->d_hmac_key.ck_data != NULL) { in setup_crypto()
2832 bzero(cd->d_hmac_key.ck_data, cd->keylen); in setup_crypto()
2833 kmem_free(cd->d_hmac_key.ck_data, cd->keylen); in setup_crypto()
2836 if (cd->enc_tmpl != NULL) in setup_crypto()
2837 (void) crypto_destroy_ctx_template(cd->enc_tmpl); in setup_crypto()
2839 if (cd->hmac_tmpl != NULL) in setup_crypto()
2840 (void) crypto_destroy_ctx_template(cd->hmac_tmpl); in setup_crypto()
2842 enc_mech.cm_type = cd->mech_type; in setup_crypto()
2843 enc_mech.cm_param = cd->ivec; in setup_crypto()
2844 enc_mech.cm_param_len = cd->ivlen; in setup_crypto()
2853 rv = create_derived_keys(cd, in setup_crypto()
2855 &cd->d_encr_key, &cd->d_hmac_key); in setup_crypto()
2864 &cd->d_encr_key, in setup_crypto()
2865 &cd->enc_tmpl, KM_SLEEP); in setup_crypto()
2867 cd->enc_tmpl = NULL; in setup_crypto()
2875 &cd->d_hmac_key, in setup_crypto()
2876 &cd->hmac_tmpl, KM_SLEEP); in setup_crypto()
2878 cd->hmac_tmpl = NULL; in setup_crypto()
2884 } else if (IS_RC4_METHOD(cd->method)) { in setup_crypto()
2885 bzero(&cd->d_encr_key, sizeof (crypto_key_t)); in setup_crypto()
2886 bzero(&cd->d_hmac_key, sizeof (crypto_key_t)); in setup_crypto()
2887 cd->ctx = NULL; in setup_crypto()
2888 cd->enc_tmpl = NULL; in setup_crypto()
2889 cd->hmac_tmpl = NULL; in setup_crypto()
2893 if (cd->method != CRYPT_METHOD_NONE) { in setup_crypto()
2894 if (cd->block == NULL && cd->blocklen > 0) { in setup_crypto()
2901 if (cd->key == NULL && cd->keylen > 0) { in setup_crypto()
2908 if (cd->method == CRYPT_METHOD_DES_CFB && in setup_crypto()
2909 cd->saveblock == NULL && cd->blocklen > 0) { in setup_crypto()
2916 if (cd->ivec == NULL && cd->ivlen > 0) { in setup_crypto()