diff options
author | Martin Willi <martin@revosec.ch> | 2015-04-13 12:12:09 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2015-04-15 14:38:42 +0200 |
commit | 41421b85a91bb91b965f241949cf1d7d49b7692e (patch) | |
tree | 34aa2e8d0e691e769370ddfc6ca90df8156bab0e /src/libstrongswan/plugins | |
parent | 0778c027a7b72e6b9d39880086a93ee9167c61ea (diff) | |
download | strongswan-41421b85a91bb91b965f241949cf1d7d49b7692e.tar.bz2 strongswan-41421b85a91bb91b965f241949cf1d7d49b7692e.tar.xz |
gcrypt: Support setting private value and testing of DH backend
Diffstat (limited to 'src/libstrongswan/plugins')
-rw-r--r-- | src/libstrongswan/plugins/gcrypt/gcrypt_dh.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c index 744ec0bbf..cee25ea74 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_dh.c @@ -145,6 +145,24 @@ METHOD(diffie_hellman_t, get_my_public_value, bool, return TRUE; } +METHOD(diffie_hellman_t, set_private_value, bool, + private_gcrypt_dh_t *this, chunk_t value) +{ + gcry_error_t err; + gcry_mpi_t xa; + + err = gcry_mpi_scan(&xa, GCRYMPI_FMT_USG, value.ptr, value.len, NULL); + if (!err) + { + gcry_mpi_release(this->xa); + this->xa = xa; + gcry_mpi_powm(this->ya, this->g, this->xa, this->p); + gcry_mpi_release(this->zz); + this->zz = NULL; + } + return !err; +} + METHOD(diffie_hellman_t, get_shared_secret, bool, private_gcrypt_dh_t *this, chunk_t *secret) { @@ -191,6 +209,7 @@ gcrypt_dh_t *create_generic(diffie_hellman_group_t group, size_t exp_len, .get_shared_secret = _get_shared_secret, .set_other_public_value = _set_other_public_value, .get_my_public_value = _get_my_public_value, + .set_private_value = _set_private_value, .get_dh_group = _get_dh_group, .destroy = _destroy, }, |