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