unit: test-ecdh: add bytes to l_getrandom wrapper
Denis Kenzior
AppliedHi James,
Quoted 8 lines · James Prestwood
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_getrandomwrapper. A check was also added sol_getrandomwill 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
PATCH 1/1 unit: test-ecdh: add bytes to l_getrandom wrapper
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(-)
unit/test-ecdh.c +13 -7
@@ -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;
Signature · 1 line
2.17.1