All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] unit: test-ecdh: add bytes to l_getrandom wrapper
  2019-01-11 17:38 [PATCH] unit: test-ecdh: add bytes to l_getrandom wrapper James Prestwood
@ 2019-01-11 17:37 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2019-01-11 17:37 UTC (permalink / raw)
  To: ell

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

Hi James,

On 01/11/2019 11:38 AM, James Prestwood wrote:
> This should have been put into the commit adding the P384 unit test.
> Since P384 works with 48 byte integers we need 48 bytes of randomness
> in the l_getrandom wrapper. A check was also added so l_getrandom will
> fail if too many bytes are requested (e.g. if a larger curve is added).
> ---
>   unit/test-ecdh.c | 20 +++++++++++++-------
>   1 file changed, 13 insertions(+), 7 deletions(-)
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] unit: test-ecdh: add bytes to l_getrandom wrapper
@ 2019-01-11 17:38 James Prestwood
  2019-01-11 17:37 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2019-01-11 17:38 UTC (permalink / raw)
  To: ell

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

This should have been put into the commit adding the P384 unit test.
Since P384 works with 48 byte integers we need 48 bytes of randomness
in the l_getrandom wrapper. A check was also added so l_getrandom will
fail if too many bytes are requested (e.g. if a larger curve is added).
---
 unit/test-ecdh.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/unit/test-ecdh.c b/unit/test-ecdh.c
index cc0f3a8..68b8d37 100644
--- a/unit/test-ecdh.c
+++ b/unit/test-ecdh.c
@@ -37,17 +37,23 @@ bool __real_l_getrandom(void *buf, size_t len);
 
 bool __wrap_l_getrandom(void *buf, size_t len)
 {
-	static const uint8_t random_buf[] = { 0x75, 0xc5, 0xfe, 0x3e, 0x53,
-						0xcc, 0x33, 0x33, 0x64, 0xea,
-						0xdd, 0xa1, 0xe6, 0x62, 0x7a,
-						0xb1, 0x98, 0xa7, 0xa0, 0x1e,
-						0xac, 0x4b, 0x1d, 0xb8, 0x71,
-						0x5b, 0x1d, 0x00, 0x36, 0xd0,
-						0x0f, 0xde };
+	static const uint8_t random_buf[] = { 0xba, 0xaf, 0x6d, 0x97, 0x71,
+						0xe5, 0xda, 0xc9, 0x89, 0x6e,
+						0x58, 0x18, 0x92, 0xf8, 0x55,
+						0x4f, 0x29, 0xf0, 0xbd, 0x10,
+						0xaf, 0x0e, 0x38, 0xb5, 0xe6,
+						0x44, 0x56, 0x9d, 0x99, 0x2a,
+						0x7f, 0xe2, 0x8d, 0x46, 0xb0,
+						0x73, 0xcd, 0xd3, 0x6a, 0x7b,
+						0xa6, 0xd3, 0xde, 0xbf, 0x38,
+						0x96, 0xb7, 0xc3 };
 
 	if (use_real_getrandom)
 		return __real_l_getrandom(buf, len);
 
+	if (len > sizeof(random_buf))
+		return false;
+
 	memcpy(buf, random_buf, len);
 
 	return true;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-11 17:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 17:38 [PATCH] unit: test-ecdh: add bytes to l_getrandom wrapper James Prestwood
2019-01-11 17:37 ` Denis Kenzior

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.