Lines Matching refs:operation

27     mbedtls_psa_aead_operation_t *operation,
48 operation->alg = PSA_ALG_CCM;
56 mbedtls_ccm_init(&operation->ctx.ccm);
58 mbedtls_ccm_setkey(&operation->ctx.ccm, cipher_id,
68 operation->alg = PSA_ALG_GCM;
76 mbedtls_gcm_init(&operation->ctx.gcm);
78 mbedtls_gcm_setkey(&operation->ctx.gcm, cipher_id,
88 operation->alg = PSA_ALG_CHACHA20_POLY1305;
94 mbedtls_chachapoly_init(&operation->ctx.chachapoly);
96 mbedtls_chachapoly_setkey(&operation->ctx.chachapoly,
110 operation->key_type = psa_get_key_type(attributes);
112 operation->tag_length = PSA_ALG_AEAD_GET_TAG_LENGTH(alg);
127 mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT;
130 status = psa_aead_setup(&operation, attributes, key_buffer,
139 if (ciphertext_size < (plaintext_length + operation.tag_length)) {
146 if (operation.alg == PSA_ALG_CCM) {
148 mbedtls_ccm_encrypt_and_tag(&operation.ctx.ccm,
154 tag, operation.tag_length));
158 if (operation.alg == PSA_ALG_GCM) {
160 mbedtls_gcm_crypt_and_tag(&operation.ctx.gcm,
166 operation.tag_length, tag));
170 if (operation.alg == PSA_ALG_CHACHA20_POLY1305) {
171 if (operation.tag_length != 16) {
176 mbedtls_chachapoly_encrypt_and_tag(&operation.ctx.chachapoly,
197 *ciphertext_length = plaintext_length + operation.tag_length;
201 mbedtls_psa_aead_abort(&operation);
239 mbedtls_psa_aead_operation_t operation = MBEDTLS_PSA_AEAD_OPERATION_INIT;
242 status = psa_aead_setup(&operation, attributes, key_buffer,
249 status = psa_aead_unpadded_locate_tag(operation.tag_length,
257 if (operation.alg == PSA_ALG_CCM) {
259 mbedtls_ccm_auth_decrypt(&operation.ctx.ccm,
260 ciphertext_length - operation.tag_length,
265 tag, operation.tag_length));
269 if (operation.alg == PSA_ALG_GCM) {
271 mbedtls_gcm_auth_decrypt(&operation.ctx.gcm,
272 ciphertext_length - operation.tag_length,
276 tag, operation.tag_length,
281 if (operation.alg == PSA_ALG_CHACHA20_POLY1305) {
282 if (operation.tag_length != 16) {
287 mbedtls_chachapoly_auth_decrypt(&operation.ctx.chachapoly,
288 ciphertext_length - operation.tag_length,
307 *plaintext_length = ciphertext_length - operation.tag_length;
311 mbedtls_psa_aead_abort(&operation);
314 *plaintext_length = ciphertext_length - operation.tag_length;
320 * operation. */
322 mbedtls_psa_aead_operation_t *operation,
330 status = psa_aead_setup(operation, attributes, key_buffer,
334 operation->is_encrypt = 1;
341 * operation. */
343 mbedtls_psa_aead_operation_t *operation,
351 status = psa_aead_setup(operation, attributes, key_buffer,
355 operation->is_encrypt = 0;
361 /* Set a nonce for the multipart AEAD operation*/
363 mbedtls_psa_aead_operation_t *operation,
370 if (operation->alg == PSA_ALG_GCM) {
372 mbedtls_gcm_starts(&operation->ctx.gcm,
373 operation->is_encrypt ?
380 if (operation->alg == PSA_ALG_CCM) {
382 mbedtls_ccm_starts(&operation->ctx.ccm,
383 operation->is_encrypt ?
390 if (operation->alg == PSA_ALG_CHACHA20_POLY1305) {
392 * allocate a buffer in the operation, copy the nonce to it and pad
401 mbedtls_chachapoly_starts(&operation->ctx.chachapoly,
403 operation->is_encrypt ?
409 (void) operation;
421 mbedtls_psa_aead_operation_t *operation,
426 if (operation->alg == PSA_ALG_CCM) {
428 mbedtls_ccm_set_lengths(&operation->ctx.ccm,
431 operation->tag_length));
435 (void) operation;
443 /* Pass additional data to an active multipart AEAD operation. */
445 mbedtls_psa_aead_operation_t *operation,
452 if (operation->alg == PSA_ALG_GCM) {
454 mbedtls_gcm_update_ad(&operation->ctx.gcm, input, input_length));
458 if (operation->alg == PSA_ALG_CCM) {
460 mbedtls_ccm_update_ad(&operation->ctx.ccm, input, input_length));
464 if (operation->alg == PSA_ALG_CHACHA20_POLY1305) {
466 mbedtls_chachapoly_update_aad(&operation->ctx.chachapoly,
472 (void) operation;
483 * operation.*/
485 mbedtls_psa_aead_operation_t *operation,
498 if (operation->alg == PSA_ALG_GCM) {
500 mbedtls_gcm_update(&operation->ctx.gcm,
507 if (operation->alg == PSA_ALG_CCM) {
513 mbedtls_ccm_update(&operation->ctx.ccm,
520 if (operation->alg == PSA_ALG_CHACHA20_POLY1305) {
526 mbedtls_chachapoly_update(&operation->ctx.chachapoly,
533 (void) operation;
548 /* Finish encrypting a message in a multipart AEAD operation. */
550 mbedtls_psa_aead_operation_t *operation,
561 if (tag_size < operation->tag_length) {
566 if (operation->alg == PSA_ALG_GCM) {
568 mbedtls_gcm_finish(&operation->ctx.gcm,
570 tag, operation->tag_length));
574 if (operation->alg == PSA_ALG_CCM) {
577 if (tag_size < operation->tag_length) {
582 mbedtls_ccm_finish(&operation->ctx.ccm,
583 tag, operation->tag_length));
587 if (operation->alg == PSA_ALG_CHACHA20_POLY1305) {
597 mbedtls_chachapoly_finish(&operation->ctx.chachapoly,
616 *tag_length = operation->tag_length;
622 /* Abort an AEAD operation */
624 mbedtls_psa_aead_operation_t *operation)
626 switch (operation->alg) {
629 mbedtls_ccm_free(&operation->ctx.ccm);
634 mbedtls_gcm_free(&operation->ctx.gcm);
639 mbedtls_chachapoly_free(&operation->ctx.chachapoly);
644 operation->is_encrypt = 0;