[openssl.org #3606] Need RSA_pubkey_digest()

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[openssl.org #3606] Need RSA_pubkey_digest()

Rich Salz via RT
On Thu Nov 20 21:35:45 2014, [hidden email] wrote:

> Can the following function please be added:
>
> int RSA_public_digest(const RSA* key, const EVP_MD *type, unsigned
> char *md, unsigned int *len);
>
> which would use “type” to generate a digest over the DER encoding of
> the public portion of “key”, and deposit “len” bytes into the
> buffer starting at “md”.
>
> A similar function:
>
> int RSA_private_digest() would take the same parameters as
> RSA_public_digest(), but for the DER encoding of the private key.
> This function is less useful than the first, but is useful for
> symmetry in the API and some corner cases.

This could be done quite simply using i2d_RSA_PUBKEY (or i2d_RSAPublicKey
depending on what flavour of public key you want) and then using the
EVP_Digest* functions.

Closing this ticket.

Matt

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [openssl.org #3606] Need RSA_pubkey_digest()

Philip Prindeville

On 11/25/2014 07:48 AM, Matt Caswell via RT wrote:

> On Thu Nov 20 21:35:45 2014, [hidden email] wrote:
>> Can the following function please be added:
>>
>> int RSA_public_digest(const RSA* key, const EVP_MD *type, unsigned
>> char *md, unsigned int *len);
>>
>> which would use “type” to generate a digest over the DER encoding of
>> the public portion of “key”, and deposit “len” bytes into the
>> buffer starting at “md”.
>>
>> A similar function:
>>
>> int RSA_private_digest() would take the same parameters as
>> RSA_public_digest(), but for the DER encoding of the private key.
>> This function is less useful than the first, but is useful for
>> symmetry in the API and some corner cases.
> This could be done quite simply using i2d_RSA_PUBKEY (or i2d_RSAPublicKey
> depending on what flavour of public key you want) and then using the
> EVP_Digest* functions.
>
> Closing this ticket.
>
> Matt
>

Okay, but why not include a convenience wrapper to do it, whether it's
easy or not?

It seems to be a frequent construct.

-Philip

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [openssl.org #3606] Need RSA_pubkey_digest()

Rich Salz via RT

On 11/25/2014 07:48 AM, Matt Caswell via RT wrote:

> On Thu Nov 20 21:35:45 2014, [hidden email] wrote:
>> Can the following function please be added:
>>
>> int RSA_public_digest(const RSA* key, const EVP_MD *type, unsigned
>> char *md, unsigned int *len);
>>
>> which would use “type” to generate a digest over the DER encoding of
>> the public portion of “key”, and deposit “len” bytes into the
>> buffer starting at “md”.
>>
>> A similar function:
>>
>> int RSA_private_digest() would take the same parameters as
>> RSA_public_digest(), but for the DER encoding of the private key.
>> This function is less useful than the first, but is useful for
>> symmetry in the API and some corner cases.
> This could be done quite simply using i2d_RSA_PUBKEY (or i2d_RSAPublicKey
> depending on what flavour of public key you want) and then using the
> EVP_Digest* functions.
>
> Closing this ticket.
>
> Matt
>

Okay, but why not include a convenience wrapper to do it, whether it's
easy or not?

It seems to be a frequent construct.

-Philip


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [openssl.org #3606] Need RSA_pubkey_digest()

Dr. Stephen Henson
On Tue, Nov 25, 2014, Philip Prindeville via RT wrote:

>
> On 11/25/2014 07:48 AM, Matt Caswell via RT wrote:
> > On Thu Nov 20 21:35:45 2014, [hidden email] wrote:
> >> Can the following function please be added:
> >>
> >> int RSA_public_digest(const RSA* key, const EVP_MD *type, unsigned
> >> char *md, unsigned int *len);
> >>
> >> which would use ???type??? to generate a digest over the DER encoding of
> >> the public portion of ???key???, and deposit ???len??? bytes into the
> >> buffer starting at ???md???.
> >>
> >> A similar function:
> >>
> >> int RSA_private_digest() would take the same parameters as
> >> RSA_public_digest(), but for the DER encoding of the private key.
> >> This function is less useful than the first, but is useful for
> >> symmetry in the API and some corner cases.
> > This could be done quite simply using i2d_RSA_PUBKEY (or i2d_RSAPublicKey
> > depending on what flavour of public key you want) and then using the
> > EVP_Digest* functions.
> >
> > Closing this ticket.
> >
> > Matt
> >
>
> Okay, but why not include a convenience wrapper to do it, whether it's
> easy or not?
>
> It seems to be a frequent construct.
>

I'm curious: I've not seen the private key version before, where is it used?

You can actually perform the encode and digest operation all in one go using
the ASN1_item_digest function. Something like this should work:

rv = ASN1_item_digest(ASN1_ITEM_rptr(RSAPublicKey), mdtype, rsa,
                                                                        md, &mdlen);

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]