[Ttssh2-commit] [7798] DSA_SIG構造体のメンバーアクセスが不可となったため、関数経由でのアクセスに変更した。

アーカイブの一覧に戻る
scmno****@osdn***** scmno****@osdn*****
2019年 6月 24日 (月) 16:26:15 JST


Revision: 7798
          https://osdn.net/projects/ttssh2/scm/svn/commits/7798
Author:   yutakapon
Date:     2019-06-24 16:26:15 +0900 (Mon, 24 Jun 2019)
Log Message:
-----------
DSA_SIG構造体のメンバーアクセスが不可となったため、関数経由でのアクセスに変更した。
チケット #36876 

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

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

-------------- next part --------------
Modified: branches/openssl_1_1_1_v2/ttssh2/ttxssh/key.c
===================================================================
--- branches/openssl_1_1_1_v2/ttssh2/ttxssh/key.c	2019-06-24 06:22:05 UTC (rev 7797)
+++ branches/openssl_1_1_1_v2/ttssh2/ttxssh/key.c	2019-06-24 07:26:15 UTC (rev 7798)
@@ -85,6 +85,7 @@
                    u_char *signature, u_int signaturelen,
                    u_char *data, u_int datalen)
 {
+	/********* OPENSSL1.1.1 NOTEST *********/
 	DSA_SIG *sig;
 	const EVP_MD *evp_md = EVP_sha1();
 	EVP_MD_CTX *md = NULL;
@@ -92,6 +93,7 @@
 	unsigned int len, dlen;
 	int ret = -1;
 	char *ptr;
+	BIGNUM *r, *s;
 
 	/********* OPENSSL1.1.1 NOTEST *********/
 	md = EVP_MD_CTX_new();
@@ -140,16 +142,17 @@
 		ret = -5;
 		goto error;
 	}
-	if ((sig->r = BN_new()) == NULL) {
+	if ((r = BN_new()) == NULL) {
 		ret = -6;
 		goto error;
 	}
-	if ((sig->s = BN_new()) == NULL) {
+	if ((s = BN_new()) == NULL) {
 		ret = -7;
 		goto error;
 	}
-	BN_bin2bn(sigblob, INTBLOB_LEN, sig->r);
-	BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, sig->s);
+	DSA_SIG_set0(sig, r, s);
+	BN_bin2bn(sigblob, INTBLOB_LEN, r);
+	BN_bin2bn(sigblob+ INTBLOB_LEN, INTBLOB_LEN, s);
 
 	/* sha1 the data */
 	EVP_DigestInit(&md, evp_md);
@@ -367,6 +370,7 @@
                      u_char *signature, u_int signaturelen,
                      u_char *data, u_int datalen)
 {
+	/********* OPENSSL1.1.1 NOTEST *********/
 	ECDSA_SIG *sig;
 	const EVP_MD *evp_md;
 	EVP_MD_CTX *md = NULL;
@@ -374,6 +378,7 @@
 	unsigned int len, dlen;
 	int ret = -1, nid = NID_undef;
 	char *ptr;
+	BIGNUM *r, *s;
 
 	/********* OPENSSL1.1.1 NOTEST *********/
 	md = EVP_MD_CTX_new();
@@ -409,17 +414,18 @@
 		ret = -4;
 		goto error;
 	}
-	if ((sig->r = BN_new()) == NULL) {
+	if ((r = BN_new()) == NULL) {
 		ret = -5;
 		goto error;
 	}
-	if ((sig->s = BN_new()) == NULL) {
+	if ((s = BN_new()) == NULL) {
 		ret = -6;
 		goto error;
 	}
 
-	buffer_get_bignum2(&sigblob, sig->r);
-	buffer_get_bignum2(&sigblob, sig->s);
+	DSA_SIG_set0(sig, r, s);
+	buffer_get_bignum2(&sigblob, r);
+	buffer_get_bignum2(&sigblob, s);
 	if (sigblob != ptr) {
 		ret = -7;
 		goto error;
@@ -1643,11 +1649,13 @@
 	}
 	case KEY_DSA: // DSA
 	{
+		/********* OPENSSL1.1.1 NOTEST *********/
 		DSA_SIG *sig;
 		const EVP_MD *evp_md = EVP_sha1();
 		EVP_MD_CTX *md = NULL;
 		u_char digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN];
 		u_int rlen, slen, len, dlen;
+		BIGNUM *bignum_r, *bignum_s;
 
 		/********* OPENSSL1.1.1 NOTEST *********/
 		md = EVP_MD_CTX_new();
@@ -1669,15 +1677,16 @@
 		}
 
 		// BIGNUM\x82\xA9\x82\xE7\x83o\x83C\x83i\x83\x8A\x92l\x82ւ̕ϊ\xB7
-		rlen = BN_num_bytes(sig->r);
-		slen = BN_num_bytes(sig->s);
+		DSA_SIG_get0(sig, &bignum_r, &bignum_s);
+		rlen = BN_num_bytes(bignum_r);
+		slen = BN_num_bytes(bignum_s);
 		if (rlen > INTBLOB_LEN || slen > INTBLOB_LEN) {
 			DSA_SIG_free(sig);
 			goto error;
 		}
 		memset(sigblob, 0, SIGBLOB_LEN);
-		BN_bn2bin(sig->r, sigblob+ SIGBLOB_LEN - INTBLOB_LEN - rlen);
-		BN_bn2bin(sig->s, sigblob+ SIGBLOB_LEN - slen);
+		BN_bn2bin(bignum_r, sigblob+ SIGBLOB_LEN - INTBLOB_LEN - rlen);
+		BN_bn2bin(bignum_s, sigblob+ SIGBLOB_LEN - slen);
 		DSA_SIG_free(sig);
 
 		// setting
@@ -1700,6 +1709,7 @@
 	case KEY_ECDSA384:
 	case KEY_ECDSA521:
 	{
+		/********* OPENSSL1.1.1 NOTEST *********/
 		ECDSA_SIG *sig;
 		const EVP_MD *evp_md;
 		EVP_MD_CTX *md = NULL;
@@ -1706,6 +1716,7 @@
 		u_char digest[EVP_MAX_MD_SIZE];
 		u_int len, dlen, nid;
 		buffer_t *buf2 = NULL;
+		BIGNUM *r, *s;
 
 		nid = keytype_to_hash_nid(keypair->type);
 		if ((evp_md = EVP_get_digestbynid(nid)) == NULL) {
@@ -1735,8 +1746,9 @@
 			// TODO: error check
 			goto error;
 		}
-		buffer_put_bignum2(buf2, sig->r);
-		buffer_put_bignum2(buf2, sig->s);
+		DSA_SIG_get0(sig, &r, &s);
+		buffer_put_bignum2(buf2, r);
+		buffer_put_bignum2(buf2, s);
 		ECDSA_SIG_free(sig);
 
 		s = get_sshname_from_key(keypair);


Ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る