summaryrefslogtreecommitdiffstats
path: root/crypto/ecc.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2021-03-26 09:55:55 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2021-03-26 09:55:55 +0100
commit3877869d13a043a2dbab0d034e5eac3b21f4994d (patch)
tree187ed20226bc810997d968365cc25dbb683c0977 /crypto/ecc.h
parenthwrng: cctrng - delete redundant printing of return value (diff)
parentx509: Add OID for NIST P384 and extend parser for it (diff)
downloadlinux-3877869d13a043a2dbab0d034e5eac3b21f4994d.tar.xz
linux-3877869d13a043a2dbab0d034e5eac3b21f4994d.zip
Merge branch 'ecc'
This pulls in the NIST P384/256/192 x509 changes.
Diffstat (limited to 'crypto/ecc.h')
-rw-r--r--crypto/ecc.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/crypto/ecc.h b/crypto/ecc.h
index 38a81d404821..46aa9bc03ddc 100644
--- a/crypto/ecc.h
+++ b/crypto/ecc.h
@@ -31,13 +31,39 @@
/* One digit is u64 qword. */
#define ECC_CURVE_NIST_P192_DIGITS 3
#define ECC_CURVE_NIST_P256_DIGITS 4
-#define ECC_MAX_DIGITS (512 / 64)
+#define ECC_CURVE_NIST_P384_DIGITS 6
+#define ECC_MAX_DIGITS (512 / 64) /* due to ecrdsa */
#define ECC_DIGITS_TO_BYTES_SHIFT 3
+#define ECC_MAX_BYTES (ECC_MAX_DIGITS << ECC_DIGITS_TO_BYTES_SHIFT)
+
#define ECC_POINT_INIT(x, y, ndigits) (struct ecc_point) { x, y, ndigits }
/**
+ * 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