Lines Matching refs:operation

2335 psa_status_t psa_hash_abort(psa_hash_operation_t *operation)  argument
2338 if (operation->id == 0) {
2342 psa_status_t status = psa_driver_wrapper_hash_abort(operation);
2343 operation->id = 0;
2348 psa_status_t psa_hash_setup(psa_hash_operation_t *operation, argument
2354 if (operation->id != 0) {
2366 memset(&operation->ctx, 0, sizeof(operation->ctx));
2368 status = psa_driver_wrapper_hash_setup(operation, alg);
2372 psa_hash_abort(operation);
2378 psa_status_t psa_hash_update(psa_hash_operation_t *operation, argument
2385 if (operation->id == 0) {
2397 status = psa_driver_wrapper_hash_update(operation, input, input_length);
2401 psa_hash_abort(operation);
2408 static psa_status_t psa_hash_finish_internal(psa_hash_operation_t *operation, argument
2416 if (operation->id == 0) {
2421 operation, hash, hash_size, hash_length);
2422 psa_hash_abort(operation);
2427 psa_status_t psa_hash_finish(psa_hash_operation_t *operation, argument
2436 status = psa_hash_finish_internal(operation, hash, hash_size, hash_length);
2445 psa_status_t psa_hash_verify(psa_hash_operation_t *operation, argument
2455 operation,
2476 psa_hash_abort(operation);
2574 psa_status_t psa_mac_abort(psa_mac_operation_t *operation) argument
2577 if (operation->id == 0) {
2581 psa_status_t status = psa_driver_wrapper_mac_abort(operation);
2582 operation->mac_size = 0;
2583 operation->is_sign = 0;
2584 operation->id = 0;
2642 static psa_status_t psa_mac_setup(psa_mac_operation_t *operation, argument
2652 if (operation->id != 0) {
2667 &operation->mac_size);
2672 operation->is_sign = is_sign;
2675 status = psa_driver_wrapper_mac_sign_setup(operation,
2681 status = psa_driver_wrapper_mac_verify_setup(operation,
2690 psa_mac_abort(operation);
2698 psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, argument
2702 return psa_mac_setup(operation, key, alg, 1);
2705 psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, argument
2709 return psa_mac_setup(operation, key, alg, 0);
2712 psa_status_t psa_mac_update(psa_mac_operation_t *operation, argument
2719 if (operation->id == 0) {
2732 status = psa_driver_wrapper_mac_update(operation, input, input_length);
2735 psa_mac_abort(operation);
2746 psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, argument
2756 if (operation->id == 0) {
2761 if (!operation->is_sign) {
2768 if (operation->mac_size == 0) {
2773 if (mac_size < operation->mac_size) {
2779 status = psa_driver_wrapper_mac_sign_finish(operation,
2780 mac, operation->mac_size,
2792 operation->mac_size = 0;
2799 abort_status = psa_mac_abort(operation);
2805 psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, argument
2813 if (operation->id == 0) {
2818 if (operation->is_sign) {
2823 if (operation->mac_size != mac_length) {
2829 status = psa_driver_wrapper_mac_verify_finish(operation,
2833 abort_status = psa_mac_abort(operation);
3504 const psa_sign_hash_interruptible_operation_t *operation) argument
3506 return operation->num_ops;
3510 const psa_verify_hash_interruptible_operation_t *operation) argument
3512 return operation->num_ops;
3516 psa_sign_hash_interruptible_operation_t *operation) argument
3518 if (operation->id == 0) {
3527 status = psa_driver_wrapper_sign_hash_abort(operation);
3529 operation->id = 0;
3539 psa_sign_hash_interruptible_operation_t *operation, argument
3551 if (operation->id != 0 || operation->error_occurred) {
3557 operation->error_occurred = 1;
3577 operation->num_ops = 0;
3579 status = psa_driver_wrapper_sign_hash_start(operation, &slot->attr,
3586 operation->error_occurred = 1;
3587 psa_sign_hash_abort_internal(operation);
3593 operation->error_occurred = 1;
3603 psa_sign_hash_interruptible_operation_t *operation, argument
3615 if (operation->id == 0 || operation->error_occurred) {
3629 status = psa_driver_wrapper_sign_hash_complete(operation, signature,
3634 operation->num_ops = psa_driver_wrapper_sign_hash_get_num_ops(operation);
3645 operation->error_occurred = 1;
3648 psa_sign_hash_abort_internal(operation);
3657 psa_sign_hash_interruptible_operation_t *operation) argument
3661 status = psa_sign_hash_abort_internal(operation);
3665 operation->num_ops = 0;
3668 operation->error_occurred = 0;
3674 psa_verify_hash_interruptible_operation_t *operation) argument
3676 if (operation->id == 0) {
3685 status = psa_driver_wrapper_verify_hash_abort(operation);
3687 operation->id = 0;
3697 psa_verify_hash_interruptible_operation_t *operation, argument
3711 if (operation->id != 0 || operation->error_occurred) {
3717 operation->error_occurred = 1;
3726 operation->error_occurred = 1;
3734 operation->num_ops = 0;
3736 status = psa_driver_wrapper_verify_hash_start(operation, &slot->attr,
3746 operation->error_occurred = 1;
3747 psa_verify_hash_abort_internal(operation);
3753 operation->error_occurred = 1;
3763 psa_verify_hash_interruptible_operation_t *operation) argument
3769 if (operation->id == 0 || operation->error_occurred) {
3774 status = psa_driver_wrapper_verify_hash_complete(operation);
3777 operation->num_ops = psa_driver_wrapper_verify_hash_get_num_ops(
3778 operation);
3784 operation->error_occurred = 1;
3787 psa_verify_hash_abort_internal(operation);
3794 psa_verify_hash_interruptible_operation_t *operation) argument
3798 status = psa_verify_hash_abort_internal(operation);
3802 operation->num_ops = 0;
3805 operation->error_occurred = 0;
3837 const mbedtls_psa_sign_hash_interruptible_operation_t *operation) argument
3843 return operation->num_ops;
3845 (void) operation;
3853 const mbedtls_psa_verify_hash_interruptible_operation_t *operation) argument
3859 return operation->num_ops;
3861 (void) operation;
3869 mbedtls_psa_sign_hash_interruptible_operation_t *operation, argument
3889 mbedtls_ecdsa_restart_init(&operation->restart_ctx);
3892 operation->num_ops = 0;
3898 &operation->ctx);
3904 operation->coordinate_bytes = PSA_BITS_TO_BYTES(
3905 operation->ctx->grp.nbits);
3908 operation->md_alg = mbedtls_md_type_from_psa_alg(hash_alg);
3909 operation->alg = alg;
3913 required_hash_length = (hash_length < operation->coordinate_bytes ?
3914 hash_length : operation->coordinate_bytes);
3916 if (required_hash_length > sizeof(operation->hash)) {
3921 memcpy(operation->hash, hash, required_hash_length);
3922 operation->hash_length = required_hash_length;
3927 (void) operation;
3943 mbedtls_psa_sign_hash_interruptible_operation_t *operation, argument
3961 if (signature_size < 2 * operation->coordinate_bytes) {
3966 if (PSA_ALG_ECDSA_IS_DETERMINISTIC(operation->alg)) {
3970 mbedtls_ecdsa_sign_det_restartable(&operation->ctx->grp,
3973 &operation->ctx->d,
3974 operation->hash,
3975 operation->hash_length,
3976 operation->md_alg,
3979 &operation->restart_ctx));
3986 mbedtls_ecdsa_sign_restartable(&operation->ctx->grp,
3989 &operation->ctx->d,
3990 operation->hash,
3991 operation->hash_length,
3996 &operation->restart_ctx));
4001 operation->num_ops += operation->restart_ctx.ecp.ops_done;
4007 operation->coordinate_bytes)
4017 operation->coordinate_bytes,
4018 operation->coordinate_bytes)
4025 *signature_length = operation->coordinate_bytes * 2;
4038 (void) operation;
4051 mbedtls_psa_sign_hash_interruptible_operation_t *operation) argument
4058 if (operation->ctx) {
4059 mbedtls_ecdsa_free(operation->ctx);
4060 mbedtls_free(operation->ctx);
4061 operation->ctx = NULL;
4064 mbedtls_ecdsa_restart_free(&operation->restart_ctx);
4066 operation->num_ops = 0;
4072 (void) operation;
4082 mbedtls_psa_verify_hash_interruptible_operation_t *operation, argument
4105 mbedtls_ecdsa_restart_init(&operation->restart_ctx);
4106 mbedtls_mpi_init(&operation->r);
4107 mbedtls_mpi_init(&operation->s);
4110 operation->num_ops = 0;
4116 &operation->ctx);
4122 coordinate_bytes = PSA_BITS_TO_BYTES(operation->ctx->grp.nbits);
4129 mbedtls_mpi_read_binary(&operation->r,
4138 mbedtls_mpi_read_binary(&operation->s,
4147 status = mbedtls_psa_ecp_load_public_part(operation->ctx);
4158 if (required_hash_length > sizeof(operation->hash)) {
4163 memcpy(operation->hash, hash, required_hash_length);
4164 operation->hash_length = required_hash_length;
4168 (void) operation;
4187 mbedtls_psa_verify_hash_interruptible_operation_t *operation) argument
4200 mbedtls_ecdsa_verify_restartable(&operation->ctx->grp,
4201 operation->hash,
4202 operation->hash_length,
4203 &operation->ctx->Q,
4204 &operation->r,
4205 &operation->s,
4206 &operation->restart_ctx));
4210 operation->num_ops += operation->restart_ctx.ecp.ops_done;
4214 (void) operation;
4224 mbedtls_psa_verify_hash_interruptible_operation_t *operation) argument
4231 if (operation->ctx) {
4232 mbedtls_ecdsa_free(operation->ctx);
4233 mbedtls_free(operation->ctx);
4234 operation->ctx = NULL;
4237 mbedtls_ecdsa_restart_free(&operation->restart_ctx);
4239 operation->num_ops = 0;
4241 mbedtls_mpi_free(&operation->r);
4242 mbedtls_mpi_free(&operation->s);
4247 (void) operation;
4306 static psa_status_t psa_cipher_setup(psa_cipher_operation_t *operation, argument
4319 if (operation->id != 0) {
4338 operation->iv_set = 0;
4340 operation->iv_required = 0;
4342 operation->iv_required = 1;
4344 operation->default_iv_length = PSA_CIPHER_IV_LENGTH(slot->attr.type, alg);
4348 status = psa_driver_wrapper_cipher_encrypt_setup(operation,
4354 status = psa_driver_wrapper_cipher_decrypt_setup(operation,
4363 psa_cipher_abort(operation);
4371 psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, argument
4375 return psa_cipher_setup(operation, key, alg, MBEDTLS_ENCRYPT);
4378 psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, argument
4382 return psa_cipher_setup(operation, key, alg, MBEDTLS_DECRYPT);
4385 psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, argument
4395 if (operation->id == 0) {
4400 if (operation->iv_set || !operation->iv_required) {
4405 default_iv_length = operation->default_iv_length;
4423 status = psa_driver_wrapper_cipher_set_iv(operation,
4429 operation->iv_set = 1;
4432 psa_cipher_abort(operation);
4442 psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, argument
4450 if (operation->id == 0) {
4455 if (operation->iv_set || !operation->iv_required) {
4467 status = psa_driver_wrapper_cipher_set_iv(operation,
4473 operation->iv_set = 1;
4475 psa_cipher_abort(operation);
4483 psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, argument
4495 if (operation->id == 0) {
4500 if (operation->iv_required && !operation->iv_set) {
4508 status = psa_driver_wrapper_cipher_update(operation,
4517 psa_cipher_abort(operation);
4526 psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, argument
4535 if (operation->id == 0) {
4540 if (operation->iv_required && !operation->iv_set) {
4547 status = psa_driver_wrapper_cipher_finish(operation,
4554 status = psa_cipher_abort(operation);
4557 (void) psa_cipher_abort(operation);
4565 psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation) argument
4567 if (operation->id == 0) {
4574 psa_driver_wrapper_cipher_abort(operation);
4576 operation->id = 0;
4577 operation->iv_set = 0;
4578 operation->iv_required = 0;
4953 static psa_status_t psa_aead_setup(psa_aead_operation_t *operation, argument
4968 if (operation->id != 0) {
4973 if (operation->nonce_set || operation->lengths_set ||
4974 operation->ad_started || operation->body_started) {
4996 status = psa_driver_wrapper_aead_encrypt_setup(operation,
5002 status = psa_driver_wrapper_aead_decrypt_setup(operation,
5012 operation->key_type = psa_get_key_type(&slot->attr);
5019 operation->alg = psa_aead_get_base_algorithm(alg);
5020 operation->is_encrypt = is_encrypt;
5022 psa_aead_abort(operation);
5029 psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, argument
5033 return psa_aead_setup(operation, 1, key, alg);
5037 psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, argument
5041 return psa_aead_setup(operation, 0, key, alg);
5044 static psa_status_t psa_aead_set_nonce_internal(psa_aead_operation_t *operation, argument
5050 if (operation->id == 0) {
5055 if (operation->nonce_set) {
5060 status = psa_aead_check_nonce_length(operation->alg, nonce_length);
5066 status = psa_driver_wrapper_aead_set_nonce(operation, nonce,
5071 operation->nonce_set = 1;
5073 psa_aead_abort(operation);
5080 psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation, argument
5094 if (operation->id == 0) {
5099 if (operation->nonce_set || !operation->is_encrypt) {
5113 required_nonce_size = PSA_AEAD_NONCE_LENGTH(operation->key_type,
5114 operation->alg);
5125 status = psa_aead_set_nonce_internal(operation, local_nonce,
5133 psa_aead_abort(operation);
5143 psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, argument
5152 status = psa_aead_set_nonce_internal(operation, nonce, nonce_length);
5165 psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, argument
5171 if (operation->id == 0) {
5176 if (operation->lengths_set || operation->ad_started ||
5177 operation->body_started) {
5182 switch (operation->alg) {
5214 status = psa_driver_wrapper_aead_set_lengths(operation, ad_length,
5219 operation->ad_remaining = ad_length;
5220 operation->body_remaining = plaintext_length;
5221 operation->lengths_set = 1;
5223 psa_aead_abort(operation);
5230 psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, argument
5239 if (operation->id == 0) {
5244 if (!operation->nonce_set || operation->body_started) {
5255 if (operation->lengths_set) {
5256 if (operation->ad_remaining < input_length) {
5261 operation->ad_remaining -= input_length;
5264 else if (operation->alg == PSA_ALG_CCM) {
5270 status = psa_driver_wrapper_aead_update_ad(operation, input,
5275 operation->ad_started = 1;
5277 psa_aead_abort(operation);
5287 psa_status_t psa_aead_update(psa_aead_operation_t *operation, argument
5305 if (operation->id == 0) {
5310 if (!operation->nonce_set) {
5315 if (operation->lengths_set) {
5318 if (operation->ad_remaining != 0) {
5324 if (operation->body_remaining < input_length) {
5329 operation->body_remaining -= input_length;
5332 else if (operation->alg == PSA_ALG_CCM) {
5338 status = psa_driver_wrapper_aead_update(operation, input, input_length,
5344 operation->body_started = 1;
5346 psa_aead_abort(operation);
5355 static psa_status_t psa_aead_final_checks(const psa_aead_operation_t *operation) argument
5357 if (operation->id == 0 || !operation->nonce_set) {
5361 if (operation->lengths_set && (operation->ad_remaining != 0 ||
5362 operation->body_remaining != 0)) {
5370 psa_status_t psa_aead_finish(psa_aead_operation_t *operation, argument
5389 status = psa_aead_final_checks(operation);
5394 if (!operation->is_encrypt) {
5399 status = psa_driver_wrapper_aead_finish(operation, ciphertext,
5414 psa_aead_abort(operation);
5424 psa_status_t psa_aead_verify(psa_aead_operation_t *operation, argument
5441 status = psa_aead_final_checks(operation);
5446 if (operation->is_encrypt) {
5451 status = psa_driver_wrapper_aead_verify(operation, plaintext,
5457 psa_aead_abort(operation);
5466 psa_status_t psa_aead_abort(psa_aead_operation_t *operation) argument
5470 if (operation->id == 0) {
5477 status = psa_driver_wrapper_aead_abort(operation);
5479 memset(operation, 0, sizeof(*operation));
5500 psa_mac_operation_t *operation, argument
5511 operation->is_sign = 1;
5512 operation->mac_size = PSA_HASH_LENGTH(hash_alg);
5514 status = psa_driver_wrapper_mac_sign_setup(operation,
5530 const psa_key_derivation_operation_t *operation) argument
5532 if (PSA_ALG_IS_KEY_AGREEMENT(operation->alg)) {
5533 return PSA_ALG_KEY_AGREEMENT_GET_KDF(operation->alg);
5535 return operation->alg;
5539 psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation) argument
5542 psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation);
5550 mbedtls_free(operation->ctx.hkdf.info);
5551 status = psa_mac_abort(&operation->ctx.hkdf.hmac);
5559 if (operation->ctx.tls12_prf.secret != NULL) {
5560 mbedtls_zeroize_and_free(operation->ctx.tls12_prf.secret,
5561 operation->ctx.tls12_prf.secret_length);
5564 if (operation->ctx.tls12_prf.seed != NULL) {
5565 mbedtls_zeroize_and_free(operation->ctx.tls12_prf.seed,
5566 operation->ctx.tls12_prf.seed_length);
5569 if (operation->ctx.tls12_prf.label != NULL) {
5570 mbedtls_zeroize_and_free(operation->ctx.tls12_prf.label,
5571 operation->ctx.tls12_prf.label_length);
5574 if (operation->ctx.tls12_prf.other_secret != NULL) {
5575 mbedtls_zeroize_and_free(operation->ctx.tls12_prf.other_secret,
5576 operation->ctx.tls12_prf.other_secret_length);
5588 mbedtls_platform_zeroize(operation->ctx.tls12_ecjpake_to_pms.data,
5589 sizeof(operation->ctx.tls12_ecjpake_to_pms.data));
5594 if (operation->ctx.pbkdf2.salt != NULL) {
5595 mbedtls_zeroize_and_free(operation->ctx.pbkdf2.salt,
5596 operation->ctx.pbkdf2.salt_length);
5605 mbedtls_platform_zeroize(operation, sizeof(*operation));
5609 psa_status_t psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, argument
5612 if (operation->alg == 0) {
5617 *capacity = operation->capacity;
5621 psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, argument
5624 if (operation->alg == 0) {
5627 if (capacity > operation->capacity) {
5630 operation->capacity = capacity;
6067 psa_key_derivation_operation_t *operation, argument
6074 psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation);
6076 if (operation->alg == 0) {
6081 if (output_length == 0 && operation->capacity == 0) {
6092 if (output_length > operation->capacity) {
6093 operation->capacity = 0;
6100 operation->capacity -= output_length;
6104 status = psa_key_derivation_hkdf_read(&operation->ctx.hkdf, kdf_alg,
6112 status = psa_key_derivation_tls12_prf_read(&operation->ctx.tls12_prf,
6121 &operation->ctx.tls12_ecjpake_to_pms, output, output_length);
6126 status = psa_key_derivation_pbkdf2_read(&operation->ctx.pbkdf2, kdf_alg,
6145 psa_algorithm_t alg = operation->alg;
6146 psa_key_derivation_abort(operation);
6147 operation->alg = alg;
6206 psa_key_derivation_operation_t *operation, argument
6255 if ((status = psa_key_derivation_output_bytes(operation, *data, m_bytes)) != 0) {
6313 psa_key_derivation_operation_t *operation, argument
6338 status = psa_key_derivation_output_bytes(operation, *data, output_length);
6364 psa_key_derivation_operation_t *operation, uint8_t **data) argument
6368 (void) operation;
6374 size_t bits, psa_key_derivation_operation_t *operation, uint8_t **data) argument
6377 (void) operation;
6387 psa_key_derivation_operation_t *operation) argument
6404 status = psa_generate_derived_ecc_key_weierstrass_helper(slot, bits, operation, &data);
6410 status = psa_generate_derived_ecc_key_montgomery_helper(bits, operation, &data);
6427 status = psa_key_derivation_output_bytes(operation, data, bytes);
6486 psa_key_derivation_operation_t *operation, argument
6509 if (operation->alg == PSA_ALG_NONE) {
6513 if (!operation->can_output_key) {
6528 operation);
6542 psa_key_derivation_operation_t *operation, argument
6548 attributes, operation,
6556 psa_key_derivation_operation_t *operation, argument
6559 return psa_key_derivation_output_key_custom(attributes, operation,
6618 psa_hash_operation_t operation = PSA_HASH_OPERATION_INIT; local
6619 psa_status_t status = psa_hash_setup(&operation, alg);
6620 psa_hash_abort(&operation);
6625 psa_key_derivation_operation_t *operation, argument
6630 operation->capacity = PSA_HASH_LENGTH(PSA_ALG_SHA_256);
6637 operation->capacity = UINT32_MAX * (size_t) PSA_MAC_LENGTH(
6642 operation->capacity = SIZE_MAX;
6666 operation->capacity = 255 * hash_size;
6671 operation->capacity = hash_size;
6676 operation->capacity = 255 * hash_size;
6682 operation->capacity = SIZE_MAX;
6690 operation->capacity = 48U;
6696 operation->capacity = UINT32_MAX * hash_size;
6698 operation->capacity = SIZE_MAX;
6710 psa_key_derivation_operation_t *operation, argument
6715 memset(&operation->ctx, 0, sizeof(operation->ctx));
6722 psa_status_t status = psa_key_derivation_set_maximum_capacity(operation,
6756 psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, argument
6761 if (operation->alg != 0) {
6778 status = psa_key_derivation_setup_kdf(operation, kdf_alg);
6784 status = psa_key_derivation_setup_kdf(operation, alg);
6793 operation->alg = alg;
7379 psa_key_derivation_operation_t *operation, argument
7386 psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation);
7395 status = psa_hkdf_input(&operation->ctx.hkdf, kdf_alg,
7401 status = psa_tls12_prf_input(&operation->ctx.tls12_prf,
7407 status = psa_tls12_prf_psk_to_ms_input(&operation->ctx.tls12_prf,
7414 &operation->ctx.tls12_ecjpake_to_pms, step, data, data_length);
7419 status = psa_pbkdf2_input(&operation->ctx.pbkdf2, kdf_alg,
7433 psa_key_derivation_abort(operation);
7439 psa_key_derivation_operation_t *operation, argument
7444 psa_algorithm_t kdf_alg = psa_key_derivation_get_kdf_alg(operation);
7449 &operation->ctx.pbkdf2, step, value);
7460 psa_key_derivation_abort(operation);
7466 psa_key_derivation_operation_t *operation, argument
7476 status = psa_key_derivation_input_internal(operation, step,
7487 psa_key_derivation_operation_t *operation, argument
7491 return psa_key_derivation_input_integer_internal(operation, step, value);
7495 psa_key_derivation_operation_t *operation, argument
7504 key, &slot, PSA_KEY_USAGE_DERIVE, operation->alg);
7506 psa_key_derivation_abort(operation);
7514 operation->can_output_key = 1;
7517 status = psa_key_derivation_input_internal(operation,
7609 static psa_status_t psa_key_agreement_internal(psa_key_derivation_operation_t *operation, argument
7618 psa_algorithm_t ka_alg = PSA_ALG_KEY_AGREEMENT_GET_BASE(operation->alg);
7635 status = psa_key_derivation_input_internal(operation, step,
7644 psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation, argument
7655 if (!PSA_ALG_IS_KEY_AGREEMENT(operation->alg)) {
7659 private_key, &slot, PSA_KEY_USAGE_DERIVE, operation->alg);
7665 status = psa_key_agreement_internal(operation, step,
7673 psa_key_derivation_abort(operation);
7678 operation->can_output_key = 1;
8492 psa_pake_operation_t *operation, argument
8497 if (operation->stage != PSA_PAKE_OPERATION_STAGE_SETUP) {
8508 memset(&operation->data.inputs, 0, sizeof(operation->data.inputs));
8510 operation->alg = cipher_suite->algorithm;
8511 operation->primitive = PSA_PAKE_PRIMITIVE(cipher_suite->type,
8513 operation->data.inputs.cipher_suite = *cipher_suite;
8516 if (operation->alg == PSA_ALG_JPAKE) {
8518 &operation->computation_stage.jpake;
8529 operation->stage = PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS;
8533 psa_pake_abort(operation);
8538 psa_pake_operation_t *operation, argument
8546 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8553 operation->alg);
8566 operation->data.inputs.password = mbedtls_calloc(1, slot->key.bytes);
8567 if (operation->data.inputs.password == NULL) {
8572 memcpy(operation->data.inputs.password, slot->key.data, slot->key.bytes);
8573 operation->data.inputs.password_len = slot->key.bytes;
8574 operation->data.inputs.attributes = slot->attr;
8578 psa_pake_abort(operation);
8585 psa_pake_operation_t *operation, argument
8592 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8602 if (operation->data.inputs.user_len != 0) {
8607 operation->data.inputs.user = mbedtls_calloc(1, user_id_len);
8608 if (operation->data.inputs.user == NULL) {
8615 memcpy(operation->data.inputs.user, user_id, user_id_len);
8616 operation->data.inputs.user_len = user_id_len;
8623 psa_pake_abort(operation);
8629 psa_pake_operation_t *operation, argument
8636 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8646 if (operation->data.inputs.peer_len != 0) {
8651 operation->data.inputs.peer = mbedtls_calloc(1, peer_id_len);
8652 if (operation->data.inputs.peer == NULL) {
8659 memcpy(operation->data.inputs.peer, peer_id, peer_id_len);
8660 operation->data.inputs.peer_len = peer_id_len;
8667 psa_pake_abort(operation);
8673 psa_pake_operation_t *operation, argument
8678 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8683 switch (operation->alg) {
8698 psa_pake_abort(operation);
8732 psa_pake_operation_t *operation) argument
8737 psa_crypto_driver_pake_inputs_t inputs = operation->data.inputs;
8743 if (operation->alg == PSA_ALG_JPAKE) {
8750 mbedtls_platform_zeroize(&operation->data, sizeof(operation->data));
8752 status = psa_driver_wrapper_pake_setup(operation, &inputs);
8763 if (operation->alg == PSA_ALG_JPAKE) {
8764 operation->stage = PSA_PAKE_OPERATION_STAGE_COMPUTATION;
8776 psa_pake_operation_t *operation, argument
8787 &operation->computation_stage.jpake;
8815 psa_pake_operation_t *operation, argument
8819 &operation->computation_stage.jpake;
8852 psa_pake_operation_t *operation, argument
8863 if (operation->stage == PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8864 status = psa_pake_complete_inputs(operation);
8870 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COMPUTATION) {
8880 switch (operation->alg) {
8883 status = psa_jpake_prologue(operation, step, PSA_JPAKE_OUTPUT);
8888 &operation->computation_stage.jpake);
8899 status = psa_driver_wrapper_pake_output(operation, driver_step,
8906 switch (operation->alg) {
8909 status = psa_jpake_epilogue(operation, PSA_JPAKE_OUTPUT);
8923 psa_pake_abort(operation);
8929 psa_pake_operation_t *operation, argument
8936 const size_t max_input_length = (size_t) PSA_PAKE_INPUT_SIZE(operation->alg,
8937 operation->primitive,
8941 if (operation->stage == PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
8942 status = psa_pake_complete_inputs(operation);
8948 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COMPUTATION) {
8958 switch (operation->alg) {
8961 status = psa_jpake_prologue(operation, step, PSA_JPAKE_INPUT);
8966 &operation->computation_stage.jpake);
8976 status = psa_driver_wrapper_pake_input(operation, driver_step,
8983 switch (operation->alg) {
8986 status = psa_jpake_epilogue(operation, PSA_JPAKE_INPUT);
9000 psa_pake_abort(operation);
9006 psa_pake_operation_t *operation, argument
9014 if (operation->stage != PSA_PAKE_OPERATION_STAGE_COMPUTATION) {
9020 if (operation->alg == PSA_ALG_JPAKE) {
9022 &operation->computation_stage.jpake;
9034 status = psa_driver_wrapper_pake_get_implicit_key(operation,
9050 abort_status = psa_pake_abort(operation);
9055 psa_pake_operation_t *operation) argument
9059 if (operation->stage == PSA_PAKE_OPERATION_STAGE_COMPUTATION) {
9060 status = psa_driver_wrapper_pake_abort(operation);
9063 if (operation->stage == PSA_PAKE_OPERATION_STAGE_COLLECT_INPUTS) {
9064 if (operation->data.inputs.password != NULL) {
9065 mbedtls_zeroize_and_free(operation->data.inputs.password,
9066 operation->data.inputs.password_len);
9068 if (operation->data.inputs.user != NULL) {
9069 mbedtls_free(operation->data.inputs.user);
9071 if (operation->data.inputs.peer != NULL) {
9072 mbedtls_free(operation->data.inputs.peer);
9075 memset(operation, 0, sizeof(psa_pake_operation_t));