[openssl-dev] [openssl.org #3894] AutoReply: PATCH: EVP_PKEY_get_type (new function)
Kurt Roeckx
kurt at roeckx.be
Thu Jun 4 19:09:41 UTC 2015
On Wed, Jun 03, 2015 at 08:50:25PM +0000, noloader at gmail.com via RT wrote:
> Here's an updated patch that includes the documentation changes. `git
> diff master` is needed after `git add` because adding doesn't seem to
> really add things for git :)
>
> riemann::openssl-git$ cat evp_pkey_get_type.diff
> diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c
> index 1fdde9a..0cd8a42 100644
> --- a/crypto/evp/evp_lib.c
> +++ b/crypto/evp/evp_lib.c
> @@ -61,6 +61,15 @@
> #include <openssl/evp.h>
> #include <openssl/objects.h>
>
> +/* Returns the key type or EVP_PKEY_NONE if pkey is NULL */
> +int EVP_PKEY_get_type(EVP_PKEY *pkey)
> +{
> + if (!pkey)
> + return EVP_PKEY_NONE;
> +
> + return EVP_PKEY_type(pkey->type);
> +}
> +
This seems to do almost exactly the same as EVP_PKEY_base_id().
> int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type)
> {
> int ret;
> diff --git a/doc/crypto/EVP_PKEY_get_type.pod b/doc/crypto/EVP_PKEY_get_type.pod
> new file mode 100644
> index 0000000..1faaae5
> --- /dev/null
> +++ b/doc/crypto/EVP_PKEY_get_type.pod
> @@ -0,0 +1,65 @@
> +=pod
> +
> +=head1 NAME
> +
> +EVP_PKEY_get_type - queries the EVP_PKEY for the type of key
> +
> +=head1 SYNOPSIS
> +
> + #include <openssl/evp.h>
> +
> + int EVP_PKEY_get_type(EVP_PKEY *pkey);
> +
> +=head1 DESCRIPTION
> +
> +B<EVP_PKEY_get_type> queries the EVP_PKEY for the type of key.
I think I prefer that to be written as EVP_PKEY_get_type() instead
of B<EVP_PKEY_get_type>.
> +Though B<EVP_PKEY_get_type> is available, its use is discouraged
> because it peeks into implementation specific details.
This doesn't make sense. You're discouraging the function you
add? Maybe you mean EVP_PKEY_type(pkey->type)?
I don't know if there are plans to run the EVP_PKEY into a opaque
struct soon, but it probably should. I would avoid talking about
implementation details unless it's important for the user to know,
and that doesn't seem to be the case.
> +==head1 RETURN VALUES
> +
> +If B<pkey> is B<NULL>, then the function returns B<EVP_PKEY_NONE>.
> +
> +If B<pkey> is not B<NULL>, then the return value will be one of the
> following values from B<evp.h>:
> +
> + * EVP_PKEY_NONE
> + * EVP_PKEY_RSA
> + * EVP_PKEY_RSA2
> + * EVP_PKEY_DSA
> + * EVP_PKEY_DSA1
> + * EVP_PKEY_DSA2
> + * EVP_PKEY_DSA3
> + * EVP_PKEY_DSA4
> + * EVP_PKEY_DH
> + * EVP_PKEY_DHX
> + * EVP_PKEY_EC
> + * EVP_PKEY_HMAC
> + * EVP_PKEY_CMAC
EVP_PKEY_type() currently documents:
EVP_PKEY_type() returns the type of key corresponding to
the value type. The type of a key can be obtained with
EVP_PKEY_type(pkey->type). The return value will be EVP_PKEY_RSA,
EVP_PKEY_DSA, EVP_PKEY_DH or EVP_PKEY_EC for the corresponding key
types or NID_undef if the key type is unassigned.
I'm guessing one of them is wrong.
Kurt
More information about the openssl-dev
mailing list