From 76cab38a5f540f03644a03fabd28899750c1d39b Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 11:35:12 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3WIN32+MSYS32+MINGW32?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypto/skf/skf.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crypto/skf/skf.h b/crypto/skf/skf.h index 0925d89a..bba36fd5 100644 --- a/crypto/skf/skf.h +++ b/crypto/skf/skf.h @@ -99,6 +99,28 @@ typedef UINT32 DWORD; typedef UINT32 FLAGS; typedef CHAR * LPSTR; typedef void * HANDLE; +#else +#ifndef _WINDEF_H +typedef signed char INT8; +typedef signed short INT16; +typedef signed int INT32; +typedef unsigned char UINT8; +typedef unsigned short UINT16; +typedef unsigned int UINT32; +typedef long BOOL; +typedef UINT8 BYTE; +typedef UINT8 CHAR; +typedef INT16 SHORT; +typedef UINT16 USHORT; +typedef INT32 LONG; +typedef UINT32 ULONG; +typedef UINT32 UINT; +typedef UINT16 WORD; +typedef UINT32 DWORD; +typedef UINT32 FLAGS; +typedef CHAR * LPSTR; +typedef void * HANDLE; +#endif #endif typedef HANDLE DEVHANDLE; From fab30887212d86bbc5be0dc93215ae873db02552 Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 13:45:11 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=A7=A3=E5=86=B3Golang=EF=BC=88WINDOWS?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0)=E8=B0=83=E7=94=A8openssl=20X509=5FSTORE=5Fl?= =?UTF-8?q?oad=5Flocations=E5=87=BD=E6=95=B0=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BC=A0=E9=80=92NULL=E6=8C=87=E9=92=88=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E8=AF=A5=E5=87=BD=E6=95=B0=E8=BF=94=E5=9B=9E=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E3=80=82=20PS:Linux=E5=B9=B3=E5=8F=B0=E6=97=A0=E6=AD=A4?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypto/x509/x509_d2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c index 50ca2a6d..8706c2c6 100644 --- a/crypto/x509/x509_d2.c +++ b/crypto/x509/x509_d2.c @@ -86,6 +86,13 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *path) { X509_LOOKUP *lookup; + + //Support Go: + //Go调用此函数无法传递NULL指针,只能传递空串。 + if (file && *file == '\0') + file = NULL; + if (path && *path == '\0') + path = NULL if (file != NULL) { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file()); From 0bf0b268902934d9dd3ef2efd0ce0588f4ada640 Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 14:07:17 +0800 Subject: [PATCH 3/8] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 鎻愪氦WINDOW鐨凪SYS+MINGW鐜缂栬瘧鏂规硶 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a11e0638..7c3dab88 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,12 @@ make sudo make install ``` +鍦╓IN32(MINGW+MSYS)鎿嶄綔绯荤粺涓婇氳繃濡備笅鎸囦护瀹炵幇缂栬瘧鍜屽畨瑁咃細 +娉ㄦ剰锛岃В鍘嬫垨Git clone浠g爜璇峰湪MSYS鐜锛屽惁鍒欎細鍥犳崲琛岀瀵艰嚧鍑虹幇缂栬瘧閿欒 + +``` +./config +make +make install +``` + From da53a9be7d9486fcde1b3438d9aaa46a0c377705 Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 14:07:45 +0800 Subject: [PATCH 4/8] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7c3dab88..e53ec781 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ sudo make install ``` 鍦╓IN32(MINGW+MSYS)鎿嶄綔绯荤粺涓婇氳繃濡備笅鎸囦护瀹炵幇缂栬瘧鍜屽畨瑁咃細 + 娉ㄦ剰锛岃В鍘嬫垨Git clone浠g爜璇峰湪MSYS鐜锛屽惁鍒欎細鍥犳崲琛岀瀵艰嚧鍑虹幇缂栬瘧閿欒 ``` From 81303af149900c8cef147d28ebabc0cccf7f9cab Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 14:08:22 +0800 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e53ec781..39f2c223 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ sudo make install 鍦╓IN32(MINGW+MSYS)鎿嶄綔绯荤粺涓婇氳繃濡備笅鎸囦护瀹炵幇缂栬瘧鍜屽畨瑁咃細 -娉ㄦ剰锛岃В鍘嬫垨Git clone浠g爜璇峰湪MSYS鐜锛屽惁鍒欎細鍥犳崲琛岀瀵艰嚧鍑虹幇缂栬瘧閿欒 +(璇峰湪MSYS鐜瑙e帇鎴朑it clone浠g爜锛屽惁鍒欎細鍥犳崲琛岀瀵艰嚧鍑虹幇缂栬瘧閿欒) ``` ./config From b3d45522ae0ce9ab83191788d1c06723b15d0a25 Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Wed, 17 Aug 2016 14:17:44 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypto/x509/x509_d2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c index 8706c2c6..b8746a22 100644 --- a/crypto/x509/x509_d2.c +++ b/crypto/x509/x509_d2.c @@ -88,11 +88,11 @@ int X509_STORE_load_locations(X509_STORE *ctx, const char *file, X509_LOOKUP *lookup; //Support Go: - //Go调用此函数无法传递NULL指针,只能传递空串。 + //Go璋冪敤姝ゅ嚱鏁颁紶閫掔┖涓叉椂澶勭悊寮傚父 if (file && *file == '\0') file = NULL; if (path && *path == '\0') - path = NULL + path = NULL; if (file != NULL) { lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file()); From 5c315bca3f08e706e6a81a133575cda315012e4d Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Mon, 22 Aug 2016 17:44:54 +0800 Subject: [PATCH 7/8] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3TLS1.x=E7=9A=84?= =?UTF-8?q?ECDH-SM2-SM3-SM4/SM2-SM3-SM4=E4=B8=A4=E7=A7=8D=E5=A5=97?= =?UTF-8?q?=E4=BB=B6=E6=97=A0=E6=B3=95=E6=8F=A1=E6=89=8B=E6=88=90=E5=8A=9F?= =?UTF-8?q?=202=E3=80=81=E6=9A=82=E5=8E=BB=E6=8E=89=E9=9D=9ESM=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E7=9A=84=E5=A5=97=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssl/s3_clnt.c | 6 +++++ ssl/s3_lib.c | 68 ++++++++++++++++++++++++-------------------------- ssl/ssl_ciph.c | 7 +++++- ssl/ssl_lib.c | 6 +++++ ssl/t1_lib.c | 4 +++ 5 files changed, 55 insertions(+), 36 deletions(-) diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index b3977a9a..658e0993 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -1871,6 +1871,12 @@ int ssl3_get_key_exchange(SSL *s) pkey = X509_get_pubkey(s->session-> sess_cert->peer_pkeys[SSL_PKEY_ECC].x509); +# endif +# ifndef NO_GMSSL + else if (alg_a & SSL_aSM2) + pkey = + X509_get_pubkey(s->session-> + sess_cert->peer_pkeys[SSL_PKEY_ECC].x509); # endif /* else anonymous ECDH, so no certificate or pkey. */ EC_KEY_set_public_key(ecdh, srvr_ecpoint); diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index ae2d9cb3..4aaccbf1 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -163,7 +163,40 @@ const char ssl3_version_str[] = "SSLv3" OPENSSL_VERSION_PTEXT; /* list of available SSLv3 ciphers (sorted by id) */ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[] = { +# ifndef NO_GMSSL + /* (GmSSL specific) */ + { + 1, + GM1_TXT_ECDHE_SM2_SM4_SM3, + GM1_CK_ECDHE_SM2_SM4_SM3, + SSL_kEECDH, + SSL_aSM2, + SSL_SM4, + SSL_SM3, + SSL_TLSV1_2, + SSL_NOT_EXP|SSL_HIGH, + SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, + 128, + 128, + }, + /* (GmSSL Specific) */ + { + 1, + GM1_TXT_SM2_SM4_SM3, + GM1_CK_SM2_SM4_SM3, + SSL_kSM2, + SSL_aSM2, + SSL_SM4, + SSL_SM3, + SSL_TLSV1_2, + SSL_NOT_EXP|SSL_HIGH, + SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, + 128, + 128, + } +# endif +#if 0 /* The RSA ciphers */ /* Cipher 01 */ { @@ -2890,42 +2923,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[] = { 256, 256}, #endif - -#ifndef NO_GMSSL - /* (GmSSL specific) */ - { - 1, - GM1_TXT_ECDHE_SM2_SM4_SM3, - GM1_CK_ECDHE_SM2_SM4_SM3, - SSL_kEECDH, - SSL_aSM2, - SSL_SM4, - SSL_SM3, - SSL_TLSV1_2, - SSL_NOT_EXP|SSL_HIGH, - SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, - 128, - 128, - }, - - /* (GmSSL Specific) */ - { - 1, - GM1_TXT_SM2_SM4_SM3, - GM1_CK_SM2_SM4_SM3, - SSL_kSM2, - SSL_aSM2, - SSL_SM4, - SSL_SM3, - SSL_TLSV1_2, - SSL_NOT_EXP|SSL_HIGH, - SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, - 128, - 128, - } - #endif - /* end of list */ }; diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 6194a226..e18f6b22 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -2128,7 +2128,12 @@ int ssl_cipher_get_cert_index(const SSL_CIPHER *c) * chosen. */ return SSL_PKEY_ECC; - } else if (alg_a & SSL_aECDSA) + } +# ifndef NO_GMSSL + else if (alg_a & SSL_aSM2) + return SSL_PKEY_ECC; +# endif + else if (alg_a & SSL_aECDSA) return SSL_PKEY_ECC; else if (alg_k & SSL_kDHr) return SSL_PKEY_DH_RSA; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index da05eb0d..dd74a02d 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2413,6 +2413,12 @@ void ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher) mask_a |= SSL_aECDSA; emask_a |= SSL_aECDSA; } +# endif +# ifndef NO_GMSSL + mask_a |= SSL_aSM2; + emask_a |= SSL_aSM2; + mask_k |= SSL_kSM2; + emask_k |= SSL_kSM2; # endif } #endif diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 03543c68..3c075879 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1026,6 +1026,10 @@ static int tls1_check_cert_param(SSL *s, X509 *x, int set_ee_md) tlsext_sigalg_ecdsa(md) static unsigned char tls12_sigalgs[] = { +# ifndef NO_GMSSL + TLSEXT_hash_sm3, + TLSEXT_signature_sm2sign, +# endif # ifndef OPENSSL_NO_SHA512 tlsext_sigalg(TLSEXT_hash_sha512) tlsext_sigalg(TLSEXT_hash_sha384) From 95c0dba728e600aa39d176784d9c37587dc720fd Mon Sep 17 00:00:00 2001 From: zs <84500316@qq.com> Date: Mon, 22 Aug 2016 17:57:42 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=A1=A5=E5=85=85=EF=BC=88=E6=BC=8F?= =?UTF-8?q?=EF=BC=89=E6=8F=90=E4=BA=A4=E8=AF=B4=E6=98=8E=E8=A7=81https://g?= =?UTF-8?q?ithub.com/zsdev2015/GmSSL/commit/5c315bca3f08e706e6a81a133575cd?= =?UTF-8?q?a315012e4d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ssl/ssl_lib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index dd74a02d..3d9ea9bb 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2585,9 +2585,16 @@ EVP_PKEY *ssl_get_sign_pkey(SSL *s, const SSL_CIPHER *cipher, idx = SSL_PKEY_RSA_SIGN; else if (c->pkeys[SSL_PKEY_RSA_ENC].privatekey != NULL) idx = SSL_PKEY_RSA_ENC; - } else if ((alg_a & SSL_aECDSA) && + } +# ifndef NO_GMSSL + else if ((alg_a & SSL_aSM2) && (c->pkeys[SSL_PKEY_ECC].privatekey != NULL)) idx = SSL_PKEY_ECC; +# endif + else if ((alg_a & SSL_aECDSA) && + (c->pkeys[SSL_PKEY_ECC].privatekey != NULL)) + idx = SSL_PKEY_ECC; + if (idx == -1) { SSLerr(SSL_F_SSL_GET_SIGN_PKEY, ERR_R_INTERNAL_ERROR); return (NULL);