Merge branch 'development' into md-light
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
commit
45cef61fa4
107 changed files with 6916 additions and 1422 deletions
|
@ -63,7 +63,7 @@
|
|||
|
||||
#if !defined(MBEDTLS_MPI_WINDOW_SIZE)
|
||||
/*
|
||||
* Maximum window size used for modular exponentiation. Default: 6
|
||||
* Maximum window size used for modular exponentiation. Default: 2
|
||||
* Minimum value: 1. Maximum value: 6.
|
||||
*
|
||||
* Result is an array of ( 2 ** MBEDTLS_MPI_WINDOW_SIZE ) MPIs used
|
||||
|
@ -71,7 +71,7 @@
|
|||
*
|
||||
* Reduction in size, reduces speed.
|
||||
*/
|
||||
#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */
|
||||
#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
|
||||
#endif /* !MBEDTLS_MPI_WINDOW_SIZE */
|
||||
|
||||
#if !defined(MBEDTLS_MPI_MAX_SIZE)
|
||||
|
|
|
@ -87,26 +87,22 @@
|
|||
#define MBEDTLS_MD_LIGHT
|
||||
#endif
|
||||
|
||||
/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
* is defined as well to include all PSA code.
|
||||
*/
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
#define MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
|
||||
/* The PK wrappers need pk_write functions to format RSA key objects
|
||||
* when they are dispatching to the PSA API. This happens under USE_PSA_CRYPTO,
|
||||
* and also even without USE_PSA_CRYPTO for mbedtls_pk_sign_ext().
|
||||
* PSA crypto also needs pk_write to export RSA keys (otherwise the build
|
||||
* goes through but psa_export_key() and psa_export_public_key() fail on
|
||||
* RSA keys), and pk_parse to work with RSA keys in almost any way.
|
||||
*/
|
||||
* and also even without USE_PSA_CRYPTO for mbedtls_pk_sign_ext(). */
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C) && defined(MBEDTLS_RSA_C)
|
||||
#define MBEDTLS_PK_C
|
||||
#define MBEDTLS_PK_WRITE_C
|
||||
#define MBEDTLS_PK_PARSE_C
|
||||
#endif
|
||||
|
||||
/* Under MBEDTLS_USE_PSA_CRYPTO, the pk module needs pk_write functions
|
||||
* to pass ECC keys to PSA. */
|
||||
#if defined(MBEDTLS_PK_C) && \
|
||||
defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_ECP_C)
|
||||
#define MBEDTLS_PK_WRITE_C
|
||||
#endif
|
||||
|
||||
#if !defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
#undef MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
|
||||
#undef MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
|
||||
|
|
|
@ -70,6 +70,10 @@
|
|||
#error "MBEDTLS_AESNI_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_AESCE_C) && !defined(MBEDTLS_HAVE_ASM)
|
||||
#error "MBEDTLS_AESCE_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CTR_DRBG_C) && !defined(MBEDTLS_AES_C)
|
||||
#error "MBEDTLS_CTR_DRBG_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
@ -708,41 +712,6 @@
|
|||
#if defined(MBEDTLS_SHA512_ALT) || defined(MBEDTLS_SHA512_PROCESS_ALT)
|
||||
#error "MBEDTLS_SHA512_*ALT can't be used with MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
#endif
|
||||
/*
|
||||
* Best performance comes from most recent compilers, with intrinsics and -O3.
|
||||
* Must compile with -march=armv8.2-a+sha3, but we can't detect armv8.2-a, and
|
||||
* can't always detect __ARM_FEATURE_SHA512 (notably clang 7-12).
|
||||
*
|
||||
* GCC < 8 won't work at all (lacks the sha512 instructions)
|
||||
* GCC >= 8 uses intrinsics, sets __ARM_FEATURE_SHA512
|
||||
*
|
||||
* Clang < 7 won't work at all (lacks the sha512 instructions)
|
||||
* Clang 7-12 don't have intrinsics (but we work around that with inline
|
||||
* assembler) or __ARM_FEATURE_SHA512
|
||||
* Clang == 13.0.0 same as clang 12 (only seen on macOS)
|
||||
* Clang >= 13.0.1 has __ARM_FEATURE_SHA512 and intrinsics
|
||||
*/
|
||||
#if defined(__aarch64__) && !defined(__ARM_FEATURE_SHA512)
|
||||
/* Test Clang first, as it defines __GNUC__ */
|
||||
# if defined(__clang__)
|
||||
# if __clang_major__ < 7
|
||||
# error "A more recent Clang is required for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# elif __clang_major__ < 13 || \
|
||||
(__clang_major__ == 13 && __clang_minor__ == 0 && __clang_patchlevel__ == 0)
|
||||
/* We implement the intrinsics with inline assembler, so don't error */
|
||||
# else
|
||||
# error "Must use minimum -march=armv8.2-a+sha3 for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# endif
|
||||
# elif defined(__GNUC__)
|
||||
# if __GNUC__ < 8
|
||||
# error "A more recent GCC is required for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# else
|
||||
# error "Must use minimum -march=armv8.2-a+sha3 for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# endif
|
||||
# else
|
||||
# error "Only GCC and Clang supported for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT || MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY */
|
||||
|
||||
|
@ -763,9 +732,7 @@
|
|||
#if defined(MBEDTLS_SHA256_ALT) || defined(MBEDTLS_SHA256_PROCESS_ALT)
|
||||
#error "MBEDTLS_SHA256_*ALT can't be used with MBEDTLS_SHA256_USE_A64_CRYPTO_*"
|
||||
#endif
|
||||
#if defined(__aarch64__) && !defined(__ARM_FEATURE_CRYPTO)
|
||||
#error "Must use minimum -march=armv8-a+crypto for MBEDTLS_SHA256_USE_A64_CRYPTO_*"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY) && \
|
||||
|
@ -932,6 +899,11 @@
|
|||
#error "MBEDTLS_SSL_EXTENDED_MASTER_SECRET defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION) && \
|
||||
!defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
#error "MBEDTLS_SSL_RENEGOTIATION defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_TICKET_C) && ( !defined(MBEDTLS_CIPHER_C) && \
|
||||
!defined(MBEDTLS_USE_PSA_CRYPTO) )
|
||||
#error "MBEDTLS_SSL_TICKET_C defined, but not all prerequisites"
|
||||
|
|
|
@ -222,6 +222,134 @@ int mbedtls_ecdsa_sign_det_ext(mbedtls_ecp_group *grp, mbedtls_mpi *r,
|
|||
void *p_rng_blind);
|
||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
|
||||
#if !defined(MBEDTLS_ECDSA_SIGN_ALT)
|
||||
/**
|
||||
* \brief This function computes the ECDSA signature of a
|
||||
* previously-hashed message, in a restartable way.
|
||||
*
|
||||
* \note The deterministic version implemented in
|
||||
* mbedtls_ecdsa_sign_det_restartable() is usually
|
||||
* preferred.
|
||||
*
|
||||
* \note This function is like \c mbedtls_ecdsa_sign() but
|
||||
* it can return early and restart according to the
|
||||
* limit set with \c mbedtls_ecp_set_max_ops() to
|
||||
* reduce blocking.
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger
|
||||
* than the bitlength of the group order, then the
|
||||
* hash is truncated as defined in <em>Standards for
|
||||
* Efficient Cryptography Group (SECG): SEC1 Elliptic
|
||||
* Curve Cryptography</em>, section 4.1.3, step 5.
|
||||
*
|
||||
* \see ecp.h
|
||||
*
|
||||
* \param grp The context for the elliptic curve to use.
|
||||
* This must be initialized and have group parameters
|
||||
* set, for example through mbedtls_ecp_group_load().
|
||||
* \param r The MPI context in which to store the first part
|
||||
* the signature. This must be initialized.
|
||||
* \param s The MPI context in which to store the second part
|
||||
* the signature. This must be initialized.
|
||||
* \param d The private signing key. This must be initialized
|
||||
* and setup, for example through
|
||||
* mbedtls_ecp_gen_privkey().
|
||||
* \param buf The hashed content to be signed. This must be a readable
|
||||
* buffer of length \p blen Bytes. It may be \c NULL if
|
||||
* \p blen is zero.
|
||||
* \param blen The length of \p buf in Bytes.
|
||||
* \param f_rng The RNG function. This must not be \c NULL.
|
||||
* \param p_rng The RNG context to be passed to \p f_rng. This may be
|
||||
* \c NULL if \p f_rng doesn't need a context parameter.
|
||||
* \param f_rng_blind The RNG function used for blinding. This must not be
|
||||
* \c NULL.
|
||||
* \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
|
||||
* \c NULL if \p f_rng doesn't need a context parameter.
|
||||
* \param rs_ctx The restart context to use. This may be \c NULL
|
||||
* to disable restarting. If it is not \c NULL, it
|
||||
* must point to an initialized restart context.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
|
||||
* operations was reached: see \c
|
||||
* mbedtls_ecp_set_max_ops().
|
||||
* \return Another \c MBEDTLS_ERR_ECP_XXX, \c
|
||||
* MBEDTLS_ERR_MPI_XXX or \c MBEDTLS_ERR_ASN1_XXX
|
||||
* error code on failure.
|
||||
*/
|
||||
int mbedtls_ecdsa_sign_restartable(
|
||||
mbedtls_ecp_group *grp,
|
||||
mbedtls_mpi *r, mbedtls_mpi *s,
|
||||
const mbedtls_mpi *d,
|
||||
const unsigned char *buf, size_t blen,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng,
|
||||
int (*f_rng_blind)(void *, unsigned char *, size_t),
|
||||
void *p_rng_blind,
|
||||
mbedtls_ecdsa_restart_ctx *rs_ctx);
|
||||
|
||||
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
|
||||
|
||||
/**
|
||||
* \brief This function computes the ECDSA signature of a
|
||||
* previously-hashed message, in a restartable way.
|
||||
*
|
||||
* \note This function is like \c
|
||||
* mbedtls_ecdsa_sign_det_ext() but it can return
|
||||
* early and restart according to the limit set with
|
||||
* \c mbedtls_ecp_set_max_ops() to reduce blocking.
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger
|
||||
* than the bitlength of the group order, then the
|
||||
* hash is truncated as defined in <em>Standards for
|
||||
* Efficient Cryptography Group (SECG): SEC1 Elliptic
|
||||
* Curve Cryptography</em>, section 4.1.3, step 5.
|
||||
*
|
||||
* \see ecp.h
|
||||
*
|
||||
* \param grp The context for the elliptic curve to use.
|
||||
* This must be initialized and have group parameters
|
||||
* set, for example through mbedtls_ecp_group_load().
|
||||
* \param r The MPI context in which to store the first part
|
||||
* the signature. This must be initialized.
|
||||
* \param s The MPI context in which to store the second part
|
||||
* the signature. This must be initialized.
|
||||
* \param d The private signing key. This must be initialized
|
||||
* and setup, for example through
|
||||
* mbedtls_ecp_gen_privkey().
|
||||
* \param buf The hashed content to be signed. This must be a readable
|
||||
* buffer of length \p blen Bytes. It may be \c NULL if
|
||||
* \p blen is zero.
|
||||
* \param blen The length of \p buf in Bytes.
|
||||
* \param f_rng_blind The RNG function used for blinding. This must not be
|
||||
* \c NULL.
|
||||
* \param p_rng_blind The RNG context to be passed to \p f_rng. This may be
|
||||
* \c NULL if \p f_rng doesn't need a context parameter.
|
||||
* \param rs_ctx The restart context to use. This may be \c NULL
|
||||
* to disable restarting. If it is not \c NULL, it
|
||||
* must point to an initialized restart context.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
|
||||
* operations was reached: see \c
|
||||
* mbedtls_ecp_set_max_ops().
|
||||
* \return Another \c MBEDTLS_ERR_ECP_XXX, \c
|
||||
* MBEDTLS_ERR_MPI_XXX or \c MBEDTLS_ERR_ASN1_XXX
|
||||
* error code on failure.
|
||||
*/
|
||||
int mbedtls_ecdsa_sign_det_restartable(
|
||||
mbedtls_ecp_group *grp,
|
||||
mbedtls_mpi *r, mbedtls_mpi *s,
|
||||
const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
|
||||
mbedtls_md_type_t md_alg,
|
||||
int (*f_rng_blind)(void *, unsigned char *, size_t),
|
||||
void *p_rng_blind,
|
||||
mbedtls_ecdsa_restart_ctx *rs_ctx);
|
||||
|
||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
|
||||
#endif /* !MBEDTLS_ECDSA_SIGN_ALT */
|
||||
|
||||
/**
|
||||
* \brief This function verifies the ECDSA signature of a
|
||||
* previously-hashed message.
|
||||
|
@ -257,6 +385,51 @@ int mbedtls_ecdsa_verify(mbedtls_ecp_group *grp,
|
|||
const mbedtls_ecp_point *Q, const mbedtls_mpi *r,
|
||||
const mbedtls_mpi *s);
|
||||
|
||||
#if !defined(MBEDTLS_ECDSA_VERIFY_ALT)
|
||||
/**
|
||||
* \brief This function verifies the ECDSA signature of a
|
||||
* previously-hashed message, in a restartable manner
|
||||
*
|
||||
* \note If the bitlength of the message hash is larger than the
|
||||
* bitlength of the group order, then the hash is truncated as
|
||||
* defined in <em>Standards for Efficient Cryptography Group
|
||||
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
|
||||
* 4.1.4, step 3.
|
||||
*
|
||||
* \see ecp.h
|
||||
*
|
||||
* \param grp The ECP group to use.
|
||||
* This must be initialized and have group parameters
|
||||
* set, for example through mbedtls_ecp_group_load().
|
||||
* \param buf The hashed content that was signed. This must be a readable
|
||||
* buffer of length \p blen Bytes. It may be \c NULL if
|
||||
* \p blen is zero.
|
||||
* \param blen The length of \p buf in Bytes.
|
||||
* \param Q The public key to use for verification. This must be
|
||||
* initialized and setup.
|
||||
* \param r The first integer of the signature.
|
||||
* This must be initialized.
|
||||
* \param s The second integer of the signature.
|
||||
* This must be initialized.
|
||||
* \param rs_ctx The restart context to use. This may be \c NULL to disable
|
||||
* restarting. If it is not \c NULL, it must point to an
|
||||
* initialized restart context.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
|
||||
* operations was reached: see \c mbedtls_ecp_set_max_ops().
|
||||
* \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX
|
||||
* error code on failure.
|
||||
*/
|
||||
int mbedtls_ecdsa_verify_restartable(mbedtls_ecp_group *grp,
|
||||
const unsigned char *buf, size_t blen,
|
||||
const mbedtls_ecp_point *Q,
|
||||
const mbedtls_mpi *r,
|
||||
const mbedtls_mpi *s,
|
||||
mbedtls_ecdsa_restart_ctx *rs_ctx);
|
||||
|
||||
#endif /* !MBEDTLS_ECDSA_VERIFY_ALT */
|
||||
|
||||
/**
|
||||
* \brief This function computes the ECDSA signature and writes it
|
||||
* to a buffer, serialized as defined in <em>RFC-4492:
|
||||
|
|
|
@ -141,6 +141,15 @@ typedef enum {
|
|||
MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
|
||||
} mbedtls_ecp_curve_type;
|
||||
|
||||
/*
|
||||
* Curve modulus types
|
||||
*/
|
||||
typedef enum {
|
||||
MBEDTLS_ECP_MOD_NONE = 0,
|
||||
MBEDTLS_ECP_MOD_COORDINATE,
|
||||
MBEDTLS_ECP_MOD_SCALAR
|
||||
} mbedtls_ecp_modulus_type;
|
||||
|
||||
/**
|
||||
* Curve information, for use by other modules.
|
||||
*
|
||||
|
@ -472,6 +481,12 @@ mbedtls_ecp_keypair;
|
|||
* only enabled for specific sides and key exchanges
|
||||
* (currently only for clients and ECDHE-ECDSA).
|
||||
*
|
||||
* \warning Using the PSA interruptible interfaces with keys in local
|
||||
* storage and no accelerator driver will also call this
|
||||
* function to set the values specified via those interfaces,
|
||||
* overwriting values previously set. Care should be taken if
|
||||
* mixing these two interfaces.
|
||||
*
|
||||
* \param max_ops Maximum number of basic operations done in a row.
|
||||
* Default: 0 (unlimited).
|
||||
* Lower (non-zero) values mean ECC functions will block for
|
||||
|
|
|
@ -2065,6 +2065,34 @@
|
|||
*/
|
||||
#define MBEDTLS_AESNI_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_AESCE_C
|
||||
*
|
||||
* Enable AES crypto extension support on Arm64.
|
||||
*
|
||||
* Module: library/aesce.c
|
||||
* Caller: library/aes.c
|
||||
*
|
||||
* Requires: MBEDTLS_HAVE_ASM, MBEDTLS_AES_C
|
||||
*
|
||||
* \note The code uses Neon intrinsics, so \c CFLAGS must be set to a minimum
|
||||
* of \c -march=armv8-a+crypto .
|
||||
*
|
||||
* \warning If the target architecture is set to something that includes the
|
||||
* SHA3 feature (e.g. `-march=armv8.2-a+sha3`), for example because
|
||||
* `MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT` is desired, compilers
|
||||
* generate code for `MBEDTLS_AESCE_C` that includes instructions
|
||||
* only present with the (optional) SHA3 feature. This will lead to an
|
||||
* undefined instruction exception if the code is run on a CPU without
|
||||
* that feature.
|
||||
*
|
||||
* \warning Runtime detection only works on linux. For non-linux operation
|
||||
* system, crypto extension MUST be supported by CPU.
|
||||
*
|
||||
* This module adds support for the AES crypto instructions on Arm64
|
||||
*/
|
||||
#define MBEDTLS_AESCE_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_AES_C
|
||||
*
|
||||
|
@ -3087,9 +3115,6 @@
|
|||
* \note If MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT is defined when building
|
||||
* for a non-Aarch64 build it will be silently ignored.
|
||||
*
|
||||
* \note The code uses Neon intrinsics, so \c CFLAGS must be set to a minimum
|
||||
* of \c -march=armv8-a+crypto.
|
||||
*
|
||||
* \warning MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT cannot be defined at the
|
||||
* same time as MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY.
|
||||
*
|
||||
|
@ -3112,9 +3137,6 @@
|
|||
* \note This allows builds with a smaller code size than with
|
||||
* MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
|
||||
*
|
||||
* \note The code uses Neon intrinsics, so \c CFLAGS must be set to a minimum
|
||||
* of \c -march=armv8-a+crypto.
|
||||
*
|
||||
* \warning MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY cannot be defined at the same
|
||||
* time as MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT.
|
||||
*
|
||||
|
@ -3169,9 +3191,7 @@
|
|||
* for a non-Aarch64 build it will be silently ignored.
|
||||
*
|
||||
* \note The code uses the SHA-512 Neon intrinsics, so requires GCC >= 8 or
|
||||
* Clang >= 7, and \c CFLAGS must be set to a minimum of
|
||||
* \c -march=armv8.2-a+sha3. An optimisation level of \c -O3 generates the
|
||||
* fastest code.
|
||||
* Clang >= 7.
|
||||
*
|
||||
* \warning MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT cannot be defined at the
|
||||
* same time as MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY.
|
||||
|
@ -3196,9 +3216,7 @@
|
|||
* MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
|
||||
*
|
||||
* \note The code uses the SHA-512 Neon intrinsics, so requires GCC >= 8 or
|
||||
* Clang >= 7, and \c CFLAGS must be set to a minimum of
|
||||
* \c -march=armv8.2-a+sha3. An optimisation level of \c -O3 generates the
|
||||
* fastest code.
|
||||
* Clang >= 7.
|
||||
*
|
||||
* \warning MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY cannot be defined at the same
|
||||
* time as MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT.
|
||||
|
@ -3537,6 +3555,53 @@
|
|||
*/
|
||||
//#define MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE "/dev/null"
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_PSA_CRYPTO_PLATFORM_FILE
|
||||
*
|
||||
* If defined, this is a header which will be included instead of
|
||||
* `"psa/crypto_platform.h"`. This file should declare the same identifiers
|
||||
* as the one in Mbed TLS, but with definitions adapted to the platform on
|
||||
* which the library code will run.
|
||||
*
|
||||
* \note The required content of this header can vary from one version of
|
||||
* Mbed TLS to the next. Integrators who provide an alternative file
|
||||
* should review the changes in the original file whenever they
|
||||
* upgrade Mbed TLS.
|
||||
*
|
||||
* This macro is expanded after an <tt>\#include</tt> directive. This is a popular but
|
||||
* non-standard feature of the C language, so this feature is only available
|
||||
* with compilers that perform macro expansion on an <tt>\#include</tt> line.
|
||||
*
|
||||
* The value of this symbol is typically a path in double quotes, either
|
||||
* absolute or relative to a directory on the include search path.
|
||||
*/
|
||||
//#define MBEDTLS_PSA_CRYPTO_PLATFORM_FILE "psa/crypto_platform_alt.h"
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_PSA_CRYPTO_STRUCT_FILE
|
||||
*
|
||||
* If defined, this is a header which will be included instead of
|
||||
* `"psa/crypto_struct.h"`. This file should declare the same identifiers
|
||||
* as the one in Mbed TLS, but with definitions adapted to the environment
|
||||
* in which the library code will run. The typical use for this feature
|
||||
* is to provide alternative type definitions on the client side in
|
||||
* client-server integrations of PSA crypto, where operation structures
|
||||
* contain handles instead of cryptographic data.
|
||||
*
|
||||
* \note The required content of this header can vary from one version of
|
||||
* Mbed TLS to the next. Integrators who provide an alternative file
|
||||
* should review the changes in the original file whenever they
|
||||
* upgrade Mbed TLS.
|
||||
*
|
||||
* This macro is expanded after an <tt>\#include</tt> directive. This is a popular but
|
||||
* non-standard feature of the C language, so this feature is only available
|
||||
* with compilers that perform macro expansion on an <tt>\#include</tt> line.
|
||||
*
|
||||
* The value of this symbol is typically a path in double quotes, either
|
||||
* absolute or relative to a directory on the include search path.
|
||||
*/
|
||||
//#define MBEDTLS_PSA_CRYPTO_STRUCT_FILE "psa/crypto_struct_alt.h"
|
||||
|
||||
/** \} name SECTION: General configuration options */
|
||||
|
||||
/**
|
||||
|
@ -3559,7 +3624,7 @@
|
|||
* comment in the specific module. */
|
||||
|
||||
/* MPI / BIGNUM options */
|
||||
//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */
|
||||
//#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
|
||||
//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
|
||||
|
||||
/* CTR_DRBG options */
|
||||
|
|
|
@ -135,22 +135,12 @@ typedef struct mbedtls_pkcs7_signer_info {
|
|||
}
|
||||
mbedtls_pkcs7_signer_info;
|
||||
|
||||
/**
|
||||
* Structure holding attached data as part of PKCS7 signed data format
|
||||
*/
|
||||
typedef struct mbedtls_pkcs7_data {
|
||||
mbedtls_pkcs7_buf MBEDTLS_PRIVATE(oid);
|
||||
mbedtls_pkcs7_buf MBEDTLS_PRIVATE(data);
|
||||
}
|
||||
mbedtls_pkcs7_data;
|
||||
|
||||
/**
|
||||
* Structure holding the signed data section
|
||||
*/
|
||||
typedef struct mbedtls_pkcs7_signed_data {
|
||||
int MBEDTLS_PRIVATE(version);
|
||||
mbedtls_pkcs7_buf MBEDTLS_PRIVATE(digest_alg_identifiers);
|
||||
struct mbedtls_pkcs7_data MBEDTLS_PRIVATE(content);
|
||||
int MBEDTLS_PRIVATE(no_of_certs);
|
||||
mbedtls_x509_crt MBEDTLS_PRIVATE(certs);
|
||||
int MBEDTLS_PRIVATE(no_of_crls);
|
||||
|
@ -165,7 +155,6 @@ mbedtls_pkcs7_signed_data;
|
|||
*/
|
||||
typedef struct mbedtls_pkcs7 {
|
||||
mbedtls_pkcs7_buf MBEDTLS_PRIVATE(raw);
|
||||
mbedtls_pkcs7_buf MBEDTLS_PRIVATE(content_type_oid);
|
||||
mbedtls_pkcs7_signed_data MBEDTLS_PRIVATE(signed_data);
|
||||
}
|
||||
mbedtls_pkcs7;
|
||||
|
@ -178,7 +167,7 @@ mbedtls_pkcs7;
|
|||
void mbedtls_pkcs7_init(mbedtls_pkcs7 *pkcs7);
|
||||
|
||||
/**
|
||||
* \brief Parse a single DER formatted pkcs7 content.
|
||||
* \brief Parse a single DER formatted pkcs7 detached signature.
|
||||
*
|
||||
* \param pkcs7 The pkcs7 structure to be filled by parser for the output.
|
||||
* \param buf The buffer holding only the DER encoded pkcs7.
|
||||
|
@ -188,6 +177,7 @@ void mbedtls_pkcs7_init(mbedtls_pkcs7 *pkcs7);
|
|||
* \note This function makes an internal copy of the PKCS7 buffer
|
||||
* \p buf. In particular, \p buf may be destroyed or reused
|
||||
* after this call returns.
|
||||
* \note Signatures with internal data are not supported.
|
||||
*
|
||||
* \return The \c mbedtls_pkcs7_type of \p buf, if successful.
|
||||
* \return A negative error code on failure.
|
||||
|
@ -207,7 +197,8 @@ int mbedtls_pkcs7_parse_der(mbedtls_pkcs7 *pkcs7, const unsigned char *buf,
|
|||
* matches.
|
||||
*
|
||||
* This function does not use the certificates held within the
|
||||
* PKCS7 structure itself.
|
||||
* PKCS7 structure itself, and does not check that the
|
||||
* certificate is signed by a trusted certification authority.
|
||||
*
|
||||
* \param pkcs7 PKCS7 structure containing signature.
|
||||
* \param cert Certificate containing key to verify signature.
|
||||
|
@ -228,15 +219,15 @@ int mbedtls_pkcs7_signed_data_verify(mbedtls_pkcs7 *pkcs7,
|
|||
* \brief Verification of PKCS7 signature against a caller-supplied
|
||||
* certificate.
|
||||
*
|
||||
* For each signer in the PKCS structure, this function computes
|
||||
* a signature over the supplied hash, using the supplied
|
||||
* certificate and the same digest algorithm as specified by the
|
||||
* signer. It then compares this signature against the
|
||||
* signer's signature; verification succeeds if any comparison
|
||||
* matches.
|
||||
* For each signer in the PKCS structure, this function
|
||||
* validates a signature over the supplied hash, using the
|
||||
* supplied certificate and the same digest algorithm as
|
||||
* specified by the signer. Verification succeeds if any
|
||||
* signature is good.
|
||||
*
|
||||
* This function does not use the certificates held within the
|
||||
* PKCS7 structure itself.
|
||||
* PKCS7 structure itself, and does not check that the
|
||||
* certificate is signed by a trusted certification authority.
|
||||
*
|
||||
* \param pkcs7 PKCS7 structure containing signature.
|
||||
* \param cert Certificate containing key to verify signature.
|
||||
|
@ -244,7 +235,7 @@ int mbedtls_pkcs7_signed_data_verify(mbedtls_pkcs7 *pkcs7,
|
|||
* \param hashlen Length of the hash.
|
||||
*
|
||||
* \note This function is different from mbedtls_pkcs7_signed_data_verify()
|
||||
* in a way that it directly receives the hash of the data.
|
||||
* in that it is directly passed the hash of the data.
|
||||
*
|
||||
* \return 0 if the signature verifies, or a negative error code on failure.
|
||||
*/
|
||||
|
|
|
@ -257,6 +257,9 @@ static inline int mbedtls_psa_get_ecc_oid_from_id(
|
|||
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH \
|
||||
PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
|
||||
|
||||
#define MBEDTLS_PSA_MAX_EC_KEY_PAIR_LENGTH \
|
||||
PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(PSA_VENDOR_ECC_MAX_CURVE_BITS)
|
||||
|
||||
/* Expose whatever RNG the PSA subsystem uses to applications using the
|
||||
* mbedtls_xxx API. The declarations and definitions here need to be
|
||||
* consistent with the implementation in library/psa_crypto_random_impl.h.
|
||||
|
|
|
@ -294,7 +294,7 @@ typedef struct mbedtls_x509_subject_alternative_name {
|
|||
int type; /**< The SAN type, value of MBEDTLS_X509_SAN_XXX. */
|
||||
union {
|
||||
mbedtls_x509_san_other_name other_name; /**< The otherName supported type. */
|
||||
mbedtls_x509_buf unstructured_name; /**< The buffer for the un constructed types. Only dnsName currently supported */
|
||||
mbedtls_x509_buf unstructured_name; /**< The buffer for the unconstructed types. Only rfc822Name, dnsName and uniformResourceIdentifier are currently supported */
|
||||
}
|
||||
san; /**< A union of the supported SAN types */
|
||||
}
|
||||
|
@ -385,8 +385,9 @@ int mbedtls_x509_time_is_future(const mbedtls_x509_time *from);
|
|||
* \param san The target structure to populate with the parsed presentation
|
||||
* of the subject alternative name encoded in \p san_raw.
|
||||
*
|
||||
* \note Only "dnsName" and "otherName" of type hardware_module_name
|
||||
* as defined in RFC 4180 is supported.
|
||||
* \note Supported GeneralName types, as defined in RFC 5280:
|
||||
* "rfc822Name", "dnsName", "uniformResourceIdentifier" and "hardware_module_name"
|
||||
* of type "otherName", as defined in RFC 4108.
|
||||
*
|
||||
* \note This function should be called on a single raw data of
|
||||
* subject alternative name. For example, after successful
|
||||
|
|
|
@ -76,7 +76,7 @@ typedef struct mbedtls_x509_crt {
|
|||
mbedtls_x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */
|
||||
mbedtls_x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */
|
||||
mbedtls_x509_buf v3_ext; /**< Optional X.509 v3 extensions. */
|
||||
mbedtls_x509_sequence subject_alt_names; /**< Optional list of raw entries of Subject Alternative Names extension (currently only dNSName and OtherName are listed). */
|
||||
mbedtls_x509_sequence subject_alt_names; /**< Optional list of raw entries of Subject Alternative Names extension (currently only dNSName, uniformResourceIdentifier and OtherName are listed). */
|
||||
|
||||
mbedtls_x509_sequence certificate_policies; /**< Optional list of certificate policies (Only anyPolicy is printed and enforced, however the rest of the policies are still listed). */
|
||||
|
||||
|
|
1441
include/psa/crypto.h
1441
include/psa/crypto.h
File diff suppressed because it is too large
Load diff
|
@ -107,4 +107,78 @@ typedef struct {
|
|||
|
||||
#define MBEDTLS_PSA_AEAD_OPERATION_INIT { 0, 0, 0, 0, { 0 } }
|
||||
|
||||
#include "mbedtls/ecdsa.h"
|
||||
|
||||
/* Context structure for the Mbed TLS interruptible sign hash implementation. */
|
||||
typedef struct {
|
||||
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
|
||||
defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
mbedtls_ecdsa_context *MBEDTLS_PRIVATE(ctx);
|
||||
mbedtls_ecdsa_restart_ctx MBEDTLS_PRIVATE(restart_ctx);
|
||||
|
||||
uint32_t MBEDTLS_PRIVATE(num_ops);
|
||||
|
||||
size_t MBEDTLS_PRIVATE(coordinate_bytes);
|
||||
psa_algorithm_t MBEDTLS_PRIVATE(alg);
|
||||
mbedtls_md_type_t MBEDTLS_PRIVATE(md_alg);
|
||||
uint8_t MBEDTLS_PRIVATE(hash)[PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS)];
|
||||
size_t MBEDTLS_PRIVATE(hash_length);
|
||||
|
||||
#else
|
||||
/* Make the struct non-empty if algs not supported. */
|
||||
unsigned MBEDTLS_PRIVATE(dummy);
|
||||
|
||||
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
|
||||
* defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
|
||||
* defined( MBEDTLS_ECP_RESTARTABLE ) */
|
||||
} mbedtls_psa_sign_hash_interruptible_operation_t;
|
||||
|
||||
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
|
||||
defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 }
|
||||
#else
|
||||
#define MBEDTLS_PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
/* Context structure for the Mbed TLS interruptible verify hash
|
||||
* implementation.*/
|
||||
typedef struct {
|
||||
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
|
||||
defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
|
||||
mbedtls_ecdsa_context *MBEDTLS_PRIVATE(ctx);
|
||||
mbedtls_ecdsa_restart_ctx MBEDTLS_PRIVATE(restart_ctx);
|
||||
|
||||
uint32_t MBEDTLS_PRIVATE(num_ops);
|
||||
|
||||
uint8_t MBEDTLS_PRIVATE(hash)[PSA_BITS_TO_BYTES(PSA_VENDOR_ECC_MAX_CURVE_BITS)];
|
||||
size_t MBEDTLS_PRIVATE(hash_length);
|
||||
|
||||
mbedtls_mpi MBEDTLS_PRIVATE(r);
|
||||
mbedtls_mpi MBEDTLS_PRIVATE(s);
|
||||
|
||||
#else
|
||||
/* Make the struct non-empty if algs not supported. */
|
||||
unsigned MBEDTLS_PRIVATE(dummy);
|
||||
|
||||
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) ||
|
||||
* defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA) &&
|
||||
* defined( MBEDTLS_ECP_RESTARTABLE ) */
|
||||
|
||||
} mbedtls_psa_verify_hash_interruptible_operation_t;
|
||||
|
||||
#if (defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA)) && \
|
||||
defined(MBEDTLS_ECP_RESTARTABLE)
|
||||
#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, \
|
||||
{ 0 } }
|
||||
#else
|
||||
#define MBEDTLS_VERIFY_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0 }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|
||||
|
|
|
@ -105,11 +105,11 @@ static inline int psa_key_handle_is_null(psa_key_handle_t handle)
|
|||
* permission to access it. Note that this specification does not
|
||||
* define any way to create such a key, but it may be possible
|
||||
* through implementation-specific means.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The library has not been previously initialized by psa_crypto_init().
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
|
@ -149,8 +149,8 @@ psa_status_t psa_open_key(mbedtls_svc_key_id_t key,
|
|||
* \p handle was a valid handle or \c 0. It is now closed.
|
||||
* \retval #PSA_ERROR_INVALID_HANDLE
|
||||
* \p handle is not a valid handle nor \c 0.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The library has not been previously initialized by psa_crypto_init().
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
|
|
|
@ -114,5 +114,15 @@ typedef union {
|
|||
#endif
|
||||
} psa_driver_aead_context_t;
|
||||
|
||||
typedef union {
|
||||
unsigned dummy; /* Make sure this union is always non-empty */
|
||||
mbedtls_psa_sign_hash_interruptible_operation_t mbedtls_ctx;
|
||||
} psa_driver_sign_hash_interruptible_context_t;
|
||||
|
||||
typedef union {
|
||||
unsigned dummy; /* Make sure this union is always non-empty */
|
||||
mbedtls_psa_verify_hash_interruptible_operation_t mbedtls_ctx;
|
||||
} psa_driver_verify_hash_interruptible_context_t;
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_CONTEXTS_COMPOSITES_H */
|
||||
/* End of automatically generated file. */
|
||||
|
|
|
@ -189,12 +189,12 @@ static inline void psa_clear_key_slot_number(
|
|||
* or the specified slot number is not valid.
|
||||
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||
* The caller is not authorized to register the specified key slot.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The library has not been previously initialized by psa_crypto_init().
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
|
@ -491,10 +491,10 @@ psa_status_t mbedtls_psa_inject_entropy(const uint8_t *seed,
|
|||
* according to \p type as described above.
|
||||
* \param data_length Size of the \p data buffer in bytes.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_INVALID_ARGUMENT
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
* \retval #PSA_ERROR_INVALID_ARGUMENT \emptydescription
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
*/
|
||||
psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
|
||||
psa_key_type_t type,
|
||||
|
@ -521,8 +521,8 @@ psa_status_t psa_set_key_domain_parameters(psa_key_attributes_t *attributes,
|
|||
* \param[out] data_length On success, the number of bytes
|
||||
* that make up the key domain parameters data.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
* \retval #PSA_ERROR_BUFFER_TOO_SMALL \emptydescription
|
||||
*/
|
||||
psa_status_t psa_get_key_domain_parameters(
|
||||
const psa_key_attributes_t *attributes,
|
||||
|
@ -1352,8 +1352,8 @@ static psa_pake_operation_t psa_pake_operation_init(void);
|
|||
* compatible with the PAKE algorithm, or the hash algorithm in
|
||||
* \p cipher_suite is not supported or not compatible with the PAKE
|
||||
* algorithm and primitive.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid, or
|
||||
* the library has not been previously initialized by psa_crypto_init().
|
||||
|
@ -1397,11 +1397,11 @@ psa_status_t psa_pake_setup(psa_pake_operation_t *operation,
|
|||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* The key type or key size of \p password is not supported with the
|
||||
* \p operation's cipher suite.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must have been set up.), or
|
||||
* the library has not been previously initialized by psa_crypto_init().
|
||||
|
@ -1439,9 +1439,9 @@ psa_status_t psa_pake_set_password_key(psa_pake_operation_t *operation,
|
|||
* suite.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* The value of \p user_id is not supported by the implementation.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid, or
|
||||
* the library has not been previously initialized by psa_crypto_init().
|
||||
|
@ -1480,9 +1480,9 @@ psa_status_t psa_pake_set_user(psa_pake_operation_t *operation,
|
|||
* suite.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* The algorithm doesn't associate a second identity with the session.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* Calling psa_pake_set_peer() is invalid with the \p operation's
|
||||
* algorithm, the operation state is not valid, or the library has not
|
||||
|
@ -1524,8 +1524,8 @@ psa_status_t psa_pake_set_peer(psa_pake_operation_t *operation,
|
|||
* The \p role is not a valid PAKE role in the \p operation’s algorithm.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* The \p role for this algorithm is not supported or is not valid.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid, or
|
||||
* the library has not been previously initialized by psa_crypto_init().
|
||||
|
@ -1575,13 +1575,13 @@ psa_status_t psa_pake_set_role(psa_pake_operation_t *operation,
|
|||
* \p step is not compatible with the operation's algorithm.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \p step is not supported with the operation's algorithm.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_ENTROPY \emptydescription
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be active, and fully set
|
||||
* up, and this call must conform to the algorithm's requirements
|
||||
|
@ -1631,12 +1631,12 @@ psa_status_t psa_pake_output(psa_pake_operation_t *operation,
|
|||
* \p step p is not supported with the \p operation's algorithm, or the
|
||||
* \p input is not supported for the \p operation's algorithm, cipher
|
||||
* suite or \p step.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The operation state is not valid (it must be active, and fully set
|
||||
* up, and this call must conform to the algorithm's requirements
|
||||
|
@ -1691,12 +1691,12 @@ psa_status_t psa_pake_input(psa_pake_operation_t *operation,
|
|||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* Input from a PAKE is not supported by the algorithm in the \p output
|
||||
* key derivation operation.
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT
|
||||
* \retval #PSA_ERROR_DATA_INVALID
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_STORAGE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
|
||||
* \retval #PSA_ERROR_DATA_INVALID \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The PAKE operation state is not valid (it must be active, but beyond
|
||||
* that validity is specific to the algorithm), or
|
||||
|
@ -1728,8 +1728,8 @@ psa_status_t psa_pake_get_implicit_key(psa_pake_operation_t *operation,
|
|||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* Success.
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
* \retval #PSA_ERROR_BAD_STATE
|
||||
* The library has not been previously initialized by psa_crypto_init().
|
||||
* It is implementation-dependent whether a failure to initialize
|
||||
|
|
|
@ -385,8 +385,8 @@ typedef struct {
|
|||
* \param[in] direction Indicates whether the operation is an encrypt
|
||||
* or decrypt
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_cipher_setup_t)(psa_drv_se_context_t *drv_context,
|
||||
void *op_context,
|
||||
|
@ -407,7 +407,7 @@ typedef psa_status_t (*psa_drv_se_cipher_setup_t)(psa_drv_se_context_t *drv_cont
|
|||
* \param[in] p_iv A buffer containing the initialization vector
|
||||
* \param[in] iv_length The size (in bytes) of the `p_iv` buffer
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *op_context,
|
||||
const uint8_t *p_iv,
|
||||
|
@ -429,7 +429,7 @@ typedef psa_status_t (*psa_drv_se_cipher_set_iv_t)(void *op_context,
|
|||
* \param[out] p_output_length After completion, will contain the number
|
||||
* of bytes placed in the `p_output` buffer
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *op_context,
|
||||
const uint8_t *p_input,
|
||||
|
@ -450,7 +450,7 @@ typedef psa_status_t (*psa_drv_se_cipher_update_t)(void *op_context,
|
|||
* \param[out] p_output_length After completion, will contain the number of
|
||||
* bytes placed in the `p_output` buffer
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_cipher_finish_t)(void *op_context,
|
||||
uint8_t *p_output,
|
||||
|
@ -485,8 +485,8 @@ typedef psa_status_t (*psa_drv_se_cipher_abort_t)(void *op_context);
|
|||
* \param[in] output_size The allocated size in bytes of the `p_output`
|
||||
* buffer
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_cipher_ecb_t)(psa_drv_se_context_t *drv_context,
|
||||
psa_key_slot_number_t key_slot,
|
||||
|
@ -554,7 +554,7 @@ typedef struct {
|
|||
* \param[out] p_signature_length On success, the number of bytes
|
||||
* that make up the returned signature value
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_asymmetric_sign_t)(psa_drv_se_context_t *drv_context,
|
||||
psa_key_slot_number_t key_slot,
|
||||
|
@ -618,7 +618,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_verify_t)(psa_drv_se_context_t *drv
|
|||
* \param[out] p_output_length On success, the number of bytes that make up
|
||||
* the returned output
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_drv_se_context_t *drv_context,
|
||||
psa_key_slot_number_t key_slot,
|
||||
|
@ -658,7 +658,7 @@ typedef psa_status_t (*psa_drv_se_asymmetric_encrypt_t)(psa_drv_se_context_t *dr
|
|||
* \param[out] p_output_length On success, the number of bytes
|
||||
* that make up the returned output
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_asymmetric_decrypt_t)(psa_drv_se_context_t *drv_context,
|
||||
psa_key_slot_number_t key_slot,
|
||||
|
@ -904,8 +904,8 @@ typedef enum {
|
|||
* Success.
|
||||
* The core will record \c *key_slot as the key slot where the key
|
||||
* is stored and will update the persistent data in storage.
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
|
||||
* \retval #PSA_ERROR_INSUFFICIENT_STORAGE \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_allocate_key_t)(
|
||||
psa_drv_se_context_t *drv_context,
|
||||
|
@ -1043,13 +1043,13 @@ typedef psa_status_t (*psa_drv_se_destroy_key_t)(
|
|||
* \param[out] p_data_length On success, the number of bytes
|
||||
* that make up the key data.
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_ERROR_DOES_NOT_EXIST
|
||||
* \retval #PSA_ERROR_NOT_PERMITTED
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE
|
||||
* \retval #PSA_ERROR_HARDWARE_FAILURE
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
* \retval #PSA_ERROR_DOES_NOT_EXIST \emptydescription
|
||||
* \retval #PSA_ERROR_NOT_PERMITTED \emptydescription
|
||||
* \retval #PSA_ERROR_NOT_SUPPORTED \emptydescription
|
||||
* \retval #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_HARDWARE_FAILURE \emptydescription
|
||||
* \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_export_key_t)(psa_drv_se_context_t *drv_context,
|
||||
psa_key_slot_number_t key,
|
||||
|
@ -1196,7 +1196,7 @@ typedef struct {
|
|||
* \param[in] source_key The key to be used as the source material for
|
||||
* the key derivation
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_se_context_t *drv_context,
|
||||
void *op_context,
|
||||
|
@ -1216,7 +1216,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_setup_t)(psa_drv_se_context_t *
|
|||
* \param[in] p_collateral A buffer containing the collateral data
|
||||
* \param[in] collateral_size The size in bytes of the collateral
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *op_context,
|
||||
uint32_t collateral_id,
|
||||
|
@ -1231,7 +1231,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_collateral_t)(void *op_context,
|
|||
* \param[in] dest_key The slot where the generated key material
|
||||
* should be placed
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *op_context,
|
||||
psa_key_slot_number_t dest_key);
|
||||
|
@ -1245,7 +1245,7 @@ typedef psa_status_t (*psa_drv_se_key_derivation_derive_t)(void *op_context,
|
|||
* \param[out] p_output_length Upon success, contains the number of bytes of
|
||||
* key material placed in `p_output`
|
||||
*
|
||||
* \retval #PSA_SUCCESS
|
||||
* \retval #PSA_SUCCESS \emptydescription
|
||||
*/
|
||||
typedef psa_status_t (*psa_drv_se_key_derivation_export_t)(void *op_context,
|
||||
uint8_t *p_output,
|
||||
|
|
|
@ -491,6 +491,66 @@ static inline size_t psa_get_key_bits(
|
|||
return attributes->MBEDTLS_PRIVATE(core).MBEDTLS_PRIVATE(bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The context for PSA interruptible hash signing.
|
||||
*/
|
||||
struct psa_sign_hash_interruptible_operation_s {
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
* operation. Since driver contexts are driver-specific, swapping
|
||||
* drivers halfway through the operation is not supported.
|
||||
* ID values are auto-generated in psa_crypto_driver_wrappers.h
|
||||
* ID value zero means the context is not valid or not assigned to
|
||||
* any driver (i.e. none of the driver contexts are active). */
|
||||
unsigned int MBEDTLS_PRIVATE(id);
|
||||
|
||||
psa_driver_sign_hash_interruptible_context_t MBEDTLS_PRIVATE(ctx);
|
||||
|
||||
unsigned int MBEDTLS_PRIVATE(error_occurred) : 1;
|
||||
|
||||
uint32_t MBEDTLS_PRIVATE(num_ops);
|
||||
};
|
||||
|
||||
#define PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT { 0, { 0 }, 0, 0 }
|
||||
|
||||
static inline struct psa_sign_hash_interruptible_operation_s
|
||||
psa_sign_hash_interruptible_operation_init(void)
|
||||
{
|
||||
const struct psa_sign_hash_interruptible_operation_s v =
|
||||
PSA_SIGN_HASH_INTERRUPTIBLE_OPERATION_INIT;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief The context for PSA interruptible hash verification.
|
||||
*/
|
||||
struct psa_verify_hash_interruptible_operation_s {
|
||||
/** Unique ID indicating which driver got assigned to do the
|
||||
* operation. Since driver contexts are driver-specific, swapping
|
||||
* drivers halfway through the operation is not supported.
|
||||
* ID values are auto-generated in psa_crypto_driver_wrappers.h
|
||||
* ID value zero means the context is not valid or not assigned to
|
||||
* any driver (i.e. none of the driver contexts are active). */
|
||||
unsigned int MBEDTLS_PRIVATE(id);
|
||||
|
||||
psa_driver_verify_hash_interruptible_context_t MBEDTLS_PRIVATE(ctx);
|
||||
|
||||
unsigned int MBEDTLS_PRIVATE(error_occurred) : 1;
|
||||
|
||||
uint32_t MBEDTLS_PRIVATE(num_ops);
|
||||
};
|
||||
|
||||
#define PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT { 0, { 0 }, 0, 0 }
|
||||
|
||||
static inline struct psa_verify_hash_interruptible_operation_s
|
||||
psa_verify_hash_interruptible_operation_init(void)
|
||||
{
|
||||
const struct psa_verify_hash_interruptible_operation_s v =
|
||||
PSA_VERIFY_HASH_INTERRUPTIBLE_OPERATION_INIT;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,16 +32,17 @@
|
|||
|
||||
#ifndef PSA_CRYPTO_TYPES_H
|
||||
#define PSA_CRYPTO_TYPES_H
|
||||
|
||||
/* Make sure the Mbed TLS configuration is visible. */
|
||||
#include "mbedtls/build_info.h"
|
||||
/* Define the MBEDTLS_PRIVATE macro. */
|
||||
#include "mbedtls/private_access.h"
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_PLATFORM_FILE)
|
||||
#include MBEDTLS_PSA_CRYPTO_PLATFORM_FILE
|
||||
#else
|
||||
#include "crypto_platform.h"
|
||||
|
||||
/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
* is defined as well to include all PSA code.
|
||||
*/
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_C)
|
||||
#define MBEDTLS_PSA_CRYPTO_CLIENT
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_C */
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
@ -335,6 +335,13 @@
|
|||
*/
|
||||
#define PSA_ERROR_DATA_INVALID ((psa_status_t)-153)
|
||||
|
||||
/** The function that returns this status is defined as interruptible and
|
||||
* still has work to do, thus the user should call the function again with the
|
||||
* same operation context until it either returns #PSA_SUCCESS or any other
|
||||
* error. This is not an error per se, more a notification of status.
|
||||
*/
|
||||
#define PSA_OPERATION_INCOMPLETE ((psa_status_t)-248)
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/**@}*/
|
||||
|
@ -2739,4 +2746,18 @@ static inline int mbedtls_svc_key_id_is_null(mbedtls_svc_key_id_t key)
|
|||
|
||||
/**@}*/
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** \defgroup interruptible Interruptible operations
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Maximum value for use with \c psa_interruptible_set_max_ops() to determine
|
||||
* the maximum number of ops allowed to be executed by an interruptible
|
||||
* function in a single call.
|
||||
*/
|
||||
#define PSA_INTERRUPTIBLE_MAX_OPS_UNLIMITED UINT32_MAX
|
||||
|
||||
/**@}*/
|
||||
|
||||
#endif /* PSA_CRYPTO_VALUES_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue