tests/crypto/test_ecc_dsa/src/test_ecc_utils.c
/* Test ecc_make_keys, and also as keygen part of other tests */
Test ecc_make_keys, and also as keygen part of other tests
Test ecc_make_keys and also as keygen part of other tests
int keygen_vectors(EccPoint *pub, char **d_vec, char **qx_vec, char **qy_vec,
		   int tests, int verbose)
{
	u32_t seed[2 * NUM_ECC_DIGITS];
	u32_t prv[NUM_ECC_DIGITS];
	EccPoint exp_pub;
	u32_t exp_prv[NUM_ECC_DIGITS];
	int rc;
	for (int i = 0; i < tests; i++) {
		str_to_scalar(exp_prv, NUM_ECC_DIGITS, d_vec[i]);
		str_to_scalar(exp_pub.x, NUM_ECC_DIGITS, qx_vec[i]);
		str_to_scalar(exp_pub.y, NUM_ECC_DIGITS, qy_vec[i]);
		memset(seed, 0, 2 * NUM_ECC_BYTES);
		str_to_scalar(seed, NUM_ECC_DIGITS, d_vec[i]);
		ecc_make_key(pub, prv, seed);
		rc = check_ecc_result(i, "prv  ", exp_prv, prv,
				      NUM_ECC_DIGITS, verbose);
		if (rc != TC_PASS) {
			goto exit_test;
		}
		rc = check_ecc_result(i, "pub.x", exp_pub.x, pub->x,
				      NUM_ECC_DIGITS, verbose);
		if (rc != TC_PASS) {
			goto exit_test;
		}
		rc = check_ecc_result(i, "pub.y", exp_pub.y, pub->y,
				      NUM_ECC_DIGITS, verbose);
		if (rc != TC_PASS) {
			goto exit_test;
		}
	}
	rc = TC_PASS;
exit_test:
	return rc;
}
int keygen_vectors ( EccPoint * pub , char * * d_vec , char * * qx_vec , char * * qy_vec , int tests , int verbose ) { u32_t seed [ 2 * NUM_ECC_DIGITS ] ; u32_t prv [ NUM_ECC_DIGITS ] ; EccPoint exp_pub ; u32_t exp_prv [ NUM_ECC_DIGITS ] ; int rc ; for ( int i = 0 ; i < tests ; i ++ ) { str_to_scalar ( exp_prv , NUM_ECC_DIGITS , d_vec [ i ] ) ; str_to_scalar ( exp_pub . x , NUM_ECC_DIGITS , qx_vec [ i ] ) ; str_to_scalar ( exp_pub . y , NUM_ECC_DIGITS , qy_vec [ i ] ) ; memset ( seed , 0 , 2 * NUM_ECC_BYTES ) ; str_to_scalar ( seed , NUM_ECC_DIGITS , d_vec [ i ] ) ; ecc_make_key ( pub , prv , seed ) ; rc = check_ecc_result ( i , " " , exp_prv , prv , NUM_ECC_DIGITS , verbose ) ; if ( rc != TC_PASS ) { goto exit_test ; } rc = check_ecc_result ( i , " " , exp_pub . x , pub -> x , NUM_ECC_DIGITS , verbose ) ; if ( rc != TC_PASS ) { goto exit_test ; } rc = check_ecc_result ( i , " " , exp_pub . y , pub -> y , NUM_ECC_DIGITS , verbose ) ; if ( rc != TC_PASS ) { goto exit_test ; } } rc = TC_PASS ; exit_test : return rc ; }
Test ecc_make_keys, and also as keygen part of other tests
Test ecc_make_keys and also as keygen part of other tests
/* expected outputs (converted input vectors) */ /*
		 * Feed prvkey vector as padded random seed into ecc_make_key.
		 * Internal mod-reduction will be zero-op and generate correct
		 * prv/pub
		 */ /* validate correctness of vector conversion and make_key() */