Query regarding EVP_PKEY_CTX_set_cb

Bala Duvvuri b_duvvuri at yahoo.com
Wed Mar 30 08:43:00 UTC 2022


Hi All,

Can you please help to understand the use of the callback function that can be set during key generation?

1> For ex: In the OpenSSL 3.0 code, the callback "genrsa_cb" is defined in the file "apps/genrsa.c" :

      What exactly is being done in this callback function? What does EVP_PKEY_CTX_get_keygen_info() return in this case during RSA key generation?
      
static int genrsa_cb(EVP_PKEY_CTX *ctx)
{
    char c = '*';
    BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
    int p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);

    if (!verbose)
        return 1;

    if (p == 0)
        c = '.';
    if (p == 1)
        c = '+';
    if (p == 2)
        c = '*';
    if (p == 3)
        c = '\n';
    BIO_write(b, &c, 1);
    (void)BIO_flush(b);
    return 1;
}

What can be done in these callback functions?

2> Is EVP_PKEY_CTX_set_cb API replacement for the deprecated BN_GENCB_set_old in OpenSSL 3.0 code ?

Thanks
Bala


More information about the openssl-users mailing list