xref: /aosp_15_r20/external/mbedtls/library/psa_crypto_cipher.h (revision 62c56f9862f102b96d72393aff6076c951fb8148)
1*62c56f98SSadaf Ebrahimi /*
2*62c56f98SSadaf Ebrahimi  *  PSA cipher driver entry points and associated auxiliary functions
3*62c56f98SSadaf Ebrahimi  */
4*62c56f98SSadaf Ebrahimi /*
5*62c56f98SSadaf Ebrahimi  *  Copyright The Mbed TLS Contributors
6*62c56f98SSadaf Ebrahimi  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7*62c56f98SSadaf Ebrahimi  */
8*62c56f98SSadaf Ebrahimi 
9*62c56f98SSadaf Ebrahimi #ifndef PSA_CRYPTO_CIPHER_H
10*62c56f98SSadaf Ebrahimi #define PSA_CRYPTO_CIPHER_H
11*62c56f98SSadaf Ebrahimi 
12*62c56f98SSadaf Ebrahimi #include <mbedtls/cipher.h>
13*62c56f98SSadaf Ebrahimi #include <psa/crypto.h>
14*62c56f98SSadaf Ebrahimi 
15*62c56f98SSadaf Ebrahimi /** Get Mbed TLS cipher information given the cipher algorithm PSA identifier
16*62c56f98SSadaf Ebrahimi  *  as well as the PSA type and size of the key to be used with the cipher
17*62c56f98SSadaf Ebrahimi  *  algorithm.
18*62c56f98SSadaf Ebrahimi  *
19*62c56f98SSadaf Ebrahimi  * \param       alg        PSA cipher algorithm identifier
20*62c56f98SSadaf Ebrahimi  * \param       key_type   PSA key type
21*62c56f98SSadaf Ebrahimi  * \param       key_bits   Size of the key in bits
22*62c56f98SSadaf Ebrahimi  * \param[out]  cipher_id  Mbed TLS cipher algorithm identifier
23*62c56f98SSadaf Ebrahimi  *
24*62c56f98SSadaf Ebrahimi  * \return  The Mbed TLS cipher information of the cipher algorithm.
25*62c56f98SSadaf Ebrahimi  *          \c NULL if the PSA cipher algorithm is not supported.
26*62c56f98SSadaf Ebrahimi  */
27*62c56f98SSadaf Ebrahimi const mbedtls_cipher_info_t *mbedtls_cipher_info_from_psa(
28*62c56f98SSadaf Ebrahimi     psa_algorithm_t alg, psa_key_type_t key_type, size_t key_bits,
29*62c56f98SSadaf Ebrahimi     mbedtls_cipher_id_t *cipher_id);
30*62c56f98SSadaf Ebrahimi 
31*62c56f98SSadaf Ebrahimi /**
32*62c56f98SSadaf Ebrahimi  * \brief Set the key for a multipart symmetric encryption operation.
33*62c56f98SSadaf Ebrahimi  *
34*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
35*62c56f98SSadaf Ebrahimi  *       cipher_encrypt_setup entry point. This function behaves as a
36*62c56f98SSadaf Ebrahimi  *       cipher_encrypt_setup entry point as defined in the PSA driver
37*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
38*62c56f98SSadaf Ebrahimi  *
39*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     The operation object to set up. It has been
40*62c56f98SSadaf Ebrahimi  *                              initialized as per the documentation for
41*62c56f98SSadaf Ebrahimi  *                              #psa_cipher_operation_t and not yet in use.
42*62c56f98SSadaf Ebrahimi  * \param[in] attributes        The attributes of the key to use for the
43*62c56f98SSadaf Ebrahimi  *                              operation.
44*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer        The buffer containing the key context.
45*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer_size   Size of the \p key_buffer buffer in bytes.
46*62c56f98SSadaf Ebrahimi  * \param[in] alg               The cipher algorithm to compute
47*62c56f98SSadaf Ebrahimi  *                              (\c PSA_ALG_XXX value such that
48*62c56f98SSadaf Ebrahimi  *                              #PSA_ALG_IS_CIPHER(\p alg) is true).
49*62c56f98SSadaf Ebrahimi  *
50*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
51*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
52*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
53*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
54*62c56f98SSadaf Ebrahimi  */
55*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_encrypt_setup(
56*62c56f98SSadaf Ebrahimi     mbedtls_psa_cipher_operation_t *operation,
57*62c56f98SSadaf Ebrahimi     const psa_key_attributes_t *attributes,
58*62c56f98SSadaf Ebrahimi     const uint8_t *key_buffer, size_t key_buffer_size,
59*62c56f98SSadaf Ebrahimi     psa_algorithm_t alg);
60*62c56f98SSadaf Ebrahimi 
61*62c56f98SSadaf Ebrahimi /**
62*62c56f98SSadaf Ebrahimi  * \brief Set the key for a multipart symmetric decryption operation.
63*62c56f98SSadaf Ebrahimi  *
64*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
65*62c56f98SSadaf Ebrahimi  *       cipher_decrypt_setup entry point. This function behaves as a
66*62c56f98SSadaf Ebrahimi  *       cipher_decrypt_setup entry point as defined in the PSA driver
67*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
68*62c56f98SSadaf Ebrahimi  *
69*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     The operation object to set up. It has been
70*62c56f98SSadaf Ebrahimi  *                              initialized as per the documentation for
71*62c56f98SSadaf Ebrahimi  *                              #psa_cipher_operation_t and not yet in use.
72*62c56f98SSadaf Ebrahimi  * \param[in] attributes        The attributes of the key to use for the
73*62c56f98SSadaf Ebrahimi  *                              operation.
74*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer        The buffer containing the key context.
75*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer_size   Size of the \p key_buffer buffer in bytes.
76*62c56f98SSadaf Ebrahimi  * \param[in] alg               The cipher algorithm to compute
77*62c56f98SSadaf Ebrahimi  *                              (\c PSA_ALG_XXX value such that
78*62c56f98SSadaf Ebrahimi  *                              #PSA_ALG_IS_CIPHER(\p alg) is true).
79*62c56f98SSadaf Ebrahimi  *
80*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
81*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
82*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
83*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
84*62c56f98SSadaf Ebrahimi  */
85*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_decrypt_setup(
86*62c56f98SSadaf Ebrahimi     mbedtls_psa_cipher_operation_t *operation,
87*62c56f98SSadaf Ebrahimi     const psa_key_attributes_t *attributes,
88*62c56f98SSadaf Ebrahimi     const uint8_t *key_buffer, size_t key_buffer_size,
89*62c56f98SSadaf Ebrahimi     psa_algorithm_t alg);
90*62c56f98SSadaf Ebrahimi 
91*62c56f98SSadaf Ebrahimi /** Set the IV for a symmetric encryption or decryption operation.
92*62c56f98SSadaf Ebrahimi  *
93*62c56f98SSadaf Ebrahimi  * This function sets the IV (initialization vector), nonce
94*62c56f98SSadaf Ebrahimi  * or initial counter value for the encryption or decryption operation.
95*62c56f98SSadaf Ebrahimi  *
96*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
97*62c56f98SSadaf Ebrahimi  *       cipher_set_iv entry point. This function behaves as a
98*62c56f98SSadaf Ebrahimi  *       cipher_set_iv entry point as defined in the PSA driver
99*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
100*62c56f98SSadaf Ebrahimi  *
101*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     Active cipher operation.
102*62c56f98SSadaf Ebrahimi  * \param[in] iv                Buffer containing the IV to use.
103*62c56f98SSadaf Ebrahimi  * \param[in] iv_length         Size of the IV in bytes. It is guaranteed by
104*62c56f98SSadaf Ebrahimi  *                              the core to be less or equal to
105*62c56f98SSadaf Ebrahimi  *                              PSA_CIPHER_IV_MAX_SIZE.
106*62c56f98SSadaf Ebrahimi  *
107*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
108*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_ARGUMENT
109*62c56f98SSadaf Ebrahimi  *         The size of \p iv is not acceptable for the chosen algorithm,
110*62c56f98SSadaf Ebrahimi  *         or the chosen algorithm does not use an IV.
111*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
112*62c56f98SSadaf Ebrahimi  */
113*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_set_iv(
114*62c56f98SSadaf Ebrahimi     mbedtls_psa_cipher_operation_t *operation,
115*62c56f98SSadaf Ebrahimi     const uint8_t *iv, size_t iv_length);
116*62c56f98SSadaf Ebrahimi 
117*62c56f98SSadaf Ebrahimi /** Encrypt or decrypt a message fragment in an active cipher operation.
118*62c56f98SSadaf Ebrahimi  *
119*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
120*62c56f98SSadaf Ebrahimi  *       cipher_update entry point. This function behaves as a
121*62c56f98SSadaf Ebrahimi  *       cipher_update entry point as defined in the PSA driver
122*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
123*62c56f98SSadaf Ebrahimi  *
124*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     Active cipher operation.
125*62c56f98SSadaf Ebrahimi  * \param[in] input             Buffer containing the message fragment to
126*62c56f98SSadaf Ebrahimi  *                              encrypt or decrypt.
127*62c56f98SSadaf Ebrahimi  * \param[in] input_length      Size of the \p input buffer in bytes.
128*62c56f98SSadaf Ebrahimi  * \param[out] output           Buffer where the output is to be written.
129*62c56f98SSadaf Ebrahimi  * \param[in]  output_size      Size of the \p output buffer in bytes.
130*62c56f98SSadaf Ebrahimi  * \param[out] output_length    On success, the number of bytes
131*62c56f98SSadaf Ebrahimi  *                              that make up the returned output.
132*62c56f98SSadaf Ebrahimi  *
133*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
134*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_BUFFER_TOO_SMALL
135*62c56f98SSadaf Ebrahimi  *         The size of the \p output buffer is too small.
136*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
137*62c56f98SSadaf Ebrahimi  */
138*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_update(
139*62c56f98SSadaf Ebrahimi     mbedtls_psa_cipher_operation_t *operation,
140*62c56f98SSadaf Ebrahimi     const uint8_t *input, size_t input_length,
141*62c56f98SSadaf Ebrahimi     uint8_t *output, size_t output_size, size_t *output_length);
142*62c56f98SSadaf Ebrahimi 
143*62c56f98SSadaf Ebrahimi /** Finish encrypting or decrypting a message in a cipher operation.
144*62c56f98SSadaf Ebrahimi  *
145*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
146*62c56f98SSadaf Ebrahimi  *       cipher_finish entry point. This function behaves as a
147*62c56f98SSadaf Ebrahimi  *       cipher_finish entry point as defined in the PSA driver
148*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
149*62c56f98SSadaf Ebrahimi  *
150*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     Active cipher operation.
151*62c56f98SSadaf Ebrahimi  * \param[out] output           Buffer where the output is to be written.
152*62c56f98SSadaf Ebrahimi  * \param[in]  output_size      Size of the \p output buffer in bytes.
153*62c56f98SSadaf Ebrahimi  * \param[out] output_length    On success, the number of bytes
154*62c56f98SSadaf Ebrahimi  *                              that make up the returned output.
155*62c56f98SSadaf Ebrahimi  *
156*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
157*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_ARGUMENT
158*62c56f98SSadaf Ebrahimi  *         The total input size passed to this operation is not valid for
159*62c56f98SSadaf Ebrahimi  *         this particular algorithm. For example, the algorithm is a based
160*62c56f98SSadaf Ebrahimi  *         on block cipher and requires a whole number of blocks, but the
161*62c56f98SSadaf Ebrahimi  *         total input size is not a multiple of the block size.
162*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_PADDING
163*62c56f98SSadaf Ebrahimi  *         This is a decryption operation for an algorithm that includes
164*62c56f98SSadaf Ebrahimi  *         padding, and the ciphertext does not contain valid padding.
165*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_BUFFER_TOO_SMALL
166*62c56f98SSadaf Ebrahimi  *         The size of the \p output buffer is too small.
167*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
168*62c56f98SSadaf Ebrahimi  */
169*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_finish(
170*62c56f98SSadaf Ebrahimi     mbedtls_psa_cipher_operation_t *operation,
171*62c56f98SSadaf Ebrahimi     uint8_t *output, size_t output_size, size_t *output_length);
172*62c56f98SSadaf Ebrahimi 
173*62c56f98SSadaf Ebrahimi /** Abort a cipher operation.
174*62c56f98SSadaf Ebrahimi  *
175*62c56f98SSadaf Ebrahimi  * Aborting an operation frees all associated resources except for the
176*62c56f98SSadaf Ebrahimi  * \p operation structure itself. Once aborted, the operation object
177*62c56f98SSadaf Ebrahimi  * can be reused for another operation.
178*62c56f98SSadaf Ebrahimi  *
179*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
180*62c56f98SSadaf Ebrahimi  *       cipher_abort entry point. This function behaves as a
181*62c56f98SSadaf Ebrahimi  *       cipher_abort entry point as defined in the PSA driver
182*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
183*62c56f98SSadaf Ebrahimi  *
184*62c56f98SSadaf Ebrahimi  * \param[in,out] operation     Initialized cipher operation.
185*62c56f98SSadaf Ebrahimi  *
186*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
187*62c56f98SSadaf Ebrahimi  */
188*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_abort(mbedtls_psa_cipher_operation_t *operation);
189*62c56f98SSadaf Ebrahimi 
190*62c56f98SSadaf Ebrahimi /** Encrypt a message using a symmetric cipher.
191*62c56f98SSadaf Ebrahimi  *
192*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
193*62c56f98SSadaf Ebrahimi  *       cipher_encrypt entry point. This function behaves as a
194*62c56f98SSadaf Ebrahimi  *       cipher_encrypt entry point as defined in the PSA driver
195*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
196*62c56f98SSadaf Ebrahimi  *
197*62c56f98SSadaf Ebrahimi  * \param[in] attributes        The attributes of the key to use for the
198*62c56f98SSadaf Ebrahimi  *                              operation.
199*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer        The buffer containing the key context.
200*62c56f98SSadaf Ebrahimi  * \param[in] key_buffer_size   Size of the \p key_buffer buffer in bytes.
201*62c56f98SSadaf Ebrahimi  * \param[in] alg               The cipher algorithm to compute
202*62c56f98SSadaf Ebrahimi  *                              (\c PSA_ALG_XXX value such that
203*62c56f98SSadaf Ebrahimi  *                              #PSA_ALG_IS_CIPHER(\p alg) is true).
204*62c56f98SSadaf Ebrahimi  * \param[in] iv                Buffer containing the IV for encryption. The
205*62c56f98SSadaf Ebrahimi  *                              IV has been generated by the core.
206*62c56f98SSadaf Ebrahimi  * \param[in] iv_length         Size of the \p iv in bytes.
207*62c56f98SSadaf Ebrahimi  * \param[in] input             Buffer containing the message to encrypt.
208*62c56f98SSadaf Ebrahimi  * \param[in] input_length      Size of the \p input buffer in bytes.
209*62c56f98SSadaf Ebrahimi  * \param[in,out] output        Buffer where the output is to be written.
210*62c56f98SSadaf Ebrahimi  * \param[in]  output_size      Size of the \p output buffer in bytes.
211*62c56f98SSadaf Ebrahimi  * \param[out] output_length    On success, the number of bytes that make up
212*62c56f98SSadaf Ebrahimi  *                              the returned output. Initialized to zero
213*62c56f98SSadaf Ebrahimi  *                              by the core.
214*62c56f98SSadaf Ebrahimi  *
215*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
216*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
217*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
218*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
219*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_BUFFER_TOO_SMALL
220*62c56f98SSadaf Ebrahimi  *         The size of the \p output buffer is too small.
221*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_ARGUMENT
222*62c56f98SSadaf Ebrahimi  *         The size \p iv_length is not acceptable for the chosen algorithm,
223*62c56f98SSadaf Ebrahimi  *         or the chosen algorithm does not use an IV.
224*62c56f98SSadaf Ebrahimi  *         The total input size passed to this operation is not valid for
225*62c56f98SSadaf Ebrahimi  *         this particular algorithm. For example, the algorithm is a based
226*62c56f98SSadaf Ebrahimi  *         on block cipher and requires a whole number of blocks, but the
227*62c56f98SSadaf Ebrahimi  *         total input size is not a multiple of the block size.
228*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_PADDING
229*62c56f98SSadaf Ebrahimi  *         This is a decryption operation for an algorithm that includes
230*62c56f98SSadaf Ebrahimi  *         padding, and the ciphertext does not contain valid padding.
231*62c56f98SSadaf Ebrahimi  */
232*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_encrypt(const psa_key_attributes_t *attributes,
233*62c56f98SSadaf Ebrahimi                                         const uint8_t *key_buffer,
234*62c56f98SSadaf Ebrahimi                                         size_t key_buffer_size,
235*62c56f98SSadaf Ebrahimi                                         psa_algorithm_t alg,
236*62c56f98SSadaf Ebrahimi                                         const uint8_t *iv,
237*62c56f98SSadaf Ebrahimi                                         size_t iv_length,
238*62c56f98SSadaf Ebrahimi                                         const uint8_t *input,
239*62c56f98SSadaf Ebrahimi                                         size_t input_length,
240*62c56f98SSadaf Ebrahimi                                         uint8_t *output,
241*62c56f98SSadaf Ebrahimi                                         size_t output_size,
242*62c56f98SSadaf Ebrahimi                                         size_t *output_length);
243*62c56f98SSadaf Ebrahimi 
244*62c56f98SSadaf Ebrahimi /** Decrypt a message using a symmetric cipher.
245*62c56f98SSadaf Ebrahimi  *
246*62c56f98SSadaf Ebrahimi  * \note The signature of this function is that of a PSA driver
247*62c56f98SSadaf Ebrahimi  *       cipher_decrypt entry point. This function behaves as a
248*62c56f98SSadaf Ebrahimi  *       cipher_decrypt entry point as defined in the PSA driver
249*62c56f98SSadaf Ebrahimi  *       interface specification for transparent drivers.
250*62c56f98SSadaf Ebrahimi  *
251*62c56f98SSadaf Ebrahimi  * \param[in]  attributes       The attributes of the key to use for the
252*62c56f98SSadaf Ebrahimi  *                              operation.
253*62c56f98SSadaf Ebrahimi  * \param[in]  key_buffer       The buffer containing the key context.
254*62c56f98SSadaf Ebrahimi  * \param[in]  key_buffer_size  Size of the \p key_buffer buffer in bytes.
255*62c56f98SSadaf Ebrahimi  * \param[in]  alg              The cipher algorithm to compute
256*62c56f98SSadaf Ebrahimi  *                              (\c PSA_ALG_XXX value such that
257*62c56f98SSadaf Ebrahimi  *                              #PSA_ALG_IS_CIPHER(\p alg) is true).
258*62c56f98SSadaf Ebrahimi  * \param[in]  input            Buffer containing the iv and the ciphertext.
259*62c56f98SSadaf Ebrahimi  * \param[in]  input_length     Size of the \p input buffer in bytes.
260*62c56f98SSadaf Ebrahimi  * \param[out] output           Buffer where the output is to be written.
261*62c56f98SSadaf Ebrahimi  * \param[in]  output_size      Size of the \p output buffer in bytes.
262*62c56f98SSadaf Ebrahimi  * \param[out] output_length    On success, the number of bytes that make up
263*62c56f98SSadaf Ebrahimi  *                              the returned output. Initialized to zero
264*62c56f98SSadaf Ebrahimi  *                              by the core.
265*62c56f98SSadaf Ebrahimi  *
266*62c56f98SSadaf Ebrahimi  * \retval #PSA_SUCCESS \emptydescription
267*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
268*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
269*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
270*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_BUFFER_TOO_SMALL
271*62c56f98SSadaf Ebrahimi  *         The size of the \p output buffer is too small.
272*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_ARGUMENT
273*62c56f98SSadaf Ebrahimi  *         The size of \p iv is not acceptable for the chosen algorithm,
274*62c56f98SSadaf Ebrahimi  *         or the chosen algorithm does not use an IV.
275*62c56f98SSadaf Ebrahimi  *         The total input size passed to this operation is not valid for
276*62c56f98SSadaf Ebrahimi  *         this particular algorithm. For example, the algorithm is a based
277*62c56f98SSadaf Ebrahimi  *         on block cipher and requires a whole number of blocks, but the
278*62c56f98SSadaf Ebrahimi  *         total input size is not a multiple of the block size.
279*62c56f98SSadaf Ebrahimi  * \retval #PSA_ERROR_INVALID_PADDING
280*62c56f98SSadaf Ebrahimi  *         This is a decryption operation for an algorithm that includes
281*62c56f98SSadaf Ebrahimi  *         padding, and the ciphertext does not contain valid padding.
282*62c56f98SSadaf Ebrahimi  */
283*62c56f98SSadaf Ebrahimi psa_status_t mbedtls_psa_cipher_decrypt(const psa_key_attributes_t *attributes,
284*62c56f98SSadaf Ebrahimi                                         const uint8_t *key_buffer,
285*62c56f98SSadaf Ebrahimi                                         size_t key_buffer_size,
286*62c56f98SSadaf Ebrahimi                                         psa_algorithm_t alg,
287*62c56f98SSadaf Ebrahimi                                         const uint8_t *input,
288*62c56f98SSadaf Ebrahimi                                         size_t input_length,
289*62c56f98SSadaf Ebrahimi                                         uint8_t *output,
290*62c56f98SSadaf Ebrahimi                                         size_t output_size,
291*62c56f98SSadaf Ebrahimi                                         size_t *output_length);
292*62c56f98SSadaf Ebrahimi 
293*62c56f98SSadaf Ebrahimi #endif /* PSA_CRYPTO_CIPHER_H */
294