* [PATCH BlueZ 0/1] ECC Cleanup
@ 2018-05-07 22:35 Brian Gix
2018-05-07 22:35 ` [PATCH BlueZ 0/1] shared/ecc: Make ecc_make_key() a stand alone API Brian Gix
2018-05-30 7:23 ` [PATCH BlueZ 0/1] ECC Cleanup Luiz Augusto von Dentz
0 siblings, 2 replies; 3+ messages in thread
From: Brian Gix @ 2018-05-07 22:35 UTC (permalink / raw)
To: Luiz Augusto von Dentz, Marcel Holtmann, linux-bluetooth; +Cc: Brian Gix
Revert ecc_make_key to original implementation, and cleanup API
Brian Gix (1):
shared/ecc: Make ecc_make_key() a stand alone API
src/shared/ecc.c | 25 +++++++++++++++++--------
src/shared/ecc.h | 4 +++-
2 files changed, 20 insertions(+), 9 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH BlueZ 0/1] shared/ecc: Make ecc_make_key() a stand alone API
2018-05-07 22:35 [PATCH BlueZ 0/1] ECC Cleanup Brian Gix
@ 2018-05-07 22:35 ` Brian Gix
2018-05-30 7:23 ` [PATCH BlueZ 0/1] ECC Cleanup Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Brian Gix @ 2018-05-07 22:35 UTC (permalink / raw)
To: Luiz Augusto von Dentz, Marcel Holtmann, linux-bluetooth; +Cc: Brian Gix
And correct minor flaws in API descriptions
---
src/shared/ecc.c | 25 +++++++++++++++++--------
src/shared/ecc.h | 4 +++-
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/shared/ecc.c b/src/shared/ecc.c
index 15f6b8a93..1c1c3446a 100644
--- a/src/shared/ecc.c
+++ b/src/shared/ecc.c
@@ -883,20 +883,29 @@ bool ecc_make_public_key(const uint8_t private_key[32], uint8_t public_key[64])
bool ecc_make_key(uint8_t public_key[64], uint8_t private_key[32])
{
+ struct ecc_point pk;
uint64_t priv[NUM_ECC_DIGITS];
- unsigned int tries = 0;
- bool result = false;
+ unsigned tries = 0;
+
+ do {
+ if (!get_random_number(priv) || (tries++ >= MAX_TRIES))
+ return false;
- for (tries = 0; !result && tries < MAX_TRIES; tries++) {
- if (!get_random_number(priv))
+ if (vli_is_zero(priv))
continue;
- ecc_native2bytes(priv, private_key);
+ /* Make sure the private key is in the range [1, n-1]. */
+ if (vli_cmp(curve_n, priv) != 1)
+ continue;
- result = ecc_make_public_key(private_key, public_key);
- }
+ ecc_point_mult(&pk, &curve_g, priv, NULL, vli_num_bits(priv));
+ } while (ecc_point_is_zero(&pk));
- return result;
+ ecc_native2bytes(priv, private_key);
+ ecc_native2bytes(pk.x, public_key);
+ ecc_native2bytes(pk.y, &public_key[32]);
+
+ return true;
}
bool ecc_valid_public_key(const uint8_t public_key[64])
diff --git a/src/shared/ecc.h b/src/shared/ecc.h
index a88e735c7..8c15e4ee8 100644
--- a/src/shared/ecc.h
+++ b/src/shared/ecc.h
@@ -28,9 +28,11 @@
#include <stdint.h>
/* Create a public key from a private key.
+ *
+ * Inputs:
+ * private_key - Your private key.
*
* Outputs:
- * private_key - Const private key
* public_key - Will be filled in with the public key.
*
* Returns true if the public key was generated successfully, false
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ 0/1] ECC Cleanup
2018-05-07 22:35 [PATCH BlueZ 0/1] ECC Cleanup Brian Gix
2018-05-07 22:35 ` [PATCH BlueZ 0/1] shared/ecc: Make ecc_make_key() a stand alone API Brian Gix
@ 2018-05-30 7:23 ` Luiz Augusto von Dentz
1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-05-30 7:23 UTC (permalink / raw)
To: Brian Gix; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
Hi Brian,
On Tue, May 8, 2018 at 1:35 AM, Brian Gix <brian.gix@intel.com> wrote:
> Revert ecc_make_key to original implementation, and cleanup API
>
> Brian Gix (1):
> shared/ecc: Make ecc_make_key() a stand alone API
>
> src/shared/ecc.c | 25 +++++++++++++++++--------
> src/shared/ecc.h | 4 +++-
> 2 files changed, 20 insertions(+), 9 deletions(-)
>
> --
> 2.14.3
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-30 7:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-07 22:35 [PATCH BlueZ 0/1] ECC Cleanup Brian Gix
2018-05-07 22:35 ` [PATCH BlueZ 0/1] shared/ecc: Make ecc_make_key() a stand alone API Brian Gix
2018-05-30 7:23 ` [PATCH BlueZ 0/1] ECC Cleanup Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).