| 41 |
#include <string.h> |
#include <string.h> |
| 42 |
#include <stdlib.h> |
#include <stdlib.h> |
| 43 |
#include <process.h> |
#include <process.h> |
| 44 |
|
#include <time.h> |
| 45 |
#include "buffer.h" |
#include "buffer.h" |
| 46 |
#include "ssh.h" |
#include "ssh.h" |
| 47 |
#include "crypt.h" |
#include "crypt.h" |
| 50 |
#define SSH2_DEBUG |
#define SSH2_DEBUG |
| 51 |
#endif |
#endif |
| 52 |
|
|
| 53 |
|
// SSH2 macro |
| 54 |
#define INTBLOB_LEN 20 |
#define INTBLOB_LEN 20 |
| 55 |
#define SIGBLOB_LEN (2*INTBLOB_LEN) |
#define SIGBLOB_LEN (2*INTBLOB_LEN) |
| 56 |
|
|
| 115 |
} |
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
// |
| 119 |
|
// SSH memory dump (for debug) |
| 120 |
|
// |
| 121 |
|
// (2005.3.7 yutaka) |
| 122 |
|
// |
| 123 |
|
#define MEMTAG_MAX 100 |
| 124 |
|
#define LOGDUMP "ssh2dump.log" |
| 125 |
|
#define SENDTOME "Please send '"LOGDUMP"' file to TeraTerm developer team." |
| 126 |
|
|
| 127 |
|
typedef struct memtag { |
| 128 |
|
char *name; |
| 129 |
|
char *desc; |
| 130 |
|
int len; |
| 131 |
|
char *data; |
| 132 |
|
} memtag_t; |
| 133 |
|
|
| 134 |
|
static memtag_t memtags[MEMTAG_MAX]; |
| 135 |
|
static int memtag_count = 0; |
| 136 |
|
|
| 137 |
|
/* ダンプラインをフォーマット表示する */ |
| 138 |
|
static void displine_memdump(FILE *fp, int addr, int *bytes, int byte_cnt) |
| 139 |
|
{ |
| 140 |
|
int i, c; |
| 141 |
|
|
| 142 |
|
/* 先頭のアドレス表示 */ |
| 143 |
|
fprintf(fp, "%08X : ", addr); |
| 144 |
|
|
| 145 |
|
/* バイナリ表示(4バイトごとに空白を挿入)*/ |
| 146 |
|
for (i = 0 ; i < byte_cnt ; i++) { |
| 147 |
|
if (i > 0 && i % 4 == 0) |
| 148 |
|
fprintf(fp, " "); |
| 149 |
|
|
| 150 |
|
fprintf(fp, "%02X", bytes[i]); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
/* ASCII表示部分までの空白を補う */ |
| 154 |
|
fprintf(fp, " %*s%*s", (16-byte_cnt)*2+1, " ", (16-byte_cnt+3)/4, " "); |
| 155 |
|
|
| 156 |
|
/* ASCII表示 */ |
| 157 |
|
for (i = 0 ; i < byte_cnt ; i++) { |
| 158 |
|
c = bytes[i]; |
| 159 |
|
if (c >= 0x20 && c <= 0x7f) { |
| 160 |
|
fprintf(fp, "%c", c); |
| 161 |
|
} else { |
| 162 |
|
fprintf(fp, "."); |
| 163 |
|
} |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
fprintf(fp, "\n"); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
/* ダンプルーチン */ |
| 171 |
|
static void dump_memdump(FILE *fp, char *data, int len) |
| 172 |
|
{ |
| 173 |
|
int c, addr; |
| 174 |
|
int bytes[16], *ptr; |
| 175 |
|
int byte_cnt; |
| 176 |
|
int i; |
| 177 |
|
|
| 178 |
|
addr = 0; |
| 179 |
|
byte_cnt = 0; |
| 180 |
|
ptr = bytes; |
| 181 |
|
for (i = 0 ; i < len ; i++) { |
| 182 |
|
c = data[i]; |
| 183 |
|
*ptr++ = c & 0xff; |
| 184 |
|
byte_cnt++; |
| 185 |
|
|
| 186 |
|
if (byte_cnt == 16) { |
| 187 |
|
displine_memdump(fp, addr, bytes, byte_cnt); |
| 188 |
|
|
| 189 |
|
addr += 16; |
| 190 |
|
byte_cnt = 0; |
| 191 |
|
ptr = bytes; |
| 192 |
|
} |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
if (byte_cnt > 0) { |
| 196 |
|
displine_memdump(fp, addr, bytes, byte_cnt); |
| 197 |
|
} |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
void init_memdump(void) |
| 201 |
|
{ |
| 202 |
|
int i; |
| 203 |
|
|
| 204 |
|
for (i = 0 ; i < MEMTAG_MAX ; i++) { |
| 205 |
|
memtags[i].name = NULL; |
| 206 |
|
memtags[i].desc = NULL; |
| 207 |
|
memtags[i].data = NULL; |
| 208 |
|
memtags[i].len = 0; |
| 209 |
|
} |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
void finish_memdump(void) |
| 213 |
|
{ |
| 214 |
|
int i; |
| 215 |
|
|
| 216 |
|
for (i = 0 ; i < MEMTAG_MAX ; i++) { |
| 217 |
|
free(memtags[i].name); |
| 218 |
|
free(memtags[i].desc); |
| 219 |
|
free(memtags[i].data); |
| 220 |
|
memtags[i].len = 0; |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
void save_memdump(char *filename) |
| 225 |
|
{ |
| 226 |
|
FILE *fp; |
| 227 |
|
int i; |
| 228 |
|
time_t t; |
| 229 |
|
struct tm *tm; |
| 230 |
|
|
| 231 |
|
fp = fopen(filename, "w"); |
| 232 |
|
if (fp == NULL) |
| 233 |
|
return; |
| 234 |
|
|
| 235 |
|
t = time(NULL); |
| 236 |
|
tm = localtime(&t); |
| 237 |
|
|
| 238 |
|
fprintf(fp, "<<< TeraTerm SSH2 log dump >>>\n"); |
| 239 |
|
fprintf(fp, "saved time: %04d/%02d/%02d %02d:%02d:%02d\n", |
| 240 |
|
tm->tm_year + 1900, |
| 241 |
|
tm->tm_mon + 1, |
| 242 |
|
tm->tm_mday, |
| 243 |
|
tm->tm_hour, |
| 244 |
|
tm->tm_min, |
| 245 |
|
tm->tm_sec); |
| 246 |
|
fprintf(fp, "\n"); |
| 247 |
|
|
| 248 |
|
for (i = 0 ; i < memtag_count ; i++) { |
| 249 |
|
fprintf(fp, "============================================\n"); |
| 250 |
|
fprintf(fp, "name: %s\n", memtags[i].name); |
| 251 |
|
fprintf(fp, "--------------------------------------------\n"); |
| 252 |
|
fprintf(fp, "description: %s\n", memtags[i].desc); |
| 253 |
|
fprintf(fp, "============================================\n"); |
| 254 |
|
dump_memdump(fp, memtags[i].data, memtags[i].len); |
| 255 |
|
fprintf(fp, "\n\n\n"); |
| 256 |
|
} |
| 257 |
|
|
| 258 |
|
fprintf(fp, "[EOF]\n"); |
| 259 |
|
|
| 260 |
|
fclose(fp); |
| 261 |
|
} |
| 262 |
|
|
| 263 |
|
void push_memdump(char *name, char *desc, char *data, int len) |
| 264 |
|
{ |
| 265 |
|
memtag_t *ptr; |
| 266 |
|
char *dp; |
| 267 |
|
|
| 268 |
|
dp = malloc(len); |
| 269 |
|
if (dp == NULL) |
| 270 |
|
return; |
| 271 |
|
memcpy(dp, data, len); |
| 272 |
|
|
| 273 |
|
if (memtag_count >= MEMTAG_MAX) |
| 274 |
|
return; |
| 275 |
|
|
| 276 |
|
ptr = &memtags[memtag_count]; |
| 277 |
|
memtag_count++; |
| 278 |
|
ptr->name = strdup(name); |
| 279 |
|
ptr->desc = strdup(desc); |
| 280 |
|
ptr->data = dp; |
| 281 |
|
ptr->len = len; |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
void push_bignum_memdump(char *name, char *desc, BIGNUM *bignum) |
| 285 |
|
{ |
| 286 |
|
int len; |
| 287 |
|
char *buf; |
| 288 |
|
|
| 289 |
|
len = BN_num_bytes(bignum); |
| 290 |
|
buf = malloc(len); // allocate |
| 291 |
|
if (buf == NULL) |
| 292 |
|
return; |
| 293 |
|
BN_bn2bin(bignum, buf); |
| 294 |
|
push_memdump(name, desc, buf, len); // at push_bignum_memdump() |
| 295 |
|
free(buf); // free |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
|
| 299 |
|
// |
| 300 |
|
// |
| 301 |
|
// |
| 302 |
|
|
| 303 |
|
|
| 304 |
static int get_predecryption_amount(PTInstVar pvar) |
static int get_predecryption_amount(PTInstVar pvar) |
| 305 |
{ |
{ |
| 306 |
static int small_block_decryption_sizes[] = { 5, 5, 6, 6, 8 }; |
static int small_block_decryption_sizes[] = { 5, 5, 6, 6, 8 }; |
| 1173 |
{ |
{ |
| 1174 |
static const char prefix[] = "Received server prologue string: "; |
static const char prefix[] = "Received server prologue string: "; |
| 1175 |
|
|
| 1176 |
|
// initialize SSH2 memory dump (2005.3.7 yutaka) |
| 1177 |
|
init_memdump(); |
| 1178 |
|
push_memdump("pure server ID", "プロトコル識別文字列交換開始", ID, ID_len); |
| 1179 |
|
|
| 1180 |
if (ID_len <= 0) { |
if (ID_len <= 0) { |
| 1181 |
return FALSE; |
return FALSE; |
| 1182 |
} else { |
} else { |
| 1248 |
pvar->server_version_string[--ID_len] = 0; |
pvar->server_version_string[--ID_len] = 0; |
| 1249 |
pvar->client_version_string[--TTSSH_ID_len] = 0; |
pvar->client_version_string[--TTSSH_ID_len] = 0; |
| 1250 |
|
|
| 1251 |
|
push_memdump("server ID", NULL, pvar->server_version_string, strlen(pvar->server_version_string)); |
| 1252 |
|
push_memdump("client ID", NULL, pvar->client_version_string, strlen(pvar->client_version_string)); |
| 1253 |
|
|
| 1254 |
// SSHハンドラの登録を行う |
// SSHハンドラの登録を行う |
| 1255 |
init_protocol(pvar); |
init_protocol(pvar); |
| 1256 |
|
|
| 1257 |
SSH2_dispatch_init(1); |
SSH2_dispatch_init(1); |
| 1258 |
SSH2_dispatch_add_message(SSH2_MSG_KEXINIT); |
SSH2_dispatch_add_message(SSH2_MSG_KEXINIT); |
| 1259 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.3 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.3 yutaka) |
| 1260 |
} |
} |
| 1261 |
} |
} |
| 1262 |
|
|
| 2938 |
len = pvar->ssh_state.payloadlen; |
len = pvar->ssh_state.payloadlen; |
| 2939 |
|
|
| 2940 |
//write_buffer_file(data, len); |
//write_buffer_file(data, len); |
| 2941 |
|
push_memdump("KEXINIT", "アルゴリズムリストの交換", data, len); |
| 2942 |
|
|
| 2943 |
if (offset + 20 >= len) { |
if (offset + 20 >= len) { |
| 2944 |
msg = "payload size too small @ handle_SSH2_kexinit()"; |
msg = "payload size too small @ handle_SSH2_kexinit()"; |
| 3271 |
|
|
| 3272 |
SSH2_dispatch_init(2); |
SSH2_dispatch_init(2); |
| 3273 |
SSH2_dispatch_add_message(SSH2_MSG_KEXDH_REPLY); |
SSH2_dispatch_add_message(SSH2_MSG_KEXDH_REPLY); |
| 3274 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 3275 |
|
|
| 3276 |
buffer_free(msg); |
buffer_free(msg); |
| 3277 |
return; |
return; |
| 3332 |
pvar->kexgex_bits = bits; |
pvar->kexgex_bits = bits; |
| 3333 |
pvar->kexgex_max = max; |
pvar->kexgex_max = max; |
| 3334 |
|
|
| 3335 |
|
{ |
| 3336 |
|
char tmp[128]; |
| 3337 |
|
_snprintf(tmp, sizeof(tmp), "we_need %d min %d bits %d max %d", |
| 3338 |
|
pvar->we_need, min, bits, max); |
| 3339 |
|
push_memdump("DH_GEX_REQUEST", "requested key bits", tmp, strlen(tmp)); |
| 3340 |
|
} |
| 3341 |
|
|
| 3342 |
SSH2_dispatch_init(2); |
SSH2_dispatch_init(2); |
| 3343 |
SSH2_dispatch_add_message(SSH2_MSG_KEX_DH_GEX_GROUP); |
SSH2_dispatch_add_message(SSH2_MSG_KEX_DH_GEX_GROUP); |
| 3344 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 3345 |
|
|
| 3346 |
buffer_free(msg); |
buffer_free(msg); |
| 3347 |
return; |
return; |
| 3399 |
// ここで作成したDH鍵は、あとでハッシュ計算に使うため取っておく。(2004.10.31 yutaka) |
// ここで作成したDH鍵は、あとでハッシュ計算に使うため取っておく。(2004.10.31 yutaka) |
| 3400 |
pvar->kexdh = dh; |
pvar->kexdh = dh; |
| 3401 |
|
|
| 3402 |
|
{ |
| 3403 |
|
push_bignum_memdump("DH_GEX_GROUP", "p", dh->p); |
| 3404 |
|
push_bignum_memdump("DH_GEX_GROUP", "g", dh->g); |
| 3405 |
|
push_bignum_memdump("DH_GEX_GROUP", "pub_key", dh->pub_key); |
| 3406 |
|
} |
| 3407 |
|
|
| 3408 |
SSH2_dispatch_init(2); |
SSH2_dispatch_init(2); |
| 3409 |
SSH2_dispatch_add_message(SSH2_MSG_KEX_DH_GEX_REPLY); |
SSH2_dispatch_add_message(SSH2_MSG_KEX_DH_GEX_REPLY); |
| 3410 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 3411 |
|
|
| 3412 |
buffer_free(msg); |
buffer_free(msg); |
| 3413 |
|
|
| 3624 |
OpenSSL_add_all_digests(); |
OpenSSL_add_all_digests(); |
| 3625 |
|
|
| 3626 |
if (key == NULL) { |
if (key == NULL) { |
| 3627 |
return -1; |
return -2; |
| 3628 |
} |
} |
| 3629 |
|
|
| 3630 |
ptr = signature; |
ptr = signature; |
| 3633 |
len = get_uint32_MSBfirst(ptr); |
len = get_uint32_MSBfirst(ptr); |
| 3634 |
ptr += 4; |
ptr += 4; |
| 3635 |
if (strncmp("ssh-dss", ptr, len) != 0) { |
if (strncmp("ssh-dss", ptr, len) != 0) { |
| 3636 |
return -1; |
return -3; |
| 3637 |
} |
} |
| 3638 |
ptr += len; |
ptr += len; |
| 3639 |
|
|
| 3644 |
ptr += len; |
ptr += len; |
| 3645 |
|
|
| 3646 |
if (len != SIGBLOB_LEN) { |
if (len != SIGBLOB_LEN) { |
| 3647 |
return -1; |
return -4; |
| 3648 |
} |
} |
| 3649 |
|
|
| 3650 |
/* parse signature */ |
/* parse signature */ |
| 3651 |
if ((sig = DSA_SIG_new()) == NULL) |
if ((sig = DSA_SIG_new()) == NULL) |
| 3652 |
return -1; |
return -5; |
| 3653 |
if ((sig->r = BN_new()) == NULL) |
if ((sig->r = BN_new()) == NULL) |
| 3654 |
return -1; |
return -6; |
| 3655 |
if ((sig->s = BN_new()) == NULL) |
if ((sig->s = BN_new()) == NULL) |
| 3656 |
return -1; |
return -7; |
| 3657 |
BN_bin2bn(sigblob, INTBLOB_LEN, sig->r); |
BN_bin2bn(sigblob, INTBLOB_LEN, sig->r); |
| 3658 |
BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s); |
BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s); |
| 3659 |
|
|
| 3782 |
OpenSSL_add_all_digests(); |
OpenSSL_add_all_digests(); |
| 3783 |
|
|
| 3784 |
if (key == NULL) { |
if (key == NULL) { |
| 3785 |
return -1; |
return -2; |
| 3786 |
} |
} |
| 3787 |
if (BN_num_bits(key->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) { |
if (BN_num_bits(key->n) < SSH_RSA_MINIMUM_MODULUS_SIZE) { |
| 3788 |
return -1; |
return -3; |
| 3789 |
} |
} |
| 3790 |
//debug_print(41, signature, signaturelen); |
//debug_print(41, signature, signaturelen); |
| 3791 |
ptr = signature; |
ptr = signature; |
| 3794 |
len = get_uint32_MSBfirst(ptr); |
len = get_uint32_MSBfirst(ptr); |
| 3795 |
ptr += 4; |
ptr += 4; |
| 3796 |
if (strncmp("ssh-rsa", ptr, len) != 0) { |
if (strncmp("ssh-rsa", ptr, len) != 0) { |
| 3797 |
return -1; |
return -4; |
| 3798 |
} |
} |
| 3799 |
ptr += len; |
ptr += len; |
| 3800 |
|
|
| 3813 |
/* RSA_verify expects a signature of RSA_size */ |
/* RSA_verify expects a signature of RSA_size */ |
| 3814 |
modlen = RSA_size(key); |
modlen = RSA_size(key); |
| 3815 |
if (len > modlen) { |
if (len > modlen) { |
| 3816 |
return -1; |
return -5; |
| 3817 |
|
|
| 3818 |
} else if (len < modlen) { |
} else if (len < modlen) { |
| 3819 |
u_int diff = modlen - len; |
u_int diff = modlen - len; |
| 3826 |
nid = NID_sha1; |
nid = NID_sha1; |
| 3827 |
if ((evp_md = EVP_get_digestbynid(nid)) == NULL) { |
if ((evp_md = EVP_get_digestbynid(nid)) == NULL) { |
| 3828 |
//error("ssh_rsa_verify: EVP_get_digestbynid %d failed", nid); |
//error("ssh_rsa_verify: EVP_get_digestbynid %d failed", nid); |
| 3829 |
return -1; |
return -6; |
| 3830 |
} |
} |
| 3831 |
EVP_DigestInit(&md, evp_md); |
EVP_DigestInit(&md, evp_md); |
| 3832 |
EVP_DigestUpdate(&md, data, datalen); |
EVP_DigestUpdate(&md, data, datalen); |
| 4023 |
} |
} |
| 4024 |
} |
} |
| 4025 |
|
|
|
#if 1 |
|
| 4026 |
if (key_verify(rsa, dsa, signature, siglen, hash, 20) != 1) { |
if (key_verify(rsa, dsa, signature, siglen, hash, 20) != 1) { |
| 4027 |
emsg = "key verify error @ handle_SSH2_dh_kex_reply()"; |
emsg = "key verify error @ handle_SSH2_dh_kex_reply()"; |
| 4028 |
|
save_memdump(LOGDUMP); |
| 4029 |
goto error; |
goto error; |
| 4030 |
} |
} |
|
#endif |
|
| 4031 |
|
|
| 4032 |
kex_derive_keys(pvar, pvar->we_need, hash, share_key, pvar->session_id, pvar->session_id_len); |
kex_derive_keys(pvar, pvar->we_need, hash, share_key, pvar->session_id, pvar->session_id_len); |
| 4033 |
|
|
| 4059 |
|
|
| 4060 |
SSH2_dispatch_init(3); |
SSH2_dispatch_init(3); |
| 4061 |
SSH2_dispatch_add_message(SSH2_MSG_NEWKEYS); |
SSH2_dispatch_add_message(SSH2_MSG_NEWKEYS); |
| 4062 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 4063 |
|
|
| 4064 |
BN_free(dh_server_pub); |
BN_free(dh_server_pub); |
| 4065 |
RSA_free(rsa); |
RSA_free(rsa); |
| 4167 |
BIGNUM *share_key = NULL; |
BIGNUM *share_key = NULL; |
| 4168 |
char *hash; |
char *hash; |
| 4169 |
char *emsg, emsg_tmp[1024]; // error message |
char *emsg, emsg_tmp[1024]; // error message |
| 4170 |
|
int ret; |
| 4171 |
|
|
| 4172 |
|
|
| 4173 |
// TODO: buffer overrun check |
// TODO: buffer overrun check |
| 4177 |
// パケットサイズ - (パディングサイズ+1);真のパケットサイズ |
// パケットサイズ - (パディングサイズ+1);真のパケットサイズ |
| 4178 |
len = pvar->ssh_state.payloadlen; |
len = pvar->ssh_state.payloadlen; |
| 4179 |
|
|
| 4180 |
|
push_memdump("DH_GEX_REPLY", "full dump", data, len); |
| 4181 |
|
|
| 4182 |
// for debug |
// for debug |
| 4183 |
//write_buffer_file(data, len); |
//write_buffer_file(data, len); |
| 4184 |
|
|
| 4186 |
data += 4; |
data += 4; |
| 4187 |
server_host_key_blob = data; // for hash |
server_host_key_blob = data; // for hash |
| 4188 |
|
|
| 4189 |
|
push_memdump("DH_GEX_REPLY", "server_host_key_blob", server_host_key_blob, bloblen); |
| 4190 |
|
|
| 4191 |
keynamelen = get_uint32_MSBfirst(data); |
keynamelen = get_uint32_MSBfirst(data); |
| 4192 |
if (keynamelen >= 128) { |
if (keynamelen >= 128) { |
| 4193 |
emsg = "keyname length too big @ handle_SSH2_dh_kex_reply()"; |
emsg = "keyname length too big @ handle_SSH2_dh_kex_reply()"; |
| 4198 |
key[keynamelen] = 0; |
key[keynamelen] = 0; |
| 4199 |
data += keynamelen; |
data += keynamelen; |
| 4200 |
|
|
| 4201 |
|
push_memdump("DH_GEX_REPLY", "keyname", key, keynamelen); |
| 4202 |
|
|
| 4203 |
// RSA key |
// RSA key |
| 4204 |
if (strcmp(key, "ssh-rsa") == 0) { |
if (strcmp(key, "ssh-rsa") == 0) { |
| 4205 |
rsa = RSA_new(); |
rsa = RSA_new(); |
| 4261 |
signature = data; |
signature = data; |
| 4262 |
data += siglen; |
data += siglen; |
| 4263 |
|
|
| 4264 |
|
push_memdump("DH_GEX_REPLY", "signature", signature, siglen); |
| 4265 |
|
|
| 4266 |
// check DH public value |
// check DH public value |
| 4267 |
if (!dh_pub_is_valid(pvar->kexdh, dh_server_pub)) { |
if (!dh_pub_is_valid(pvar->kexdh, dh_server_pub)) { |
| 4304 |
dh_server_pub, |
dh_server_pub, |
| 4305 |
share_key |
share_key |
| 4306 |
); |
); |
| 4307 |
|
|
| 4308 |
|
|
| 4309 |
|
{ |
| 4310 |
|
push_memdump("DH_GEX_REPLY kex_dh_gex_hash", "my_kex", buffer_ptr(pvar->my_kex), buffer_len(pvar->my_kex)); |
| 4311 |
|
push_memdump("DH_GEX_REPLY kex_dh_gex_hash", "peer_kex", buffer_ptr(pvar->peer_kex), buffer_len(pvar->peer_kex)); |
| 4312 |
|
|
| 4313 |
|
push_bignum_memdump("DH_GEX_REPLY kex_dh_gex_hash", "dh_server_pub", dh_server_pub); |
| 4314 |
|
push_bignum_memdump("DH_GEX_REPLY kex_dh_gex_hash", "share_key", share_key); |
| 4315 |
|
|
| 4316 |
|
push_memdump("DH_GEX_REPLY kex_dh_gex_hash", "hash", hash, 20); |
| 4317 |
|
} |
| 4318 |
|
|
| 4319 |
//debug_print(30, hash, 20); |
//debug_print(30, hash, 20); |
| 4320 |
//debug_print(31, pvar->client_version_string, strlen(pvar->client_version_string)); |
//debug_print(31, pvar->client_version_string, strlen(pvar->client_version_string)); |
| 4321 |
//debug_print(32, pvar->server_version_string, strlen(pvar->server_version_string)); |
//debug_print(32, pvar->server_version_string, strlen(pvar->server_version_string)); |
| 4334 |
} |
} |
| 4335 |
} |
} |
| 4336 |
|
|
| 4337 |
#if 1 |
if ((ret = key_verify(rsa, dsa, signature, siglen, hash, 20)) != 1) { |
| 4338 |
if (key_verify(rsa, dsa, signature, siglen, hash, 20) != 1) { |
_snprintf(emsg_tmp, sizeof(emsg_tmp), "key verify error(%d) @ SSH2_DH_GEX\r\n%s", ret, SENDTOME); |
| 4339 |
emsg = "key verify error @ handle_SSH2_dh_kex_reply()"; |
emsg = emsg_tmp; |
| 4340 |
|
save_memdump(LOGDUMP); |
| 4341 |
goto error; |
goto error; |
| 4342 |
} |
} |
|
#endif |
|
| 4343 |
|
|
| 4344 |
kex_derive_keys(pvar, pvar->we_need, hash, share_key, pvar->session_id, pvar->session_id_len); |
kex_derive_keys(pvar, pvar->we_need, hash, share_key, pvar->session_id, pvar->session_id_len); |
| 4345 |
|
|
| 4371 |
|
|
| 4372 |
SSH2_dispatch_init(3); |
SSH2_dispatch_init(3); |
| 4373 |
SSH2_dispatch_add_message(SSH2_MSG_NEWKEYS); |
SSH2_dispatch_add_message(SSH2_MSG_NEWKEYS); |
| 4374 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 4375 |
|
|
| 4376 |
BN_free(dh_server_pub); |
BN_free(dh_server_pub); |
| 4377 |
RSA_free(rsa); |
RSA_free(rsa); |
| 4428 |
int supported_ciphers = (1 << SSH_CIPHER_3DES_CBC | 1 << SSH_CIPHER_AES128); |
int supported_ciphers = (1 << SSH_CIPHER_3DES_CBC | 1 << SSH_CIPHER_AES128); |
| 4429 |
int type = (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA); |
int type = (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA); |
| 4430 |
|
|
| 4431 |
|
// ログ採取の終了 (2005.3.7 yutaka) |
| 4432 |
|
finish_memdump(); |
| 4433 |
|
|
| 4434 |
// finish key exchange |
// finish key exchange |
| 4435 |
pvar->key_done = 1; |
pvar->key_done = 1; |
| 4436 |
|
|
| 4491 |
|
|
| 4492 |
SSH2_dispatch_init(4); |
SSH2_dispatch_init(4); |
| 4493 |
SSH2_dispatch_add_message(SSH2_MSG_SERVICE_ACCEPT); |
SSH2_dispatch_add_message(SSH2_MSG_SERVICE_ACCEPT); |
| 4494 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 4495 |
|
|
| 4496 |
return TRUE; |
return TRUE; |
| 4497 |
} |
} |
| 4808 |
buffer_free(msg); |
buffer_free(msg); |
| 4809 |
|
|
| 4810 |
SSH2_dispatch_init(5); |
SSH2_dispatch_init(5); |
| 4811 |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workground (2005.3.5 yutaka) |
SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX: Tru64 UNIX workaround (2005.3.5 yutaka) |
| 4812 |
if (kbdint == 1) { // keyboard-interactive method |
if (kbdint == 1) { // keyboard-interactive method |
| 4813 |
SSH2_dispatch_add_message(SSH2_MSG_USERAUTH_INFO_REQUEST); |
SSH2_dispatch_add_message(SSH2_MSG_USERAUTH_INFO_REQUEST); |
| 4814 |
} |
} |
| 5380 |
|
|
| 5381 |
/* |
/* |
| 5382 |
* $Log: not supported by cvs2svn $ |
* $Log: not supported by cvs2svn $ |
| 5383 |
|
* Revision 1.18 2005/03/05 10:19:05 yutakakn |
| 5384 |
|
* Tru64 UNIX(HP-UX)向けworkaroundを追加。 |
| 5385 |
|
* |
| 5386 |
* Revision 1.17 2005/03/03 13:37:31 yutakakn |
* Revision 1.17 2005/03/03 13:37:31 yutakakn |
| 5387 |
* Tru64 UNIX(HP-UX)向けworkaroundを追加。 |
* Tru64 UNIX(HP-UX)向けworkaroundを追加。 |
| 5388 |
* KEXINIT時にSSH2_MSG_IGNOREを受信可能とした。 |
* KEXINIT時にSSH2_MSG_IGNOREを受信可能とした。 |