CN114584393B - 一种自动选择加密协议的方法 - Google Patents

一种自动选择加密协议的方法 Download PDF

Info

Publication number
CN114584393B
CN114584393B CN202210334744.1A CN202210334744A CN114584393B CN 114584393 B CN114584393 B CN 114584393B CN 202210334744 A CN202210334744 A CN 202210334744A CN 114584393 B CN114584393 B CN 114584393B
Authority
CN
China
Prior art keywords
server
message
client
tls
protocol
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210334744.1A
Other languages
English (en)
Other versions
CN114584393A (zh
Inventor
李盈亮
邹琼
周双全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Yunyu Technology Co ltd
Shenzhen Rayvision Technology Co ltd
Original Assignee
Shenzhen Yunyu Technology Co ltd
Shenzhen Rayvision Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Yunyu Technology Co ltd, Shenzhen Rayvision Technology Co ltd filed Critical Shenzhen Yunyu Technology Co ltd
Priority to CN202210334744.1A priority Critical patent/CN114584393B/zh
Publication of CN114584393A publication Critical patent/CN114584393A/zh
Application granted granted Critical
Publication of CN114584393B publication Critical patent/CN114584393B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/0435Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0823Network architectures or network communication protocols for network security for authentication of entities using certificates
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/083Network architectures or network communication protocols for network security for authentication of entities using passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • H04L63/123Applying verification of the received information received data contents, e.g. message integrity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/16Implementing security features at a particular protocol layer
    • H04L63/166Implementing security features at a particular protocol layer at the transport layer

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)

Abstract

本发明公开一种自动选择加密协议的方法,包括如下步骤:步骤1,通过TLS协议向服务端发送TLS握手请求ClientHello消息;步骤2,根据从服务端返回的响应消息来确定是否建立连接;若返回的响应消息包括ServerHello消息,则向服务端发送第一校验消息,检验通过后建立与服务端的TLS连接;若返回的响应消息包括HandshakeFailure消息,则断开连接,通过国密SSL协议向服务端发送SSL握手消息,向服务端发送第二校验消息,检验通过后建立与服务端的SSL连接。

Description

一种自动选择加密协议的方法
技术领域
本发明涉及到网站加密、文件传输加密的技术领域,尤其涉及一种自动选择加密协议的方法。
背景技术
当前几乎所有网站都会使用加密算法保护客户端到服务器端之间的数据传递不被非法的第三方窃取或篡改;比较常用的是使用安全传输层协议(TLS:TransportLayerSecurity,以下简称“TLS”),国内部分企事业单位和科研机构对于信息安全要求高或基于加密算法必须自主可控的原则会使用国家商用密码算法(以下简称“国密”或“国密算法”)。
目前在网站加密协议中大多数使用了TLS,少数国内网站使用了国密算法。客户端在连接服务器前无法确定服务器使用了何种协议进行加密,如果使用了错误的协议则会导致连接失败。
因此,现有技术存在缺陷,需要改进。
发明内容
本发明的目的在于为解决上述问题而提供一种自动选择加密协议的方法,使客户端自动选择一种合适的加密协议与服务器建立安全的连接,其技术方案如下:
一种自动选择加密协议的方法,包括步骤1,通过TLS协议向服务端发送TLS握手请求ClientHello消息;
步骤2,根据从服务端返回的响应消息来确定是否建立连接;
若返回的响应消息包括ServerHello消息,则向服务端发送第一校验消息,检验通过后建立与服务端的TLS连接;
若返回的响应消息包括HandshakeFailure消息,则断开连接,通过国密SSL协议向服务端发送SSL握手消息,向服务端发送第二校验消息,检验通过后建立与服务端的SSL连接。
可选地,所述步骤1中,TLS握手请求ClientHello消息包括客户端使用的TLS协议的版本信息、加密套件候选列cipher suites、压缩算法候选列表compression methods以及随机数random_C。
可选地,所述步骤2中,协商信息ServerHello包括选择使用的协议版本Version,选择的加密套件cipher suite,选择的压缩算法compression method以及随机数random_S。
可选地,所述步骤2中,响应消息还包括Certificates消息;
在向服务端发送第一校验消息前,先验证Certificates消息中证书的合法性,验证通过后,向服务端发送第一校验消息。
本发明具有以下有益效果:通过客户端与服务端第一次握手消息的交互,可以选择出合适的加密协议与服务端建立安全连接;客户端只需要一个服务端的端口,不需要事先指定使用何种加密协议即可兼容两种加密协议,保证了系统的兼容性。
附图说明
图1为本发明提供的自动选择加密协议的方法的流程图。
具体实施方式
以下结合附图和具体实施例,对本发明进行详细说明。
如图1所示,本发明提供一种自动选择加密协议的方法,该自动选择加密协议的方法包括步骤:
步骤1,客户端使用TLS协议向服务端发起握手请求,以明文传输ClientHello消息,该ClientHello消息包括客户端使用的TLS协议的版本信息、加密套件候选列ciphersuites、压缩算法候选列表compression methods以及随机数Random_C等,其中,版本信息为客户端支持的最高TSL协议版本,从低到高依次TLS_v1、 TLS_v1.1 、TLS_v1.2。客户端支持的加密套件列表cipher suites,每个加密套件对应前面 TLS 原理中的四个功能的组合:认证算法 Au (身份验证)、密钥交换算法 KeyExchange(密钥协商)、对称加密算法 Enc(信息加密)和信息摘要 Mac(完整性校验);压缩算法列表compression methods中的压缩算法,用于后续的信息压缩传输;随机数 random_C,用于后续的密钥的生成。
步骤2,服务端根据当前配置的是TLS协议或国密SSL协议返回响应消息。具体地,若服务端配置的是TLS协议时,返回ServerHello消息;否则返回HandshakeFailure消息。
在步骤S2中,ServerHello消息为服务端返回协商的信息结果,包括选择使用的协议版本version,选择的加密套件cipher suite,选择的压缩算法 compression method、随机数 random_S等,其中随机数用于后续的密钥协商。同时,响应信息还包括Certificates消息以及ServerHelloDone消息,Certificates消息中包含有服务端配置对应的证书,用于身份验证与密钥交换;Serverhellodone消息用于通知客户端ServerHello消息发送结束。
步骤3,客户端根据服务端返回的响应消息来判断是否建立连接。具体地,当客户端收到服务端返回的ServerHello消息时,表示服务端当前使用的是TLS协议,则继续向服务端发送校验消息以完成TLS连接的建立,具体TLS连接的建立包括如下步骤:
步骤31,客户端对服务端返回的证书进行合法性验证,如果验证通过进行下一步,否则根据错误情况不同做出提示和操作;
步骤32,客户端产生一个随机数pre_master_secret,并用证书中的公钥进行加密再发送给服务端;
步骤33,客户端根据随机数random_C 、 random_S以及master-secret生成协商密钥Fuc(random_C, random_S,pre_ master_secret);
步骤34,客户端根据接收的所有握手消息的MAC值生成一段验证数据,并采用协商密钥和服务端选择的加密算法进行加密,然后然后发送给服务端进行握手验证;
步骤35,服务端采用其证书私钥解密以得到pre_master_secret,结合之前交换的明文随机数random_C 、 random_S,得到协商密钥2。
步骤36,服务端采用步骤S35中得到的协商密钥2和在步骤S2中选择的加密算法对步骤S34中的发送过来的验证数据进行解码,再通过协商密钥2和加密算法对解密出来的验证数据重新加密;
步骤37,客户端接收步骤36中返回的验证数据并解密,将该验证数据中MAC值与步骤S34中的MAC值进行一致性校验,验证通过后则握手完成,建立客户端与服务端之间的TLS连接。
当客户端收到服务端返回的HandshakeFailure消息时,则表示服务端当前使用的不是TLS协议,并断开与服务端的连接;由客户端使用国密SSL协议向服务端重新发送SSL握手请求并建立SSL连接。
应当说明书的是,建立SSL连接的过程与建立TSL连接的过程原理相同,再次不详细赘述。
本发明具有以下有益效果:通过客户端与服务端第一次握手消息的交互,可以选择出合适的加密协议与服务端建立安全连接;客户端只需要一个服务端的端口,不需要事先指定使用何种加密协议即可兼容两种加密协议,保证了系统的兼容性。
以上仅为本发明的较佳实施例而已,并不用于限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。

Claims (1)

1.一种自动选择加密协议的方法,包括如下步骤:
步骤1,通过TLS协议向服务端发送TLS握手请求ClientHello消息;
步骤2,根据从服务端返回的响应消息来确定是否建立连接;
若返回的响应消息包括ServerHello消息,则向服务端发送第一校验消息,检验通过后建立与服务端的TLS连接;
若返回的响应消息包括HandshakeFailure消息,则断开连接,通过国密SSL协议向服务端发送SSL握手消息,向服务端发送第二校验消息,检验通过后建立与服务端的SSL连接;
所述步骤1中,TLS握手请求ClientHello消息包括客户端使用的TLS协议的版本信息、加密套件候选列cipher suites、压缩算法候选列表compression methods以及随机数random_C;
所述步骤2中,协商信息ServerHello包括选择使用的协议版本Version,选择的加密套件cipher suite,选择的压缩算法compression method以及随机数random_S;
所述步骤2中,响应消息还包括Certificates消息;
在向服务端发送第一校验消息前,先验证Certificates消息中证书的合法性,验证通过后,向服务端发送第一校验消息;
步骤3,客户端根据服务端返回的响应消息来判断是否建立连接;具体地,当客户端收到服务端返回的ServerHello消息时,表示服务端当前使用的是TLS协议,则继续向服务端发送校验消息以完成TLS连接的建立,具体TLS连接的建立包括如下步骤:
步骤31,客户端对服务端返回的证书进行合法性验证,如果验证通过进行下一步,否则根据错误情况不同做出提示和操作;
步骤32,客户端产生一个随机数pre_master_secret,并用证书中的公钥进行加密再发送给服务端;
步骤33,客户端根据随机数random_C 、 random_S以及master-secret生成协商密钥Fuc(random_C, random_S,pre_ master_secret);
步骤34,客户端根据接收的所有握手消息的MAC值生成一段验证数据,并采用协商密钥和服务端选择的加密算法进行加密,然后然后发送给服务端进行握手验证;
步骤35,服务端采用其证书私钥解密以得到pre_master_secret,结合之前交换的明文随机数random_C 、 random_S,得到协商密钥2;
步骤36,服务端采用步骤S35中得到的协商密钥2和在步骤S2中选择的加密算法对步骤S34中的发送过来的验证数据进行解码,再通过协商密钥2和加密算法对解密出来的验证数据重新加密;
步骤37,客户端接收步骤36中返回的验证数据并解密,将该验证数据中MAC值与步骤S34中的MAC值进行一致性校验,验证通过后则握手完成,建立客户端与服务端之间的TLS连接;
当客户端收到服务端返回的HandshakeFailure消息时,则表示服务端当前使用的不是TLS协议,并断开与服务端的连接;由客户端使用国密SSL协议向服务端重新发送SSL握手请求并建立SSL连接。
CN202210334744.1A 2022-03-31 2022-03-31 一种自动选择加密协议的方法 Active CN114584393B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210334744.1A CN114584393B (zh) 2022-03-31 2022-03-31 一种自动选择加密协议的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210334744.1A CN114584393B (zh) 2022-03-31 2022-03-31 一种自动选择加密协议的方法

Publications (2)

Publication Number Publication Date
CN114584393A CN114584393A (zh) 2022-06-03
CN114584393B true CN114584393B (zh) 2023-10-20

Family

ID=81784108

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210334744.1A Active CN114584393B (zh) 2022-03-31 2022-03-31 一种自动选择加密协议的方法

Country Status (1)

Country Link
CN (1) CN114584393B (zh)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104137511A (zh) * 2012-02-29 2014-11-05 微软公司 安全协议的动态选择
CN107124385A (zh) * 2016-02-24 2017-09-01 中国科学院声学研究所 一种基于镜像流的ssl/tls协议明文数据采集方法
CN108566361A (zh) * 2018-01-05 2018-09-21 武汉信安珞珈科技有限公司 一种基于ssl/tls协议的安全参数协商方法和系统

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9961103B2 (en) * 2014-10-28 2018-05-01 International Business Machines Corporation Intercepting, decrypting and inspecting traffic over an encrypted channel
ES2953589T3 (es) * 2018-11-13 2023-11-14 Fraunhofer Ges Forschung Un método para generar un número aleatorio, circuito de generación de número aleatorio y programa de ordenador

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104137511A (zh) * 2012-02-29 2014-11-05 微软公司 安全协议的动态选择
CN107124385A (zh) * 2016-02-24 2017-09-01 中国科学院声学研究所 一种基于镜像流的ssl/tls协议明文数据采集方法
CN108566361A (zh) * 2018-01-05 2018-09-21 武汉信安珞珈科技有限公司 一种基于ssl/tls协议的安全参数协商方法和系统

Also Published As

Publication number Publication date
CN114584393A (zh) 2022-06-03

Similar Documents

Publication Publication Date Title
CN109728909B (zh) 基于USBKey的身份认证方法和系统
US8904178B2 (en) System and method for secure remote access
JP4617763B2 (ja) 機器認証システム、機器認証サーバ、端末機器、機器認証方法、および機器認証プログラム
JP5845393B2 (ja) 暗号通信装置および暗号通信システム
US8583809B2 (en) Destroying a secure session maintained by a server on behalf of a connection owner
US20130219166A1 (en) Hardware based identity manager
CN107147611B (zh) 传输层安全tls建链的方法、用户设备、服务器和系统
WO2016115807A1 (zh) 无线路由器的接入处理、接入方法及装置
CN111756529B (zh) 一种量子会话密钥分发方法及系统
KR20080089500A (ko) 모바일 네트워크를 기반으로 하는 엔드 투 엔드 통신에서의 인증을 위한 방법, 시스템 및 인증 센터
CN112235235A (zh) 一种基于国密算法的sdp认证协议实现方法
CN103763356A (zh) 一种安全套接层连接的建立方法、装置及系统
EP3375133B1 (fr) Procede de securisation et d'authentification d'une telecommunication
CN110839240B (zh) 一种建立连接的方法及装置
CN114143082B (zh) 一种加密通信方法、系统及装置
KR102128244B1 (ko) Ssl/tls 기반의 네트워크 보안 장치 및 방법
KR20090012013A (ko) 커버로스를 이용한 상호 인증 방법 및 그 시스템
KR101448866B1 (ko) 웹 보안 프로토콜에 따른 암호화 데이터를 복호화하는 보안 장치 및 그것의 동작 방법
CN110855561A (zh) 一种物联网智能网关
JPH10242957A (ja) ユーザ認証方法およびシステムおよびユーザ認証用記憶媒体
EP3820186A1 (en) Method and apparatus for transmitting router security information
CN114584393B (zh) 一种自动选择加密协议的方法
CN116248290A (zh) 身份认证的方法、装置及电子设备
CN115664725A (zh) 基于国密算法的tls密钥交换方法及系统
CN113660271B (zh) 一种车联网的安全认证方法及装置

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant