diff --git a/lib/hcrypto/dh.c b/lib/hcrypto/dh.c index a6a5c2ff9..a6c5fd48c 100644 --- a/lib/hcrypto/dh.c +++ b/lib/hcrypto/dh.c @@ -183,6 +183,18 @@ DH_size(const DH *dh) return BN_num_bytes(dh->p); } +/** + * Set the data index idx in the DH object to data. + * + * @param dh DH object. + * @param idx index to set the data for. + * @param data data to store for the index idx. + * + * @return 1 on success. + * + * @ingroup hcrypto_dh + */ + int DH_set_ex_data(DH *dh, int idx, void *data) { @@ -190,6 +202,17 @@ DH_set_ex_data(DH *dh, int idx, void *data) return 1; } +/** + * Get the data for index idx in the DH object. + * + * @param dh DH object. + * @param idx index to get the data for. + * + * @return the object store in index idx + * + * @ingroup hcrypto_dh + */ + void * DH_get_ex_data(DH *dh, int idx) { @@ -338,6 +361,11 @@ DH_compute_key(unsigned char *shared_key, { int codes; + /** + * Checks that the pubkey passed in is valid using + * dh_check_pubkey(). + */ + if (!DH_check_pubkey(dh, peer_pub_key, &codes) || codes != 0) return -1;