signature check with public x and y component of ECC key

100 views
Skip to first unread message

Robert Zillner

unread,
Oct 3, 2014, 7:38:26 AM10/3/14
to openssl...@googlegroups.com
Hello,

i´m trying to initialize a public key only in openssl to verify an external created signature of a message.

The private key is not available because an external signature device signs the message. The public key is available
in hex format (x + y).

My problem is that i don´t know how to initialize only a public key and to verify the signature in openssl.

The used curve for the sifgnature is "sect283k1" 

Can anyone help me?

This is my current try:

EC_KEY *key;
if(NULL == (key = EC_KEY_new_by_curve_name(NID_sect283k1)))
     cout << "Generating instance of key failed! \r" << endl;
EC_GROUP *ec_group = EC_GROUP_new_by_curve_name(NID_sect283k1);
EC_KEY_set_group(key, ec_group); 
EC_POINT *publ;

publ = EC_POINT_hex2point(ec_group, (const char *)pubKey.data(), 0, NULL);
if(EC_KEY_set_public_key(key, publ) != 1)
{
  cout << "Setting failed !" << endl;
}

Matt Caswell

unread,
Oct 3, 2014, 8:16:28 AM10/3/14
to Robert Zillner, openssl...@googlegroups.com
On 3 October 2014 12:38, Robert Zillner <robzi...@gmail.com> wrote:
>
> Hello,
>
> i´m trying to initialize a public key only in openssl to verify an external created signature of a message.


Not sure why this is an openssl-testing question...but anyway...

>
>
> The private key is not available because an external signature device signs the message. The public key is available
> in hex format (x + y).


Do you mean a string containing only the hex characters
0-9,a-z,A-Z....or do you actually mean an octet string?


>
>
> My problem is that i don´t know how to initialize only a public key and to verify the signature in openssl.
>
> The used curve for the sifgnature is "sect283k1"
>
> Can anyone help me?
>
> This is my current try:
>
> EC_KEY *key;
> if(NULL == (key = EC_KEY_new_by_curve_name(NID_sect283k1)))
> cout << "Generating instance of key failed! \r" << endl;
> EC_GROUP *ec_group = EC_GROUP_new_by_curve_name(NID_sect283k1);
> EC_KEY_set_group(key, ec_group);
> EC_POINT *publ;
>

EC_KEY_new_by_curve_name implicitly sets the group, so you don't need
to do this bit.


>
> publ = EC_POINT_hex2point(ec_group, (const char *)pubKey.data(), 0, NULL);
> if(EC_KEY_set_public_key(key, publ) != 1)
> {
> cout << "Setting failed !" << endl;
> }
>
Its not clear from your description of the problem whether this works
or not - it looks ok. If you're actually dealing with an octet string
then you would need to use EC_POINT_oct2point instead.

Assuming it works you might want to call EC_KEY_check_key at this
point to make sure its sane.

Next step is to create an EVP_PKEY object. Use:

int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,EC_KEY *key);

Then use the standard EVP routines for verifying a signature. See:
http://wiki.openssl.org/index.php/EVP_Signing_and_Verifying

Hope that helps

Matt
Message has been deleted

Robert Zillner

unread,
Oct 3, 2014, 8:43:03 AM10/3/14
to openssl...@googlegroups.com
Short introduction what i´m going to do:

1. A Security chip (ATECC108) on a client generates a signature of type R + S (72 bytes concatinated) K283 curve. The private key is not available. 
2. The message sent to the chip and the generated returned signature must be verified with the known public key on the host to be sure the signature is valid.


The verification on the Client works, but i wanna be sure it is compatible with an external framework like openssl or crypto++
Now i´m stuck on setting the public key of type X + Y (72 bytes concatinated) to be used to verify this signature.

Leonardo Fernandes

unread,
Oct 31, 2014, 8:33:42 AM10/31/14
to openssl...@googlegroups.com
I have the same problem, you solved ?

Robert Zillner

unread,
Nov 1, 2014, 12:11:41 PM11/1/14
to openssl...@googlegroups.com
Yes, my problem was that the ATECC needs the SHA256 of the message to be signed and i did´t do that before.

So i hashed the message on the host and than sent it to the ATECC. Then the initialization of the public key 
and the signature check succeeded on the host using crypto++.

Regards

Rob
Reply all
Reply to author
Forward
0 new messages