What I am trying to do with ECDSA is take an x "compressed" coordinate and a y "bit" from values taken from external ECDSA hardware (it's really a public key) and then trying to recover the y coordinate (uncompressed) with OpenSSL function calls.
I am trying the following code, but it does not work as I expected (my xy[] array does not get populated with correct data). Can anyone help?
I'm new to ECDSA and even newer to OpenSSL, but I was thinking I could do the following:
EC_GROUP *curve_group = EC_GROUP_new_by_curve_name(NID_X9_62_prime192v1);
EC_POINT *point;
BIGNUM *x_compressed = BN_new();
int y_chooser_bit = 1;
int results = 0;
size_t returnsize = 0;
unsigned char x_compressed_byte_array[25] = {0x02, 0x71, 0xc0, 0x73, 0x73,
0x9b, 0xbf, 0xc2, 0x0a,
0x81, 0xcd, 0xdd, 0xf4,
0xcf, 0xca, 0xc7, 0xb5,
0xa9, 0x99, 0x61, 0x23,
0x2c, 0x5c, 0x63, 0x7a};
unsigned char xy[49];
// create a big number from the unsigned char array
BN_bin2bn(&x_compressed_byte_array[0],200,NULL); // length is in bits?
point = EC_POINT_new(curve_group);
results = EC_POINT_set_compressed_coordinates_GFp(curve_group, point,
x_compressed,
y_chooser_bit, NULL);
returnsize = EC_POINT_point2oct(curve_group, point,
POINT_CONVERSION_UNCOMPRESSED,
&xy[0], 49, NULL); // 49
// clean up allocated memory
BN_free(x_compressed);
EC_POINT_free(point);
EC_GROUP_free(curve_group);