Lines Matching refs:ctx

201 void mbedtls_cipher_init(mbedtls_cipher_context_t *ctx)  in mbedtls_cipher_init()  argument
203 memset(ctx, 0, sizeof(mbedtls_cipher_context_t)); in mbedtls_cipher_init()
206 void mbedtls_cipher_free(mbedtls_cipher_context_t *ctx) in mbedtls_cipher_free() argument
208 if (ctx == NULL) { in mbedtls_cipher_free()
213 if (ctx->psa_enabled == 1) { in mbedtls_cipher_free()
214 if (ctx->cipher_ctx != NULL) { in mbedtls_cipher_free()
216 (mbedtls_cipher_context_psa *) ctx->cipher_ctx; in mbedtls_cipher_free()
226 mbedtls_platform_zeroize(ctx, sizeof(mbedtls_cipher_context_t)); in mbedtls_cipher_free()
232 if (ctx->cmac_ctx) { in mbedtls_cipher_free()
233 mbedtls_zeroize_and_free(ctx->cmac_ctx, in mbedtls_cipher_free()
238 if (ctx->cipher_ctx) { in mbedtls_cipher_free()
239 mbedtls_cipher_get_base(ctx->cipher_info)->ctx_free_func(ctx->cipher_ctx); in mbedtls_cipher_free()
242 mbedtls_platform_zeroize(ctx, sizeof(mbedtls_cipher_context_t)); in mbedtls_cipher_free()
245 int mbedtls_cipher_setup(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_setup() argument
252 memset(ctx, 0, sizeof(mbedtls_cipher_context_t)); in mbedtls_cipher_setup()
255 ctx->cipher_ctx = mbedtls_cipher_get_base(cipher_info)->ctx_alloc_func(); in mbedtls_cipher_setup()
256 if (ctx->cipher_ctx == NULL) { in mbedtls_cipher_setup()
261 ctx->cipher_info = cipher_info; in mbedtls_cipher_setup()
267 int mbedtls_cipher_setup_psa(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_setup_psa() argument
274 if (NULL == cipher_info || NULL == ctx) { in mbedtls_cipher_setup_psa()
288 memset(ctx, 0, sizeof(mbedtls_cipher_context_t)); in mbedtls_cipher_setup_psa()
295 ctx->cipher_ctx = cipher_psa; in mbedtls_cipher_setup_psa()
296 ctx->cipher_info = cipher_info; in mbedtls_cipher_setup_psa()
297 ctx->psa_enabled = 1; in mbedtls_cipher_setup_psa()
302 int mbedtls_cipher_setkey(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_setkey() argument
310 if (ctx->cipher_info == NULL) { in mbedtls_cipher_setkey()
314 if (MBEDTLS_MODE_ECB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) && in mbedtls_cipher_setkey()
321 if (ctx->psa_enabled == 1) { in mbedtls_cipher_setkey()
323 (mbedtls_cipher_context_psa *) ctx->cipher_ctx; in mbedtls_cipher_setkey()
342 ((mbedtls_cipher_type_t) ctx->cipher_info->type)); in mbedtls_cipher_setkey()
372 ctx->key_bitlen = key_bitlen; in mbedtls_cipher_setkey()
373 ctx->operation = operation; in mbedtls_cipher_setkey()
378 if ((ctx->cipher_info->flags & MBEDTLS_CIPHER_VARIABLE_KEY_LEN) == 0 && in mbedtls_cipher_setkey()
379 (int) mbedtls_cipher_info_get_key_bitlen(ctx->cipher_info) != key_bitlen) { in mbedtls_cipher_setkey()
383 ctx->key_bitlen = key_bitlen; in mbedtls_cipher_setkey()
384 ctx->operation = operation; in mbedtls_cipher_setkey()
391 MBEDTLS_MODE_CFB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_setkey()
392 MBEDTLS_MODE_OFB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_setkey()
393 MBEDTLS_MODE_CTR == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_setkey()
394 return mbedtls_cipher_get_base(ctx->cipher_info)->setkey_enc_func(ctx->cipher_ctx, key, in mbedtls_cipher_setkey()
395 ctx->key_bitlen); in mbedtls_cipher_setkey()
399 return mbedtls_cipher_get_base(ctx->cipher_info)->setkey_dec_func(ctx->cipher_ctx, key, in mbedtls_cipher_setkey()
400 ctx->key_bitlen); in mbedtls_cipher_setkey()
404 return mbedtls_cipher_get_base(ctx->cipher_info)->setkey_enc_func(ctx->cipher_ctx, key, in mbedtls_cipher_setkey()
405 ctx->key_bitlen); in mbedtls_cipher_setkey()
412 int mbedtls_cipher_set_iv(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_set_iv() argument
418 if (ctx->cipher_info == NULL) { in mbedtls_cipher_set_iv()
422 if (ctx->psa_enabled == 1) { in mbedtls_cipher_set_iv()
435 if ((ctx->cipher_info->flags & MBEDTLS_CIPHER_VARIABLE_IV_LEN) != 0) { in mbedtls_cipher_set_iv()
438 actual_iv_size = mbedtls_cipher_info_get_iv_size(ctx->cipher_info); in mbedtls_cipher_set_iv()
447 if (((mbedtls_cipher_type_t) ctx->cipher_info->type) == MBEDTLS_CIPHER_CHACHA20) { in mbedtls_cipher_set_iv()
455 if (0 != mbedtls_chacha20_starts((mbedtls_chacha20_context *) ctx->cipher_ctx, in mbedtls_cipher_set_iv()
462 if (((mbedtls_cipher_type_t) ctx->cipher_info->type) == MBEDTLS_CIPHER_CHACHA20_POLY1305 && in mbedtls_cipher_set_iv()
470 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_set_iv()
471 return mbedtls_gcm_starts((mbedtls_gcm_context *) ctx->cipher_ctx, in mbedtls_cipher_set_iv()
472 ctx->operation, in mbedtls_cipher_set_iv()
478 if (MBEDTLS_MODE_CCM_STAR_NO_TAG == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_set_iv()
483 (mbedtls_ccm_context *) ctx->cipher_ctx, in mbedtls_cipher_set_iv()
489 if (ctx->operation == MBEDTLS_DECRYPT) { in mbedtls_cipher_set_iv()
491 } else if (ctx->operation == MBEDTLS_ENCRYPT) { in mbedtls_cipher_set_iv()
497 return mbedtls_ccm_starts((mbedtls_ccm_context *) ctx->cipher_ctx, in mbedtls_cipher_set_iv()
504 memcpy(ctx->iv, iv, actual_iv_size); in mbedtls_cipher_set_iv()
505 ctx->iv_size = actual_iv_size; in mbedtls_cipher_set_iv()
511 int mbedtls_cipher_reset(mbedtls_cipher_context_t *ctx) in mbedtls_cipher_reset() argument
513 if (ctx->cipher_info == NULL) { in mbedtls_cipher_reset()
518 if (ctx->psa_enabled == 1) { in mbedtls_cipher_reset()
525 ctx->unprocessed_len = 0; in mbedtls_cipher_reset()
531 int mbedtls_cipher_update_ad(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_update_ad() argument
534 if (ctx->cipher_info == NULL) { in mbedtls_cipher_update_ad()
539 if (ctx->psa_enabled == 1) { in mbedtls_cipher_update_ad()
548 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_update_ad()
549 return mbedtls_gcm_update_ad((mbedtls_gcm_context *) ctx->cipher_ctx, in mbedtls_cipher_update_ad()
555 if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) { in mbedtls_cipher_update_ad()
559 mode = (ctx->operation == MBEDTLS_ENCRYPT) in mbedtls_cipher_update_ad()
563 result = mbedtls_chachapoly_starts((mbedtls_chachapoly_context *) ctx->cipher_ctx, in mbedtls_cipher_update_ad()
564 ctx->iv, in mbedtls_cipher_update_ad()
570 return mbedtls_chachapoly_update_aad((mbedtls_chachapoly_context *) ctx->cipher_ctx, in mbedtls_cipher_update_ad()
579 int mbedtls_cipher_update(mbedtls_cipher_context_t *ctx, const unsigned char *input, in mbedtls_cipher_update() argument
585 if (ctx->cipher_info == NULL) { in mbedtls_cipher_update()
590 if (ctx->psa_enabled == 1) { in mbedtls_cipher_update()
599 block_size = mbedtls_cipher_get_block_size(ctx); in mbedtls_cipher_update()
604 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_ECB) { in mbedtls_cipher_update()
611 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ecb_func(ctx->cipher_ctx, in mbedtls_cipher_update()
612 ctx->operation, input, in mbedtls_cipher_update()
621 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_GCM) { in mbedtls_cipher_update()
622 return mbedtls_gcm_update((mbedtls_gcm_context *) ctx->cipher_ctx, in mbedtls_cipher_update()
629 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_CCM_STAR_NO_TAG) { in mbedtls_cipher_update()
630 return mbedtls_ccm_update((mbedtls_ccm_context *) ctx->cipher_ctx, in mbedtls_cipher_update()
637 if (((mbedtls_cipher_type_t) ctx->cipher_info->type) == MBEDTLS_CIPHER_CHACHA20_POLY1305) { in mbedtls_cipher_update()
639 return mbedtls_chachapoly_update((mbedtls_chachapoly_context *) ctx->cipher_ctx, in mbedtls_cipher_update()
645 (ctx->unprocessed_len != 0 || ilen % block_size)) { in mbedtls_cipher_update()
650 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_CBC) { in mbedtls_cipher_update()
656 if ((ctx->operation == MBEDTLS_DECRYPT && NULL != ctx->add_padding && in mbedtls_cipher_update()
657 ilen <= block_size - ctx->unprocessed_len) || in mbedtls_cipher_update()
658 (ctx->operation == MBEDTLS_DECRYPT && NULL == ctx->add_padding && in mbedtls_cipher_update()
659 ilen < block_size - ctx->unprocessed_len) || in mbedtls_cipher_update()
660 (ctx->operation == MBEDTLS_ENCRYPT && in mbedtls_cipher_update()
661 ilen < block_size - ctx->unprocessed_len)) { in mbedtls_cipher_update()
662 memcpy(&(ctx->unprocessed_data[ctx->unprocessed_len]), input, in mbedtls_cipher_update()
665 ctx->unprocessed_len += ilen; in mbedtls_cipher_update()
672 if (0 != ctx->unprocessed_len) { in mbedtls_cipher_update()
673 copy_len = block_size - ctx->unprocessed_len; in mbedtls_cipher_update()
675 memcpy(&(ctx->unprocessed_data[ctx->unprocessed_len]), input, in mbedtls_cipher_update()
678 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx, in mbedtls_cipher_update()
679 ctx->operation, in mbedtls_cipher_update()
680 block_size, ctx->iv, in mbedtls_cipher_update()
681 ctx-> in mbedtls_cipher_update()
689 ctx->unprocessed_len = 0; in mbedtls_cipher_update()
705 ctx->operation == MBEDTLS_DECRYPT && in mbedtls_cipher_update()
706 NULL != ctx->add_padding) { in mbedtls_cipher_update()
710 memcpy(ctx->unprocessed_data, &(input[ilen - copy_len]), in mbedtls_cipher_update()
713 ctx->unprocessed_len += copy_len; in mbedtls_cipher_update()
721 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx, in mbedtls_cipher_update()
722 ctx->operation, in mbedtls_cipher_update()
723 ilen, ctx->iv, in mbedtls_cipher_update()
737 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_CFB) { in mbedtls_cipher_update()
738 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cfb_func(ctx->cipher_ctx, in mbedtls_cipher_update()
739 ctx->operation, ilen, in mbedtls_cipher_update()
740 &ctx->unprocessed_len, in mbedtls_cipher_update()
741 ctx->iv, in mbedtls_cipher_update()
753 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_OFB) { in mbedtls_cipher_update()
754 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ofb_func(ctx->cipher_ctx, in mbedtls_cipher_update()
756 &ctx->unprocessed_len, in mbedtls_cipher_update()
757 ctx->iv, in mbedtls_cipher_update()
769 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_CTR) { in mbedtls_cipher_update()
770 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->ctr_func(ctx->cipher_ctx, in mbedtls_cipher_update()
772 &ctx->unprocessed_len, in mbedtls_cipher_update()
773 ctx->iv, in mbedtls_cipher_update()
774 ctx->unprocessed_data, in mbedtls_cipher_update()
786 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_XTS) { in mbedtls_cipher_update()
787 if (ctx->unprocessed_len > 0) { in mbedtls_cipher_update()
792 ret = mbedtls_cipher_get_base(ctx->cipher_info)->xts_func(ctx->cipher_ctx, in mbedtls_cipher_update()
793 ctx->operation, in mbedtls_cipher_update()
795 ctx->iv, in mbedtls_cipher_update()
809 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) == MBEDTLS_MODE_STREAM) { in mbedtls_cipher_update()
810 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->stream_func(ctx->cipher_ctx, in mbedtls_cipher_update()
1014 int mbedtls_cipher_finish(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_finish() argument
1017 if (ctx->cipher_info == NULL) { in mbedtls_cipher_finish()
1022 if (ctx->psa_enabled == 1) { in mbedtls_cipher_finish()
1035 if (MBEDTLS_MODE_CBC == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_finish()
1036 if (ctx->get_padding == NULL) { in mbedtls_cipher_finish()
1042 if (MBEDTLS_MODE_CFB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1043 MBEDTLS_MODE_OFB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1044 MBEDTLS_MODE_CTR == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1045 MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1046 MBEDTLS_MODE_CCM_STAR_NO_TAG == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1047 MBEDTLS_MODE_XTS == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_finish()
1048 MBEDTLS_MODE_STREAM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_finish()
1052 if ((MBEDTLS_CIPHER_CHACHA20 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) || in mbedtls_cipher_finish()
1053 (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type))) { in mbedtls_cipher_finish()
1057 if (MBEDTLS_MODE_ECB == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_finish()
1058 if (ctx->unprocessed_len != 0) { in mbedtls_cipher_finish()
1066 if (MBEDTLS_MODE_CBC == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_finish()
1069 if (MBEDTLS_ENCRYPT == ctx->operation) { in mbedtls_cipher_finish()
1071 if (NULL == ctx->add_padding) { in mbedtls_cipher_finish()
1072 if (0 != ctx->unprocessed_len) { in mbedtls_cipher_finish()
1079 ctx->add_padding(ctx->unprocessed_data, mbedtls_cipher_get_iv_size(ctx), in mbedtls_cipher_finish()
1080 ctx->unprocessed_len); in mbedtls_cipher_finish()
1081 } else if (mbedtls_cipher_get_block_size(ctx) != ctx->unprocessed_len) { in mbedtls_cipher_finish()
1086 if (NULL == ctx->add_padding && 0 == ctx->unprocessed_len) { in mbedtls_cipher_finish()
1094 if (0 != (ret = mbedtls_cipher_get_base(ctx->cipher_info)->cbc_func(ctx->cipher_ctx, in mbedtls_cipher_finish()
1095 ctx->operation, in mbedtls_cipher_finish()
1097 ctx), in mbedtls_cipher_finish()
1098 ctx->iv, in mbedtls_cipher_finish()
1099 ctx->unprocessed_data, in mbedtls_cipher_finish()
1105 if (MBEDTLS_DECRYPT == ctx->operation) { in mbedtls_cipher_finish()
1106 return ctx->get_padding(output, mbedtls_cipher_get_block_size(ctx), in mbedtls_cipher_finish()
1111 *olen = mbedtls_cipher_get_block_size(ctx); in mbedtls_cipher_finish()
1122 int mbedtls_cipher_set_padding_mode(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_set_padding_mode() argument
1125 if (NULL == ctx->cipher_info || in mbedtls_cipher_set_padding_mode()
1126 MBEDTLS_MODE_CBC != ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_set_padding_mode()
1131 if (ctx->psa_enabled == 1) { in mbedtls_cipher_set_padding_mode()
1146 ctx->add_padding = add_pkcs_padding; in mbedtls_cipher_set_padding_mode()
1147 ctx->get_padding = get_pkcs_padding; in mbedtls_cipher_set_padding_mode()
1152 ctx->add_padding = add_one_and_zeros_padding; in mbedtls_cipher_set_padding_mode()
1153 ctx->get_padding = get_one_and_zeros_padding; in mbedtls_cipher_set_padding_mode()
1158 ctx->add_padding = add_zeros_and_len_padding; in mbedtls_cipher_set_padding_mode()
1159 ctx->get_padding = get_zeros_and_len_padding; in mbedtls_cipher_set_padding_mode()
1164 ctx->add_padding = add_zeros_padding; in mbedtls_cipher_set_padding_mode()
1165 ctx->get_padding = get_zeros_padding; in mbedtls_cipher_set_padding_mode()
1169 ctx->add_padding = NULL; in mbedtls_cipher_set_padding_mode()
1170 ctx->get_padding = get_no_padding; in mbedtls_cipher_set_padding_mode()
1182 int mbedtls_cipher_write_tag(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_write_tag() argument
1185 if (ctx->cipher_info == NULL) { in mbedtls_cipher_write_tag()
1189 if (MBEDTLS_ENCRYPT != ctx->operation) { in mbedtls_cipher_write_tag()
1194 if (ctx->psa_enabled == 1) { in mbedtls_cipher_write_tag()
1203 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_write_tag()
1207 return mbedtls_gcm_finish((mbedtls_gcm_context *) ctx->cipher_ctx, in mbedtls_cipher_write_tag()
1214 if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) { in mbedtls_cipher_write_tag()
1221 (mbedtls_chachapoly_context *) ctx->cipher_ctx, tag); in mbedtls_cipher_write_tag()
1228 int mbedtls_cipher_check_tag(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_check_tag() argument
1234 if (ctx->cipher_info == NULL) { in mbedtls_cipher_check_tag()
1238 if (MBEDTLS_DECRYPT != ctx->operation) { in mbedtls_cipher_check_tag()
1243 if (ctx->psa_enabled == 1) { in mbedtls_cipher_check_tag()
1255 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_check_tag()
1265 (mbedtls_gcm_context *) ctx->cipher_ctx, in mbedtls_cipher_check_tag()
1280 if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) { in mbedtls_cipher_check_tag()
1287 (mbedtls_chachapoly_context *) ctx->cipher_ctx, check_tag); in mbedtls_cipher_check_tag()
1309 int mbedtls_cipher_crypt(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_crypt() argument
1318 if (ctx->psa_enabled == 1) { in mbedtls_cipher_crypt()
1325 (mbedtls_cipher_context_psa *) ctx->cipher_ctx; in mbedtls_cipher_crypt()
1331 if (ctx->operation == MBEDTLS_DECRYPT) { in mbedtls_cipher_crypt()
1335 } else if (ctx->operation == MBEDTLS_ENCRYPT) { in mbedtls_cipher_crypt()
1351 if (((mbedtls_cipher_mode_t) ctx->cipher_info->mode) != MBEDTLS_MODE_ECB) { in mbedtls_cipher_crypt()
1377 if ((ret = mbedtls_cipher_set_iv(ctx, iv, iv_len)) != 0) { in mbedtls_cipher_crypt()
1381 if ((ret = mbedtls_cipher_reset(ctx)) != 0) { in mbedtls_cipher_crypt()
1385 if ((ret = mbedtls_cipher_update(ctx, input, ilen, in mbedtls_cipher_crypt()
1390 if ((ret = mbedtls_cipher_finish(ctx, output + *olen, in mbedtls_cipher_crypt()
1405 static int mbedtls_cipher_aead_encrypt(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_aead_encrypt() argument
1413 if (ctx->psa_enabled == 1) { in mbedtls_cipher_aead_encrypt()
1420 (mbedtls_cipher_context_psa *) ctx->cipher_ctx; in mbedtls_cipher_aead_encrypt()
1446 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_aead_encrypt()
1448 return mbedtls_gcm_crypt_and_tag(ctx->cipher_ctx, MBEDTLS_GCM_ENCRYPT, in mbedtls_cipher_aead_encrypt()
1454 if (MBEDTLS_MODE_CCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_aead_encrypt()
1456 return mbedtls_ccm_encrypt_and_tag(ctx->cipher_ctx, ilen, in mbedtls_cipher_aead_encrypt()
1462 if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) { in mbedtls_cipher_aead_encrypt()
1464 if ((iv_len != mbedtls_cipher_info_get_iv_size(ctx->cipher_info)) || in mbedtls_cipher_aead_encrypt()
1470 return mbedtls_chachapoly_encrypt_and_tag(ctx->cipher_ctx, in mbedtls_cipher_aead_encrypt()
1482 static int mbedtls_cipher_aead_decrypt(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_aead_decrypt() argument
1490 if (ctx->psa_enabled == 1) { in mbedtls_cipher_aead_decrypt()
1497 (mbedtls_cipher_context_psa *) ctx->cipher_ctx; in mbedtls_cipher_aead_decrypt()
1524 if (MBEDTLS_MODE_GCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_aead_decrypt()
1528 ret = mbedtls_gcm_auth_decrypt(ctx->cipher_ctx, ilen, in mbedtls_cipher_aead_decrypt()
1540 if (MBEDTLS_MODE_CCM == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) { in mbedtls_cipher_aead_decrypt()
1544 ret = mbedtls_ccm_auth_decrypt(ctx->cipher_ctx, ilen, in mbedtls_cipher_aead_decrypt()
1556 if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ((mbedtls_cipher_type_t) ctx->cipher_info->type)) { in mbedtls_cipher_aead_decrypt()
1560 if ((iv_len != mbedtls_cipher_info_get_iv_size(ctx->cipher_info)) || in mbedtls_cipher_aead_decrypt()
1566 ret = mbedtls_chachapoly_auth_decrypt(ctx->cipher_ctx, ilen, in mbedtls_cipher_aead_decrypt()
1585 int mbedtls_cipher_auth_encrypt_ext(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_auth_encrypt_ext() argument
1595 ctx->psa_enabled == 0 && in mbedtls_cipher_auth_encrypt_ext()
1597 (MBEDTLS_MODE_KW == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_auth_encrypt_ext()
1598 MBEDTLS_MODE_KWP == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode))) { in mbedtls_cipher_auth_encrypt_ext()
1600 (MBEDTLS_MODE_KW == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) ? in mbedtls_cipher_auth_encrypt_ext()
1612 return mbedtls_nist_kw_wrap(ctx->cipher_ctx, mode, input, ilen, in mbedtls_cipher_auth_encrypt_ext()
1623 int ret = mbedtls_cipher_aead_encrypt(ctx, iv, iv_len, ad, ad_len, in mbedtls_cipher_auth_encrypt_ext()
1636 int mbedtls_cipher_auth_decrypt_ext(mbedtls_cipher_context_t *ctx, in mbedtls_cipher_auth_decrypt_ext() argument
1646 ctx->psa_enabled == 0 && in mbedtls_cipher_auth_decrypt_ext()
1648 (MBEDTLS_MODE_KW == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode) || in mbedtls_cipher_auth_decrypt_ext()
1649 MBEDTLS_MODE_KWP == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode))) { in mbedtls_cipher_auth_decrypt_ext()
1651 (MBEDTLS_MODE_KW == ((mbedtls_cipher_mode_t) ctx->cipher_info->mode)) ? in mbedtls_cipher_auth_decrypt_ext()
1663 return mbedtls_nist_kw_unwrap(ctx->cipher_ctx, mode, input, ilen, in mbedtls_cipher_auth_decrypt_ext()
1674 return mbedtls_cipher_aead_decrypt(ctx, iv, iv_len, ad, ad_len, in mbedtls_cipher_auth_decrypt_ext()