aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/api.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/api.c')
-rw-r--r--crypto/api.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 033a714..0686dc5 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -361,6 +361,11 @@ struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
unsigned int tfm_size;
int err = -ENOMEM;
+#ifdef CONFIG_CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);
tfm = kzalloc(tfm_size, GFP_KERNEL);
if (tfm == NULL)
@@ -417,6 +422,11 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
struct crypto_tfm *tfm;
int err;
+#ifdef CONFIG_CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
for (;;) {
struct crypto_alg *alg;
@@ -455,6 +465,13 @@ void *crypto_create_tfm(struct crypto_alg *alg,
unsigned int total;
int err = -ENOMEM;
+#ifdef CONFIG_CRYPTO_FIPS
+ if (unlikely(in_fips_err())) {
+ printk(KERN_ERR
+ "Fail crypto_create_tfm due to fips error state.\n");
+ return ERR_PTR(-EACCES);
+ }
+#endif
tfmsize = frontend->tfmsize;
total = tfmsize + sizeof(*tfm) + frontend->extsize(alg);
@@ -534,6 +551,11 @@ void *crypto_alloc_tfm(const char *alg_name,
void *tfm;
int err;
+#ifdef CONFIG_CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
for (;;) {
struct crypto_alg *alg;