c - How do I feed OpenSSL random data for use in ECDSA signing? -
I use OpenSSL feeding specific data to use as a random seed during signature of data with an EC key Want to I am comparing my application with another reference (closed source). This utility takes a file with a private key, files with data to sign and files with random data as parameters.
I have found a generation of keys, and data has been signed, but can not be compared, since two applications I have no common ground OpenSSL random data signing data (Possibly from / dev / random) and thus gives me a different signature of every run.
I have tried RAND_clar ()
in combination with RAND_add ()
, but keep changing the signature. Either I can not understand the entire ECDSA concept, or I am doing something wrong.
To compare applications, my second option is to import the public key and confirm signature prepared by the reference program. This is a better option, but I am unable to import the given public key (83 characters hex string). EC_POINT_oct2point ()
gives me unusable results.
Any help / hints / references will be highly appreciated.
char * key_as_binary_data; // 36 9 368 AF 243193 D 003E3C 076bb1d5aa8a9bc 06a63307 ab 352338a5aa 5cff 0 ak2531866f3e3c 2702 int data_us ize; // main buffer size EC_POINT * ecpoint = NULL; EC_GROUP * ecgroup = NULL; EC_KEY * EK = Faucet; Point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; Int asn1_flag = OPENSSL_EC_NAMED_CURVE; Single = EC_K_YA (); Ecpoint = EC_POINT_new (ecgroup); Ecgroup = EC_GROUP_new_by_curve_name (obje_sn2nid ("sect163k1")); EC_GROUP_set_asn1_flag (ecgroup, asn1_flag); EC_GROUP_set_point_conversion_form (ecgroup, form); EC_KEY_set_group (eckey, ecgroup); EC_KEY_generate_key (eckey); // This gives me a nulled ecpoint EC_POINT_oct2point (ecgroup, ecpoint, key_as_binary_data, data_size-1, ctx); EC_KEY_set_public_key (eckey, ecpoint);
This way you should go about loading that public key: < / P> To verify this fine, then think it should work for a signature check. I think your bug may have been passed just for a zero (in ecgroup) EC_POINT_new ().
EC_KEY * key = NULL; EC_POINT * pub_key; Const EC_GROUP * Group; SSL_library_init (); SSL_load_error_strings (); Key = EC_KEY_new_by_curve_name (NID_sect163k1); Group = EC_KEY_get0_group (key); Pub_key = EC_POINT_new (group); EC_POINT_hex2point (group, "369368AF243193D001E39CE76BB1D5DA08A9BC0A63307AB352338E5EA5C0E05A0C2531866F3E3C2702", pub_key, zero); EC_KEY_set_public_key (key, pub_key); (! EC_KEY_check_key (key)) if {printf ("EC_KEY_check_key failed: \ n"); Printf ("% s \ n", ERR_error_string (ERR_get_error (), zero)); } Other {printf ("public key is verified exactly \ n"); }
Comments
Post a Comment