| 3165 |
UTIL_get_lang_msg("DLG_ABOUT_MAC_INFO", pvar, |
UTIL_get_lang_msg("DLG_ABOUT_MAC_INFO", pvar, |
| 3166 |
"%s to server, %s from server"); |
"%s to server, %s from server"); |
| 3167 |
_snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, |
_snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, |
| 3168 |
get_ssh2_mac_name(pvar->ctos_hmac), |
get_ssh2_mac_name(pvar->macs[MODE_OUT]), |
| 3169 |
get_ssh2_mac_name(pvar->stoc_hmac)); |
get_ssh2_mac_name(pvar->macs[MODE_IN])); |
| 3170 |
} |
} |
| 3171 |
|
|
| 3172 |
void SSH_end(PTInstVar pvar) |
void SSH_end(PTInstVar pvar) |
| 4216 |
return EVP_md_null(); |
return EVP_md_null(); |
| 4217 |
} |
} |
| 4218 |
|
|
| 4219 |
char* get_ssh2_mac_name(hmac_type type) |
SSH2Mac *get_ssh2_mac(SSH2MacId id) |
| 4220 |
{ |
{ |
| 4221 |
ssh2_mac_t *ptr = ssh2_macs; |
SSH2Mac *ptr = ssh2_macs; |
| 4222 |
|
|
| 4223 |
while (ptr->name != NULL) { |
while (ptr->name != NULL) { |
| 4224 |
if (type == ptr->type) { |
if (ptr->id == id) { |
| 4225 |
return ptr->name; |
return ptr; |
| 4226 |
} |
} |
| 4227 |
ptr++; |
ptr++; |
| 4228 |
} |
} |
| 4229 |
|
|
| 4230 |
// not found. |
return NULL; |
|
return "unknown"; |
|
| 4231 |
} |
} |
| 4232 |
|
|
| 4233 |
const EVP_MD* get_ssh2_mac_EVP_MD(hmac_type type) |
char* get_ssh2_mac_name(SSH2Mac *mac) |
| 4234 |
{ |
{ |
| 4235 |
ssh2_mac_t *ptr = ssh2_macs; |
if (mac) { |
| 4236 |
|
return mac->name; |
| 4237 |
while (ptr->name != NULL) { |
} |
| 4238 |
if (type == ptr->type) { |
else { |
| 4239 |
return ptr->evp_md(); |
return "unknown"; |
|
} |
|
|
ptr++; |
|
| 4240 |
} |
} |
|
|
|
|
// not found. |
|
|
return EVP_md_null(); |
|
| 4241 |
} |
} |
| 4242 |
|
|
| 4243 |
int get_ssh2_mac_truncatebits(hmac_type type) |
char* get_ssh2_mac_name_by_id(SSH2MacId id) |
| 4244 |
{ |
{ |
| 4245 |
ssh2_mac_t *ptr = ssh2_macs; |
return get_ssh2_mac_name(get_ssh2_mac(id)); |
| 4246 |
|
} |
| 4247 |
|
|
| 4248 |
while (ptr->name != NULL) { |
const EVP_MD* get_ssh2_mac_EVP_MD(SSH2Mac *mac) |
| 4249 |
if (type == ptr->type) { |
{ |
| 4250 |
return ptr->truncatebits; |
if (mac) { |
| 4251 |
} |
return mac->evp_md(); |
| 4252 |
ptr++; |
} |
| 4253 |
|
else { |
| 4254 |
|
return EVP_md_null(); |
| 4255 |
} |
} |
|
|
|
|
// not found. |
|
|
return 0; |
|
| 4256 |
} |
} |
| 4257 |
|
|
| 4258 |
int get_ssh2_mac_etm(hmac_type type) |
int get_ssh2_mac_truncatebits(SSH2Mac *mac) |
| 4259 |
{ |
{ |
| 4260 |
ssh2_mac_t *ptr = ssh2_macs; |
if (mac) { |
| 4261 |
|
return mac->truncatebits; |
|
while (ptr->name != NULL) { |
|
|
if (type == ptr->type) { |
|
|
return ptr->etm; |
|
|
} |
|
|
ptr++; |
|
| 4262 |
} |
} |
| 4263 |
|
else { |
| 4264 |
|
return 0; |
| 4265 |
|
} |
| 4266 |
|
} |
| 4267 |
|
|
| 4268 |
// not found |
int get_ssh2_mac_etm(SSH2Mac *mac) |
| 4269 |
return 0; |
{ |
| 4270 |
|
if (mac) { |
| 4271 |
|
return mac->etm; |
| 4272 |
|
} |
| 4273 |
|
else { |
| 4274 |
|
return 0; |
| 4275 |
|
} |
| 4276 |
} |
} |
| 4277 |
|
|
| 4278 |
char* get_ssh2_comp_name(compression_type type) |
char* get_ssh2_comp_name(compression_type type) |
| 4579 |
index = pvar->settings.MacOrder[i] - '0'; |
index = pvar->settings.MacOrder[i] - '0'; |
| 4580 |
if (index == HMAC_NONE) // disabled line |
if (index == HMAC_NONE) // disabled line |
| 4581 |
break; |
break; |
| 4582 |
strncat_s(buf, sizeof(buf), get_ssh2_mac_name(index), _TRUNCATE); |
strncat_s(buf, sizeof(buf), get_ssh2_mac_name_by_id(index), _TRUNCATE); |
| 4583 |
strncat_s(buf, sizeof(buf), ",", _TRUNCATE); |
strncat_s(buf, sizeof(buf), ",", _TRUNCATE); |
| 4584 |
} |
} |
| 4585 |
len = strlen(buf); |
len = strlen(buf); |
| 4729 |
} |
} |
| 4730 |
|
|
| 4731 |
|
|
| 4732 |
static hmac_type choose_SSH2_hmac_algorithm(char *server_proposal, char *my_proposal) |
static SSH2Mac *choose_SSH2_mac_algorithm(char *server_proposal, char *my_proposal) |
| 4733 |
{ |
{ |
|
hmac_type type = HMAC_UNKNOWN; |
|
| 4734 |
char str_hmac[64]; |
char str_hmac[64]; |
| 4735 |
ssh2_mac_t *ptr = ssh2_macs; |
SSH2Mac *ptr = ssh2_macs; |
| 4736 |
|
|
| 4737 |
choose_SSH2_proposal(server_proposal, my_proposal, str_hmac, sizeof(str_hmac)); |
choose_SSH2_proposal(server_proposal, my_proposal, str_hmac, sizeof(str_hmac)); |
| 4738 |
|
|
| 4739 |
while (ptr->name != NULL) { |
while (ptr->name != NULL) { |
| 4740 |
if (strcmp(ptr->name, str_hmac) == 0) { |
if (strcmp(ptr->name, str_hmac) == 0) { |
| 4741 |
type = ptr->type; |
return ptr; |
|
break; |
|
| 4742 |
} |
} |
| 4743 |
ptr++; |
ptr++; |
| 4744 |
} |
} |
| 4745 |
|
|
| 4746 |
return (type); |
return (NULL); |
| 4747 |
} |
} |
| 4748 |
|
|
| 4749 |
|
|
| 4780 |
unsigned int need = 0; |
unsigned int need = 0; |
| 4781 |
const EVP_MD *md; |
const EVP_MD *md; |
| 4782 |
SSH2Cipher *cipher; |
SSH2Cipher *cipher; |
| 4783 |
hmac_type mac; |
SSH2Mac *mac; |
| 4784 |
|
|
| 4785 |
for (mode = 0; mode < MODE_MAX; mode++) { |
for (mode = 0; mode < MODE_MAX; mode++) { |
|
if (mode == MODE_OUT) { |
|
|
mac = pvar->ctos_hmac; |
|
|
} |
|
|
else { |
|
|
mac = pvar->stoc_hmac; |
|
|
} |
|
|
|
|
| 4786 |
cipher = pvar->ciphers[mode]; |
cipher = pvar->ciphers[mode]; |
| 4787 |
|
mac = pvar->macs[mode]; |
| 4788 |
|
|
| 4789 |
// current_keys[]に設定しておいて、あとで pvar->ssh2_keys[] へコピーする。 |
// current_keys[]に設定しておいて、あとで pvar->ssh2_keys[] へコピーする。 |
| 4790 |
md = get_ssh2_mac_EVP_MD(mac); |
md = get_ssh2_mac_EVP_MD(mac); |
| 4808 |
// 現時点ではMACはdisable |
// 現時点ではMACはdisable |
| 4809 |
pvar->ssh2_keys[mode].mac.enabled = 0; |
pvar->ssh2_keys[mode].mac.enabled = 0; |
| 4810 |
pvar->ssh2_keys[mode].comp.enabled = 0; // (2005.7.9 yutaka) |
pvar->ssh2_keys[mode].comp.enabled = 0; // (2005.7.9 yutaka) |
|
} |
|
| 4811 |
|
|
|
for (mode = 0; mode < MODE_MAX; mode++) { |
|
| 4812 |
need = max(need, current_keys[mode].enc.key_len); |
need = max(need, current_keys[mode].enc.key_len); |
| 4813 |
need = max(need, current_keys[mode].enc.block_size); |
need = max(need, current_keys[mode].enc.block_size); |
| 4814 |
need = max(need, current_keys[mode].enc.iv_len); |
need = max(need, current_keys[mode].enc.iv_len); |
| 4980 |
|
|
| 4981 |
logprintf(LOG_LEVEL_VERBOSE, "server proposal: MAC algorithm client to server: %s", buf); |
logprintf(LOG_LEVEL_VERBOSE, "server proposal: MAC algorithm client to server: %s", buf); |
| 4982 |
|
|
| 4983 |
pvar->ctos_hmac = choose_SSH2_hmac_algorithm(buf, myproposal[PROPOSAL_MAC_ALGS_CTOS]); |
pvar->macs[MODE_OUT] = choose_SSH2_mac_algorithm(buf, myproposal[PROPOSAL_MAC_ALGS_CTOS]); |
| 4984 |
if (pvar->ctos_hmac == HMAC_UNKNOWN) { // not match |
if (pvar->macs[MODE_OUT] == NULL) { // not match |
| 4985 |
strncpy_s(tmp, sizeof(tmp), "unknown MAC algorithm: ", _TRUNCATE); |
strncpy_s(tmp, sizeof(tmp), "unknown MAC algorithm: ", _TRUNCATE); |
| 4986 |
strncat_s(tmp, sizeof(tmp), buf, _TRUNCATE); |
strncat_s(tmp, sizeof(tmp), buf, _TRUNCATE); |
| 4987 |
msg = tmp; |
msg = tmp; |
| 4999 |
|
|
| 5000 |
logprintf(LOG_LEVEL_VERBOSE, "server proposal: MAC algorithm server to client: %s", buf); |
logprintf(LOG_LEVEL_VERBOSE, "server proposal: MAC algorithm server to client: %s", buf); |
| 5001 |
|
|
| 5002 |
pvar->stoc_hmac = choose_SSH2_hmac_algorithm(buf, myproposal[PROPOSAL_MAC_ALGS_STOC]); |
pvar->macs[MODE_IN] = choose_SSH2_mac_algorithm(buf, myproposal[PROPOSAL_MAC_ALGS_STOC]); |
| 5003 |
if (pvar->stoc_hmac == HMAC_UNKNOWN) { // not match |
if (pvar->macs[MODE_IN] == NULL) { // not match |
| 5004 |
strncpy_s(tmp, sizeof(tmp), "unknown MAC algorithm: ", _TRUNCATE); |
strncpy_s(tmp, sizeof(tmp), "unknown MAC algorithm: ", _TRUNCATE); |
| 5005 |
strncat_s(tmp, sizeof(tmp), buf, _TRUNCATE); |
strncat_s(tmp, sizeof(tmp), buf, _TRUNCATE); |
| 5006 |
msg = tmp; |
msg = tmp; |
| 5067 |
|
|
| 5068 |
logprintf(LOG_LEVEL_VERBOSE, |
logprintf(LOG_LEVEL_VERBOSE, |
| 5069 |
"MAC algorithm client to server: %s", |
"MAC algorithm client to server: %s", |
| 5070 |
get_ssh2_mac_name(pvar->ctos_hmac)); |
get_ssh2_mac_name(pvar->macs[MODE_OUT])); |
| 5071 |
|
|
| 5072 |
logprintf(LOG_LEVEL_VERBOSE, |
logprintf(LOG_LEVEL_VERBOSE, |
| 5073 |
"MAC algorithm server to client: %s", |
"MAC algorithm server to client: %s", |
| 5074 |
get_ssh2_mac_name(pvar->stoc_hmac)); |
get_ssh2_mac_name(pvar->macs[MODE_IN])); |
| 5075 |
|
|
| 5076 |
logprintf(LOG_LEVEL_VERBOSE, |
logprintf(LOG_LEVEL_VERBOSE, |
| 5077 |
"compression algorithm client to server: %s", |
"compression algorithm client to server: %s", |