Skip to content

Commit 4ccfc40

Browse files
author
Hanno Becker
committed
Add declaration and dummy-definition of mbedtls_cipher_setup_psa()
1 parent 73907f8 commit 4ccfc40

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

include/mbedtls/cipher.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,26 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx );
413413
int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx,
414414
const mbedtls_cipher_info_t *cipher_info );
415415

416+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
417+
/**
418+
* \brief This function initializes a cipher context for
419+
* PSA-based use with the given cipher primitive.
420+
*
421+
* \note See #MBEDTLS_USE_PSA_CRYPTO for information on PSA.
422+
*
423+
* \param ctx The context to initialize. May not be \c NULL.
424+
* \param cipher_info The cipher to use.
425+
*
426+
* \return \c 0 on success.
427+
* \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on
428+
* parameter-verification failure.
429+
* \return #MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the
430+
* cipher-specific context fails.
431+
*/
432+
int mbedtls_cipher_setup_psa( mbedtls_cipher_context_t *ctx,
433+
const mbedtls_cipher_info_t *cipher_info );
434+
#endif /* MBEDTLS_USE_PSA_CRYPTO */
435+
416436
/**
417437
* \brief This function returns the block size of the given cipher.
418438
*

library/cipher.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
#include "mbedtls/cmac.h"
5959
#endif
6060

61+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
62+
#include "psa/crypto.h"
63+
#endif /* MBEDTLS_USE_PSA_CRYPTO */
64+
6165
#if defined(MBEDTLS_PLATFORM_C)
6266
#include "mbedtls/platform.h"
6367
#else
@@ -204,6 +208,14 @@ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx,
204208
return( 0 );
205209
}
206210

211+
#if defined(MBEDTLS_USE_PSA_CRYPTO)
212+
int mbedtls_cipher_setup_psa( mbedtls_cipher_context_t *ctx,
213+
const mbedtls_cipher_info_t *cipher_info )
214+
{
215+
return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE );
216+
}
217+
#endif /* MBEDTLS_USE_PSA_CRYPTO */
218+
207219
int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx,
208220
const unsigned char *key,
209221
int key_bitlen,

0 commit comments

Comments
 (0)