Message encryption method and device, electronic equipment storage medium and computer program product
By negotiating and determining the digest length attribute in IPSEC, the problem of slow application of digest algorithms and poor interoperability of products from different manufacturers in IPsec is solved, and rapid application and interoperability are achieved, and network security is improved.
Patent Information
- Application Number
- CN202411221330.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-11-19
AI Technical Summary
In the IPsec protocol, the old digest algorithm cannot meet the current network security requirements, the application process of the new algorithm is slow, and there are differences in the length of ESP authentication data when using the SM3 Guose algorithm, which affects the promotion of Guose algorithm.
By receiving the IPSEC SA sent by the second device, determine whether there is a digest length attribute, negotiate the supported digest length, and encrypt the communication message based on the negotiated digest length to ensure interoperability of products from different manufacturers.
It realizes the rapid application of the digest algorithm in IPSEC and the interoperability of products from different manufacturers, improving network security and interoperability.
Smart Images

Figure CN118984245A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to encryption technology, and in particular to a message encryption method, device, electronic device, storage medium and computer program product. Background Art
[0002] In the IPsec protocol suite, protocols such as IKE / AH / ESP used for key exchange and data transmission have been developed for many years and have basically become stable and no longer modified.
[0003] As network security risks grow, old digest algorithms may no longer meet security requirements, and new and more secure digest algorithms continue to emerge. For example, the previously widely used MD5 algorithm is no longer recommended for applications with high security requirements.
[0004] The process of applying a new digest algorithm to IPsec is relatively long and cannot fully meet security requirements: first, the new algorithm itself needs to undergo years of improvement, review and standardization to form an RFC; then, it needs to be further reviewed and standardized in the IPsec working group and updated to RFC 4868 "Using HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 with IPsec" or form a new RFC.
[0005] The current IPSec VPN technical specifications released by my country's National Standards Committee require the use of the SM3 algorithm to verify data integrity. However, there are differences in the length of ESP authentication data implemented by different products and manufacturers. There are obstacles when different IPsec products use the SM3 national encryption algorithm, which affects the promotion of the national encryption algorithm. Summary of the invention
[0006] The embodiments of the present application provide a message encryption method, device, electronic device and computer-readable storage medium, which can quickly apply the digest algorithm to IPSEC and achieve intercommunication between products of different manufacturers.
[0007] The technical solution of the embodiment of the present application is implemented as follows:
[0008] The embodiment of the present application provides a message encryption method, including: applied to a first device, including:
[0009] Receiving an Internet Security Protocol IPSEC SA sent by a second device;
[0010] Determining whether there is a digest length attribute for calibrating a message digest length in the IPSEC SA;
[0011] If the digest length attribute exists, in the case where it is determined that the first device supports the digest length attribute, determining a first digest length through negotiation with the second device based on the digest length attribute;
[0012] Based on the first digest length, message encryption is performed on the communication message when performing message communication with the second device.
[0013] In the above scheme, the method further includes:
[0014] If the digest length attribute exists, in the case where it is determined that the first device does not support the digest length attribute, determine a second digest length through negotiation with the second device from at least one digest length supported by the first device;
[0015] The communication message during message communication with the second device is encrypted based on the second digest length.
[0016] In the above scheme, the method further includes:
[0017] If the digest length attribute does not exist, the communication message during the message communication with the second device is encrypted based on a preset third digest length.
[0018] In the above scheme, the method further includes:
[0019] Adjusting the configuration parameters used by the first device for negotiating the IPSEC SA to target parameters, and sending a notification to the second device so that the second device adjusts the configuration parameters used for negotiating the IPSEC SA to the target parameters;
[0020] Perform IPSEC SA negotiation with the second device based on the target parameters.
[0021] In the above solution, the configuration parameters include at least one of the following: security parameters, key length and algorithm.
[0022] The present application provides a message encryption device, including:
[0023] A receiving module, used for receiving an Internet security protocol IPSEC SA sent by a second device;
[0024] A determination module, used to determine whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA;
[0025] a negotiation module, configured to determine a first digest length through negotiation with the second device based on the digest length attribute if the digest length attribute exists and if it is determined that the first device supports the digest length attribute;
[0026] An encryption module is used to encrypt a communication message when performing message communication with the second device based on the first summary length.
[0027] In the above solution, the negotiation module is further used to, if the summary length attribute exists, negotiate with the second device to determine a second summary length from at least one summary length supported by the first device when it is determined that the first device does not support the summary length attribute;
[0028] The encryption module is further used to encrypt the communication message when performing message communication with the second device based on the second summary length.
[0029] An embodiment of the present application provides an electronic device, including:
[0030] A memory for storing executable instructions;
[0031] The processor is used to implement the message encryption method provided in the embodiment of the present application when executing the executable instructions stored in the memory.
[0032] An embodiment of the present application provides a computer-readable storage medium storing executable instructions for causing a processor to execute and implement the message encryption method provided in the embodiment of the present application.
[0033] An embodiment of the present application provides a computer program product storing a computer program for implementing the message encryption method provided in the embodiment of the present application when executed by a processor.
[0034] The embodiment of the present application receives an Internet security protocol IPSEC SA sent by a second device; determines whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA; if the digest length attribute exists, and if it is determined that the first device supports the digest length attribute, determines a first digest length through negotiation with the second device based on the digest length attribute; based on the first digest length, encrypts the communication message when communicating with the second device, thereby quickly implementing the application of the digest algorithm to IPSEC and achieving interoperability between products from different manufacturers. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is an optional structural diagram of the message encryption system 100 provided in the embodiment of the present application.
[0036] Figure 2 is an optional structural diagram of an electronic device 200 provided in an embodiment of the present application;
[0037] Figure 3This is an optional flowchart of the message encryption method provided in the embodiment of the present application;
[0038] Figure 4 It is an optional schematic diagram of the summary length attribute provided in an embodiment of the present application. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.
[0040] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0041] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0042] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0043] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0044] 1) The IPSEC protocol family defines IKE / AH / ESP and other protocols for key exchange and data transmission. During the communication process, the message digest algorithm is used to calculate the integrity check value (ICV) and transmit it to the peer. After receiving it, the peer device uses the agreed message digest algorithm to calculate the ICV and compare whether the two are the same. If they are different, the authentication fails.
[0045] In the related art, there are many internationally standardized message digest algorithms, such as HMAC-SHA-256, HMAC-SHA-384, etc. The length of the ICV value calculated by the same algorithm is fixed. For example, the length of the ICV calculated by HMAC-SHA-256 is 256 bits = 32 bytes, that is, to transmit 8 bytes of user data, an additional 32 bytes of ICV value need to be transmitted.
[0046] In order to improve bandwidth utilization, the industry usually uses variants of digest algorithms, truncating the digest to different lengths before use. For example, HMAC-SHA-256-96 means that the digest calculated by SHA256 is 256 bits, which is truncated to 96 bits before output; HMAC-SHA-384-192 means that the digest calculated by SHA384 is 384 bits, which is truncated to 192 bits before output.
[0047] However, the AH and ESP protocols only define the storage location of the ICV value, but do not define the length of the ICV value, resulting in the receiver being unable to confirm the ICV value in the message.
[0048] Based on this, the embodiments of the present application provide a message encryption method, device, electronic device and computer-readable storage medium, which can quickly implement the application of digest algorithm to IPSEC and realize the intercommunication of products from different manufacturers.
[0049] First, the message encryption system provided in the embodiment of the present application is described. Figure 1 , Figure 1 It is an optional structural diagram of the message encryption system 100 provided in the embodiment of the present application. To realize supporting a message encryption application, the first device 101 is connected to the second device 103 through the network 102. In some embodiments, the first device 101 can be a terminal or a server, and the second device 103 can also be a terminal or a server. Among them, the terminal can be a laptop, a tablet computer, a desktop computer, a smart phone, a dedicated message device, a portable game device, a smart speaker, a smart watch, etc., but is not limited to this. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (CDN, Content Delivery Network) services, and basic cloud computing services such as big data and artificial intelligence platforms. Network 102 can be a wide area network or a local area network, or a combination of the two. The first device 101 and the second device 103 can be directly or indirectly connected by wired or wireless communication, which is not limited in the embodiment of the present application.
[0050] Next, the electronic device for implementing the above-mentioned message encryption method provided in the embodiment of the present application is described, see Figure 2 , Figure 2 is an optional structural diagram of an electronic device 200 provided in an embodiment of the present application. In practical applications, the electronic device 200 can be implemented as Figure 1 The first device 101 in the embodiment of the present application is described below.
[0051] Figure 2 The electronic device 200 shown includes: at least one processor 201, a memory 205, at least one network interface 202 and a user interface 203. The various components in the electronic device 200 are coupled together via a bus system 204. It is understood that the bus system 204 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 204 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 204 is not described in detail. Figure 2 Various buses are labeled as bus system 204 .
[0052] The processor 201 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0053] The user interface 203 includes one or more output devices 2031 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 203 also includes one or more input devices 2032, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0054] The memory 205 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 205 may optionally include one or more storage devices that are physically remote from the processor 201.
[0055] The memory 205 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 205 described in the embodiment of the present application is intended to include any suitable type of memory.
[0056] In some embodiments, the memory 205 can store data to support various operations. Examples of these data include programs, modules, and data structures, or subsets or supersets thereof. In the embodiment of the present application, the memory 205 stores an operating system 2051, a network communication module 2052, a presentation module 2053, an input processing module 2054, and a message encryption device 2055; specifically,
[0057] Operating system 2051, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;
[0058] A network communication module 2052, for reaching other computing devices via one or more (wired or wireless) network interfaces 202, exemplary network interfaces 202 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB);
[0059] a presentation module 2053 for enabling presentation of information (e.g., a user interface for operating peripherals and displaying content and information) via one or more output devices 2031 (e.g., a display screen, a speaker, etc.) associated with the user interface 203;
[0060] The input processing module 2054 is used to detect one or more user inputs or interactions from one of the one or more input devices 2032 and translate the detected inputs or interactions.
[0061] In some embodiments, the message encryption device provided in the embodiments of the present application can be implemented in software. Figure 2 The message encryption device 2055 stored in the memory 205 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a receiving module 20551, a determining module 20552, a negotiation module 20553 and an encryption module 20554. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.
[0062] In other embodiments, the message encryption device provided in the embodiments of the present application can be implemented in hardware. As an example, the message encryption device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the message encryption method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs) or other electronic components.
[0063] The message encryption method provided in the embodiment of the present application will be explained below in combination with the exemplary application and implementation of the first electronic device provided in the embodiment of the present application.
[0064] See also Figure 3 , Figure 3 is an optional flow chart of the message encryption method provided in the embodiment of the present application, which will be combined with Figure 3 The steps shown are explained.
[0065] Step 301, receiving an Internet Security Protocol IPSEC Security Association SA sent by a second device;
[0066] Step 302, determining whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA;
[0067] Step 303: if the digest length attribute exists, and if it is determined that the first device supports the digest length attribute, determine a first digest length through negotiation with the second device based on the digest length attribute;
[0068] Step 304: Encrypt the communication message with the second device based on the first digest length.
[0069] In actual implementation, the two parties in IPsec communication will exchange necessary parameters through the negotiation phase, including encryption algorithm, authentication algorithm, key length, operation mode, etc. There are two main negotiation modes: main mode and quick mode. In the main mode, the two parties in communication exchange key materials through the Diffie-Hellman key exchange protocol and verify the identity of each other. After the main mode is completed, the two parties in communication negotiate specific encryption and authentication parameters through the quick mode and exchange keys for protecting communications.
[0070] During IKE negotiation, the IPsec implementations of both parties will negotiate based on their respective policies and capabilities. Normally, the strongest security algorithm and key length supported by both ends will be selected. Before the communicating parties (usually two hosts or two gateways) establish an IPsec connection, they will negotiate SA through the IKE protocol. SA includes security parameters such as encryption algorithm, hash algorithm, key length, etc. At the same time, this process will also confirm the negotiated summary length. In IPsec, the summary length is actually determined by the selected algorithm, rather than directly negotiating the summary length itself. The hash algorithm selected by the present invention adopts a structure similar to SHA-256, with an output length of 256 bits (32 bytes), combining steps such as data segmentation, padding, and compression to generate a hash value of fixed length.
[0071] Dynamic negotiation refers to the process in which two communicating nodes dynamically determine SA through a negotiation protocol before communication begins, without pre-configuring SA when they need to establish secure communication. The main advantages of dynamic negotiation are flexibility and security. It allows nodes to dynamically adapt to the network environment and security requirements before actual communication, avoiding the potential security risks of static configuration. The method for confirming the length of the digest (or authentication data) is usually determined by the selected authentication algorithm.
[0072] There are three IPSEC protocol clusters defined by IETF, one is IKE, one is AH protocol, and the third is ESP protocol. ESP is an important component of the IPsec protocol suite, which is used to provide data encryption and authentication. It can be used to protect the secure transmission of IP data packets on public networks and ensure the confidentiality and integrity of data. ESP can select encryption algorithm and authentication algorithm when transmitting data.
[0073] ICV is a technology used to verify data integrity in network communications. ICV is usually transmitted together with data and can be attached to the end of the data or sent as part of the data. After receiving the data, the receiver will extract the ICV separately and verify it.
[0074] In actual implementation, when the second device needs to establish message communication with the first device, it first performs communication negotiation with the second device. Here, the communication negotiation includes encryption negotiation. In the embodiment of the present application, the first device receives the IPSEC SA sent by the second device, and determines whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA. Here, the message digest length is an attribute added to the IPSEC SA based on the related technology, which is used to calibrate the length of the message digest. The message digest length is used for the second device to negotiate the message digest length with the first device.
[0075] In actual implementation, if there is a digest length attribute, it is determined whether the first device supports the digest length attribute, that is, whether the first device can identify the digest length attribute and perform encryption negotiation with the second device based on the digest length attribute. In the case of determining that the first device supports the digest length attribute, the first digest length is determined through negotiation with the second device based on the digest length attribute.
[0076] In actual implementation, if the digest length attribute exists, when it is determined that the first device supports the digest length attribute, the first digest length is determined through negotiation with the second device based on the digest length attribute, and then, based on the first digest length, the communication message during the message communication with the second device is encrypted. Specifically, if the IPsec SA proposal received by the first device contains the "digest length" attribute, and the first device itself also supports this attribute, then during the SA negotiation process, the first device will select a suitable digest length according to its own configuration and policy. The digest length attribute is usually used to specify the output length of the hash algorithm used in the encryption process. In IPsec, the output length of the hash algorithm can be configured and selected according to application requirements. If a specific digest length is specified in the SA proposal received by the device, and the device supports this digest length, then the digest length can be determined as the first digest length.
[0077] The embodiment of the present application dynamically determines the length of the ESP authentication data, that is, the digest length, through an IPSEC SA proposal. In the embodiment of the present application, when the first device receives a negotiation request from the second device, it obtains the IPSEC SA sent by the second device. Then, it is determined from the IPSEC SA whether there is a digest length attribute for calibrating the message digest length. For example, see Figure 4 , Figure 4 4 is an optional schematic diagram of the digest length attribute provided in the embodiment of the present application, wherein the digest length attribute 401 is named Authentication Legth and has a value of 10.
[0078] In some embodiments, the method also includes: if the summary length attribute exists, when it is determined that the first device does not support the summary length attribute, negotiating with the second device to determine a second summary length from at least one summary length supported by the first device; and encrypting the communication message when communicating messages with the second device based on the second summary length.
[0079] In actual implementation, if the received IPSEC SA security authentication data length contains a digest length attribute, and the first device does not support the digest length attribute, that is, the first device does not have the digest length attribute, the first device continues to use at least one digest length it supports to negotiate SA with the second device. This avoids the first device directly terminating or reporting an error when the first device does not support the digest length attribute, thereby affecting the negotiation efficiency.
[0080] In some embodiments, the method further includes: if the digest length attribute does not exist, encrypting the communication message when performing message communication with the second device based on a preset third digest length.
[0081] In actual implementation, if the digest length attribute does not exist in the authentication length in the IPSEC SA received by the first device, that is, the "digest length" attribute is not included, then the first device continues to process the negotiated SA according to the previous behavior. The first device adopts the same behavior as before, and the device behaviors such as IPsec RFC documents, encryption algorithms and key lengths, and security policies remain unchanged. Specifically, this means that when the first device processes the SA proposal, the first device will continue to use the pre-configured default third digest length or the default configuration of the digest algorithm, use the negotiated message digest algorithm to calculate the data, and generate the ICV authentication data length to ensure the negotiation and establishment of the SA. This practice helps to ensure the stability and interoperability of the first device in various situations, so as to achieve normal communication and collaboration with other IPsec.
[0082] In some embodiments, the method further includes: adjusting the configuration parameters used by the first device to negotiate the IPSEC SA to target parameters, and sending a notification to the second device so that the second device adjusts the configuration parameters used to negotiate the IPSEC SA to the target parameters; and performing IPSEC SA negotiation with the second device based on the target parameters. In some embodiments, the configuration parameters include at least one of the following: security parameters, key length, and algorithm.
[0083] In actual implementation, if the encryption negotiation algorithm needs to be updated, for example, to improve the security of the encryption negotiation algorithm, specifically, if the previously configured truncation length is too short and there is a security risk, the configuration parameters used to negotiate the IPSEC SA in the first device are directly adjusted, for example, adjusted to the target parameters, and a notification is sent to the second device so that the second device also adjusts the configuration parameters used to negotiate the IPSEC SA to the target parameters, so that the first device negotiates the IPSEC SA with the second device based on the target parameters. The configuration parameters here include security parameters, key length and algorithm, and the configuration update in the negotiation phase is completed by adjusting the configuration parameters. If a shorter truncation length of a certain algorithm is used in the previous configuration, and now the security needs to be improved, the configuration can be adjusted to use a longer truncation length without changing the protocol itself or updating the RFC. At the same time, the key length can also be adjusted to increase or replace it with a more secure encryption algorithm.
[0084] The following is a description of an exemplary structure of the message encryption device 2055 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2 As shown, the software modules stored in the message encryption device 2055 of the memory 205 may include:
[0085] The receiving module 20551 is used to receive the Internet Security Protocol IPSEC SA sent by the second device;
[0086] Determining module 20552, used to determine whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA;
[0087] A negotiation module 20553 is configured to determine a first digest length through negotiation with the second device based on the digest length attribute if the digest length attribute exists and if it is determined that the first device supports the digest length attribute;
[0088] The encryption module 20554 is used to encrypt the communication message when communicating with the second device based on the first summary length.
[0089] In some embodiments, the negotiation module is further used to, if the summary length attribute exists, negotiate with the second device to determine a second summary length from at least one summary length supported by the first device when it is determined that the first device does not support the summary length attribute; the encryption module is further used to encrypt communication messages based on the second summary length when communicating messages with the second device.
[0090] In some embodiments, the encryption module is further used to encrypt the communication message when communicating messages with the second device based on a preset third digest length if the digest length attribute does not exist.
[0091] In some embodiments, the device also includes: a configuration module, used to adjust the configuration parameters used by the first device to negotiate IPSEC SA to target parameters, and send a notification to the second device so that the second device adjusts the configuration parameters used to negotiate IPSEC SA to the target parameters; and negotiate IPSEC SA with the second device based on the target parameters.
[0092] In some embodiments, the configuration parameters include at least one of the following: security parameters, key length, and algorithm.
[0093] It should be noted that the description of the device of the embodiment of the present application is similar to the description of the above-mentioned method embodiment, and has similar beneficial effects as the method embodiment, so it will not be repeated.
[0094] The embodiment of the present application provides a computer program product, which includes computer instructions, which are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the message encryption method described in the embodiment of the present application.
[0095] An embodiment of the present application provides a computer-readable storage medium storing executable instructions, wherein executable instructions are stored. When the executable instructions are executed by a processor, the processor will execute the message encryption method provided by the embodiment of the present application.
[0096] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0097] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0098] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0099] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0100] In summary, the embodiments of the present application can quickly implement the application of the digest algorithm to IPSEC and achieve intercommunication between products of different manufacturers.
[0101] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A message encryption method, characterized in that: Applied to a first device, comprising: Receiving an Internet Security Protocol IPSEC Security Alliance SA sent by the second device; Determining whether there is a digest length attribute for calibrating a message digest length in the IPSEC SA; If the digest length attribute exists, in the case where it is determined that the first device supports the digest length attribute, determining a first digest length through negotiation with the second device based on the digest length attribute; Based on the first digest length, message encryption is performed on the communication message when performing message communication with the second device.
2. The method according to claim 1, characterized in that The method further comprises: If the digest length attribute exists, in the case where it is determined that the first device does not support the digest length attribute, determine a second digest length through negotiation with the second device from at least one digest length supported by the first device; The communication message during message communication with the second device is encrypted based on the second digest length.
3. The method according to claim 1, characterized in that The method further comprises: If the digest length attribute does not exist, the communication message during the message communication with the second device is encrypted based on a preset third digest length.
4. The method according to claim 1, characterized in that: The method further comprises: Adjusting the configuration parameters used by the first device for negotiating the IPSEC SA to target parameters, and sending a notification to the second device so that the second device adjusts the configuration parameters used for negotiating the IPSEC SA to the target parameters; Perform IPSEC SA negotiation with the second device based on the target parameters.
5. The method according to claim 4, characterized in that The configuration parameters include at least one of the following: security parameters, key length, and algorithm.
6. A message encryption device, characterized in that: include: A receiving module, used for receiving an Internet security protocol IPSEC SA sent by a second device; A determination module, used to determine whether there is a digest length attribute for calibrating the message digest length in the IPSEC SA; a negotiation module, configured to determine a first digest length through negotiation with the second device based on the digest length attribute if the digest length attribute exists and if it is determined that the first device supports the digest length attribute; An encryption module is used to encrypt a communication message when performing message communication with the second device based on the first summary length.
7. The message encryption device according to claim 6, characterized in that: The negotiation module is further configured to, if the summary length attribute exists, negotiate with the second device to determine a second summary length from at least one summary length supported by the first device in the case where it is determined that the first device does not support the summary length attribute; The encryption module is further used to encrypt the communication message when performing message communication with the second device based on the second summary length.
8. An electronic device, characterized in that: include: A memory for storing executable instructions; A processor, configured to implement the message encryption method according to any one of claims 1 to 5 when executing the executable instructions stored in the memory.
9. A computer-readable storage medium, characterized in that: Executable instructions are stored, which are used to implement the message encryption method described in any one of claims 1 to 5 when executed by a processor.
10. A computer program product, characterized in that A computer program is stored, which is used to implement the message encryption method described in any one of claims 1 to 5 when executed by a processor.
