[PATCH RFC 064/104] crypto: fips140: convert crypto/rsa_helper.c to using crypto API wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use CRYPTO_API() etc. from include/crypto/api.h in preparation for
compilation as part of support for FIPS 140 standalone modules.

Generated using:

  ./fipsify.py --config CONFIG_CRYPTO_RSA --source crypto/rsa_helper.c --header include/crypto/internal/rsa.h

Signed-off-by: Vegard Nossum <vegard.nossum@xxxxxxxxxx>
---
 crypto/fips140-api.c          | 12 ++++++++++++
 crypto/rsa_helper.c           |  8 ++++----
 include/crypto/internal/rsa.h | 12 ++++++++----
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/crypto/fips140-api.c b/crypto/fips140-api.c
index 8810af32dd43..47977f5b8554 100644
--- a/crypto/fips140-api.c
+++ b/crypto/fips140-api.c
@@ -488,3 +488,15 @@ DEFINE_CRYPTO_API_STUB(crypto_del_default_rng);
 
 #endif
 
+/*
+ * crypto/rsa_helper.c
+ */
+#if !IS_BUILTIN(CONFIG_CRYPTO_RSA)
+
+#include <crypto/internal/rsa.h>
+
+DEFINE_CRYPTO_API_STUB(rsa_parse_pub_key);
+DEFINE_CRYPTO_API_STUB(rsa_parse_priv_key);
+
+#endif
+
diff --git a/crypto/rsa_helper.c b/crypto/rsa_helper.c
index 94266f29049c..ba1278fcf393 100644
--- a/crypto/rsa_helper.c
+++ b/crypto/rsa_helper.c
@@ -159,12 +159,12 @@ int rsa_get_qinv(void *context, size_t hdrlen, unsigned char tag,
  *
  * Return:	0 on success or error code in case of error
  */
-int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
+int CRYPTO_API(rsa_parse_pub_key)(struct rsa_key *rsa_key, const void *key,
 		      unsigned int key_len)
 {
 	return asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len);
 }
-EXPORT_SYMBOL_GPL(rsa_parse_pub_key);
+DEFINE_CRYPTO_API(rsa_parse_pub_key);
 
 /**
  * rsa_parse_priv_key() - decodes the BER encoded buffer and stores in the
@@ -178,9 +178,9 @@ EXPORT_SYMBOL_GPL(rsa_parse_pub_key);
  *
  * Return:	0 on success or error code in case of error
  */
-int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
+int CRYPTO_API(rsa_parse_priv_key)(struct rsa_key *rsa_key, const void *key,
 		       unsigned int key_len)
 {
 	return asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len);
 }
-EXPORT_SYMBOL_GPL(rsa_parse_priv_key);
+DEFINE_CRYPTO_API(rsa_parse_priv_key);
diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h
index 071a1951b992..1265aa81f6fe 100644
--- a/include/crypto/internal/rsa.h
+++ b/include/crypto/internal/rsa.h
@@ -7,6 +7,8 @@
  */
 #ifndef _RSA_HELPER_
 #define _RSA_HELPER_
+
+#include <crypto/api.h>
 #include <linux/types.h>
 #include <crypto/akcipher.h>
 
@@ -48,11 +50,13 @@ struct rsa_key {
 	size_t qinv_sz;
 };
 
-int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key,
-		      unsigned int key_len);
+DECLARE_CRYPTO_API(rsa_parse_pub_key, int,
+	(struct rsa_key *rsa_key, const void *key, unsigned int key_len),
+	(rsa_key, key, key_len));
 
-int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key,
-		       unsigned int key_len);
+DECLARE_CRYPTO_API(rsa_parse_priv_key, int,
+	(struct rsa_key *rsa_key, const void *key, unsigned int key_len),
+	(rsa_key, key, key_len));
 
 #define RSA_PUB (true)
 #define RSA_PRIV (false)
-- 
2.39.3





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux