diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2005-11-15 17:35:02 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2005-11-15 17:35:02 +0000 |
commit | 28742fa959f05142f2659f73a5ea1260175179a7 (patch) | |
tree | b29435e31924e409e58bf034cf30092e5e39cf2e /lib/gnutls_dh.c | |
parent | dea22989089a7c2de01a606a9e6ed60caee2742f (diff) | |
download | gnutls-28742fa959f05142f2659f73a5ea1260175179a7.tar.gz |
added DHE-PSK ciphersuites and some cleanups.
Diffstat (limited to 'lib/gnutls_dh.c')
-rw-r--r-- | lib/gnutls_dh.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/gnutls_dh.c b/lib/gnutls_dh.c index 5eae3c2366..76c851ecfe 100644 --- a/lib/gnutls_dh.c +++ b/lib/gnutls_dh.c @@ -122,3 +122,40 @@ gnutls_calc_dh_key (mpi_t f, mpi_t x, mpi_t prime) _gnutls_mpi_powm (k, f, x, prime); return k; } + +/*- + * _gnutls_get_dh_params - Returns the DH parameters pointer + * @dh_params: is an DH parameters structure, or NULL. + * @func: is a callback function to receive the parameters or NULL. + * @session: a gnutls session. + * + * This function will return the dh parameters pointer. + * + -*/ +gnutls_dh_params_t +_gnutls_get_dh_params (gnutls_dh_params_t dh_params, gnutls_params_function* func, + gnutls_session_t session) +{ + gnutls_params_st params; + int ret; + + /* if cached return the cached */ + if (session->internals.params.dh_params) + return session->internals.params.dh_params; + + if (dh_params) + { + session->internals.params.dh_params = dh_params; + } + else if (func) + { + ret = func (session, GNUTLS_PARAMS_DH, ¶ms); + if (ret == 0 && params.type == GNUTLS_PARAMS_DH) + { + session->internals.params.dh_params = params.params.dh; + session->internals.params.free_dh_params = params.deinit; + } + } + + return session->internals.params.dh_params; +} |