core: ltc: export ECC key helper functions
The static functions ecc_populate_ltc_private_key() and
ecc_populate_ltc_public_key() will be useful for other ECC algorithms
than the ones currently handled by core/lib/libtomcrypt/ecc.c, namely:
the SM2 family of algorithms. Therefore, export these functions in
"acipher_helpers.h".
Signed-off-by: Jerome Forissier <jerome@forissier.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
diff --git a/core/lib/libtomcrypt/acipher_helpers.h b/core/lib/libtomcrypt/acipher_helpers.h
index d867730..ecd12d7 100644
--- a/core/lib/libtomcrypt/acipher_helpers.h
+++ b/core/lib/libtomcrypt/acipher_helpers.h
@@ -3,8 +3,13 @@
* Copyright (c) 2014-2019, Linaro Limited
*/
+#ifndef ACIPHER_HELPERS_H
+#define ACIPHER_HELPERS_H
+
#include <crypto/crypto.h>
#include <tee_api_defines.h>
+#include <tee_api_types.h>
+#include <tomcrypt_private.h>
#include <types_ext.h>
static inline bool bn_alloc_max(struct bignum **s)
@@ -28,3 +33,14 @@
return TEE_ERROR_GENERIC;
}
}
+
+#ifdef CFG_CRYPTOLIB_NAME_tomcrypt
+TEE_Result ecc_populate_ltc_private_key(ecc_key *ltc_key,
+ struct ecc_keypair *key,
+ uint32_t algo, size_t *key_size_bytes);
+TEE_Result ecc_populate_ltc_public_key(ecc_key *ltc_key,
+ struct ecc_public_key *key,
+ uint32_t algo, size_t *key_size_bytes);
+#endif
+
+#endif /* ACIPHER_HELPERS_H */
diff --git a/core/lib/libtomcrypt/dh.c b/core/lib/libtomcrypt/dh.c
index 048acc9..2e7aebe 100644
--- a/core/lib/libtomcrypt/dh.c
+++ b/core/lib/libtomcrypt/dh.c
@@ -7,7 +7,6 @@
#include <stdlib.h>
#include <string.h>
#include <tee_api_types.h>
-#include <tomcrypt_private.h>
#include <trace.h>
#include <utee_defines.h>
diff --git a/core/lib/libtomcrypt/dsa.c b/core/lib/libtomcrypt/dsa.c
index 9db95a6..2ccbcbd 100644
--- a/core/lib/libtomcrypt/dsa.c
+++ b/core/lib/libtomcrypt/dsa.c
@@ -8,7 +8,6 @@
#include <string.h>
#include <tee_api_types.h>
#include <tee/tee_cryp_utl.h>
-#include <tomcrypt_private.h>
#include <trace.h>
#include <utee_defines.h>
diff --git a/core/lib/libtomcrypt/ecc.c b/core/lib/libtomcrypt/ecc.c
index 48ed04d..8322ba2 100644
--- a/core/lib/libtomcrypt/ecc.c
+++ b/core/lib/libtomcrypt/ecc.c
@@ -7,7 +7,6 @@
#include <stdlib.h>
#include <string.h>
#include <tee_api_types.h>
-#include <tomcrypt_private.h>
#include <trace.h>
#include <utee_defines.h>
@@ -205,10 +204,9 @@
* Given a keypair "key", populate the Libtomcrypt private key "ltc_key"
* It also returns the key size, in bytes
*/
-static TEE_Result ecc_populate_ltc_private_key(ecc_key *ltc_key,
- struct ecc_keypair *key,
- uint32_t algo,
- size_t *key_size_bytes)
+TEE_Result ecc_populate_ltc_private_key(ecc_key *ltc_key,
+ struct ecc_keypair *key,
+ uint32_t algo, size_t *key_size_bytes)
{
TEE_Result res = TEE_ERROR_GENERIC;
const char *name = NULL;
@@ -233,10 +231,9 @@
* Given a public "key", populate the Libtomcrypt public key "ltc_key"
* It also returns the key size, in bytes
*/
-static TEE_Result ecc_populate_ltc_public_key(ecc_key *ltc_key,
- struct ecc_public_key *key,
- uint32_t algo,
- size_t *key_size_bytes)
+TEE_Result ecc_populate_ltc_public_key(ecc_key *ltc_key,
+ struct ecc_public_key *key,
+ uint32_t algo, size_t *key_size_bytes)
{
TEE_Result res = TEE_ERROR_GENERIC;
const char *name = NULL;
diff --git a/core/lib/libtomcrypt/rsa.c b/core/lib/libtomcrypt/rsa.c
index d94a5d3..b3651b4 100644
--- a/core/lib/libtomcrypt/rsa.c
+++ b/core/lib/libtomcrypt/rsa.c
@@ -9,7 +9,6 @@
#include <tee_api_types.h>
#include <tee_api_defines_extensions.h>
#include <tee/tee_cryp_utl.h>
-#include <tomcrypt_private.h>
#include <trace.h>
#include <utee_defines.h>