svnno****@sourc*****
svnno****@sourc*****
2017年 5月 11日 (木) 13:29:22 JST
Revision: 6710 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6710 Author: doda Date: 2017-05-11 13:29:22 +0900 (Thu, 11 May 2017) Log Message: ----------- ログ出力を強化 Modified Paths: -------------- trunk/ttssh2/ttxssh/keyfiles.c -------------- next part -------------- Modified: trunk/ttssh2/ttxssh/keyfiles.c =================================================================== --- trunk/ttssh2/ttxssh/keyfiles.c 2017-05-09 14:25:17 UTC (rev 6709) +++ trunk/ttssh2/ttxssh/keyfiles.c 2017-05-11 04:29:22 UTC (rev 6710) @@ -387,6 +387,7 @@ len = fread(buf, 1, sizeof(buf), fp); buffer_append(blob, buf, len); if (buffer_len(blob) > MAX_KEY_FILE_SIZE) { + logprintf(pvar, LOG_LEVEL_WARNING, "%s: key file too large.", __FUNCTION__); goto error; } if (len < sizeof(buf)) @@ -399,7 +400,7 @@ cp = buffer_ptr(blob); len = buffer_len(blob); if (len < m1len || memcmp(cp, MARK_BEGIN, m1len)) { - //debug("%s: missing begin marker", __func__); + logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: missing begin marker", __FUNCTION__); goto error; } cp += m1len; @@ -418,7 +419,7 @@ } } if (!len) { - //debug("%s: no end marker", __func__); + logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: no end marker", __FUNCTION__); goto error; } @@ -425,15 +426,15 @@ // \x83t\x83@\x83C\x83\x8B\x82̃X\x83L\x83\x83\x83\x93\x82\xAA\x8FI\x82\xED\x82\xC1\x82\xBD\x82̂ŁAbase64 decode\x82\xB7\x82\xE9\x81B len = buffer_len(encoded); if ((cp = buffer_append_space(copy_consumed, len)) == NULL) { - //error("%s: buffer_append_space", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: buffer_append_space", __FUNCTION__); goto error; } if ((dlen = b64decode(cp, len, buffer_ptr(encoded))) < 0) { - //error("%s: base64 decode failed", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: base64 decode failed", __FUNCTION__); goto error; } if ((unsigned int)dlen > len) { - //error("%s: crazy base64 length %d > %u", __func__, dlen, len); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: crazy base64 length %d > %u", __FUNCTION__, dlen, len); goto error; } @@ -440,7 +441,7 @@ buffer_consume_end(copy_consumed, len - dlen); if (buffer_remain_len(copy_consumed) < sizeof(AUTH_MAGIC) || memcmp(buffer_tail_ptr(copy_consumed), AUTH_MAGIC, sizeof(AUTH_MAGIC))) { - //error("%s: bad magic", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: bad magic", __FUNCTION__); goto error; } buffer_consume(copy_consumed, sizeof(AUTH_MAGIC)); @@ -452,7 +453,7 @@ ciphername = buffer_get_string_msg(copy_consumed, NULL); ciphernameval = get_cipher_by_name(ciphername); if (ciphernameval == SSH_CIPHER_NONE && strcmp(ciphername, "none") != 0) { - //error("%s: unknown cipher name", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: unknown cipher name", __FUNCTION__); goto error; } // \x83p\x83X\x83t\x83\x8C\x81[\x83Y\x82̃`\x83F\x83b\x83N\x81B\x88Í\x86\x89\xBB\x82\xAA none \x82łȂ\xA2\x8Fꍇ\x82͋\xF3\x82̃p\x83X\x83\x8F\x81[\x83h\x82\xF0\x94F\x82߂Ȃ\xA2\x81B @@ -465,11 +466,11 @@ kdfname = buffer_get_string_msg(copy_consumed, NULL); if (kdfname == NULL || (!strcmp(kdfname, "none") && !strcmp(kdfname, KDFNAME))) { - //error("%s: unknown kdf name", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: unknown kdf name", __FUNCTION__); goto error; } if (!strcmp(kdfname, "none") && strcmp(ciphername, "none") != 0) { - //error("%s: cipher %s requires kdf", __func__, ciphername); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: cipher %s requires kdf", __FUNCTION__, ciphername); goto error; } @@ -476,12 +477,12 @@ /* kdf options */ kdfp = buffer_get_string_msg(copy_consumed, &klen); if (kdfp == NULL) { - //error("%s: kdf options not set", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: kdf options not set", __FUNCTION__); goto error; } if (klen > 0) { if ((cp = buffer_append_space(kdf, klen)) == NULL) { - //error("%s: kdf alloc failed", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: kdf alloc failed", __FUNCTION__); goto error; } memcpy(cp, kdfp, klen); @@ -489,11 +490,11 @@ /* number of keys */ if (buffer_get_int_ret(&nkeys, copy_consumed) < 0) { - //error("%s: key counter missing", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: key counter missing", __FUNCTION__); goto error; } if (nkeys != 1) { - //error("%s: only one key supported", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: only one key supported", __FUNCTION__); goto error; } @@ -500,7 +501,7 @@ /* pubkey */ cp = buffer_get_string_msg(copy_consumed, &len); if (cp == NULL) { - //error("%s: pubkey not found", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: pubkey not found", __FUNCTION__); goto error; } free(cp); /* XXX check pubkey against decrypted private key */ @@ -510,11 +511,11 @@ blocksize = get_cipher_block_size(ciphernameval); authlen = 0; // TODO: \x82Ƃ肠\x82\xA6\x82\xB8\x8CŒ艻 if (len < blocksize) { - //error("%s: encrypted data too small", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: encrypted data too small", __FUNCTION__); goto error; } if (len % blocksize) { - //error("%s: length not multiple of blocksize", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: length not multiple of blocksize", __FUNCTION__); goto error; } @@ -525,7 +526,7 @@ if (!strcmp(kdfname, KDFNAME)) { salt = buffer_get_string_msg(kdf, &slen); if (salt == NULL) { - //error("%s: salt not set", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: salt not set", __FUNCTION__); goto error; } rounds = buffer_get_int(kdf); @@ -532,7 +533,7 @@ // TODO: error check if (bcrypt_pbkdf(passphrase, strlen(passphrase), salt, slen, key, keylen + ivlen, rounds) < 0) { - //error("%s: bcrypt_pbkdf failed", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: bcrypt_pbkdf failed", __FUNCTION__); goto error; } } @@ -549,8 +550,8 @@ buffer_consume(copy_consumed, len); if (buffer_remain_len(copy_consumed) != 0) { - //error("%s: key blob has trailing data (len = %u)", __func__, - // buffer_len(©)); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: key blob has trailing data (len = %u)", + __FUNCTION__, buffer_remain_len(copy_consumed)); goto error; } @@ -557,12 +558,12 @@ /* check bytes */ if (buffer_get_int_ret(&check1, b) < 0 || buffer_get_int_ret(&check2, b) < 0) { - //error("check bytes missing"); + logprintf(pvar, LOG_LEVEL_ERROR, "check bytes missing"); goto error; } if (check1 != check2) { - //debug("%s: decrypt failed: 0x%08x != 0x%08x", __func__, - // check1, check2); + logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: decrypt failed: 0x%08x != 0x%08x", + __FUNCTION__, check1, check2); goto error; } @@ -577,7 +578,7 @@ while (buffer_remain_len(b)) { if (buffer_get_char_ret(&pad, b) == -1 || pad != (++i & 0xff)) { - //error("%s: bad padding", __func__); + logprintf(pvar, LOG_LEVEL_ERROR, "%s: bad padding", __FUNCTION__); key_free(keyfmt); keyfmt = NULL; goto error;