blob: e3231fc7cda4adbfdb3e9af9b8d85132c8457d9a [file] [log] [blame]
Ronald Cron0ff57952021-03-08 16:46:35 +01001/*
2 * PSA cipher driver entry points
3 */
4/*
5 * Copyright The Mbed TLS Contributors
6 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#ifndef PSA_CRYPTO_CIPHER_H
22#define PSA_CRYPTO_CIPHER_H
23
24#include <psa/crypto.h>
25
Ronald Crond6d28882020-12-14 14:56:02 +010026/**
27 * \brief Set the key for a multipart symmetric encryption operation.
28 *
29 * \note The signature of this function is that of a PSA driver
30 * cipher_encrypt_setup entry point. This function behaves as a
31 * cipher_encrypt_setup entry point as defined in the PSA driver
32 * interface specification for transparent drivers.
33 *
34 * \param[in,out] operation The operation object to set up. It has been
35 * initialized as per the documentation for
36 * #psa_cipher_operation_t and not yet in use.
37 * \param[in] attributes The attributes of the key to use for the
38 * operation.
39 * \param[in] key_buffer The buffer containing the key context.
40 * \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
41 * \param[in] alg The cipher algorithm to compute
42 * (\c PSA_ALG_XXX value such that
43 * #PSA_ALG_IS_CIPHER(\p alg) is true).
44 *
45 * \retval #PSA_SUCCESS
46 * \retval #PSA_ERROR_NOT_SUPPORTED
47 * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
48 * \retval #PSA_ERROR_CORRUPTION_DETECTED
49 */
50psa_status_t mbedtls_psa_cipher_encrypt_setup(
51 psa_cipher_operation_t *operation,
52 const psa_key_attributes_t *attributes,
53 const uint8_t *key_buffer, size_t key_buffer_size,
54 psa_algorithm_t alg );
55
56/**
57 * \brief Set the key for a multipart symmetric decryption operation.
58 *
59 * \note The signature of this function is that of a PSA driver
60 * cipher_decrypt_setup entry point. This function behaves as a
61 * cipher_decrypt_setup entry point as defined in the PSA driver
62 * interface specification for transparent drivers.
63 *
64 * \param[in,out] operation The operation object to set up. It has been
65 * initialized as per the documentation for
66 * #psa_cipher_operation_t and not yet in use.
67 * \param[in] attributes The attributes of the key to use for the
68 * operation.
69 * \param[in] key_buffer The buffer containing the key context.
70 * \param[in] key_buffer_size Size of the \p key_buffer buffer in bytes.
71 * \param[in] alg The cipher algorithm to compute
72 * (\c PSA_ALG_XXX value such that
73 * #PSA_ALG_IS_CIPHER(\p alg) is true).
74 *
75 * \retval #PSA_SUCCESS
76 * \retval #PSA_ERROR_NOT_SUPPORTED
77 * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
78 * \retval #PSA_ERROR_CORRUPTION_DETECTED
79 */
80psa_status_t mbedtls_psa_cipher_decrypt_setup(
81 psa_cipher_operation_t *operation,
82 const psa_key_attributes_t *attributes,
83 const uint8_t *key_buffer, size_t key_buffer_size,
84 psa_algorithm_t alg );
85
Ronald Cron0ff57952021-03-08 16:46:35 +010086#endif /* PSA_CRYPTO_CIPHER_H */