| 3236 |
#endif |
#endif |
| 3237 |
} |
} |
| 3238 |
|
|
|
// クライアントからサーバへの提案事項 |
|
|
#ifdef SSH2_DEBUG |
|
|
static char *myproposal[PROPOSAL_MAX] = { |
|
|
// "diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1", |
|
|
"diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1", |
|
|
"ssh-rsa,ssh-dss", |
|
|
// "ssh-dss,ssh-rsa", |
|
|
"3des-cbc,aes128-cbc", |
|
|
"3des-cbc,aes128-cbc", |
|
|
"hmac-md5,hmac-sha1", |
|
|
"hmac-md5,hmac-sha1", |
|
|
// "hmac-sha1,hmac-md5", |
|
|
// "hmac-sha1,hmac-md5", |
|
|
// "hmac-sha1", |
|
|
// "hmac-sha1", |
|
|
KEX_DEFAULT_COMP, |
|
|
KEX_DEFAULT_COMP, |
|
|
"", |
|
|
"", |
|
|
}; |
|
|
#else |
|
|
static char *myproposal[PROPOSAL_MAX] = { |
|
|
"diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1", |
|
|
"ssh-rsa,ssh-dss", |
|
|
"3des-cbc,aes128-cbc", |
|
|
"3des-cbc,aes128-cbc", |
|
|
"hmac-sha1,hmac-md5", |
|
|
"hmac-sha1,hmac-md5", |
|
|
KEX_DEFAULT_COMP, |
|
|
KEX_DEFAULT_COMP, |
|
|
"", |
|
|
"", |
|
|
}; |
|
|
#endif |
|
|
|
|
|
|
|
|
typedef struct ssh2_cipher { |
|
|
SSHCipher cipher; |
|
|
char *name; |
|
|
int block_size; |
|
|
int key_len; |
|
|
const EVP_CIPHER *(*func)(void); |
|
|
} ssh2_cipher_t; |
|
|
|
|
|
ssh2_cipher_t ssh2_ciphers[] = { |
|
|
{SSH_CIPHER_3DES_CBC, "3des-cbc", 8, 24, EVP_des_ede3_cbc}, |
|
|
{SSH_CIPHER_AES128, "aes128-cbc", 16, 16, EVP_aes_128_cbc}, |
|
|
{SSH_CIPHER_NONE, NULL, 0, 0, NULL}, |
|
|
}; |
|
|
|
|
|
|
|
|
typedef struct ssh2_mac { |
|
|
char *name; |
|
|
const EVP_MD *(*func)(void); |
|
|
int truncatebits; |
|
|
} ssh2_mac_t; |
|
|
|
|
|
ssh2_mac_t ssh2_macs[] = { |
|
|
{"hmac-sha1", EVP_sha1, 0}, |
|
|
{"hmac-md5", EVP_md5, 0}, |
|
|
{NULL, NULL, 0}, |
|
|
}; |
|
|
|
|
|
|
|
|
char *ssh_comp[] = { |
|
|
"none", |
|
|
"zlib", |
|
|
"zlib@openssh.com", |
|
|
}; |
|
|
|
|
| 3239 |
static Newkeys current_keys[MODE_MAX]; |
static Newkeys current_keys[MODE_MAX]; |
| 3240 |
|
|
| 3241 |
|
|
| 3246 |
// general |
// general |
| 3247 |
// |
// |
| 3248 |
|
|
| 3249 |
static int get_cipher_block_size(SSHCipher cipher) |
int get_cipher_block_size(SSHCipher cipher) |
| 3250 |
{ |
{ |
| 3251 |
ssh2_cipher_t *ptr = ssh2_ciphers; |
ssh2_cipher_t *ptr = ssh2_ciphers; |
| 3252 |
int val = 0; |
int val = 0; |
| 3261 |
return (val); |
return (val); |
| 3262 |
} |
} |
| 3263 |
|
|
| 3264 |
static int get_cipher_key_len(SSHCipher cipher) |
int get_cipher_key_len(SSHCipher cipher) |
| 3265 |
{ |
{ |
| 3266 |
ssh2_cipher_t *ptr = ssh2_ciphers; |
ssh2_cipher_t *ptr = ssh2_ciphers; |
| 3267 |
int val = 0; |
int val = 0; |
| 3291 |
return buf; |
return buf; |
| 3292 |
} |
} |
| 3293 |
|
|
| 3294 |
|
const EVP_CIPHER * (*get_cipher_EVP_CIPHER(SSHCipher cipher))(void) |
| 3295 |
|
{ |
| 3296 |
|
ssh2_cipher_t *ptr = ssh2_ciphers; |
| 3297 |
|
const EVP_CIPHER *(*type)(void); |
| 3298 |
|
|
| 3299 |
|
type = EVP_enc_null; |
| 3300 |
|
|
| 3301 |
|
while (ptr->name != NULL) { |
| 3302 |
|
if (cipher == ptr->cipher) { |
| 3303 |
|
type = ptr->func; |
| 3304 |
|
break; |
| 3305 |
|
} |
| 3306 |
|
ptr++; |
| 3307 |
|
} |
| 3308 |
|
return type; |
| 3309 |
|
} |
| 3310 |
|
|
| 3311 |
#if 0 |
#if 0 |
| 3312 |
static int get_mac_index(char *name) |
static int get_mac_index(char *name) |
| 3313 |
{ |
{ |
| 3376 |
if (cipher == SSH_CIPHER_AES128) { |
if (cipher == SSH_CIPHER_AES128) { |
| 3377 |
strncat_s(buf, sizeof(buf), "aes128-cbc,", _TRUNCATE); |
strncat_s(buf, sizeof(buf), "aes128-cbc,", _TRUNCATE); |
| 3378 |
} |
} |
| 3379 |
if (cipher == SSH_CIPHER_3DES_CBC) { |
else if (cipher == SSH_CIPHER_3DES_CBC) { |
| 3380 |
strncat_s(buf, sizeof(buf), "3des-cbc,", _TRUNCATE); |
strncat_s(buf, sizeof(buf), "3des-cbc,", _TRUNCATE); |
| 3381 |
} |
} |
| 3382 |
|
else if (cipher == SSH_CIPHER_AES256) { |
| 3383 |
|
strncat_s(buf, sizeof(buf), "aes256-cbc,", _TRUNCATE); |
| 3384 |
|
} |
| 3385 |
|
#ifdef SSH2_BLOWFISH |
| 3386 |
|
else if (cipher == SSH_CIPHER_BLOWFISH) { |
| 3387 |
|
strncat_s(buf, sizeof(buf), "blowfish-cbc,", _TRUNCATE); |
| 3388 |
|
} |
| 3389 |
|
#endif |
| 3390 |
} |
} |
| 3391 |
if (buf[0] != '\0') { |
if (buf[0] != '\0') { |
| 3392 |
len = strlen(buf); |
len = strlen(buf); |
| 3482 |
} |
} |
| 3483 |
if (strstr(ptr, "3des-cbc")) { |
if (strstr(ptr, "3des-cbc")) { |
| 3484 |
cipher = SSH_CIPHER_3DES_CBC; |
cipher = SSH_CIPHER_3DES_CBC; |
|
|
|
| 3485 |
} else if (strstr(ptr, "aes128-cbc")) { |
} else if (strstr(ptr, "aes128-cbc")) { |
| 3486 |
cipher = SSH_CIPHER_AES128; |
cipher = SSH_CIPHER_AES128; |
| 3487 |
|
} else if (strstr(ptr, "aes256-cbc")) { |
| 3488 |
|
cipher = SSH_CIPHER_AES256; |
| 3489 |
|
#ifdef SSH2_BLOWFISH |
| 3490 |
|
} else if (strstr(ptr, "blowfish-cbc")) { |
| 3491 |
|
cipher = SSH_CIPHER_BLOWFISH; |
| 3492 |
|
#endif |
| 3493 |
} |
} |
| 3494 |
|
|
| 3495 |
return (cipher); |
return (cipher); |
| 3608 |
else |
else |
| 3609 |
ctos = 0; |
ctos = 0; |
| 3610 |
|
|
| 3611 |
val = current_keys[mode].enc.key_len; |
val = current_keys[mode].enc.key_len; |
| 3612 |
if (need < val) |
if (need < val) |
| 3613 |
need = val; |
need = val; |
| 3614 |
|
|
| 3615 |
val = current_keys[mode].enc.block_size; |
val = current_keys[mode].enc.block_size; |
| 3616 |
if (need < val) |
if (need < val) |
| 3617 |
need = val; |
need = val; |
| 3618 |
|
|
| 5669 |
|
|
| 5670 |
static BOOL handle_SSH2_newkeys(PTInstVar pvar) |
static BOOL handle_SSH2_newkeys(PTInstVar pvar) |
| 5671 |
{ |
{ |
| 5672 |
int supported_ciphers = (1 << SSH_CIPHER_3DES_CBC | 1 << SSH_CIPHER_AES128); |
int supported_ciphers = (1 << SSH_CIPHER_3DES_CBC | 1 << SSH_CIPHER_AES128 |
| 5673 |
|
| 1 << SSH_CIPHER_AES256 |
| 5674 |
|
#ifdef SSH2_BLOWFISH |
| 5675 |
|
| 1 << SSH_CIPHER_BLOWFISH |
| 5676 |
|
#endif |
| 5677 |
|
); |
| 5678 |
int type = (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA) | (1 << SSH_AUTH_TIS); |
int type = (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA) | (1 << SSH_AUTH_TIS); |
| 5679 |
|
|
| 5680 |
notify_verbose_message(pvar, "SSH2_MSG_NEWKEYS is received(DH key generation is completed).", LOG_LEVEL_VERBOSE); |
notify_verbose_message(pvar, "SSH2_MSG_NEWKEYS is received(DH key generation is completed).", LOG_LEVEL_VERBOSE); |