[Ttssh2-commit] [7885] 単体テスト完了した箇所のコメントを除去した。

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 7月 24日 (水) 21:08:01 JST


Revision: 7885
          https://osdn.net/projects/ttssh2/scm/svn/commits/7885
Author:   yutakapon
Date:     2019-07-24 21:08:00 +0900 (Wed, 24 Jul 2019)
Log Message:
-----------
単体テスト完了した箇所のコメントを除去した。
単体テストがしやすいように、EVP_Cipher()の返り値を変数に代入するようにした。
EVP_CIPHER_CTX_new()の返り値チェックを追加した。
チケット #36876 

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/36876

Modified Paths:
--------------
    branches/openssl_1_1_1_v2/ttssh2/ttxssh/keyfiles.c

-------------- next part --------------
Modified: branches/openssl_1_1_1_v2/ttssh2/ttxssh/keyfiles.c
===================================================================
--- branches/openssl_1_1_1_v2/ttssh2/ttxssh/keyfiles.c	2019-07-23 14:51:41 UTC (rev 7884)
+++ branches/openssl_1_1_1_v2/ttssh2/ttxssh/keyfiles.c	2019-07-24 12:08:00 UTC (rev 7885)
@@ -670,7 +670,6 @@
 		goto error;
 	}
 
-	/********* OPENSSL1.1.1 NOTEST *********/
 	pk_type = EVP_PKEY_id(pk);
 	switch (pk_type) {
 	case EVP_PKEY_RSA: // RSA key
@@ -940,14 +939,13 @@
 		unsigned char key[40], iv[32];
 		EVP_CIPHER_CTX *cipher_ctx = NULL;
 		char *decrypted = NULL;
+		int ret;
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		ctx = EVP_MD_CTX_new();
 		if (ctx == NULL) {
 			goto error;
 		}
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		cipher_ctx = EVP_CIPHER_CTX_new();
 		if (ctx == NULL) {
 			EVP_MD_CTX_free(ctx);
@@ -968,12 +966,12 @@
 
 		memset(iv, 0, sizeof(iv));
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		// decrypt
 		cipher_init_SSH2(cipher_ctx, key, 32, iv, 16, CIPHER_DECRYPT, EVP_aes_256_cbc(), 0, 0, pvar);
 		len = buffer_len(prikey);
 		decrypted = (char *)malloc(len);
-		if (EVP_Cipher(cipher_ctx, decrypted, prikey->buf, len) == 0) {
+		ret = EVP_Cipher(cipher_ctx, decrypted, prikey->buf, len);
+		if (ret == 0) {
 			strncpy_s(errmsg, errmsg_len, "Key decrypt error", _TRUNCATE);
 			free(decrypted);
 			cipher_cleanup_SSH2(cipher_ctx);
@@ -1015,7 +1013,6 @@
 		const EVP_MD *md = EVP_sha1();
 		EVP_MD_CTX *ctx = NULL;
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		ctx = EVP_MD_CTX_new();
 		if (ctx == NULL) {
 			goto error;
@@ -1037,7 +1034,6 @@
 		unsigned char foo[64];
 		int i;
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		ctx[0] = EVP_MD_CTX_new();
 		if (ctx[0] == NULL) {
 			goto error;
@@ -1105,7 +1101,6 @@
 	switch (result->type) {
 	case KEY_RSA:
 	{
-		/********* OPENSSL1.1.1 NOTEST *********/
 		char *pubkey_type, *pub, *pri;
 		BIGNUM *e, *n, *d, *iqmp, *p, *q;
 
@@ -1525,10 +1520,13 @@
 		unsigned char key[32], iv[16];
 		EVP_CIPHER_CTX *cipher_ctx = NULL;
 		char *decrypted = NULL;
+		int ret;
 
-		/********* OPENSSL1.1.1 NOTEST *********/
 		cipher_ctx = EVP_CIPHER_CTX_new();
-		/*** TODO: OPENSSL1.1.1 ERROR CHECK(ticket#39335\x82ŏ\x88\x92u\x97\\x92\xE8) ***/
+		if (cipher_ctx == NULL) {
+			strncpy_s(errmsg, errmsg_len, "Out of memory: EVP_CIPHER_CTX_new()", _TRUNCATE);
+			goto error;
+		}
 
 		MD5_Init(&md);
 		MD5_Update(&md, passphrase, strlen(passphrase));
@@ -1544,7 +1542,8 @@
 		// decrypt
 		cipher_init_SSH2(cipher_ctx, key, 24, iv, 8, CIPHER_DECRYPT, EVP_des_ede3_cbc(), 0, 0, pvar);
 		decrypted = (char *)malloc(len);
-		if (EVP_Cipher(cipher_ctx, decrypted, blob->buf + blob->offset, len) == 0) {
+		ret = EVP_Cipher(cipher_ctx, decrypted, blob->buf + blob->offset, len);
+		if (ret == 0) {
 			strncpy_s(errmsg, errmsg_len, "Key decrypt error", _TRUNCATE);
 			cipher_cleanup_SSH2(cipher_ctx);
 			EVP_CIPHER_CTX_free(cipher_ctx);
@@ -1571,7 +1570,6 @@
 	switch (result->type) {
 	case KEY_RSA:
 	{
-		/********* OPENSSL1.1.1 NOTEST *********/
 		BIGNUM *e, *n, *d, *iqmp, *p, *q;
 
 		result->rsa = RSA_new();


Ttssh2-commit メーリングリストの案内
Back to archive index