summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorYashpal Dutta <yashpal.dutta@freescale.com>2012-12-10 23:32:13 (GMT)
committerRivera Jose-B46482 <German.Rivera@freescale.com>2013-10-09 20:10:20 (GMT)
commitae361bb7fb946a230c366d4f257fe8476dec01ad (patch)
tree144d61fefbf3f0046403573e03bb6aee304db156 /crypto
parentdfd7db444fa8588e37a1ceda7bd291f65ea53109 (diff)
downloadlinux-fsl-qoriq-ae361bb7fb946a230c366d4f257fe8476dec01ad.tar.xz
Support for Public Key Cryptography in CryptoAPI
Public Key Cryptography added in Linux CryptoAPI. CryptoAPI till now only supports symmetric ciphers and Digests. With support for asymmetric ciphers, any cryptographic accelerator driver will be able to registers its asymmetric cipher primitive functions Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> Change-Id: I9af49fb2c40cec0f5ecb73da15b6e738ed3987b6 Reviewed-on: http://git.am.freescale.net:8181/5447 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Rivera Jose-B46482 <German.Rivera@freescale.com>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/Makefile2
-rw-r--r--crypto/pkc.c67
2 files changed, 68 insertions, 1 deletions
diff --git a/crypto/Makefile b/crypto/Makefile
index d59dec7..5ce7975 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o
obj-$(CONFIG_CRYPTO_AEAD2) += aead.o
-crypto_blkcipher-y := ablkcipher.o
+crypto_blkcipher-y := ablkcipher.o pkc.o
crypto_blkcipher-y += blkcipher.o
obj-$(CONFIG_CRYPTO_BLKCIPHER2) += crypto_blkcipher.o
obj-$(CONFIG_CRYPTO_BLKCIPHER2) += chainiv.o
diff --git a/crypto/pkc.c b/crypto/pkc.c
new file mode 100644
index 0000000..ada7eaf
--- /dev/null
+++ b/crypto/pkc.c
@@ -0,0 +1,67 @@
+/*
+ * \file: pkc.c
+ * \brief: Public Key Cipher operations.
+ *
+ * This is the Public Key Cipher Implementation
+ *
+ * Author: Yashpal Dutta <yashpal.dutta@freescale.com>
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ */
+
+#include <linux/cpumask.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rtnetlink.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/seq_file.h>
+#include <crypto/scatterwalk.h>
+#include "internal.h"
+
+static unsigned int crypto_pkc_ctxsize(struct crypto_alg *alg, u32 type,
+ u32 mask)
+{
+ return alg->cra_ctxsize;
+}
+
+static int crypto_init_pkc_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
+{
+ struct pkc_alg *alg = &tfm->__crt_alg->cra_pkc;
+ struct pkc_tfm *crt = &tfm->crt_pkc;
+
+ crt->pkc_op = alg->pkc_op;
+ crt->min_keysize = alg->min_keysize;
+ crt->max_keysize = alg->max_keysize;
+ crt->base = tfm;
+
+ return 0;
+}
+
+static void crypto_pkc_show(struct seq_file *m, struct crypto_alg *alg)
+{
+ struct pkc_alg *pkc_alg = &alg->cra_pkc;
+
+ seq_printf(m, "type : pkc_cipher\n");
+ seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ?
+ "yes" : "no");
+ seq_printf(m, "min keysize : %u\n", pkc_alg->min_keysize);
+ seq_printf(m, "max keysize : %u\n", pkc_alg->max_keysize);
+}
+
+const struct crypto_type crypto_pkc_type = {
+ .ctxsize = crypto_pkc_ctxsize,
+ .init = crypto_init_pkc_ops,
+#ifdef CONFIG_PROC_FS
+ .show = crypto_pkc_show,
+#endif
+};
+EXPORT_SYMBOL_GPL(crypto_pkc_type);