In message <mailman.6072.1542969228.21411.openssl-us...@openssl.org> on Fri, 23 
Nov 2018 10:33:48 +0000, openssl-users-requ...@openssl.org said:

> Hi,
> 
> In this snippet,
> 
>        DH *dh;
>               if ((dh->g = BN_new()) == NULL)-------------> 1
>                      goto end;
>              if (!BN_set_word(dh->g, g)) -----------------------> 2
>                       goto end;

    DH *dh;
    BIGNUM *bn_g;

    if ((bn_g= BN_new()) == NULL)
        goto end;
    if (!BN_set_word(bn_g, g))
        goto end;
    if (!DH_set0_pqg(dh, NULL, NULL, bn_g))
        goto end;

Note that if the p parameter hasn't been set in dh, you must give that
one too, so essentially, this is safer:

    if (!DH_set0_pqg(dh, bn_p, NULL, bn_g))
        goto end;

See the manual pages for DH_set0_pqg and DH_get0_pqg

Cheers,
Richard

-- 
Richard Levitte         levi...@openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/
-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

Reply via email to