| 48 |
#define DEATTACK_DETECTED 1 |
#define DEATTACK_DETECTED 1 |
| 49 |
|
|
| 50 |
/* |
/* |
| 51 |
* $Id: crypt.c,v 1.8 2007-06-06 14:10:12 maya Exp $ Cryptographic attack |
* $Id: crypt.c,v 1.9 2007-08-08 16:04:08 maya Exp $ Cryptographic attack |
| 52 |
* detector for ssh - source code (C)1998 CORE-SDI, Buenos Aires Argentina |
* detector for ssh - source code (C)1998 CORE-SDI, Buenos Aires Argentina |
| 53 |
* Ariel Futoransky(futo@core-sdi.com) <http://www.core-sdi.com> |
* Ariel Futoransky(futo@core-sdi.com) <http://www.core-sdi.com> |
| 54 |
*/ |
*/ |
| 231 |
if (bytes % block_size) { |
if (bytes % block_size) { |
| 232 |
char tmp[80]; |
char tmp[80]; |
| 233 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 234 |
strcpy(pvar->ts->UIMsg, "AES128 encrypt error(1): bytes %d (%d)"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "AES128 encrypt error(1): bytes %d (%d)", _TRUNCATE); |
| 235 |
UTIL_get_lang_msg("MSG_AES128_ENCRYPT_ERROR1", pvar); |
UTIL_get_lang_msg("MSG_AES128_ENCRYPT_ERROR1", pvar); |
| 236 |
_snprintf(tmp, sizeof(tmp), pvar->ts->UIMsg, bytes, block_size); |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, |
| 237 |
|
pvar->ts->UIMsg, bytes, block_size); |
| 238 |
#else |
#else |
| 239 |
_snprintf(tmp, sizeof(tmp), "AES128 encrypt error(1): bytes %d (%d)", bytes, block_size); |
_snprintf(tmp, sizeof(tmp), "AES128 encrypt error(1): bytes %d (%d)", bytes, block_size); |
| 240 |
#endif |
#endif |
| 245 |
if (EVP_Cipher(&pvar->evpcip[MODE_OUT], newbuf, buf, bytes) == 0) { |
if (EVP_Cipher(&pvar->evpcip[MODE_OUT], newbuf, buf, bytes) == 0) { |
| 246 |
// TODO: failure |
// TODO: failure |
| 247 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 248 |
strcpy(pvar->ts->UIMsg, "AES128 encrypt error(1): bytes %d (%d)"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "AES128 encrypt error(1): bytes %d (%d)", _TRUNCATE); |
| 249 |
UTIL_get_lang_msg("MSG_AES128_ENCRYPT_ERROR2", pvar); |
UTIL_get_lang_msg("MSG_AES128_ENCRYPT_ERROR2", pvar); |
| 250 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 251 |
#else |
#else |
| 286 |
if (bytes % block_size) { |
if (bytes % block_size) { |
| 287 |
char tmp[80]; |
char tmp[80]; |
| 288 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 289 |
strcpy(pvar->ts->UIMsg, "AES128 decrypt error(1): bytes %d (%d)"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "AES128 decrypt error(1): bytes %d (%d)", _TRUNCATE); |
| 290 |
UTIL_get_lang_msg("MSG_AES128_DECRYPT_ERROR1", pvar); |
UTIL_get_lang_msg("MSG_AES128_DECRYPT_ERROR1", pvar); |
| 291 |
_snprintf(tmp, sizeof(tmp), pvar->ts->UIMsg, bytes, block_size); |
_snprintf_s(tmp, sizeof(tmp), _TRUNCATE, pvar->ts->UIMsg, bytes, block_size); |
| 292 |
#else |
#else |
| 293 |
_snprintf(tmp, sizeof(tmp), "AES128 decrypt error(1): bytes %d (%d)", bytes, block_size); |
_snprintf(tmp, sizeof(tmp), "AES128 decrypt error(1): bytes %d (%d)", bytes, block_size); |
| 294 |
#endif |
#endif |
| 299 |
if (EVP_Cipher(&pvar->evpcip[MODE_IN], newbuf, buf, bytes) == 0) { |
if (EVP_Cipher(&pvar->evpcip[MODE_IN], newbuf, buf, bytes) == 0) { |
| 300 |
// TODO: |
// TODO: |
| 301 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 302 |
strcpy(pvar->ts->UIMsg, "AES128 decrypt error(2)"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "AES128 decrypt error(2)", _TRUNCATE); |
| 303 |
UTIL_get_lang_msg("MSG_AES128_DECRYPT_ERROR2", pvar); |
UTIL_get_lang_msg("MSG_AES128_DECRYPT_ERROR2", pvar); |
| 304 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 305 |
#else |
#else |
| 602 |
|
|
| 603 |
if (key == NULL || key->e == NULL || key->n == NULL) { |
if (key == NULL || key->e == NULL || key->n == NULL) { |
| 604 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 605 |
strcpy(pvar->ts->UIMsg, "Error setting up RSA keys"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "Error setting up RSA keys", _TRUNCATE); |
| 606 |
UTIL_get_lang_msg("MSG_RSAKEY_SETUP_ERROR", pvar); |
UTIL_get_lang_msg("MSG_RSAKEY_SETUP_ERROR", pvar); |
| 607 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 608 |
#else |
#else |
| 684 |
|
|
| 685 |
if (sender_ciphers == 0) { |
if (sender_ciphers == 0) { |
| 686 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 687 |
strcpy(pvar->ts->UIMsg, |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), |
| 688 |
"The server does not support any of the TTSSH encryption algorithms.\n" |
"The server does not support any of the TTSSH encryption algorithms.\n" |
| 689 |
"A secure connection cannot be made in the TTSSH-to-server direction.\n" |
"A secure connection cannot be made in the TTSSH-to-server direction.\n" |
| 690 |
"The connection will be closed."); |
"The connection will be closed.", |
| 691 |
|
_TRUNCATE); |
| 692 |
UTIL_get_lang_msg("MSG_UNAVAILABLE_CIPHERS_ERROR", pvar); |
UTIL_get_lang_msg("MSG_UNAVAILABLE_CIPHERS_ERROR", pvar); |
| 693 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 694 |
|
|
| 701 |
return FALSE; |
return FALSE; |
| 702 |
} else if (receiver_ciphers == 0) { |
} else if (receiver_ciphers == 0) { |
| 703 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 704 |
strcpy(pvar->ts->UIMsg, |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), |
| 705 |
"The server does not support any of the TTSSH encryption algorithms.\n" |
"The server does not support any of the TTSSH encryption algorithms.\n" |
| 706 |
"A secure connection cannot be made in the TTSSH-to-server direction.\n" |
"A secure connection cannot be made in the TTSSH-to-server direction.\n" |
| 707 |
"The connection will be closed."); |
"The connection will be closed.", |
| 708 |
|
_TRUNCATE); |
| 709 |
UTIL_get_lang_msg("MSG_UNAVAILABLE_CIPHERS_ERROR", pvar); |
UTIL_get_lang_msg("MSG_UNAVAILABLE_CIPHERS_ERROR", pvar); |
| 710 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 711 |
|
|
| 882 |
if (pvar->crypt_state.sender_cipher == SSH_CIPHER_NONE |
if (pvar->crypt_state.sender_cipher == SSH_CIPHER_NONE |
| 883 |
|| pvar->crypt_state.receiver_cipher == SSH_CIPHER_NONE) { |
|| pvar->crypt_state.receiver_cipher == SSH_CIPHER_NONE) { |
| 884 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 885 |
strcpy(pvar->ts->UIMsg, |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), |
| 886 |
"All the encryption algorithms that this program and the server both understand have been disabled.\n" |
"All the encryption algorithms that this program and the server both understand have been disabled.\n" |
| 887 |
"To communicate with this server, you will have to enable some more ciphers\n" |
"To communicate with this server, you will have to enable some more ciphers\n" |
| 888 |
"in the TTSSH Setup dialog box when you run Teraterm again.\n" |
"in the TTSSH Setup dialog box when you run Teraterm again.\n" |
| 889 |
"This connection will now close."); |
"This connection will now close.", |
| 890 |
|
_TRUNCATE); |
| 891 |
UTIL_get_lang_msg("MSG_CHIPHER_NONE_ERROR", pvar); |
UTIL_get_lang_msg("MSG_CHIPHER_NONE_ERROR", pvar); |
| 892 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 893 |
#else |
#else |
| 939 |
|
|
| 940 |
if (bit_delta < 128 || server_key_bits < 512 || host_key_bits < 512) { |
if (bit_delta < 128 || server_key_bits < 512 || host_key_bits < 512) { |
| 941 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 942 |
strcpy(pvar->ts->UIMsg, |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), |
| 943 |
"Server RSA keys are too weak. A secure connection cannot be established."); |
"Server RSA keys are too weak. A secure connection cannot be established.", |
| 944 |
|
_TRUNCATE); |
| 945 |
UTIL_get_lang_msg("MSG_RASKEY_TOOWEAK_ERROR", pvar); |
UTIL_get_lang_msg("MSG_RASKEY_TOOWEAK_ERROR", pvar); |
| 946 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 947 |
#else |
#else |
| 1286 |
|
|
| 1287 |
if (!isOK) { |
if (!isOK) { |
| 1288 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 1289 |
strcpy(pvar->ts->UIMsg, "No cipher selected!"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "No cipher selected!", _TRUNCATE); |
| 1290 |
UTIL_get_lang_msg("MSG_CHPHER_NOTSELECTED_ERROR", pvar); |
UTIL_get_lang_msg("MSG_CHPHER_NOTSELECTED_ERROR", pvar); |
| 1291 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 1292 |
#else |
#else |
| 1344 |
void CRYPT_get_cipher_info(PTInstVar pvar, char FAR * dest, int len) |
void CRYPT_get_cipher_info(PTInstVar pvar, char FAR * dest, int len) |
| 1345 |
{ |
{ |
| 1346 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 1347 |
strcpy(pvar->ts->UIMsg, "%s to server, %s from server"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "%s to server, %s from server", _TRUNCATE); |
| 1348 |
UTIL_get_lang_msg("DLG_ABOUT_CIPHER_INFO", pvar); |
UTIL_get_lang_msg("DLG_ABOUT_CIPHER_INFO", pvar); |
| 1349 |
_snprintf(dest, len, pvar->ts->UIMsg, |
_snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, |
| 1350 |
get_cipher_name(pvar->crypt_state.sender_cipher), |
get_cipher_name(pvar->crypt_state.sender_cipher), |
| 1351 |
get_cipher_name(pvar->crypt_state.receiver_cipher)); |
get_cipher_name(pvar->crypt_state.receiver_cipher)); |
| 1352 |
#else |
#else |
| 1363 |
if (pvar->crypt_state.server_key.RSA_key == NULL |
if (pvar->crypt_state.server_key.RSA_key == NULL |
| 1364 |
|| pvar->crypt_state.host_key.RSA_key == NULL) { |
|| pvar->crypt_state.host_key.RSA_key == NULL) { |
| 1365 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 1366 |
strcpy(pvar->ts->UIMsg, "None"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "None", _TRUNCATE); |
| 1367 |
UTIL_get_lang_msg("DLG_ABOUT_KEY_NONE", pvar); |
UTIL_get_lang_msg("DLG_ABOUT_KEY_NONE", pvar); |
| 1368 |
strncpy(dest, pvar->ts->UIMsg, len); |
strncpy_s(dest, len, pvar->ts->UIMsg, _TRUNCATE); |
| 1369 |
#else |
#else |
| 1370 |
strncpy(dest, "None", len); |
strncpy(dest, "None", len); |
| 1371 |
#endif |
#endif |
| 1372 |
} else { |
} else { |
| 1373 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 1374 |
strcpy(pvar->ts->UIMsg, "%d-bit server key, %d-bit host key"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "%d-bit server key, %d-bit host key", _TRUNCATE); |
| 1375 |
UTIL_get_lang_msg("DLG_ABOUT_KEY_INFO", pvar); |
UTIL_get_lang_msg("DLG_ABOUT_KEY_INFO", pvar); |
| 1376 |
_snprintf(dest, len, pvar->ts->UIMsg, |
_snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, |
| 1377 |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n), |
BN_num_bits(pvar->crypt_state.server_key.RSA_key->n), |
| 1378 |
BN_num_bits(pvar->crypt_state.host_key.RSA_key->n)); |
BN_num_bits(pvar->crypt_state.host_key.RSA_key->n)); |
| 1379 |
#else |
#else |
| 1385 |
|
|
| 1386 |
} else { // SSH2 |
} else { // SSH2 |
| 1387 |
#ifndef NO_I18N |
#ifndef NO_I18N |
| 1388 |
strcpy(pvar->ts->UIMsg, "%d-bit server key, %d-bit host key"); |
strncpy_s(pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), "%d-bit server key, %d-bit host key", _TRUNCATE); |
| 1389 |
UTIL_get_lang_msg("DLG_ABOUT_KEY_INFO", pvar); |
UTIL_get_lang_msg("DLG_ABOUT_KEY_INFO", pvar); |
| 1390 |
_snprintf(dest, len, pvar->ts->UIMsg, |
_snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, |
| 1391 |
pvar->server_key_bits, |
pvar->server_key_bits, |
| 1392 |
pvar->client_key_bits); |
pvar->client_key_bits); |
| 1393 |
#else |
#else |
| 1532 |
|
|
| 1533 |
/* |
/* |
| 1534 |
* $Log: not supported by cvs2svn $ |
* $Log: not supported by cvs2svn $ |
| 1535 |
|
* Revision 1.8 2007/06/06 14:10:12 maya |
| 1536 |
|
* プリプロセッサにより構造体が変わってしまうので、INET6 と I18N の #define を逆転させた。 |
| 1537 |
|
* |
| 1538 |
* Revision 1.7 2007/01/22 13:45:19 maya |
* Revision 1.7 2007/01/22 13:45:19 maya |
| 1539 |
* 表示メッセージの読み込み対応 |
* 表示メッセージの読み込み対応 |
| 1540 |
* |
* |