mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Merge pull request #5263 from ronald-cron-arm/psa-test-driver_3.x
Forward port to 3.x: Introduce PSA test driver library to test PSA configuration
This commit is contained in:
@@ -112,21 +112,4 @@ typedef struct
|
||||
|
||||
#define MBEDTLS_PSA_AEAD_OPERATION_INIT {0, 0, 0, 0, {0}}
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY.
|
||||
*/
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
typedef mbedtls_psa_mac_operation_t mbedtls_transparent_test_driver_mac_operation_t;
|
||||
typedef mbedtls_psa_mac_operation_t mbedtls_opaque_test_driver_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
|
||||
typedef mbedtls_psa_aead_operation_t mbedtls_transparent_test_driver_aead_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT MBEDTLS_PSA_AEAD_OPERATION_INIT
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_COMPOSITES_H */
|
||||
|
@@ -61,21 +61,23 @@ typedef struct
|
||||
psa_algorithm_t MBEDTLS_PRIVATE(alg);
|
||||
union
|
||||
{
|
||||
unsigned MBEDTLS_PRIVATE(dummy); /* Make the union non-empty even with no supported algorithms. */
|
||||
#if defined(MBEDTLS_MD5_C)
|
||||
mbedtls_md5_context MBEDTLS_PRIVATE(md5);
|
||||
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_MD5)
|
||||
mbedtls_md5_context md5;
|
||||
#endif
|
||||
#if defined(MBEDTLS_RIPEMD160_C)
|
||||
mbedtls_ripemd160_context MBEDTLS_PRIVATE(ripemd160);
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_RIPEMD160)
|
||||
mbedtls_ripemd160_context ripemd160;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
mbedtls_sha1_context MBEDTLS_PRIVATE(sha1);
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_1)
|
||||
mbedtls_sha1_context sha1;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
mbedtls_sha256_context MBEDTLS_PRIVATE(sha256);
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_256) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_224)
|
||||
mbedtls_sha256_context sha256;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
mbedtls_sha512_context MBEDTLS_PRIVATE(sha512);
|
||||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_512) || \
|
||||
defined(MBEDTLS_PSA_BUILTIN_ALG_SHA_384)
|
||||
mbedtls_sha512_context sha512;
|
||||
#endif
|
||||
} MBEDTLS_PRIVATE(ctx);
|
||||
} mbedtls_psa_hash_operation_t;
|
||||
@@ -112,29 +114,4 @@ typedef struct {
|
||||
|
||||
#define MBEDTLS_PSA_CIPHER_OPERATION_INIT {0, 0, 0, {0}}
|
||||
|
||||
/*
|
||||
* BEYOND THIS POINT, TEST DRIVER DECLARATIONS ONLY.
|
||||
*/
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
typedef mbedtls_psa_hash_operation_t mbedtls_transparent_test_driver_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
|
||||
typedef mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int initialised : 1;
|
||||
mbedtls_transparent_test_driver_cipher_operation_t ctx;
|
||||
} mbedtls_opaque_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
{ 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
#endif /* PSA_CRYPTO_BUILTIN_PRIMITIVES_H */
|
||||
|
@@ -36,11 +36,59 @@
|
||||
|
||||
#include "psa/crypto_driver_common.h"
|
||||
|
||||
/* Include the context structure definitions for the Mbed TLS software drivers */
|
||||
#include "psa/crypto_builtin_composites.h"
|
||||
|
||||
/* Include the context structure definitions for those drivers that were
|
||||
* declared during the autogeneration process. */
|
||||
|
||||
/* Include the context structure definitions for the Mbed TLS software drivers */
|
||||
#include "psa/crypto_builtin_composites.h"
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
|
||||
#include <libtestdriver1/include/psa/crypto.h>
|
||||
#endif
|
||||
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC)
|
||||
typedef libtestdriver1_mbedtls_psa_mac_operation_t
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
typedef libtestdriver1_mbedtls_psa_mac_operation_t
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
|
||||
#else
|
||||
typedef mbedtls_psa_mac_operation_t
|
||||
mbedtls_transparent_test_driver_mac_operation_t;
|
||||
typedef mbedtls_psa_mac_operation_t
|
||||
mbedtls_opaque_test_driver_mac_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_MAC_OPERATION_INIT \
|
||||
MBEDTLS_PSA_MAC_OPERATION_INIT
|
||||
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_MAC */
|
||||
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD)
|
||||
typedef libtestdriver1_mbedtls_psa_aead_operation_t
|
||||
mbedtls_transparent_test_driver_aead_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_AEAD_OPERATION_INIT
|
||||
#else
|
||||
typedef mbedtls_psa_aead_operation_t
|
||||
mbedtls_transparent_test_driver_aead_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_AEAD_OPERATION_INIT \
|
||||
MBEDTLS_PSA_AEAD_OPERATION_INIT
|
||||
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 && LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_AEAD */
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
/* Define the context to be used for an operation that is executed through the
|
||||
* PSA Driver wrapper layer as the union of all possible driver's contexts.
|
||||
|
@@ -35,11 +35,59 @@
|
||||
|
||||
#include "psa/crypto_driver_common.h"
|
||||
|
||||
/* Include the context structure definitions for the Mbed TLS software drivers */
|
||||
#include "psa/crypto_builtin_primitives.h"
|
||||
|
||||
/* Include the context structure definitions for those drivers that were
|
||||
* declared during the autogeneration process. */
|
||||
|
||||
/* Include the context structure definitions for the Mbed TLS software drivers */
|
||||
#include "psa/crypto_builtin_primitives.h"
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1)
|
||||
#include <libtestdriver1/include/psa/crypto.h>
|
||||
#endif
|
||||
|
||||
#if defined(PSA_CRYPTO_DRIVER_TEST)
|
||||
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER)
|
||||
typedef libtestdriver1_mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
#else
|
||||
typedef mbedtls_psa_cipher_operation_t
|
||||
mbedtls_transparent_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
MBEDTLS_PSA_CIPHER_OPERATION_INIT
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_CIPHER */
|
||||
|
||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||
defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH)
|
||||
typedef libtestdriver1_mbedtls_psa_hash_operation_t
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
#else
|
||||
typedef mbedtls_psa_hash_operation_t
|
||||
mbedtls_transparent_test_driver_hash_operation_t;
|
||||
|
||||
#define MBEDTLS_TRANSPARENT_TEST_DRIVER_HASH_OPERATION_INIT \
|
||||
MBEDTLS_PSA_HASH_OPERATION_INIT
|
||||
#endif /* MBEDTLS_TEST_LIBTESTDRIVER1 &&
|
||||
LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_HASH */
|
||||
|
||||
typedef struct {
|
||||
unsigned int initialised : 1;
|
||||
mbedtls_transparent_test_driver_cipher_operation_t ctx;
|
||||
} mbedtls_opaque_test_driver_cipher_operation_t;
|
||||
|
||||
#define MBEDTLS_OPAQUE_TEST_DRIVER_CIPHER_OPERATION_INIT \
|
||||
{ 0, MBEDTLS_TRANSPARENT_TEST_DRIVER_CIPHER_OPERATION_INIT }
|
||||
|
||||
#endif /* PSA_CRYPTO_DRIVER_TEST */
|
||||
|
||||
/* Define the context to be used for an operation that is executed through the
|
||||
* PSA Driver wrapper layer as the union of all possible driver's contexts.
|
||||
|
@@ -121,7 +121,7 @@
|
||||
/* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-226,
|
||||
* 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
|
||||
* HMAC-SHA3-512. */
|
||||
#if defined(MBEDTLS_SHA512_C)
|
||||
#if defined(PSA_WANT_ALG_SHA_512) || defined(PSA_WANT_ALG_SHA_384)
|
||||
#define PSA_HASH_MAX_SIZE 64
|
||||
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
|
||||
#else
|
||||
|
Reference in New Issue
Block a user