tests/crypto/test_ecc_dh/src/test_ecc_dh.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 pkv_vectors(char **qx_vec, char **qy_vec, char **res_vec, int *results,
		int tests, int verbose)
{
	EccPoint pub;
	int exp_rc;
	int rc = TC_FAIL;
	for (int i = 0; i < tests; i++) {
		exp_rc = results[i];
		if (strlen(qx_vec[i]) > 2 * NUM_ECC_BYTES ||
				strlen(qy_vec[i]) > 2 * NUM_ECC_BYTES) {
			rc = -2;
		} else {
			str_to_scalar(pub.x, NUM_ECC_DIGITS, qx_vec[i]);
			str_to_scalar(pub.y, NUM_ECC_DIGITS, qy_vec[i]);
			rc = ecc_valid_public_key(&pub);
		}
		if (rc == -3) {
			rc = 2;
		}
		if (rc == -2) {
			rc = 1;
		}
		rc = check_code(i, res_vec[i], exp_rc, rc, verbose);
		if (rc != TC_PASS) {
			goto exit_test;
		}
	}
	rc = TC_PASS;
exit_test:
	return rc;
}
int pkv_vectors ( char * * qx_vec , char * * qy_vec , char * * res_vec , int * results , int tests , int verbose ) { EccPoint pub ; int exp_rc ; int rc = TC_FAIL ; for ( int i = 0 ; i < tests ; i ++ ) { exp_rc = results [ i ] ; if ( strlen ( qx_vec [ i ] ) > 2 * NUM_ECC_BYTES || strlen ( qy_vec [ i ] ) > 2 * NUM_ECC_BYTES ) { rc = -2 ; } else { str_to_scalar ( pub . x , NUM_ECC_DIGITS , qx_vec [ i ] ) ; str_to_scalar ( pub . y , NUM_ECC_DIGITS , qy_vec [ i ] ) ; rc = ecc_valid_public_key ( & pub ) ; } if ( rc == -3 ) { rc = 2 ; } if ( rc == -2 ) { rc = 1 ; } rc = check_code ( i , res_vec [ i ] , exp_rc , rc , 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
/* invalid input to ECC digit conversion
			 * (string2native())
			 */ /*
		 * map to CAVP error codes
		 *  0 => 0 - success
		 * -1 => ? - (x,y) = (0,0) (not covered)
		 * -2 => 1 - out of bounds (pubverify or ecc import)
		 * -3 => 2 - not on curve
		 */