| 1 |
/* |
| 2 |
Copyright (c) 2011, TeraTerm Project |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Redistribution and use in source and binary forms, with or without modification, |
| 6 |
are permitted provided that the following conditions are met: |
| 7 |
|
| 8 |
Redistributions of source code must retain the above copyright notice, this list of |
| 9 |
conditions and the following disclaimer. |
| 10 |
|
| 11 |
Redistributions in binary form must reproduce the above copyright notice, this list |
| 12 |
of conditions and the following disclaimer in the documentation and/or other materials |
| 13 |
provided with the distribution. |
| 14 |
|
| 15 |
The name of Robert O'Callahan may not be used to endorse or promote products derived from |
| 16 |
this software without specific prior written permission. |
| 17 |
|
| 18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND |
| 19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 21 |
THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 22 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
*/ |
| 28 |
|
| 29 |
#include "ttxssh.h" |
| 30 |
|
| 31 |
#define GEX_GRP_MINSIZE 1024 |
| 32 |
#define GEX_GRP_MAXSIZE 8192 |
| 33 |
|
| 34 |
DH *dh_new_group1(void); |
| 35 |
DH *dh_new_group14(void); |
| 36 |
void dh_gen_key(PTInstVar pvar, DH *dh, int we_need /* bytes */ ); |
| 37 |
int dh_estimate(int bits); |
| 38 |
|
| 39 |
unsigned char *kex_dh_hash(char *client_version_string, |
| 40 |
char *server_version_string, |
| 41 |
char *ckexinit, int ckexinitlen, |
| 42 |
char *skexinit, int skexinitlen, |
| 43 |
u_char *serverhostkeyblob, int sbloblen, |
| 44 |
BIGNUM *client_dh_pub, |
| 45 |
BIGNUM *server_dh_pub, |
| 46 |
BIGNUM *shared_secret, |
| 47 |
unsigned int *hashlen); |
| 48 |
unsigned char *kex_dh_gex_hash(const EVP_MD *evp_md, |
| 49 |
char *client_version_string, |
| 50 |
char *server_version_string, |
| 51 |
char *ckexinit, int ckexinitlen, |
| 52 |
char *skexinit, int skexinitlen, |
| 53 |
u_char *serverhostkeyblob, int sbloblen, |
| 54 |
int kexgex_min, |
| 55 |
int kexgex_bits, |
| 56 |
int kexgex_max, |
| 57 |
BIGNUM *kexgex_p, |
| 58 |
BIGNUM *kexgex_g, |
| 59 |
BIGNUM *client_dh_pub, |
| 60 |
BIGNUM *server_dh_pub, |
| 61 |
BIGNUM *shared_secret, |
| 62 |
unsigned int *hashlen); |
| 63 |
unsigned char *kex_ecdh_hash(const EVP_MD *evp_md, |
| 64 |
const EC_GROUP *ec_group, |
| 65 |
char *client_version_string, |
| 66 |
char *server_version_string, |
| 67 |
char *ckexinit, int ckexinitlen, |
| 68 |
char *skexinit, int skexinitlen, |
| 69 |
u_char *serverhostkeyblob, int sbloblen, |
| 70 |
const EC_POINT *client_dh_pub, |
| 71 |
const EC_POINT *server_dh_pub, |
| 72 |
BIGNUM *shared_secret, |
| 73 |
unsigned int *hashlen); |
| 74 |
|
| 75 |
int dh_pub_is_valid(DH *dh, BIGNUM *dh_pub); |
| 76 |
int key_ec_validate_public(const EC_GROUP *group, const EC_POINT *public); |
| 77 |
void kex_derive_keys(PTInstVar pvar, int need, u_char *hash, BIGNUM *shared_secret, |
| 78 |
char *session_id, int session_id_len); |