summaryrefslogtreecommitdiffstats
path: root/crypto/ecc.h
diff options
context:
space:
mode:
authorStefan Berger <stefanb@linux.ibm.com>2021-03-16 17:07:32 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2021-03-26 19:41:58 +1100
commit4e6602916bc692ee31ac5b8bd8195fb078556844 (patch)
tree94f5e1d9f2819521eac2590b3dc95490e13e3437 /crypto/ecc.h
parent7547738d28dd572d40e0e1c1f854c80e3cb41bec (diff)
downloadlinux-stable-4e6602916bc692ee31ac5b8bd8195fb078556844.tar.gz
linux-stable-4e6602916bc692ee31ac5b8bd8195fb078556844.tar.bz2
linux-stable-4e6602916bc692ee31ac5b8bd8195fb078556844.zip
crypto: ecdsa - Add support for ECDSA signature verification
Add support for parsing the parameters of a NIST P256 or NIST P192 key. Enable signature verification using these keys. The new module is enabled with CONFIG_ECDSA: Elliptic Curve Digital Signature Algorithm (NIST P192, P256 etc.) is A NIST cryptographic standard algorithm. Only signature verification is implemented. Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: "David S. Miller" <davem@davemloft.net> Cc: linux-crypto@vger.kernel.org Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ecc.h')
-rw-r--r--crypto/ecc.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/crypto/ecc.h b/crypto/ecc.h
index d4e546b9ad79..e0e2aed0557a 100644
--- a/crypto/ecc.h
+++ b/crypto/ecc.h
@@ -33,6 +33,8 @@
#define ECC_DIGITS_TO_BYTES_SHIFT 3
+#define ECC_MAX_BYTES (ECC_MAX_DIGITS << ECC_DIGITS_TO_BYTES_SHIFT)
+
/**
* struct ecc_point - elliptic curve point in affine coordinates
*
@@ -71,6 +73,29 @@ struct ecc_curve {
};
/**
+ * ecc_swap_digits() - Copy ndigits from big endian array to native array
+ * @in: Input array
+ * @out: Output array
+ * @ndigits: Number of digits to copy
+ */
+static inline void ecc_swap_digits(const u64 *in, u64 *out, unsigned int ndigits)
+{
+ const __be64 *src = (__force __be64 *)in;
+ int i;
+
+ for (i = 0; i < ndigits; i++)
+ out[i] = be64_to_cpu(src[ndigits - 1 - i]);
+}
+
+/**
+ * ecc_get_curve() - Get a curve given its curve_id
+ * @curve_id: Id of the curve
+ *
+ * Returns pointer to the curve data, NULL if curve is not available
+ */
+const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
+
+/**
* ecc_is_key_valid() - Validate a given ECDH private key
*
* @curve_id: id representing the curve to use