Lines Matching defs:aes_ctx

360 	aes_ctx_t *aes_ctx;
372 if ((rv = aes_check_mech_param(mechanism, &aes_ctx, kmflag))
376 rv = aes_common_init_ctx(aes_ctx, template, mechanism, key, kmflag,
379 crypto_free_mode_ctx(aes_ctx);
383 ctx->cc_provider_private = aes_ctx;
410 aes_ctx_t *aes_ctx;
414 aes_ctx = ctx->cc_provider_private;
420 if (((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE))
430 switch (aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) {
432 length_needed = plaintext->cd_length + aes_ctx->ac_mac_len;
435 length_needed = plaintext->cd_length + aes_ctx->ac_tag_len;
441 length_needed = aes_ctx->ac_tag_len;
467 if (aes_ctx->ac_flags & CCM_MODE) {
477 ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, ciphertext,
488 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
498 ret = gcm_encrypt_final((gcm_ctx_t *)aes_ctx, ciphertext,
512 ASSERT(aes_ctx->ac_remainder_len == 0);
525 aes_ctx_t *aes_ctx;
530 aes_ctx = ctx->cc_provider_private;
536 if (((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE))
551 switch (aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) {
553 length_needed = aes_ctx->ac_processed_data_len;
556 length_needed = ciphertext->cd_length - aes_ctx->ac_tag_len;
584 if (aes_ctx->ac_flags & CCM_MODE) {
585 ASSERT(aes_ctx->ac_processed_data_len == aes_ctx->ac_data_len);
586 ASSERT(aes_ctx->ac_processed_mac_len == aes_ctx->ac_mac_len);
592 ret = ccm_decrypt_final((ccm_ctx_t *)aes_ctx, plaintext,
605 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
610 ret = gcm_decrypt_final((gcm_ctx_t *)aes_ctx, plaintext,
624 ASSERT(aes_ctx->ac_remainder_len == 0);
641 aes_ctx_t *aes_ctx;
644 aes_ctx = ctx->cc_provider_private;
649 out_len = aes_ctx->ac_remainder_len;
691 if ((aes_ctx->ac_flags & CTR_MODE) && (aes_ctx->ac_remainder_len > 0)) {
692 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx,
716 aes_ctx_t *aes_ctx;
719 aes_ctx = ctx->cc_provider_private;
728 if ((aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) == 0) {
729 out_len = aes_ctx->ac_remainder_len;
743 if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE))
744 gcm_set_kmflag((gcm_ctx_t *)aes_ctx, crypto_kmflag(req));
775 if ((aes_ctx->ac_flags & CTR_MODE) && (aes_ctx->ac_remainder_len > 0)) {
776 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, plaintext,
800 aes_ctx_t *aes_ctx;
804 aes_ctx = ctx->cc_provider_private;
812 if (aes_ctx->ac_flags & CTR_MODE) {
813 if (aes_ctx->ac_remainder_len > 0) {
814 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, data,
819 } else if (aes_ctx->ac_flags & CCM_MODE) {
820 ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, data,
825 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
828 ret = gcm_encrypt_final((gcm_ctx_t *)aes_ctx, data,
842 if (aes_ctx->ac_remainder_len > 0) {
858 aes_ctx_t *aes_ctx;
864 aes_ctx = ctx->cc_provider_private;
877 if (aes_ctx->ac_remainder_len > 0) {
878 if ((aes_ctx->ac_flags & CTR_MODE) == 0)
881 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, data,
890 if (aes_ctx->ac_flags & CCM_MODE) {
895 size_t pt_len = aes_ctx->ac_data_len;
901 ASSERT(aes_ctx->ac_processed_data_len == pt_len);
902 ASSERT(aes_ctx->ac_processed_mac_len == aes_ctx->ac_mac_len);
905 ret = ccm_decrypt_final((ccm_ctx_t *)aes_ctx, data,
918 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
923 gcm_ctx_t *ctx = (gcm_ctx_t *)aes_ctx;
933 ret = gcm_decrypt_final((gcm_ctx_t *)aes_ctx, data,
948 if ((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE)) == 0) {
964 aes_ctx_t aes_ctx; /* on the stack */
990 bzero(&aes_ctx, sizeof (aes_ctx_t));
992 ret = aes_common_init_ctx(&aes_ctx, template, mechanism, key,
999 length_needed = plaintext->cd_length + aes_ctx.ac_mac_len;
1006 length_needed = plaintext->cd_length + aes_ctx.ac_tag_len;
1027 ret = crypto_update_iov(&aes_ctx, plaintext, ciphertext,
1031 ret = crypto_update_uio(&aes_ctx, plaintext, ciphertext,
1035 ret = crypto_update_mp(&aes_ctx, plaintext, ciphertext,
1044 ret = ccm_encrypt_final((ccm_ctx_t *)&aes_ctx,
1049 ASSERT(aes_ctx.ac_remainder_len == 0);
1052 ret = gcm_encrypt_final((gcm_ctx_t *)&aes_ctx,
1057 ASSERT(aes_ctx.ac_remainder_len == 0);
1059 if (aes_ctx.ac_remainder_len > 0) {
1060 ret = ctr_mode_final((ctr_ctx_t *)&aes_ctx,
1066 ASSERT(aes_ctx.ac_remainder_len == 0);
1079 if (aes_ctx.ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1080 bzero(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1081 kmem_free(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1094 aes_ctx_t aes_ctx; /* on the stack */
1120 bzero(&aes_ctx, sizeof (aes_ctx_t));
1122 ret = aes_common_init_ctx(&aes_ctx, template, mechanism, key,
1129 length_needed = aes_ctx.ac_data_len;
1132 length_needed = ciphertext->cd_length - aes_ctx.ac_tag_len;
1155 gcm_set_kmflag((gcm_ctx_t *)&aes_ctx, crypto_kmflag(req));
1162 ret = crypto_update_iov(&aes_ctx, ciphertext, plaintext,
1166 ret = crypto_update_uio(&aes_ctx, ciphertext, plaintext,
1170 ret = crypto_update_mp(&aes_ctx, ciphertext, plaintext,
1179 ASSERT(aes_ctx.ac_processed_data_len
1180 == aes_ctx.ac_data_len);
1181 ASSERT(aes_ctx.ac_processed_mac_len
1182 == aes_ctx.ac_mac_len);
1183 ret = ccm_decrypt_final((ccm_ctx_t *)&aes_ctx,
1186 ASSERT(aes_ctx.ac_remainder_len == 0);
1196 ret = gcm_decrypt_final((gcm_ctx_t *)&aes_ctx,
1199 ASSERT(aes_ctx.ac_remainder_len == 0);
1208 ASSERT(aes_ctx.ac_remainder_len == 0);
1213 if (aes_ctx.ac_remainder_len > 0) {
1214 ret = ctr_mode_final((ctr_ctx_t *)&aes_ctx,
1231 if (aes_ctx.ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1232 bzero(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1233 kmem_free(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1236 if (aes_ctx.ac_flags & CCM_MODE) {
1237 if (aes_ctx.ac_pt_buf != NULL) {
1238 kmem_free(aes_ctx.ac_pt_buf, aes_ctx.ac_data_len);
1240 } else if (aes_ctx.ac_flags & (GCM_MODE|GMAC_MODE)) {
1241 if (((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf != NULL) {
1242 kmem_free(((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf,
1243 ((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf_len);
1296 aes_ctx_t *aes_ctx = ctx->cc_provider_private;
1298 if (aes_ctx != NULL) {
1299 if (aes_ctx->ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1300 ASSERT(aes_ctx->ac_keysched_len != 0);
1301 bzero(aes_ctx->ac_keysched, aes_ctx->ac_keysched_len);
1302 kmem_free(aes_ctx->ac_keysched,
1303 aes_ctx->ac_keysched_len);
1305 crypto_free_mode_ctx(aes_ctx);
1314 aes_common_init_ctx(aes_ctx_t *aes_ctx, crypto_spi_ctx_template_t *template,
1334 aes_ctx->ac_flags |= PROVIDER_OWNS_KEY_SCHEDULE;
1335 aes_ctx->ac_keysched_len = size;
1339 aes_ctx->ac_keysched = keysched;
1343 rv = cbc_init_ctx((cbc_ctx_t *)aes_ctx, mechanism->cm_param,
1354 rv = ctr_init_ctx((ctr_ctx_t *)aes_ctx, pp->ulCounterBits,
1363 rv = ccm_init_ctx((ccm_ctx_t *)aes_ctx, mechanism->cm_param,
1372 rv = gcm_init_ctx((gcm_ctx_t *)aes_ctx, mechanism->cm_param,
1381 rv = gmac_init_ctx((gcm_ctx_t *)aes_ctx, mechanism->cm_param,
1386 aes_ctx->ac_flags |= ECB_MODE;
1390 if (aes_ctx->ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {