aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/algapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r--crypto/algapi.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index c3cf1a6..3fa383c 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -61,6 +61,15 @@ static inline int crypto_set_driver_name(struct crypto_alg *alg)
static int crypto_check_alg(struct crypto_alg *alg)
{
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err())) {
+ printk(KERN_ERR
+ "crypto_check_alg failed due to FIPS error: %s",
+ alg->cra_name);
+ return -EACCES;
+ }
+#endif
+
if (alg->cra_alignmask & (alg->cra_alignmask + 1))
return -EINVAL;
@@ -355,6 +364,15 @@ int crypto_register_alg(struct crypto_alg *alg)
struct crypto_larval *larval;
int err;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err())) {
+ printk(KERN_ERR
+ "Unable to registrer alg: %s because of FIPS ERROR\n"
+ , alg->cra_name);
+ return -EACCES;
+ }
+#endif
+
err = crypto_check_alg(alg);
if (err)
return err;
@@ -411,6 +429,11 @@ int crypto_register_template(struct crypto_template *tmpl)
struct crypto_template *q;
int err = -EEXIST;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return -EACCES;
+#endif
+
down_write(&crypto_alg_sem);
list_for_each_entry(q, &crypto_template_list, list) {
@@ -478,6 +501,13 @@ static struct crypto_template *__crypto_lookup_template(const char *name)
struct crypto_template *crypto_lookup_template(const char *name)
{
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err())) {
+ printk(KERN_ERR
+ "crypto_lookup failed due to FIPS error: %s", name);
+ return -EACCES;
+ }
+#endif
return try_then_request_module(__crypto_lookup_template(name), name);
}
EXPORT_SYMBOL_GPL(crypto_lookup_template);
@@ -488,6 +518,11 @@ int crypto_register_instance(struct crypto_template *tmpl,
struct crypto_larval *larval;
int err;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return -EACCES;
+#endif
+
err = crypto_check_alg(&inst->alg);
if (err)
goto err;
@@ -523,6 +558,11 @@ int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
{
int err = -EAGAIN;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return -EACCES;
+#endif
+
spawn->inst = inst;
spawn->mask = mask;
@@ -738,6 +778,11 @@ void *crypto_alloc_instance2(const char *name, struct crypto_alg *alg,
char *p;
int err;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
p = kzalloc(head + sizeof(*inst) + sizeof(struct crypto_spawn),
GFP_KERNEL);
if (!p)
@@ -769,6 +814,11 @@ struct crypto_instance *crypto_alloc_instance(const char *name,
struct crypto_spawn *spawn;
int err;
+ #ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
inst = crypto_alloc_instance2(name, alg, 0);
if (IS_ERR(inst))
goto out;
@@ -805,6 +855,11 @@ int crypto_enqueue_request(struct crypto_queue *queue,
{
int err = -EINPROGRESS;
+#ifdef CRYPTO_FIPS
+ if (unlikely(in_fips_err()))
+ return ERR_PTR(-EACCES);
+#endif
+
if (unlikely(queue->qlen >= queue->max_qlen)) {
err = -EBUSY;
if (!(request->flags & CRYPTO_TFM_REQ_MAY_BACKLOG))
@@ -909,13 +964,13 @@ EXPORT_SYMBOL_GPL(crypto_xor);
static int __init crypto_algapi_init(void)
{
- crypto_init_proc();
+ /*crypto_init_proc(); //Moved to testmgr*/
return 0;
}
static void __exit crypto_algapi_exit(void)
{
- crypto_exit_proc();
+ /*crypto_exit_proc(); //Moved to testmgr*/
}
module_init(crypto_algapi_init);