@@ -337,11 +337,28 @@ static int rsa_keygen_helper(const struct json_array *processdata,
337
337
int (* callback )(struct rsa_keygen_data * vector , flags_t parsed_flags ),
338
338
struct rsa_keygen_data * vector )
339
339
{
340
-
341
340
int ret = 0 ;
341
+ const char * bitlens_name = "bitlens" ;
342
+ struct json_object * json_nobj ;
343
+ unsigned int i ;
342
344
343
- (void )testvector ;
345
+ if (!json_find_key (testvector , bitlens_name , & json_nobj , json_type_array )) {
346
+ if (!json_nobj ) {
347
+ logger (LOGGER_ERR ,
348
+ "Parsing of entry %s with expected array failed\n" , bitlens_name );
349
+ return - EINVAL ;
350
+ }
351
+ vector -> bitlen_in = (unsigned int )json_object_array_length (json_nobj );
352
+ for (i = 0 ; i < vector -> bitlen_in ; i ++ ) {
353
+ struct json_object * testvector =
354
+ json_object_array_get_idx (json_nobj , i );
344
355
356
+ CKNULL_LOG (testvector , - EINVAL , "No vector\n" );
357
+ vector -> bitlen [i ] = json_object_get_int (testvector );
358
+ }
359
+ } else {
360
+ vector -> bitlen_in = 0 ;
361
+ }
345
362
CKINT (callback (vector , parsed_flags ));
346
363
347
364
if (parsed_flags & FLAG_OP_RSA_PQ_B36_PRIMES ) {
@@ -364,7 +381,7 @@ static int rsa_keygen_helper(const struct json_array *processdata,
364
381
bitlenarray = json_object_new_array ();
365
382
CKNULL (bitlenarray , - ENOMEM );
366
383
/* Append the output JSON stream with test results. */
367
- json_object_object_add (testresult , "bitlens" , bitlenarray );
384
+ json_object_object_add (testresult , bitlens_name , bitlenarray );
368
385
json_object_array_add (bitlenarray ,
369
386
json_object_new_int ((int )vector -> bitlen [0 ]));
370
387
json_object_array_add (bitlenarray ,
@@ -432,8 +449,23 @@ static int rsa_tester(struct json_object *in, struct json_object *out,
432
449
};
433
450
const struct json_testresult rsa_keygen_testresult = SET_ARRAY (rsa_keygen_testresult_entries , & rsa_keygen_callbacks );
434
451
435
- /* search for empty arrays */
436
- const struct json_array rsa_keygen_test = {NULL , 0 , & rsa_keygen_testresult };
452
+ const struct json_entry rsa_keygen_test_entries [] = {
453
+ {"xP" , {.data .buf = & rsa_keygen_vector .xp , PARSER_BIN },
454
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
455
+ {"xP1" , {.data .buf = & rsa_keygen_vector .xp1 , PARSER_BIN },
456
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
457
+ {"xP2" , {.data .buf = & rsa_keygen_vector .xp2 , PARSER_BIN },
458
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
459
+ {"xQ" , {.data .buf = & rsa_keygen_vector .xq , PARSER_BIN },
460
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
461
+ {"xQ1" , {.data .buf = & rsa_keygen_vector .xq1 , PARSER_BIN },
462
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
463
+ {"xQ2" , {.data .buf = & rsa_keygen_vector .xq2 , PARSER_BIN },
464
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
465
+ {"e" , {.data .buf = & rsa_keygen_vector .e , PARSER_BIN },
466
+ FLAG_OP_ASYM_TYPE_KEYGEN | FLAG_OP_AFT | FLAG_OP_GDT | FLAG_OP_RSA_PQ_B36_PRIMES | FLAG_OPTIONAL },
467
+ };
468
+ const struct json_array rsa_keygen_test = SET_ARRAY (rsa_keygen_test_entries , & rsa_keygen_testresult );
437
469
438
470
/**********************************************************************
439
471
* RSA B.3.2 KeyGen KAT and KeyGen GDT
0 commit comments