diff options
author | Julian Hall <julian.hall@arm.com> | 2021-08-04 10:43:34 +0100 |
---|---|---|
committer | Gyorgy Szing <Gyorgy.Szing@arm.com> | 2021-10-06 00:48:57 +0200 |
commit | a9490045b471587de964081f416647dfff15e102 (patch) | |
tree | 3f3e04db7f65724de7992e2fdebdc85e7087f601 | |
parent | 7a7034029ddce9ca90b52f5fe42a434376cab51f (diff) | |
download | trusted-services-a9490045b471587de964081f416647dfff15e102.tar.gz |
Allow build-time selection of backend for PSA crypto client
To allow the PSA crypto API client to be used with different backend
callers, the facility to configure a build to use an alternative
crypto caller backed is provided. By default, the packed-c
crypto caller is used. To use an alternative, the preprocessor
define PSA_CRYPTO_CLIENT_CALLER_SELECTION_H should be defined
to the path of the interface header file for the alternative
crypto caller.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I4da50c1847c3fd16843988bcee4c56254312c125
19 files changed, 43 insertions, 18 deletions
diff --git a/components/service/crypto/client/psa/crypto_caller_selector.h b/components/service/crypto/client/psa/crypto_caller_selector.h new file mode 100644 index 000000000..ed84d43e7 --- /dev/null +++ b/components/service/crypto/client/psa/crypto_caller_selector.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef CRYPTO_CALLER_SELECTOR_H +#define CRYPTO_CALLER_SELECTOR_H + +/** + * This header file selects which crypto caller is used as a backend + * for the psa crypto API client. Selection is made at build-time to + * allow psa crypto API operations to be handled by alternative backend + * crypto callers to meet the needs of a deployment. + */ + +/* Set the default if no deployment specific selection has been made */ +#ifndef PSA_CRYPTO_CLIENT_CALLER_SELECTION_H +#define PSA_CRYPTO_CLIENT_CALLER_SELECTION_H "service/crypto/client/caller/packed-c/crypto_caller.h" +#endif + +/* Include the selected crypto caller interface header file */ +#include PSA_CRYPTO_CLIENT_CALLER_SELECTION_H + +#endif /* CRYPTO_CALLER_SELECTOR_H */ diff --git a/components/service/crypto/client/psa/psa_aead.c b/components/service/crypto/client/psa/psa_aead.c index 39e0f1e96..22fd3da17 100644 --- a/components/service/crypto/client/psa/psa_aead.c +++ b/components/service/crypto/client/psa/psa_aead.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_aead_encrypt(psa_key_id_t key, diff --git a/components/service/crypto/client/psa/psa_asymmetric_decrypt.c b/components/service/crypto/client/psa/psa_asymmetric_decrypt.c index d137b6ef7..856c7e9dc 100644 --- a/components/service/crypto/client/psa/psa_asymmetric_decrypt.c +++ b/components/service/crypto/client/psa/psa_asymmetric_decrypt.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_asymmetric_decrypt(psa_key_id_t id, psa_algorithm_t alg, diff --git a/components/service/crypto/client/psa/psa_asymmetric_encrypt.c b/components/service/crypto/client/psa/psa_asymmetric_encrypt.c index bb9665701..d82d26ca7 100644 --- a/components/service/crypto/client/psa/psa_asymmetric_encrypt.c +++ b/components/service/crypto/client/psa/psa_asymmetric_encrypt.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_asymmetric_encrypt(psa_key_id_t id, psa_algorithm_t alg, diff --git a/components/service/crypto/client/psa/psa_cipher.c b/components/service/crypto/client/psa/psa_cipher.c index 23d52d109..70836ea6b 100644 --- a/components/service/crypto/client/psa/psa_cipher.c +++ b/components/service/crypto/client/psa/psa_cipher.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, diff --git a/components/service/crypto/client/psa/psa_copy_key.c b/components/service/crypto/client/psa/psa_copy_key.c index c2f790435..63f1c5e89 100644 --- a/components/service/crypto/client/psa/psa_copy_key.c +++ b/components/service/crypto/client/psa/psa_copy_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_copy_key(psa_key_id_t source_key, diff --git a/components/service/crypto/client/psa/psa_destroy_key.c b/components/service/crypto/client/psa/psa_destroy_key.c index c8114cb82..5a425c742 100644 --- a/components/service/crypto/client/psa/psa_destroy_key.c +++ b/components/service/crypto/client/psa/psa_destroy_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_destroy_key(psa_key_id_t id) { diff --git a/components/service/crypto/client/psa/psa_export_key.c b/components/service/crypto/client/psa/psa_export_key.c index 0596b6f3d..b90be673f 100644 --- a/components/service/crypto/client/psa/psa_export_key.c +++ b/components/service/crypto/client/psa/psa_export_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_export_key(psa_key_id_t id, diff --git a/components/service/crypto/client/psa/psa_export_public_key.c b/components/service/crypto/client/psa/psa_export_public_key.c index 434351689..2e836c915 100644 --- a/components/service/crypto/client/psa/psa_export_public_key.c +++ b/components/service/crypto/client/psa/psa_export_public_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_export_public_key(psa_key_id_t id, diff --git a/components/service/crypto/client/psa/psa_generate_key.c b/components/service/crypto/client/psa/psa_generate_key.c index 732068f30..ef183b577 100644 --- a/components/service/crypto/client/psa/psa_generate_key.c +++ b/components/service/crypto/client/psa/psa_generate_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_generate_key(const psa_key_attributes_t *attributes, psa_key_id_t *id) diff --git a/components/service/crypto/client/psa/psa_generate_random.c b/components/service/crypto/client/psa/psa_generate_random.c index 1eaa490f7..597d823e5 100644 --- a/components/service/crypto/client/psa/psa_generate_random.c +++ b/components/service/crypto/client/psa/psa_generate_random.c @@ -5,7 +5,7 @@ */ #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_generate_random(uint8_t *output, size_t output_size) { diff --git a/components/service/crypto/client/psa/psa_get_key_attributes.c b/components/service/crypto/client/psa/psa_get_key_attributes.c index d625b5dd5..39356b314 100644 --- a/components/service/crypto/client/psa/psa_get_key_attributes.c +++ b/components/service/crypto/client/psa/psa_get_key_attributes.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_get_key_attributes(psa_key_id_t key, diff --git a/components/service/crypto/client/psa/psa_hash.c b/components/service/crypto/client/psa/psa_hash.c index eab35edef..7005c3900 100644 --- a/components/service/crypto/client/psa/psa_hash.c +++ b/components/service/crypto/client/psa/psa_hash.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg) diff --git a/components/service/crypto/client/psa/psa_import_key.c b/components/service/crypto/client/psa/psa_import_key.c index a7699cb03..246e60dcc 100644 --- a/components/service/crypto/client/psa/psa_import_key.c +++ b/components/service/crypto/client/psa/psa_import_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_import_key(const psa_key_attributes_t *attributes, diff --git a/components/service/crypto/client/psa/psa_key_derivation.c b/components/service/crypto/client/psa/psa_key_derivation.c index 719d90c97..07c593fd5 100644 --- a/components/service/crypto/client/psa/psa_key_derivation.c +++ b/components/service/crypto/client/psa/psa_key_derivation.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_key_derivation_setup( psa_key_derivation_operation_t *operation, diff --git a/components/service/crypto/client/psa/psa_mac.c b/components/service/crypto/client/psa/psa_mac.c index 87a000d70..5efa1c4df 100644 --- a/components/service/crypto/client/psa/psa_mac.c +++ b/components/service/crypto/client/psa/psa_mac.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, diff --git a/components/service/crypto/client/psa/psa_purge_key.c b/components/service/crypto/client/psa/psa_purge_key.c index 36f85e194..819b69724 100644 --- a/components/service/crypto/client/psa/psa_purge_key.c +++ b/components/service/crypto/client/psa/psa_purge_key.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_purge_key(psa_key_id_t key) diff --git a/components/service/crypto/client/psa/psa_sign_hash.c b/components/service/crypto/client/psa/psa_sign_hash.c index d93cb6b42..2248c8301 100644 --- a/components/service/crypto/client/psa/psa_sign_hash.c +++ b/components/service/crypto/client/psa/psa_sign_hash.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_sign_hash(psa_key_id_t id, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, diff --git a/components/service/crypto/client/psa/psa_verify_hash.c b/components/service/crypto/client/psa/psa_verify_hash.c index d0ab32b90..ae678d341 100644 --- a/components/service/crypto/client/psa/psa_verify_hash.c +++ b/components/service/crypto/client/psa/psa_verify_hash.c @@ -6,7 +6,7 @@ #include <psa/crypto.h> #include "psa_crypto_client.h" -#include <service/crypto/client/caller/packed-c/crypto_caller.h> +#include "crypto_caller_selector.h" psa_status_t psa_verify_hash(psa_key_id_t id, psa_algorithm_t alg, |