RSA, DSA, DH: Allow some given input to be NULL on already initialised keys
authorRichard Levitte <levitte@openssl.org>
Mon, 25 Apr 2016 18:28:54 +0000 (20:28 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 27 Apr 2016 13:07:53 +0000 (15:07 +0200)
commit1da12e34ed69cec206f3a251a1e62ceeb694a6ea
tree5dfc32c8085b5e1cf77134786e778b861e38640d
parent3aec886ed4af1ca945f5d10da2ce40e4538fe5fc
RSA, DSA, DH: Allow some given input to be NULL on already initialised keys

The diverse {RSA,DSA,DH}_set0_* functions are made to allow some
parameters to be NULL IF the corresponding numbers in the given key
structure have already been previously initialised.  Specifically,
this allows the addition of private components to be added to a key
that already has the public half, approximately like this:

    RSA_get0_key(rsa, NULL, &e, NULL);
    RSA_get0_factors(rsa, &p, &q);
    /* calculate new d */
    RSA_set0_key(rsa, NULL, NULL, d);

Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c
crypto/rsa/rsa_lib.c