aboutsummaryrefslogtreecommitdiff
path: root/include/libssh
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-05-02 16:00:26 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-11-03 15:20:36 +0100
commite3a866b8c19601803d1f8aaea40573c738d4acfd (patch)
treed5c130d2830d24651505dc5be67efdc835b1afe3 /include/libssh
parentf62cded9f0bc2d08afe0ef2d79e247951f193559 (diff)
downloadlibssh-e3a866b8c19601803d1f8aaea40573c738d4acfd.tar.gz
libssh-e3a866b8c19601803d1f8aaea40573c738d4acfd.tar.xz
libssh-e3a866b8c19601803d1f8aaea40573c738d4acfd.zip
ecdh: Implement ECDH using libgcrypt
* include/libssh/crypto.h (struct ssh_crypto_struct): Provide a suitable 'ecdh_privkey'. * include/libssh/ecdh.h: Also define 'HAVE_ECDH' if we do ECC using libgcrypt. (ecdh_build_k): New prototype. * src/CMakeLists.txt (libssh_SRCS): Add backend-specific files. * src/ecdh.c: Move backend-specific parts to... * src/ecdh_crypto.c: ... this file. * src/ecdh_gcrypt.c: New file. * src/wrapper.c (crypto_free): Free 'ecdh_privkey'. Signed-off-by: Justus Winter <justus@g10code.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/libssh')
-rw-r--r--include/libssh/crypto.h4
-rw-r--r--include/libssh/ecdh.h10
2 files changed, 13 insertions, 1 deletions
diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h
index e370c748..102c8d7e 100644
--- a/include/libssh/crypto.h
+++ b/include/libssh/crypto.h
@@ -76,7 +76,11 @@ enum ssh_cipher_e {
struct ssh_crypto_struct {
bignum e,f,x,k,y;
#ifdef HAVE_ECDH
+#ifdef HAVE_OPENSSL_ECC
EC_KEY *ecdh_privkey;
+#elif defined HAVE_GCRYPT_ECC
+ gcry_sexp_t ecdh_privkey;
+#endif
ssh_string ecdh_client_pubkey;
ssh_string ecdh_server_pubkey;
#endif
diff --git a/include/libssh/ecdh.h b/include/libssh/ecdh.h
index 8d1e7515..9f94d69c 100644
--- a/include/libssh/ecdh.h
+++ b/include/libssh/ecdh.h
@@ -33,9 +33,17 @@
#endif /* HAVE_OPENSSL_ECDH_H */
#endif /* HAVE_LIBCRYPTO */
-int ssh_client_ecdh_init(ssh_session session);
+#ifdef HAVE_GCRYPT_ECC
+#define HAVE_ECDH 1
+#endif
+
+/* Common functions. */
int ssh_client_ecdh_reply(ssh_session session, ssh_buffer packet);
+/* Backend-specific functions. */
+int ssh_client_ecdh_init(ssh_session session);
+int ecdh_build_k(ssh_session session);
+
#ifdef WITH_SERVER
int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet);
#endif /* WITH_SERVER */