dhkey
struct dhkey *pk = 0;
static struct dhkey *
struct dhkey *binkey;
uid_t, struct dhkey *);
static struct dhkey *keybuf3_2_dhkey(keybuf3 *);
struct dhkey secret;
struct dhkey public;
find_cache_item(struct cachekey_header **ch, uid_t uid, struct dhkey *public)
struct dhkey *pk;
struct dhkey *sk;
struct dhkey *pk = 0;
#define DHKEYALLOC(keylen) ALIGN4(sizeof (struct dhkey) + KEYLEN(keylen))
#define DHKEYSIZE(dhkey_ptr) ALIGN4(sizeof (struct dhkey) + \
DHkey dhkey;
if ((brv = DH_key_init(&dhkey, bkey->prime_bits)) != BIG_OK) {
if ((brv = big_extend(&(dhkey.p), CHARLEN2BIGNUMLEN(prime_bytes))) !=
bytestring2bignum(&(dhkey.p), bkey->prime, prime_bytes);
if ((brv = big_extend(&(dhkey.g),
bytestring2bignum(&(dhkey.g), bkey->base, bkey->base_bytes);
if (big_cmp_abs(&(dhkey.g), &(dhkey.p)) >= 0) {
primebit_len = big_bitlength(&(dhkey.p));
if ((brv = big_extend(&(dhkey.x), BITLEN2BIGNUMLEN(bkey->value_bits)))
if ((brv = big_extend(&(dhkey.y), CHARLEN2BIGNUMLEN(prime_bytes)))
if ((brv = big_random(&(dhkey.x), bkey->value_bits, rf)) != BIG_OK) {
if ((brv = big_modexp(&(dhkey.y), &(dhkey.g), &(dhkey.x),
&(dhkey.p), NULL)) != BIG_OK) {
bignum2bytestring(bkey->private_x, &(dhkey.x),
bignum2bytestring(bkey->public_y, &(dhkey.y), prime_bytes);
DH_key_finish(&dhkey);
DHkey dhkey;
if ((brv = DH_key_init(&dhkey, bkey->prime_bits)) != BIG_OK) {
if ((brv = big_extend(&(dhkey.p), CHARLEN2BIGNUMLEN(prime_bytes))) !=
bytestring2bignum(&(dhkey.p), bkey->prime, prime_bytes);
if ((brv = big_extend(&(dhkey.x), CHARLEN2BIGNUMLEN(value_bytes))) !=
bytestring2bignum(&(dhkey.x), bkey->private_x, value_bytes);
if ((brv = big_extend(&(dhkey.y), CHARLEN2BIGNUMLEN(prime_bytes))) !=
bytestring2bignum(&(dhkey.y), bkey->public_y, prime_bytes);
if ((brv = big_extend(&(dhkey.g), CHARLEN2BIGNUMLEN(prime_bytes))) !=
if ((brv = big_modexp(&(dhkey.g), &(dhkey.y), &(dhkey.x),
&(dhkey.p), NULL)) != BIG_OK) {
s_bytes = dhkey.g.len * (int)sizeof (BIG_CHUNK_TYPE);
bignum2bytestring(s, &(dhkey.g), s_bytes);
DH_key_finish(&dhkey);