Skip to content

EVP_PKEY_keygen from EVP_PKEY_CTX_new seems to be broken #11549

@vt-alt

Description

@vt-alt

After commit 2972af1 there is error in EVP_PKEY_keygen if ctx is created by EVP_PKEY_CTX_new. While it works good if ctx is created by EVP_PKEY_CTX_new_id.

Reproduction example (based on man EVP_PKEY_keygen):

#include <openssl/evp.h>
#include <openssl/rsa.h>

int main(void)
{
        EVP_PKEY_CTX *ctx;
        EVP_PKEY *pkey = NULL;
#if 0
        ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL);
#else
        EVP_PKEY *tkey;
        tkey = EVP_PKEY_new();
        EVP_PKEY_set_type(tkey, EVP_PKEY_RSA);
        ctx = EVP_PKEY_CTX_new(tkey, NULL);
#endif
        if (!ctx)
                OpenSSLDie(__FILE__, __LINE__, "EVP_PKEY_CTX_new_id");
        if (EVP_PKEY_keygen_init(ctx) <= 0)
                OpenSSLDie(__FILE__, __LINE__, "EVP_PKEY_keygen_init");
        if (EVP_PKEY_keygen(ctx, &pkey) <= 0)
                OpenSSLDie(__FILE__, __LINE__, "EVP_PKEY_keygen");
        return 0;
}

Produces an error:

OpenSSL internal error: EVP_PKEY_keygen

This error is mentioned in issue #11510 and found by gost-engine test suite.
@beldmit @levitte @slontis

Metadata

Metadata

Assignees

No one assigned

    Labels

    triaged: bugThe issue/pr is/fixes a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions