| 1849 |
free(ctx); |
free(ctx); |
| 1850 |
} |
} |
| 1851 |
|
|
| 1852 |
|
|
| 1853 |
|
// 許可されたホスト鍵アルゴリズムかをチェックする。 |
| 1854 |
|
// |
| 1855 |
|
// return 1: matched |
| 1856 |
|
// 0: not matched |
| 1857 |
|
// |
| 1858 |
|
static int check_hostkey_algorithm(PTInstVar pvar, Key *key) |
| 1859 |
|
{ |
| 1860 |
|
int ret = 0; |
| 1861 |
|
int i, index; |
| 1862 |
|
|
| 1863 |
|
for (i = 0; pvar->settings.HostKeyOrder[i] != 0; i++) { |
| 1864 |
|
index = pvar->settings.HostKeyOrder[i] - '0'; |
| 1865 |
|
if (index == KEY_NONE) // disabled line |
| 1866 |
|
break; |
| 1867 |
|
|
| 1868 |
|
if (strcmp(get_sshname_from_key(key), get_ssh_keytype_name(index)) == 0) |
| 1869 |
|
return 1; |
| 1870 |
|
} |
| 1871 |
|
|
| 1872 |
|
return (ret); |
| 1873 |
|
} |
| 1874 |
|
|
| 1875 |
// |
// |
| 1876 |
// SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support) |
// SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support) |
| 1877 |
// |
// |
| 1915 |
blob = buffer_get_string_msg(b, &len); |
blob = buffer_get_string_msg(b, &len); |
| 1916 |
key = key_from_blob(blob, len); |
key = key_from_blob(blob, len); |
| 1917 |
if (key == NULL) { |
if (key == NULL) { |
| 1918 |
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "Not found key into blob %p (%d)", blob, len); |
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "Not found host key into blob %p (%d)", blob, len); |
| 1919 |
notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE); |
notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE); |
| 1920 |
goto error; |
goto error; |
| 1921 |
} |
} |
| 1923 |
blob = NULL; |
blob = NULL; |
| 1924 |
|
|
| 1925 |
fp = key_fingerprint(key, SSH_FP_HEX); |
fp = key_fingerprint(key, SSH_FP_HEX); |
| 1926 |
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "SSH2_MSG_GLOBAL_REQUEST: received %s key %s", |
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "Received %s host key %s", |
| 1927 |
get_sshname_from_key(key), fp); |
get_sshname_from_key(key), fp); |
| 1928 |
notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE); |
notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE); |
| 1929 |
free(fp); |
free(fp); |
| 1930 |
|
|
| 1931 |
|
// 許可されたホストキーアルゴリズムかをチェックする。 |
| 1932 |
|
if (check_hostkey_algorithm(pvar, key) == 0) { |
| 1933 |
|
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "%s host key is not permitted by ts.HostKeyOrder", |
| 1934 |
|
get_sshname_from_key(key)); |
| 1935 |
|
notify_verbose_message(pvar, msg, LOG_LEVEL_VERBOSE); |
| 1936 |
|
continue; |
| 1937 |
|
} |
| 1938 |
|
|
| 1939 |
|
|
| 1940 |
} |
} |
| 1941 |
|
|
| 1942 |
success = 1; |
success = 1; |