xref: /freebsd/crypto/libecc/src/wycheproof_tests/libecc_wycheproof.h (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
1 /*
2  *  Copyright (C) 2021 - This file is part of libecc project
3  *
4  *  Authors:
5  *      Ryad BENADJILA <ryadbenadjila@gmail.com>
6  *      Arnaud EBALARD <arnaud.ebalard@ssi.gouv.fr>
7  *
8  *  This software is licensed under a dual BSD and GPL v2 license.
9  *  See LICENSE file at the root folder of the project.
10  */
11 
12 /*
13  * Source code for handling tests imported from the wycheproof project:
14  *     https://github.com/google/wycheproof
15  *
16  * As this project primarily targets java cryptographic libraries, the
17  * json test files have been parsed to generate libecc friendly test cases.
18  *
19  * NOTE: we skip here all the tests related to ASN.1 format errors as libecc
20  * does not handle ASN.1 parsing at all. This explains the "skipped" tests from
21  * the wycheproof project.
22  *
23  */
24 
25 #include <libecc/libsig.h>
26 
27 typedef struct {
28 	/* Test case name */
29 	const char *name;
30 
31 	ec_alg_type sig_alg;
32 
33 	hash_alg_type hash;
34 
35 	/* Curve params */
36 	const ec_str_params *curve;
37 
38 	const unsigned char *pubkey;
39 	unsigned int pubkeylen;
40 
41 	const unsigned char *msg;
42 	unsigned int msglen;
43 
44 	const unsigned char *sig;
45 	unsigned int siglen;
46 
47 	int result;
48 
49 	const char *comment;
50 } wycheproof_ecdsa_test;
51 
52 typedef struct {
53 	/* Test case name */
54 	const char *name;
55 
56 	ec_alg_type sig_alg;
57 
58 	hash_alg_type hash;
59 
60 	/* Curve params */
61 	const ec_str_params *curve;
62 
63 	const unsigned char *pubkey;
64 	unsigned int pubkeylen;
65 
66 	const unsigned char *privkey;
67 	unsigned int privkeylen;
68 
69 	const unsigned char *msg;
70 	unsigned int msglen;
71 
72 	const unsigned char *sig;
73 	unsigned int siglen;
74 
75 	int result;
76 
77 	const char *comment;
78 } wycheproof_eddsa_test;
79 
80 typedef struct {
81 	/* Test case name */
82 	const char *name;
83 
84 	ec_alg_type xdh_alg;
85 
86 	/* Curve params */
87 	const ec_str_params *curve;
88 
89 	const unsigned char *peerpubkey;
90 	unsigned int peerpubkeylen;
91 
92 	const unsigned char *ourpubkey;
93 	unsigned int ourpubkeylen;
94 
95 	const unsigned char *privkey;
96 	unsigned int privkeylen;
97 
98 	const unsigned char *sharedsecret;
99 	unsigned int sharedsecretlen;
100 
101 	int result;
102 
103 	const char *comment;
104 } wycheproof_xdh_test;
105 
106 typedef struct {
107 	/* Test case name */
108 	const char *name;
109 
110 	ec_alg_type ecdh_alg;
111 
112 	/* Curve params */
113 	const ec_str_params *curve;
114 
115 	const unsigned char *peerpubkey;
116 	unsigned int peerpubkeylen;
117 	int compressed;
118 
119 	const unsigned char *ourpubkey;
120 	unsigned int ourpubkeylen;
121 
122 	const unsigned char *privkey;
123 	unsigned int privkeylen;
124 
125 	const unsigned char *sharedsecret;
126 	unsigned int sharedsecretlen;
127 
128 	int result;
129 
130 	const char *comment;
131 } wycheproof_ecdh_test;
132 
133 typedef struct {
134 	/* Test case name */
135 	const char *name;
136 
137 	hash_alg_type hash;
138 
139 	const unsigned char *key;
140 	unsigned int keylen;
141 
142 	const unsigned char *msg;
143 	unsigned int msglen;
144 
145 	const unsigned char *tag;
146 	unsigned int taglen;
147 
148 	int result;
149 
150 	const char *comment;
151 } wycheproof_hmac_test;
152