diffie-hellman: Add a bool return value to get_my_public_value()
This commit is contained in:
@@ -132,10 +132,11 @@ static chunk_t export_mpi(gcry_mpi_t value, size_t len)
|
||||
return chunk;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_gcrypt_dh_t *this, chunk_t *value)
|
||||
{
|
||||
*value = export_mpi(this->ya, this->p_len);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
@@ -144,7 +144,7 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
mpz_clear(p_min_1);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_gmp_diffie_hellman_t *this,chunk_t *value)
|
||||
{
|
||||
value->len = this->p_len;
|
||||
@@ -153,6 +153,7 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
{
|
||||
value->len = 0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
@@ -109,7 +109,7 @@ struct private_ntru_ke_t {
|
||||
ntru_drbg_t *drbg;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_ntru_ke_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_empty;
|
||||
@@ -130,13 +130,14 @@ METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
if (!this->privkey)
|
||||
{
|
||||
DBG1(DBG_LIB, "NTRU keypair generation failed");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
this->pubkey = this->privkey->get_public_key(this->privkey);
|
||||
}
|
||||
*value = chunk_clone(this->pubkey->get_encoding(this->pubkey));
|
||||
DBG3(DBG_LIB, "NTRU public key: %B", value);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
@@ -61,13 +61,14 @@ struct private_openssl_diffie_hellman_t {
|
||||
bool computed;
|
||||
};
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_openssl_diffie_hellman_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_alloc(DH_size(this->dh));
|
||||
memset(value->ptr, 0, value->len);
|
||||
BN_bn2bin(this->dh->pub_key,
|
||||
value->ptr + value->len - BN_num_bytes(this->dh->pub_key));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
@@ -235,10 +235,11 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
this->computed = TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_openssl_ec_diffie_hellman_t *this,chunk_t *value)
|
||||
{
|
||||
ecp2chunk(this->ec_group, EC_KEY_get0_public_key(this->key), value, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
@@ -148,10 +148,11 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
derive_secret(this, value);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, void,
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
private_pkcs11_dh_t *this, chunk_t *value)
|
||||
{
|
||||
*value = chunk_clone(this->pub_key);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_shared_secret, bool,
|
||||
|
||||
Reference in New Issue
Block a user