All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <james.prestwood@linux.intel.com>
To: ell@lists.01.org
Subject: [PATCH v2 1/2] ecc: add l_ecc_curve_get_supported_groups
Date: Tue, 15 Jan 2019 14:23:38 -0800	[thread overview]
Message-ID: <20190115222339.9323-1-james.prestwood@linux.intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]

---
 ell/ecc.c   | 18 ++++++++++++++++++
 ell/ecc.h   |  1 +
 ell/ell.sym |  1 +
 3 files changed, 20 insertions(+)

diff --git a/ell/ecc.c b/ell/ecc.c
index 053e5fb..b2110df 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -90,6 +90,9 @@ static const struct l_ecc_curve *curves[] = {
 	&p384,
 };
 
+static unsigned int supported_groups[L_ARRAY_SIZE(curves) + 1];
+static bool first = true;
+
 LIB_EXPORT const struct l_ecc_curve *l_ecc_curve_get(unsigned int group)
 {
 	int i;
@@ -102,6 +105,21 @@ LIB_EXPORT const struct l_ecc_curve *l_ecc_curve_get(unsigned int group)
 	return NULL;
 }
 
+LIB_EXPORT const unsigned int *l_ecc_curve_get_supported_groups(void)
+{
+	if (first) {
+		unsigned int i;
+
+		for (i = 0; i < L_ARRAY_SIZE(curves); i++)
+			supported_groups[i] = curves[i]->group;
+
+		supported_groups[i] = 0;
+		first = false;
+	}
+
+	return supported_groups;
+}
+
 static bool ecc_valid_point(struct l_ecc_point *point)
 {
 	const struct l_ecc_curve *curve = point->curve;
diff --git a/ell/ecc.h b/ell/ecc.h
index 9a852ff..0c2b33c 100644
--- a/ell/ecc.h
+++ b/ell/ecc.h
@@ -43,6 +43,7 @@ enum l_ecc_point_type {
 };
 
 const struct l_ecc_curve *l_ecc_curve_get(unsigned int group);
+const unsigned int *l_ecc_curve_get_supported_groups(void);
 
 struct l_ecc_point *l_ecc_point_new(const struct l_ecc_curve *curve);
 struct l_ecc_point *l_ecc_point_from_data(const struct l_ecc_curve *curve,
diff --git a/ell/ell.sym b/ell/ell.sym
index 58b8c8e..4a806aa 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -458,6 +458,7 @@ global:
 	l_certchain_verify;
 	/* ecc */
 	l_ecc_curve_get;
+	l_ecc_curve_get_supported_groups;
 	l_ecc_curve_get_order;
 	l_ecc_curve_get_prime;
 	l_ecc_point_add;
-- 
2.17.1


             reply	other threads:[~2019-01-15 22:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 22:23 James Prestwood [this message]
2019-01-15 22:23 ` [PATCH v2 2/2] ecc: document where ECC groups came from James Prestwood
2019-01-15 22:43 [PATCH v2 1/2] ecc: add l_ecc_curve_get_supported_groups James Prestwood
2019-01-16 16:35 ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190115222339.9323-1-james.prestwood@linux.intel.com \
    --to=james.prestwood@linux.intel.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.