• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision10387 (tree)
Time2022-11-27 22:51:05
Authornmaya

Log Message

公開鍵認証(RSA鍵)の署名に使われるダイジェスト方式を About TTSSH ダイアログに表示するようにした

Change Summary

Incremental Difference

--- branches/4-stable/ttssh2/ttxssh/auth.c (revision 10386)
+++ branches/4-stable/ttssh2/ttxssh/auth.c (revision 10387)
@@ -1761,22 +1761,25 @@
17611761 strncpy_s(dest, len, "None", _TRUNCATE);
17621762 } else if (pvar->auth_state.cur_cred.method != SSH_AUTH_NONE) {
17631763 if (SSHv1(pvar)) {
1764- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1764+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', %s authentication");
17651765 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
17661766 pvar->auth_state.user,
17671767 get_auth_method_name(pvar->auth_state.cur_cred.method));
17681768
17691769 if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1770- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1770+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, ", %s key");
17711771 _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
17721772 "RSA");
17731773 strncat_s(dest, len, buf, _TRUNCATE);
17741774 }
17751775 else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
1776- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1776+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, ", %s key");
17771777 _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
17781778 "RSA");
17791779 strncat_s(dest, len, buf, _TRUNCATE);
1780+
1781+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, " (from Pageant)");
1782+ strncat_s(dest, len, buf, _TRUNCATE);
17801783 }
17811784 } else {
17821785 // SSH2:認証メソッドの判別 (2004.12.23 yutaka)
@@ -1789,28 +1792,45 @@
17891792 } else {
17901793 method = get_auth_method_name(pvar->auth_state.cur_cred.method);
17911794 }
1792- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1795+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', %s authentication");
17931796 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
17941797 pvar->auth_state.user, method);
17951798 }
17961799 else if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1800+ ssh_keyalgo pubkey_algo;
1801+ char *digest_name;
1802+
17971803 method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1798- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1804+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', %s authentication");
17991805 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
18001806 pvar->auth_state.user,
18011807 get_auth_method_name(pvar->auth_state.cur_cred.method));
18021808
1803- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1804- _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1805- ssh_key_type(pvar->auth_state.cur_cred.key_pair->type));
1806- strncat_s(dest, len, buf, _TRUNCATE);
1809+ pubkey_algo = choose_SSH2_keysign_algorithm(pvar, pvar->auth_state.cur_cred.key_pair->type);
1810+ digest_name = get_ssh2_hostkey_algorithm_digest_name(pubkey_algo);
1811+ if (strlen(digest_name) == 0) {
1812+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, ", %s key");
1813+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1814+ ssh_key_type(pvar->auth_state.cur_cred.key_pair->type));
1815+ strncat_s(dest, len, buf, _TRUNCATE);
1816+ }
1817+ else {
1818+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, ", %s key with %s");
1819+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1820+ ssh_key_type(pvar->auth_state.cur_cred.key_pair->type),
1821+ digest_name);
1822+ strncat_s(dest, len, buf, _TRUNCATE);
1823+ }
18071824 }
18081825 else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
18091826 int key_len = get_uint32_MSBfirst(pvar->pageant_curkey + 4);
18101827 char *s = (char *)malloc(key_len+1);
1828+ ssh_keytype keytype;
1829+ ssh_keyalgo pubkey_algo;
1830+ char *digest_name;
18111831
18121832 method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1813- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1833+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', %s authentication");
18141834 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
18151835 pvar->auth_state.user,
18161836 get_auth_method_name(pvar->auth_state.cur_cred.method));
@@ -1817,9 +1837,24 @@
18171837
18181838 memcpy(s, pvar->pageant_curkey+4+4, key_len);
18191839 s[key_len] = '\0';
1820- UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1821- _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1822- ssh_key_type(get_hostkey_type_from_name(s)));
1840+ keytype = get_hostkey_type_from_name(s);
1841+ pubkey_algo = choose_SSH2_keysign_algorithm(pvar, keytype);
1842+ digest_name = get_ssh2_hostkey_algorithm_digest_name(pubkey_algo);
1843+ if (strlen(digest_name) == 0) {
1844+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, ", %s key");
1845+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1846+ ssh_key_type(get_hostkey_type_from_name(s)));
1847+ strncat_s(dest, len, buf, _TRUNCATE);
1848+ }
1849+ else {
1850+ UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, ", %s key with %s");
1851+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1852+ ssh_key_type(get_hostkey_type_from_name(s)),
1853+ digest_name);
1854+ strncat_s(dest, len, buf, _TRUNCATE);
1855+ }
1856+
1857+ _snprintf_s(buf, sizeof(buf), _TRUNCATE, " (from Pageant)");
18231858 strncat_s(dest, len, buf, _TRUNCATE);
18241859
18251860 free(s);
--- branches/4-stable/ttssh2/ttxssh/hostkey.c (revision 10386)
+++ branches/4-stable/ttssh2/ttxssh/hostkey.c (revision 10387)
@@ -345,3 +345,19 @@
345345
346346 normalize_generic_order(buf, default_strings, NUM_ELEM(default_strings));
347347 }
348+
349+/*
350+ * ssh_keyalgo から、鍵に対して標準ではないダイジェスト方式名を返す
351+ * 今のところ rsa-sha2-256, rsa-sha2-512 のときだけ "SHA-256", "SHA-512" を返す
352+ * About ダイアログで、非標準のダイジェスト方式のときだけ表示するため
353+ */
354+char* get_ssh2_hostkey_algorithm_digest_name(ssh_keyalgo algo)
355+{
356+ switch (algo) {
357+ case KEY_ALGO_RSASHA256:
358+ return "SHA-256";
359+ case KEY_ALGO_RSASHA512:
360+ return "SHA-512";
361+ }
362+ return "";
363+}
--- branches/4-stable/ttssh2/ttxssh/hostkey.h (revision 10386)
+++ branches/4-stable/ttssh2/ttxssh/hostkey.h (revision 10387)
@@ -118,5 +118,6 @@
118118 ssh_keyalgo choose_SSH2_host_key_algorithm(char *server_proposal, char *my_proposal);
119119 ssh_keyalgo choose_SSH2_keysign_algorithm(PTInstVar pvar, ssh_keytype keytype);
120120 void SSH2_update_host_key_myproposal(PTInstVar pvar);
121+char* get_ssh2_hostkey_algorithm_digest_name(ssh_keyalgo algo);
121122
122123 #endif /* SSHCMAC_H */
Show on old repository browser