summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/curve25519/ed25519test.c
diff options
context:
space:
mode:
authortb <>2022-11-17 21:19:43 +0000
committertb <>2022-11-17 21:19:43 +0000
commit8b720dd63cbcd96e2cdcb4e5b13fe54c45e3ccde (patch)
tree47222bb8678923e2bbfc08f06cac0f21c9394260 /src/regress/lib/libcrypto/curve25519/ed25519test.c
parent0504f59283ccc7094091b7208ebf93447dac3e17 (diff)
downloadopenbsd-8b720dd63cbcd96e2cdcb4e5b13fe54c45e3ccde.tar.gz
openbsd-8b720dd63cbcd96e2cdcb4e5b13fe54c45e3ccde.tar.bz2
openbsd-8b720dd63cbcd96e2cdcb4e5b13fe54c45e3ccde.zip
Use a fixed-size array for the message and simplify a few other curly
things.
Diffstat (limited to 'src/regress/lib/libcrypto/curve25519/ed25519test.c')
-rw-r--r--src/regress/lib/libcrypto/curve25519/ed25519test.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/regress/lib/libcrypto/curve25519/ed25519test.c b/src/regress/lib/libcrypto/curve25519/ed25519test.c
index 9053ef0a83..4239997837 100644
--- a/src/regress/lib/libcrypto/curve25519/ed25519test.c
+++ b/src/regress/lib/libcrypto/curve25519/ed25519test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ed25519test.c,v 1.4 2022/11/17 19:06:35 tb Exp $ */ 1/* $OpenBSD: ed25519test.c,v 1.5 2022/11/17 21:19:43 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2019, 2022 Theo Buehler <tb@openbsd.org> 3 * Copyright (c) 2019, 2022 Theo Buehler <tb@openbsd.org>
4 * 4 *
@@ -26,8 +26,8 @@ struct testvector {
26 const uint8_t sec_key[ED25519_PRIVATE_KEY_LENGTH]; 26 const uint8_t sec_key[ED25519_PRIVATE_KEY_LENGTH];
27 const uint8_t pub_key[ED25519_PUBLIC_KEY_LENGTH]; 27 const uint8_t pub_key[ED25519_PUBLIC_KEY_LENGTH];
28 const uint8_t signature[ED25519_SIGNATURE_LENGTH]; 28 const uint8_t signature[ED25519_SIGNATURE_LENGTH];
29 const uint8_t message[1024];
29 size_t message_len; 30 size_t message_len;
30 const uint8_t *message;
31}; 31};
32 32
33/* 33/*
@@ -48,8 +48,9 @@ struct testvector testvectors[] = {
48 0x0e, 0xe1, 0x72, 0xf3, 0xda, 0xa6, 0x23, 0x25, 48 0x0e, 0xe1, 0x72, 0xf3, 0xda, 0xa6, 0x23, 0x25,
49 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07, 0x51, 0x1a, 49 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07, 0x51, 0x1a,
50 }, 50 },
51 .message = {
52 },
51 .message_len = 0, 53 .message_len = 0,
52 .message = (uint8_t []){ },
53 .signature = { 54 .signature = {
54 0xe5, 0x56, 0x43, 0x00, 0xc3, 0x60, 0xac, 0x72, 55 0xe5, 0x56, 0x43, 0x00, 0xc3, 0x60, 0xac, 0x72,
55 0x90, 0x86, 0xe2, 0xcc, 0x80, 0x6e, 0x82, 0x8a, 56 0x90, 0x86, 0xe2, 0xcc, 0x80, 0x6e, 0x82, 0x8a,
@@ -74,8 +75,10 @@ struct testvector testvectors[] = {
74 0x9c, 0x98, 0x2c, 0xcf, 0x2e, 0xc4, 0x96, 0x8c, 75 0x9c, 0x98, 0x2c, 0xcf, 0x2e, 0xc4, 0x96, 0x8c,
75 0xc0, 0xcd, 0x55, 0xf1, 0x2a, 0xf4, 0x66, 0x0c, 76 0xc0, 0xcd, 0x55, 0xf1, 0x2a, 0xf4, 0x66, 0x0c,
76 }, 77 },
78 .message = {
79 0x72,
80 },
77 .message_len = 1, 81 .message_len = 1,
78 .message = (uint8_t []){ 0x72 },
79 .signature = { 82 .signature = {
80 0x92, 0xa0, 0x09, 0xa9, 0xf0, 0xd4, 0xca, 0xb8, 83 0x92, 0xa0, 0x09, 0xa9, 0xf0, 0xd4, 0xca, 0xb8,
81 0x72, 0x0e, 0x82, 0x0b, 0x5f, 0x64, 0x25, 0x40, 84 0x72, 0x0e, 0x82, 0x0b, 0x5f, 0x64, 0x25, 0x40,
@@ -100,8 +103,10 @@ struct testvector testvectors[] = {
100 0x08, 0x16, 0xed, 0x13, 0xba, 0x33, 0x03, 0xac, 103 0x08, 0x16, 0xed, 0x13, 0xba, 0x33, 0x03, 0xac,
101 0x5d, 0xeb, 0x91, 0x15, 0x48, 0x90, 0x80, 0x25, 104 0x5d, 0xeb, 0x91, 0x15, 0x48, 0x90, 0x80, 0x25,
102 }, 105 },
106 .message = {
107 0xaf, 0x82,
108 },
103 .message_len = 2, 109 .message_len = 2,
104 .message = (uint8_t []){ 0xaf, 0x82, },
105 .signature = { 110 .signature = {
106 0x62, 0x91, 0xd6, 0x57, 0xde, 0xec, 0x24, 0x02, 111 0x62, 0x91, 0xd6, 0x57, 0xde, 0xec, 0x24, 0x02,
107 0x48, 0x27, 0xe6, 0x9c, 0x3a, 0xbe, 0x01, 0xa3, 112 0x48, 0x27, 0xe6, 0x9c, 0x3a, 0xbe, 0x01, 0xa3,
@@ -126,8 +131,7 @@ struct testvector testvectors[] = {
126 0xce, 0xff, 0xbf, 0x2b, 0x24, 0x28, 0xc9, 0xc5, 131 0xce, 0xff, 0xbf, 0x2b, 0x24, 0x28, 0xc9, 0xc5,
127 0x1f, 0xef, 0x7c, 0x59, 0x7f, 0x1d, 0x42, 0x6e, 132 0x1f, 0xef, 0x7c, 0x59, 0x7f, 0x1d, 0x42, 0x6e,
128 }, 133 },
129 .message_len = 1023, 134 .message = {
130 .message = (uint8_t []){
131 0x08, 0xb8, 0xb2, 0xb7, 0x33, 0x42, 0x42, 0x43, 135 0x08, 0xb8, 0xb2, 0xb7, 0x33, 0x42, 0x42, 0x43,
132 0x76, 0x0f, 0xe4, 0x26, 0xa4, 0xb5, 0x49, 0x08, 136 0x76, 0x0f, 0xe4, 0x26, 0xa4, 0xb5, 0x49, 0x08,
133 0x63, 0x21, 0x10, 0xa6, 0x6c, 0x2f, 0x65, 0x91, 137 0x63, 0x21, 0x10, 0xa6, 0x6c, 0x2f, 0x65, 0x91,
@@ -257,6 +261,7 @@ struct testvector testvectors[] = {
257 0xc6, 0x0c, 0x90, 0x5c, 0x15, 0xfc, 0x91, 0x08, 261 0xc6, 0x0c, 0x90, 0x5c, 0x15, 0xfc, 0x91, 0x08,
258 0x40, 0xb9, 0x4c, 0x00, 0xa0, 0xb9, 0xd0, 262 0x40, 0xb9, 0x4c, 0x00, 0xa0, 0xb9, 0xd0,
259 }, 263 },
264 .message_len = 1023,
260 .signature = { 265 .signature = {
261 0x0a, 0xab, 0x4c, 0x90, 0x05, 0x01, 0xb3, 0xe2, 266 0x0a, 0xab, 0x4c, 0x90, 0x05, 0x01, 0xb3, 0xe2,
262 0x4d, 0x7c, 0xdf, 0x46, 0x63, 0x32, 0x6a, 0x3a, 267 0x4d, 0x7c, 0xdf, 0x46, 0x63, 0x32, 0x6a, 0x3a,
@@ -281,8 +286,7 @@ struct testvector testvectors[] = {
281 0xc3, 0x54, 0x67, 0xef, 0x2e, 0xfd, 0x4d, 0x64, 286 0xc3, 0x54, 0x67, 0xef, 0x2e, 0xfd, 0x4d, 0x64,
282 0xeb, 0xf8, 0x19, 0x68, 0x34, 0x67, 0xe2, 0xbf, 287 0xeb, 0xf8, 0x19, 0x68, 0x34, 0x67, 0xe2, 0xbf,
283 }, 288 },
284 .message_len = 64, 289 .message = {
285 .message = (uint8_t []){
286 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, 290 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba,
287 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, 291 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31,
288 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, 292 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2,
@@ -292,6 +296,7 @@ struct testvector testvectors[] = {
292 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, 296 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e,
293 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f, 297 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f,
294 }, 298 },
299 .message_len = 64,
295 .signature = { 300 .signature = {
296 0xdc, 0x2a, 0x44, 0x59, 0xe7, 0x36, 0x96, 0x33, 301 0xdc, 0x2a, 0x44, 0x59, 0xe7, 0x36, 0x96, 0x33,
297 0xa5, 0x2b, 0x1b, 0xf2, 0x77, 0x83, 0x9a, 0x00, 302 0xa5, 0x2b, 0x1b, 0xf2, 0x77, 0x83, 0x9a, 0x00,
@@ -307,10 +312,7 @@ struct testvector testvectors[] = {
307 312
308const size_t num_testvectors = sizeof(testvectors) / sizeof(testvectors[0]); 313const size_t num_testvectors = sizeof(testvectors) / sizeof(testvectors[0]);
309 314
310int test_ED25519_verify(void); 315static int
311int test_ED25519_sign(void);
312
313int
314test_ED25519_verify(void) 316test_ED25519_verify(void)
315{ 317{
316 size_t i; 318 size_t i;
@@ -329,7 +331,7 @@ test_ED25519_verify(void)
329 return failed; 331 return failed;
330} 332}
331 333
332int 334static int
333test_ED25519_sign(void) 335test_ED25519_sign(void)
334{ 336{
335 size_t i; 337 size_t i;