• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto3";
2
3package nugget.app.protoapi;
4
5enum KeySize {
6  KS_RESERVED = 0;
7  s128b = 16;
8  s192b = 24;
9  s256b = 32;
10}
11
12enum DcryptError {
13  DE_RESERVED = 0;
14  DE_NO_ERROR = 1;
15  INVALID_PLAINTEXT = 2;
16  MISSING_PARAMETER = 3;
17  KEYSIZE_MISMATCH = 4;
18  INVALID_TEST = 5;
19  KEYGEN_ERROR = 6;
20}
21
22// TODO remove this when oneof support is added to nanopb
23enum OneofTestParametersCase {
24  TPC_RESERVED = 0;
25  kTrngTest = 1;
26  kAesCbcEncryptTest = 2;
27  kAesGcmEncryptTest = 3;
28  kAesCmacTest = 4;
29  kFullStressTest = 5;
30  kAesCavpCbcTest = 6;
31  kAesCavpEcbTest = 7;
32  kAesCavpCtrTest = 8;
33  kAesCavpMctCbcTest = 9;
34  kAesCavpMctEcbTest = 10;
35  kAesCavpMctCtrTest = 11;
36  kCavpAesGcmTest = 12;
37  kCavpHmacTest = 13;
38  kCavpShaMsgTest = 14;
39  kCavpShaMctTest = 15;
40  kCavpRsaKeyGenTest = 16;
41  kCavpRsaSigGenTest = 17;
42  kCavpRsaSigVerTest = 18;
43  kCavpDrbgTest = 19;
44  kCavpCkdfTest = 20;
45  kCavpEcdsaKeyPairTest = 21;
46  kCavpEcdsaPkvTest = 22;
47  kCavpEcdsaSigGenTest = 23;
48  kCavpEcdsaSigVerTest = 24;
49  kCavpCmacGenTest = 25;
50}
51
52// TODO remove this when oneof support is added to nanopb
53enum OneofTestResultsCase {
54  ONEOF_NAME_NOT_SET = 0;
55  kTrngTestResult = 1;
56  kAesCbcEncryptTestResult = 2;
57  kAesGcmEncryptTestResult = 3;
58  kAesCmacTestResult = 4;
59  kFullStressResult = 5;
60  kAesCavpTestResult = 6;
61  kCavpAesGcmTestResult = 7;
62  kCavpHmacTestResult = 8;
63  kCavpShaTestResult = 9;
64  kCavpRsaKeyGenTestResult = 10;
65  kCavpRsaSigGenTestResult = 11;
66  kCavpRsaSigVerTestResult = 12;
67  kCavpDrbgTestResult = 13;
68  kCavpCkdfTestResult = 14;
69  kCavpEcdsaKeyPairTestResult = 15;
70  kCavpEcdsaPkvTestResult = 16;
71  kCavpEcdsaSigGenTestResult = 17;
72  kCavpEcdsaSigVerTestResult = 18;
73  kCavpCmacGenTestResult = 19;
74}
75
76message AesCbcEncryptTest {
77  KeySize key_size = 1;
78  uint32 number_of_blocks = 2;
79  bytes key = 3;
80  bytes initialization_vector = 4;
81  // TODO plain_text and number_of_blocks should be mutually exclusive.
82  // a oneof would be good for this but nanopb doesn't support dynamic lengths
83  // inside of a oneof.
84  bytes plain_text = 5;
85}
86
87message AesCbcEncryptTestResult {
88  DcryptError result_code = 1;
89  bytes initialization_vector = 2;
90  bytes cipher_text = 3;
91}
92
93message AesGcmEncryptTest {
94  bytes key = 1;
95  bytes iv = 2;
96  bytes plain_text = 3;
97  bytes aad = 4;
98  uint32 tag_len = 5;
99}
100
101message AesGcmEncryptTestResult {
102  DcryptError result_code = 1;
103  bytes cipher_text = 2;
104  bytes tag = 3;
105}
106
107enum CavpEncryptMode {
108  ENCRYPT = 0;
109  DECRYPT = 1;
110}
111
112message AesCavpTest {
113  uint32 count = 1;
114  uint32 key_size = 3;
115  CavpEncryptMode encrypt_mode = 4;
116  bytes key = 5;
117  bytes iv = 6;
118  bytes text = 7;
119}
120
121message AesCavpTestResult {
122  DcryptError result_code = 1;
123  bytes text = 2;
124}
125
126message CavpAesGcmTest {
127  uint32 count = 1;
128  uint32 key_len = 2;
129  uint32 tag_len = 3;
130  CavpEncryptMode encrypt_mode = 4;
131  bytes key = 5;
132  bytes iv = 6;
133  bytes text = 7;
134  bytes aad = 8;
135  bytes tag = 9;
136}
137
138message CavpAesGcmTestResult {
139  DcryptError result_code = 1;
140  bytes text = 2;
141  bytes tag = 3;
142  uint32 success = 4;
143}
144
145enum CavpShaAlgorithm {
146  INVALID = 0;
147  SHA1 = 1;
148  SHA256 = 2;
149}
150
151message CavpHmacTest {
152  uint32 key_len = 1;
153  uint32 text_len = 2;
154  CavpShaAlgorithm algo = 3;
155  bytes key = 4;
156  bytes msg = 5;
157}
158
159message CavpHmacTestResult {
160  DcryptError result_code = 1;
161  bytes mac = 2;
162}
163
164message CavpShaMsgTest {
165  CavpShaAlgorithm algo = 1;
166  uint32 total_len = 2;
167  uint32 offset = 3;
168  bytes msg = 4;
169}
170
171message CavpShaMctTest {
172  CavpShaAlgorithm algo = 1;
173  bytes seed = 2;
174}
175
176message CavpShaTestResult {
177  DcryptError result_code = 1;
178  bytes md = 2;
179}
180
181enum CavpRsaMRTable {
182  C_2 = 0;
183  C_3 = 1;
184}
185
186enum CavpRsaPaddingType {
187  INVALID_PADDING = 0;
188  PKCS1 = 1;
189  PSS = 2;
190  OAEP = 3;
191}
192
193message CavpRsaKeyGenTest {
194  uint32 count = 1;
195  uint32 mod = 2;
196  CavpRsaMRTable table = 3;
197}
198
199message CavpRsaSigGenTest {
200  bool gen_n = 1;
201  CavpShaAlgorithm sha_alg = 2;
202  CavpRsaPaddingType padding = 3;
203  bytes msg = 4;
204}
205
206message CavpRsaSigVerTest {
207  uint32 mod = 1;
208  CavpShaAlgorithm sha_alg = 2;
209  CavpRsaPaddingType padding = 3;
210  uint32 e = 4;
211  bytes n = 5;
212  bytes msg = 6;
213  bytes sig = 7;
214}
215
216enum CavpRsaSigVerResult {
217  Pass = 0;
218  Fail_MessageChanged = 1;
219  Fail_General = 2;
220  Fail_SigChanged = 3;
221  Fail_EMHashMovedLeft = 4;
222  Fail_EMModPayload = 5;
223}
224
225message CavpRsaSigVerTestResult {
226  DcryptError result_code = 1;
227  CavpRsaSigVerResult verif_result = 2;
228}
229
230message CavpRsaSigGenTestResult {
231  DcryptError result_code = 1;
232  uint32 e = 2;
233  bytes n = 3;
234  bytes sig = 4;
235}
236
237message CavpRsaKeyGenTestResult {
238  DcryptError result_code = 1;
239  uint32 e = 2;
240  bytes p = 3;
241  bytes q = 4;
242  bytes n = 5;
243  bytes d = 6;
244}
245
246message CavpDrbgTest {
247  bool prediction_resistance = 2;
248  uint32 ret_len = 3;
249  bytes entropy_init = 4;
250  bytes nonce = 5;
251  bytes perso_str = 6;
252  bytes add_input_1 = 7;
253  bytes add_input_2 = 8;
254  bytes entropy_pr_1 = 10;
255  bytes entropy_pr_2 = 11;
256}
257
258message CavpDrbgTestResult {
259  DcryptError result_code = 1;
260  bytes bits = 2;
261}
262
263message CavpCkdfTest {
264  uint32 key_len = 1;
265  bytes key = 2;
266}
267
268message CavpCkdfTestResult {
269  DcryptError result_code = 1;
270  bytes key = 2;
271  bytes fixed_input_data = 3;
272}
273
274enum CavpEcdsaKeyGenTable {
275  B_4_1 = 0;
276  B_4_2 = 1;
277}
278
279message CavpEcdsaKeyPairTest {
280  CavpEcdsaKeyGenTable table = 1;
281}
282
283message CavpEcdsaKeyPairTestResult {
284  DcryptError result_code = 1;
285  bytes d = 2;
286  bytes qx = 3;
287  bytes qy = 4;
288}
289
290message CavpEcdsaPkvTest {
291  bytes qx = 1;
292  bytes qy = 2;
293}
294
295message CavpEcdsaPkvTestResult {
296  DcryptError result_code = 1;
297  bool result = 2;
298}
299
300message CavpEcdsaSigGenTest {
301  bytes msg = 1;
302}
303
304message CavpEcdsaSigGenTestResult {
305  DcryptError result_code = 1;
306  bytes qx = 2;
307  bytes qy = 3;
308  bytes r = 4;
309  bytes sig = 5;
310}
311
312message CavpEcdsaSigVerTest {
313  bytes msg = 1;
314  bytes qx = 2;
315  bytes qy = 3;
316  bytes r = 4;
317  bytes sig = 5;
318}
319
320message CavpEcdsaSigVerTestResult {
321  DcryptError result_code = 1;
322  bool result = 2;
323}
324
325message CavpCmacGenTest {
326  uint32 offset = 1;
327  uint32 key_size = 2;
328  uint32 mac_len = 3;
329  uint32 total_len = 4;
330  bytes key = 5;
331  bytes msg = 6;
332}
333
334message CavpCmacGenTestResult {
335  DcryptError result_code = 1;
336  bytes mac = 2;
337}
338
339message TrngTest {
340  uint32 number_of_bytes = 1;
341}
342
343message AesCmacTest {
344  bytes key = 1;
345  bytes plain_text = 2;
346};
347
348message AesCmacTestResult {
349  DcryptError result_code = 1;
350  bytes cmac = 2;
351};
352
353message TrngTestResult {
354  bytes random_bytes = 1;
355}
356
357/*
358TODO look into adding callback support to oneof fields in nanopb
359message TestingAPICall {
360  oneof test_parameters {
361      AesCbcEncryptTest aes_cbc_encrypt_test = 1;
362  }
363}
364
365message TestingAPIResponse {
366  oneof test_results {
367    AesCbcEncryptTestResult aes_cbc_encrypt_result = 1;
368  }
369}
370*/
371