Hashing public keys

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Hashing public keys

Jan Danielsson-3
Hello,

   Given an EVP_PKEY (can contain either RSA or EC key), is there a
function to generate a hash of the public key?  (I have some vague
memory of having read a few years ago that there wasn't any standardized
way to hashing EC keys (+parameters) yet.  If so; has this been remedied?).

   (Storing public keys in a DHT, users need to be able to - given a
public key - generate a hash to check if the hash exists in the DHT).

--
Kind Regards,
Jan Danielsson
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Hashing public keys

Dr. Pala-2
Hi Jan,

not sure if this might help you, I solved the problem by using
X509_PUBKEY + i2d_X509_PUBKEY. Here's an example:

   
https://github.com/openca/libpki/blob/b87b647170cb5f71e00baffe609f5a02edfa3845/src/openssl/pki_keypair.c#L307

I hope that helps,

Cheers,
Max


On 3/21/18 1:42 PM, Jan Danielsson wrote:

> Hello,
>
>    Given an EVP_PKEY (can contain either RSA or EC key), is there a
> function to generate a hash of the public key?  (I have some vague
> memory of having read a few years ago that there wasn't any standardized
> way to hashing EC keys (+parameters) yet.  If so; has this been remedied?).
>
>    (Storing public keys in a DHT, users need to be able to - given a
> public key - generate a hash to check if the hash exists in the DHT).
>

--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Hashing public keys

Dr. Matthias St. Pierre
In reply to this post by Jan Danielsson-3
Hello Jan,

the canonical way to create the hash of the public key is to use
d2i_PUBKEY() to save the public key in (binary) DER format and then
calculate the hash of that using
EVP_DigestInit()/EVP_DigestUpdate()/EVP_DigestFinal().

Hope that helps,

Matthias


Am 21.03.2018 um 14:42 schrieb Jan Danielsson:

> Hello,
>
>    Given an EVP_PKEY (can contain either RSA or EC key), is there a
> function to generate a hash of the public key?  (I have some vague
> memory of having read a few years ago that there wasn't any standardized
> way to hashing EC keys (+parameters) yet.  If so; has this been remedied?).
>
>    (Storing public keys in a DHT, users need to be able to - given a
> public key - generate a hash to check if the hash exists in the DHT).
>


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users