diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2016-06-02 11:51:34 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2017-06-08 10:45:54 +0200 |
commit | 930971bc65129d46be5b584d9c20694c0d7b98c3 (patch) | |
tree | 726f809884cbbd739d5e9258aab67876d88a1805 | |
parent | ef8bc65388506eb1a6eb62d78ffab05984b9ebfa (diff) | |
download | libssh-930971bc65129d46be5b584d9c20694c0d7b98c3.tar.gz libssh-930971bc65129d46be5b584d9c20694c0d7b98c3.tar.xz libssh-930971bc65129d46be5b584d9c20694c0d7b98c3.zip |
DH: fixup cleanup
-rw-r--r-- | src/dh.c | 45 |
1 files changed, 6 insertions, 39 deletions
@@ -3,7 +3,7 @@ * * This file is part of the SSH Library * - * Copyright (c) 2003-2013 by Aris Adamantiadis + * Copyright (c) 2003-2016 by Aris Adamantiadis * Copyright (c) 2009-2013 by Andreas Schneider <asn@cryptomilk.org> * Copyright (c) 2012 by Dmitriy Kuznetsov <dk@yandex.ru> * @@ -23,34 +23,7 @@ * MA 02111-1307, USA. */ -/* - * Let us resume the dh protocol. - * Each side computes a private prime number, x at client side, y at server - * side. - * g and n are two numbers common to every ssh software. - * client's public key (e) is calculated by doing: - * e = g^x mod p - * client sends e to the server. - * the server computes his own public key, f - * f = g^y mod p - * it sends it to the client - * the common key K is calculated by the client by doing - * k = f^x mod p - * the server does the same with the client public key e - * k' = e^y mod p - * if everything went correctly, k and k' are equal - */ - #include "config.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <limits.h> - -#ifndef _WIN32 -#include <netinet/in.h> -#include <arpa/inet.h> -#endif #include "libssh/priv.h" #include "libssh/crypto.h" @@ -62,14 +35,6 @@ #include "libssh/pki.h" #include "libssh/bignum.h" -/* todo: remove it */ -#include "libssh/string.h" -#ifdef HAVE_LIBCRYPTO -#include <openssl/rand.h> -#include <openssl/evp.h> -#include <openssl/err.h> -#endif - static unsigned char p_group1_value[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, @@ -123,13 +88,15 @@ static int dh_crypto_initialized; * @return SSH_OK on success, SSH_ERROR otherwise. */ int ssh_dh_init(void) { - if (dh_crypto_initialized == 0) { + int rc; + if (dh_crypto_initialized == 0) { g = bignum_new(); if (g == NULL) { goto error; } - bignum_set_word(g,g_int); - + rc = bignum_set_word(g,g_int); + if (rc != 1) + goto error; bignum_bin2bn(p_group1_value, P_GROUP1_LEN, &p_group1); bignum_bin2bn(p_group14_value, P_GROUP14_LEN, &p_group14); if (p_group1 == NULL || p_group14 == NULL) { |