Ronald Cron | de82281 | 2021-03-17 16:08:20 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Test driver for AEAD entry points. |
| 3 | */ |
| 4 | /* Copyright The Mbed TLS Contributors |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | * not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 21 | #include "mbedtls/config.h" |
| 22 | #else |
| 23 | #include MBEDTLS_CONFIG_FILE |
| 24 | #endif |
| 25 | |
| 26 | #if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST) |
| 27 | #include "psa_crypto_aead.h" |
| 28 | |
| 29 | #include "test/drivers/aead.h" |
| 30 | |
| 31 | psa_status_t test_transparent_aead_encrypt( |
| 32 | const psa_key_attributes_t *attributes, |
| 33 | const uint8_t *key_buffer, size_t key_buffer_size, |
| 34 | psa_algorithm_t alg, |
| 35 | const uint8_t *nonce, size_t nonce_length, |
| 36 | const uint8_t *additional_data, size_t additional_data_length, |
| 37 | const uint8_t *plaintext, size_t plaintext_length, |
| 38 | uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length ) |
| 39 | { |
| 40 | return( mbedtls_psa_aead_encrypt( |
| 41 | attributes, key_buffer, key_buffer_size, |
| 42 | alg, |
| 43 | nonce, nonce_length, |
| 44 | additional_data, additional_data_length, |
| 45 | plaintext, plaintext_length, |
| 46 | ciphertext, ciphertext_size, ciphertext_length ) ); |
| 47 | } |
| 48 | |
| 49 | psa_status_t test_transparent_aead_decrypt( |
| 50 | const psa_key_attributes_t *attributes, |
| 51 | const uint8_t *key_buffer, size_t key_buffer_size, |
| 52 | psa_algorithm_t alg, |
| 53 | const uint8_t *nonce, size_t nonce_length, |
| 54 | const uint8_t *additional_data, size_t additional_data_length, |
| 55 | const uint8_t *ciphertext, size_t ciphertext_length, |
| 56 | uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length ) |
| 57 | { |
| 58 | return( mbedtls_psa_aead_decrypt( |
| 59 | attributes, key_buffer, key_buffer_size, |
| 60 | alg, |
| 61 | nonce, nonce_length, |
| 62 | additional_data, additional_data_length, |
| 63 | ciphertext, ciphertext_length, |
| 64 | plaintext, plaintext_size, plaintext_length ) ); |
| 65 | } |
| 66 | |
| 67 | #endif /* MBEDTLS_PSA_CRYPTO_DRIVERS && PSA_CRYPTO_DRIVER_TEST */ |