Lines Matching defs:aes_ctx

385 	aes_ctx_t *aes_ctx;
397 if ((rv = aes_check_mech_param(mechanism, &aes_ctx, kmflag))
401 rv = aes_common_init_ctx(aes_ctx, template, mechanism, key, kmflag,
404 crypto_free_mode_ctx(aes_ctx);
408 ctx->cc_provider_private = aes_ctx;
439 aes_ctx_t *aes_ctx;
443 aes_ctx = ctx->cc_provider_private;
449 if (((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE))
459 switch (aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) {
461 length_needed = plaintext->cd_length + aes_ctx->ac_mac_len;
464 length_needed = plaintext->cd_length + aes_ctx->ac_tag_len;
470 length_needed = aes_ctx->ac_tag_len;
496 if (aes_ctx->ac_flags & CCM_MODE) {
506 ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, ciphertext,
517 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
527 ret = gcm_encrypt_final((gcm_ctx_t *)aes_ctx, ciphertext,
541 ASSERT(aes_ctx->ac_remainder_len == 0);
558 aes_ctx_t *aes_ctx;
563 aes_ctx = ctx->cc_provider_private;
569 if (((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE))
584 switch (aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) {
586 length_needed = aes_ctx->ac_processed_data_len;
589 length_needed = ciphertext->cd_length - aes_ctx->ac_tag_len;
617 if (aes_ctx->ac_flags & CCM_MODE) {
618 ASSERT(aes_ctx->ac_processed_data_len == aes_ctx->ac_data_len);
619 ASSERT(aes_ctx->ac_processed_mac_len == aes_ctx->ac_mac_len);
625 ret = ccm_decrypt_final((ccm_ctx_t *)aes_ctx, plaintext,
638 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
643 ret = gcm_decrypt_final((gcm_ctx_t *)aes_ctx, plaintext,
657 ASSERT(aes_ctx->ac_remainder_len == 0);
676 aes_ctx_t *aes_ctx;
679 aes_ctx = ctx->cc_provider_private;
684 out_len = aes_ctx->ac_remainder_len;
726 if ((aes_ctx->ac_flags & CTR_MODE) && (aes_ctx->ac_remainder_len > 0)) {
727 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx,
751 aes_ctx_t *aes_ctx;
754 aes_ctx = ctx->cc_provider_private;
763 if ((aes_ctx->ac_flags & (CCM_MODE|GCM_MODE|GMAC_MODE)) == 0) {
764 out_len = aes_ctx->ac_remainder_len;
778 if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE))
779 gcm_set_kmflag((gcm_ctx_t *)aes_ctx, crypto_kmflag(req));
810 if ((aes_ctx->ac_flags & CTR_MODE) && (aes_ctx->ac_remainder_len > 0)) {
811 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, plaintext,
838 aes_ctx_t *aes_ctx;
842 aes_ctx = ctx->cc_provider_private;
850 if (aes_ctx->ac_flags & CTR_MODE) {
851 if (aes_ctx->ac_remainder_len > 0) {
852 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, data,
857 } else if (aes_ctx->ac_flags & CCM_MODE) {
858 ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, data,
863 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
866 ret = gcm_encrypt_final((gcm_ctx_t *)aes_ctx, data,
880 if (aes_ctx->ac_remainder_len > 0) {
901 aes_ctx_t *aes_ctx;
907 aes_ctx = ctx->cc_provider_private;
920 if (aes_ctx->ac_remainder_len > 0) {
921 if ((aes_ctx->ac_flags & CTR_MODE) == 0)
924 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, data,
933 if (aes_ctx->ac_flags & CCM_MODE) {
938 size_t pt_len = aes_ctx->ac_data_len;
944 ASSERT(aes_ctx->ac_processed_data_len == pt_len);
945 ASSERT(aes_ctx->ac_processed_mac_len == aes_ctx->ac_mac_len);
948 ret = ccm_decrypt_final((ccm_ctx_t *)aes_ctx, data,
961 } else if (aes_ctx->ac_flags & (GCM_MODE|GMAC_MODE)) {
966 gcm_ctx_t *ctx = (gcm_ctx_t *)aes_ctx;
976 ret = gcm_decrypt_final((gcm_ctx_t *)aes_ctx, data,
991 if ((aes_ctx->ac_flags & (CTR_MODE|CCM_MODE|GCM_MODE|GMAC_MODE)) == 0) {
1009 aes_ctx_t aes_ctx; /* on the stack */
1035 bzero(&aes_ctx, sizeof (aes_ctx_t));
1037 ret = aes_common_init_ctx(&aes_ctx, template, mechanism, key,
1044 length_needed = plaintext->cd_length + aes_ctx.ac_mac_len;
1051 length_needed = plaintext->cd_length + aes_ctx.ac_tag_len;
1072 ret = crypto_update_iov(&aes_ctx, plaintext, ciphertext,
1076 ret = crypto_update_uio(&aes_ctx, plaintext, ciphertext,
1080 ret = crypto_update_mp(&aes_ctx, plaintext, ciphertext,
1089 ret = ccm_encrypt_final((ccm_ctx_t *)&aes_ctx,
1094 ASSERT(aes_ctx.ac_remainder_len == 0);
1097 ret = gcm_encrypt_final((gcm_ctx_t *)&aes_ctx,
1102 ASSERT(aes_ctx.ac_remainder_len == 0);
1104 if (aes_ctx.ac_remainder_len > 0) {
1105 ret = ctr_mode_final((ctr_ctx_t *)&aes_ctx,
1111 ASSERT(aes_ctx.ac_remainder_len == 0);
1124 if (aes_ctx.ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1125 bzero(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1126 kmem_free(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1139 aes_ctx_t aes_ctx; /* on the stack */
1165 bzero(&aes_ctx, sizeof (aes_ctx_t));
1167 ret = aes_common_init_ctx(&aes_ctx, template, mechanism, key,
1174 length_needed = aes_ctx.ac_data_len;
1177 length_needed = ciphertext->cd_length - aes_ctx.ac_tag_len;
1200 gcm_set_kmflag((gcm_ctx_t *)&aes_ctx, crypto_kmflag(req));
1207 ret = crypto_update_iov(&aes_ctx, ciphertext, plaintext,
1211 ret = crypto_update_uio(&aes_ctx, ciphertext, plaintext,
1215 ret = crypto_update_mp(&aes_ctx, ciphertext, plaintext,
1224 ASSERT(aes_ctx.ac_processed_data_len
1225 == aes_ctx.ac_data_len);
1226 ASSERT(aes_ctx.ac_processed_mac_len
1227 == aes_ctx.ac_mac_len);
1228 ret = ccm_decrypt_final((ccm_ctx_t *)&aes_ctx,
1231 ASSERT(aes_ctx.ac_remainder_len == 0);
1241 ret = gcm_decrypt_final((gcm_ctx_t *)&aes_ctx,
1244 ASSERT(aes_ctx.ac_remainder_len == 0);
1253 ASSERT(aes_ctx.ac_remainder_len == 0);
1258 if (aes_ctx.ac_remainder_len > 0) {
1259 ret = ctr_mode_final((ctr_ctx_t *)&aes_ctx,
1276 if (aes_ctx.ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1277 bzero(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1278 kmem_free(aes_ctx.ac_keysched, aes_ctx.ac_keysched_len);
1281 if (aes_ctx.ac_flags & CCM_MODE) {
1282 if (aes_ctx.ac_pt_buf != NULL) {
1283 kmem_free(aes_ctx.ac_pt_buf, aes_ctx.ac_data_len);
1285 } else if (aes_ctx.ac_flags & (GCM_MODE|GMAC_MODE)) {
1286 if (((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf != NULL) {
1287 kmem_free(((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf,
1288 ((gcm_ctx_t *)&aes_ctx)->gcm_pt_buf_len);
1349 aes_ctx_t *aes_ctx = ctx->cc_provider_private;
1351 if (aes_ctx != NULL) {
1352 if (aes_ctx->ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {
1353 ASSERT(aes_ctx->ac_keysched_len != 0);
1354 bzero(aes_ctx->ac_keysched, aes_ctx->ac_keysched_len);
1355 kmem_free(aes_ctx->ac_keysched,
1356 aes_ctx->ac_keysched_len);
1358 crypto_free_mode_ctx(aes_ctx);
1369 aes_common_init_ctx(aes_ctx_t *aes_ctx, crypto_spi_ctx_template_t *template,
1392 aes_ctx->ac_flags |= PROVIDER_OWNS_KEY_SCHEDULE;
1393 aes_ctx->ac_keysched_len = size;
1397 aes_ctx->ac_keysched = keysched;
1401 rv = cbc_init_ctx((cbc_ctx_t *)aes_ctx, mechanism->cm_param,
1412 rv = ctr_init_ctx((ctr_ctx_t *)aes_ctx, pp->ulCounterBits,
1421 rv = ccm_init_ctx((ccm_ctx_t *)aes_ctx, mechanism->cm_param,
1430 rv = gcm_init_ctx((gcm_ctx_t *)aes_ctx, mechanism->cm_param,
1439 rv = gmac_init_ctx((gcm_ctx_t *)aes_ctx, mechanism->cm_param,
1444 aes_ctx->ac_flags |= ECB_MODE;
1448 if (aes_ctx->ac_flags & PROVIDER_OWNS_KEY_SCHEDULE) {