Digital envelope encryption method and apparatus

The combined encryption method of SM4 and SM2 algorithms solves the security and decryption performance issues when using SM2 or SM4 algorithms alone, realizes dual password protection and fast signature verification of plaintext data, and ensures the security and reliability of data transmission.

CN116389100BActive Publication Date: 2025-10-24湖北省楚天云有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310324811.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2022-12-28
Filing Date
2023-03-29
Publication Date
2025-10-24
Estimated Expiration
2043-03-29

AI Technical Summary

Technical Problem

SM2 public key encryption is suitable for encrypting shorter data. Encryption and decryption using the SM2 or SM4 algorithm alone is not secure. The SM2 ciphertext decryption performance is weak, and untimely decryption at the receiving end can easily lead to data channel congestion.

Method used

The plaintext data is symmetrically encrypted using the SM4 data encryption key to generate a random SM4 symmetric key, and is asymmetrically encrypted using the receiver's SM2 public key. This is combined with the sender's SM2 private key signature to form a digital envelope, which is encrypted and decrypted using the combined SM2 asymmetric key and SM4 symmetric key.

Benefits of technology

It achieves double cryptographic protection for plaintext data, improves decryption performance, prevents data channel congestion, and ensures the confidentiality, integrity, and non-repudiation of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116389100B_ABST
    Figure CN116389100B_ABST
Patent Text Reader

Abstract

The application relates to a digital envelope encryption method and device, which comprises the following steps: using an SM4 data encryption key to symmetrically encrypt plaintext data to be uploaded to obtain first ciphertext, and generating a random SM4 symmetric key according to the ID of the plaintext data; using a receiver SM2 public key to asymmetrically encrypt the random SM4 symmetric key to obtain second ciphertext; using the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain third ciphertext; using a sender SM2 private key to sign the SM4 data encryption key to obtain a signature value; encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope; the application utilizes the decryption performance of the SM4 symmetric encryption algorithm and the signature speed, anti-repudiation and other characteristics of the SM2 digital envelope, and when a receiver receives a large amount of SM2 ciphertext sent by multiple senders, the signature verification speed is fast, and the data channel is not blocked.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a digital envelope encryption method and device. BACKGROUND

[0002] SM2 cryptographic algorithm is a public key cryptographic algorithm, which is based on more secure and advanced elliptic curve cryptographic mechanism, and is improved on the basis of international standard ECC elliptic curve cryptographic theory, and has higher encryption strength. SM2 belongs to an asymmetric encryption algorithm, uses public key encryption, and private key decryption, and is superior to RSA algorithm in security and operation speed. In summary, as a public key algorithm, SM2 algorithm can complete signature, key exchange and encryption application.

[0003] SM4 cryptographic algorithm is a block symmetric cryptographic algorithm, which is used for realizing data encryption / decryption operation to ensure the confidentiality of data and information. The encryption algorithm and the key expansion algorithm both adopt a 32-round nonlinear iteration structure. The key expansion algorithm is an operation unit for transforming the encryption key into a round key. The algorithm structure of data decryption and data encryption is the same, except that the use order of the round keys is opposite, and the decryption round key is the reverse order of the encryption round key. SM4 belongs to a symmetric encryption algorithm, and can be used to replace international algorithms such as DES / AES. SM4 algorithm and AES algorithm have the same key length and block length, both of which are 128 bits. SUMMARY

[0004] The present application relates to a digital envelope encryption method and device.

[0005] In the first aspect, the present application provides a digital envelope encryption method, comprising:

[0006] using an SM4 data encryption key to perform symmetric encryption on plaintext data to be uploaded to obtain first ciphertext, and generating a random SM4 symmetric key according to an ID of the plaintext data;

[0007] using a receiver SM2 public key to perform asymmetric encryption on the random SM4 symmetric key to obtain second ciphertext;

[0008] encrypting the SM4 data encryption key using the random SM4 symmetric key to obtain third ciphertext;

[0009] signing the SM4 data encryption key using a sender SM2 private key to obtain a signature value;

[0010] encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope;

[0011] obtaining a sender identifier and a receiver identifier, and storing the digital envelope identifier, the sender identifier, the receiver identifier and the digital envelope into a data exchange key table;

[0012] storing the first ciphertext and the digital envelope identifier into a ciphertext table, and sending the data exchange key table and the ciphertext table to the receiver.

[0013] In an optional embodiment, the step of encrypting the SM4 data encryption key using the random SM4 symmetric key to obtain third ciphertext comprises:

[0014] encrypting the SM4 data encryption key using the random SM4 symmetric key in ECB mode, and filling data using a PKCS5 padding mode to obtain the third ciphertext.

[0015] In an optional embodiment, the step of encrypting the random SM4 symmetric key using a receiver SM2 public key to obtain second ciphertext comprises:

[0016] encrypting the random SM4 symmetric key using a first SM2 cryptographic algorithm based on the receiver SM2 public key to obtain the second ciphertext.

[0017] In an optional embodiment, the step of encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope comprises:

[0018] encapsulating the second ciphertext, the third ciphertext and the signature value using a preset signature digital envelope structure to obtain the digital envelope, and randomly generating a digital envelope identifier of the digital envelope.

[0019] In an optional embodiment, the step of encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope comprises:

[0020] encapsulating the second ciphertext, the third ciphertext and the signature value using a preset digital envelope format to obtain the digital envelope, and randomly generating a digital envelope identifier of the digital envelope.

[0021] In a second aspect, the present application provides a digital envelope decryption method for decrypting a digital envelope encrypted by the digital envelope encryption method of the first aspect, by the following steps:

[0022] Obtaining a data exchange key table and a ciphertext table sent by a sender;

[0023] Obtaining a digital envelope identifier from the data exchange key table, and obtaining a corresponding digital envelope from the data exchange key table according to the digital envelope identifier;

[0024] Decrypting the digital envelope to obtain a second ciphertext, a third ciphertext and a signature value;

[0025] Decrypting the signature value using a sender SM2 public key to obtain a first SM4 data encryption key;

[0026] Decrypting the second ciphertext using a receiver SM2 private key to obtain a random SM4 symmetric key generated based on an ID of plaintext data;

[0027] Decrypting the third ciphertext using the random SM4 symmetric key to obtain a second SM4 data encryption key;

[0028] If the first SM4 data encryption key and the second SM4 data encryption key are consistent, obtaining a first ciphertext from the ciphertext table based on the digital envelope identifier, and decrypting the first ciphertext using the first SM4 data encryption key or the second SM4 data encryption key to obtain plaintext data sent by the sender.

[0029] In a third aspect, the present application provides a digital envelope encryption device, comprising:

[0030] A random SM4 symmetric key generation module for symmetrically encrypting plaintext data to be uploaded using an SM4 data encryption key to obtain a first ciphertext, and generating a random SM4 symmetric key according to an ID of the plaintext data;

[0031] A first encryption module for asymmetrically encrypting the random SM4 symmetric key using a receiver SM2 public key to obtain a second ciphertext;

[0032] A second encryption module for symmetrically encrypting the SM4 data encryption key using the random SM4 symmetric key to obtain a third ciphertext;

[0033] A signature module for signing the SM4 data encryption key using a sender SM2 private key to obtain a signature value;

[0034] an encapsulation module, configured to encapsulate the second ciphertext, the third ciphertext, and the signature value into a digital envelope, and randomly generate a digital envelope identifier for the digital envelope;

[0035] A data storage module is used to obtain a sender identifier and a receiver identifier, and store the digital envelope identifier, the sender identifier, the receiver identifier and the digital envelope into a data exchange key table;

[0036] The sending module is used to store the first ciphertext and the digital envelope identifier in a ciphertext table, and send the data exchange key table and the ciphertext table to the recipient.

[0037] In a fourth aspect, the present invention provides a digital envelope decryption device, comprising:

[0038] The receiving module is used to obtain the data exchange key table and ciphertext table sent by the sender;

[0039] A digital envelope obtaining module, configured to obtain a digital envelope identifier from the data exchange key table, and obtain a corresponding digital envelope from the data exchange key table according to the digital envelope identifier;

[0040] a decryption module, configured to decrypt the digital envelope to obtain a second ciphertext, a third ciphertext, and a signature value;

[0041] A first decryption module is used to decrypt the signature value using the sender SM2 public key to obtain a first SM4 data encryption key;

[0042] A second decryption module is used to decrypt the second ciphertext using the recipient's SM2 private key to obtain a random SM4 symmetric key generated based on the ID of the plaintext data;

[0043] A third decryption module is configured to decrypt the third ciphertext using the random SM4 symmetric key to obtain a second SM4 data encryption key;

[0044] a signature verification module, configured to obtain a first ciphertext from the ciphertext table based on the digital envelope identifier if the first SM4 data encryption key and the second SM4 data encryption key are consistent, and decrypt the first ciphertext using the first SM4 data encryption key or the second SM4 data encryption key to obtain the plaintext data sent by the sender.

[0045] In a fifth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the digital envelope encryption method as described in the first aspect and / or the digital envelope decryption method as described in the second aspect.

[0046] In a sixth aspect, the present application provides an electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;

[0047] a memory for storing a computer program;

[0048] a processor for executing the program stored on the memory to implement the digital envelope encryption method of the first aspect and / or the digital envelope decryption method of the second aspect.

[0049] Based on the above technical solution, the present application has the following beneficial effects compared with the prior art:

[0050] The digital envelope encryption method provided by the embodiment of the present application first uses an SM4 data encryption key to symmetrically encrypt the plaintext data to be uploaded to obtain a first ciphertext, and generates a random SM4 symmetric key according to the ID of the plaintext data; secondly, uses an SM2 public key of the receiver to asymmetrically encrypt the random SM4 symmetric key to obtain a second ciphertext, which is fast in signing; thirdly, uses the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain a third ciphertext; and finally, encapsulates the second ciphertext, the third ciphertext and a signature value into a digital envelope, and the receiver can use an SM2 asymmetric key to complete decryption of the content of the digital envelope, that is, uses an SM2 public key of the sender to decrypt the signature value in the content of the digital envelope to obtain a first SM4 data encryption key, uses an SM2 private key of the receiver to decrypt the second ciphertext in the content of the digital envelope to obtain a random SM4 symmetric key, and uses the random SM4 symmetric key to decrypt the third ciphertext in the content of the digital envelope to obtain a second SM4 data encryption key, and the signature is verified by comparing the first SM4 data encryption key and the second SM4 data encryption key, and the decryption performance is good. The data sender of the present application uses an SM4 symmetric encryption algorithm to encrypt the plaintext data content, and uses an SM2 asymmetric encryption algorithm to sign the digital envelope. The receiver first uses an SM2 asymmetric encryption algorithm to verify the digital envelope, and after successful verification, achieves anti-repudiation, and in addition, the SM4 symmetric encryption algorithm needs the same key for encryption and decryption, and the same key can be generated and exchanged through the digital envelope for SM4 symmetric encryption. The present application not only utilizes the decryption performance of the SM4 symmetric encryption algorithm, but also utilizes the signature speed and anti-repudiation characteristics of the SM2 digital envelope, and when the receiver receives a large amount of SM2 ciphertext sent by multiple senders, the verification speed is fast, and the data channel is not blocked.

[0051] The digital envelope encryption method provided by the embodiment of the present application first uses an SM4 data encryption key to symmetrically encrypt to-be-uploaded plaintext data to obtain first ciphertext, and generates a random SM4 symmetric key according to the ID of the plaintext data; secondly, the random SM4 symmetric key is asymmetrically encrypted using the SM2 public key of the receiving party to obtain second ciphertext; and thirdly, the SM4 data encryption key is symmetrically encrypted using the random SM4 symmetric key to obtain third ciphertext, so that the plaintext data is encrypted, and the SM4 data encryption key used for encrypting the plaintext data is encrypted, thereby forming double password protection for each batch of ciphertext data, that is, the first ciphertext and the data encryption key; the data exchange key table and the ciphertext table are sent to the receiving party, so that the digital envelope content and the batch of ciphertext data, that is, the first ciphertext, are sent to the receiving party through a secure data channel.

[0052] Other features and advantages of the present application will be set forth in the descriptions below, and in part will become apparent to those skilled in the art upon examination of the following or can be learned by practice of the present application. The objects and other advantages of the present application can be realized and attained by the structure particularly pointed out in the description, claims and drawings.

[0053] In order to make the above-mentioned objects, features and advantages of the present application more apparent, the following preferred embodiments are specifically described in detail below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0054] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings described below are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.

[0055] Figure 1 is a flowchart of the digital envelope encryption method provided by the first embodiment of the present application Figure One ;

[0056] Figure 2 is a flowchart of the digital envelope encryption method provided by the first embodiment of the present application Figure Two ;

[0057] Figure 3 is a flowchart of the digital envelope decryption method provided by the second embodiment of the present application

[0058] Figure 4 is a structural schematic diagram of the digital envelope encryption device provided by the third embodiment of the present application

[0059] Figure 5is a structural schematic diagram of a digital envelope decryption device provided by an embodiment four of the present application;

[0060] Figure 6 is a structural schematic diagram of an electronic device provided by an embodiment six of the present application. DETAILED DESCRIPTION

[0061] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings; however, they are not limited to the embodiments set forth herein but can be implemented in various forms. The present disclosure will be described herein with reference to exemplary embodiments illustrating preferred embodiments of the application. A detailed description of the exemplary embodiments of the present disclosure is provided herein with reference to the attached drawings.

[0062] The exemplary embodiments will be described in detail with reference to the drawings. In the following description, the same drawing reference numerals are used to denote elements in the various figures. The embodiments described in the following exemplary embodiments are not meant to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the appended claims.

[0063] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like, indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the purpose of facilitating the description of the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third" are only for the purpose of description and cannot be understood as indicating or implying relative importance.

[0064] In the description of the present application, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connection" should be broadly understood, for example, it can be fixedly connected, or it can be detachably connected, or integrally connected; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0065] Embodiment one

[0066] Based on the analysis of the relationship between the digital envelope and the key, the digital envelope encryption process focuses on the content of the digital envelope, the identification processing of the digital envelope, the association between the digital envelope identification and the ciphertext data, and the plaintext data encryption, etc. The embodiment of the application provides a digital envelope encryption method, as shown in Figure 1 and Figure 2 , which comprises:

[0067] S101, using the SM4 data encryption key A, the plaintext data to be uploaded is symmetrically encrypted to obtain the first ciphertext A, and the random SM4 symmetric key K is generated according to the ID of the plaintext data; the plaintext data ID in the embodiment of the application is the database unique identifier UUID generated based on the UUID generation algorithm. UUID (Universally Unique Identifier) represents a universal unique identifier, which is defined based on the "RFC 4122" universal unique identifier URN namespace. UUID is designed to be a globally unique number in space and time, and it is expected that two UUID values are different, even if they are generated on two independent servers. Using UUID as a random primary key has the advantages that the UUID value is unique in the table, database, and even in the server, allows merging rows from different databases or distributing databases across servers, the UUID value does not disclose information about the data, the UUID value can be generated anywhere to avoid round trips to the database server, and the logic in the application is simplified. The process of generating the plaintext data ID based on the UUID generation algorithm can refer to the specific description in the prior art, for example, a unique UUID can be generated using the timestamp and the MAC address of the network card, which will not be described here.

[0068] The random SM4 symmetric key K is a key protection key, which is used to obtain the ciphertext of the random SM4 symmetric key K, i.e. the second ciphertext B, using the SM2 public key of the receiver, and to encrypt the SM4 data encryption key A to obtain the ciphertext of the SM4 data encryption key A, i.e. the third ciphertext C.

[0069] S102, using the receiver's SM2 public key, the random SM4 symmetric key K is asymmetrically encrypted to obtain the second ciphertext B;

[0070] S103, using the random SM4 symmetric key K, the SM4 data encryption key A is symmetrically encrypted to obtain the third ciphertext C;

[0071] S104, using the sender's SM2 private key, the SM4 data encryption key A is signed to obtain the signature value S;

[0072] In the steps S101-S104, the digital envelope uses the SM2 asymmetric key (i.e., the sender SM2 public key and the receiver SM2 private key) to encrypt the random SM4 symmetric key K and the SM4 data encryption key A; the ciphertext data is encrypted using the SM4 data encryption key A. Then, the digital envelope is a key protected by the SM2 password, and the digital envelope content is decrypted using the SM2 key to obtain the SM4 symmetric key (i.e., the random SM4 symmetric key K) for opening the ciphertext data. Since the random SM4 symmetric key K is randomly generated according to the ID of the plaintext data each time, the SM4 symmetric key K of each batch is different; the ciphertext data is obtained, but without the random SM4 symmetric key K of this batch, the ciphertext content cannot be decrypted. This is different from the traditional single use of SM2 asymmetric key or SM4 symmetric key, and the security of the key cannot be guaranteed, forming double password protection for each batch of ciphertext data and key.

[0073] S105, encapsulating the second ciphertext B, the third ciphertext C, and the signature value S into a digital envelope, and randomly generating a digital envelope identifier (random digital envelope ID) of the digital envelope;

[0074] S106, obtaining a sender identifier and a receiver identifier, storing the digital envelope identifier, the sender identifier, the receiver identifier, and the digital envelope into a data exchange key table;

[0075] Storing the digital envelope identifier, the sender identifier, the receiver identifier, the table name, and the encapsulated digital envelope into the data exchange key table.

[0076] S107, storing the first ciphertext A and the digital envelope identifier into a ciphertext table, and sending the data exchange key table and the ciphertext table to the receiver.

[0077] Encrypting the plaintext data using the SM4 symmetric key (i.e., the SM4 data encryption key A) to obtain the ciphertext data, and storing the digital envelope identifier of this batch of ciphertext data together with the ciphertext data (i.e., the first ciphertext A) into the ciphertext table.

[0078] The "SM2+SM4" combined encryption scheme is implemented by software, and the data exchange key table is used to store the unique identifier of the digital envelope, the sender identifier, the receiver identifier, and the digital envelope content, etc. After the data exchange key table and the ciphertext table are transmitted to the receiver, the receiver performs digital envelope verification and ciphertext data decryption according to the digital envelope format and the ciphertext field specification. In the implementation mode selection of the traditional single use of SM2 or SM4 single encryption method for data encryption transmission, the application increases the "SM2+SM4" combined encryption scheme for implementation, and further improves the confidentiality, integrity, authenticity, and non-repudiation of data transmission.

[0079] The data exchange key table and the ciphertext table can be sent to the data receiver through a government affair extranet or other secure channels to form a batch digital envelope encryption closed loop.

[0080] In the steps S102-S105, the sender uses the SM2 public key of the receiver and the SM2 private key of the sender to encrypt and sign the SM4 symmetric key (i.e. the random SM4 symmetric key K and the SM4 data encryption key A) through the SM2 asymmetric encryption algorithm to obtain the digital envelope content; the digital envelope content and the ciphertext data of the same batch of the digital envelope, i.e. the first ciphertext, are sent to the receiver through a secure data channel. After receiving, the receiver uses the SM2 asymmetric key (i.e. the sender SM2 public key and the receiver SM2 private key) to decrypt the digital envelope content; after the digital envelope content is decrypted, the SM4 data encryption key A is obtained, which is used to decrypt the ciphertext data, i.e. the first ciphertext A, encrypted by the sender using the SM4 data encryption key A.

[0081] The digital envelope encryption method provided by the embodiment of the application first uses an SM4 data encryption key to perform symmetric encryption on to-be-uploaded plaintext data to obtain first ciphertext, and generates a random SM4 symmetric key according to the ID of the plaintext data; secondly, the random SM4 symmetric key is asymmetrically encrypted using an SM2 public key of a receiving party to obtain second ciphertext, and the signature speed is fast; thirdly, the SM4 data encryption key is symmetrically encrypted using the random SM4 symmetric key to obtain third ciphertext; and finally, the second ciphertext, the third ciphertext and a signature value are encapsulated into a digital envelope, and the receiving party can complete decryption of the content of the digital envelope using an SM2 asymmetric key, that is, the signature value in the content of the digital envelope is decrypted using an SM2 public key of a sending party to obtain a first SM4 data encryption key, the second ciphertext in the content of the digital envelope is decrypted using an SM2 private key of the receiving party to obtain a random SM4 symmetric key, and the third ciphertext in the content of the digital envelope is decrypted using the random SM4 symmetric key to obtain a second SM4 data encryption key, and the first SM4 data encryption key and the second SM4 data encryption key are compared to realize signature verification, and the SM4 data encryption key is used for signature verification, and the decryption performance is good. The data sending party uses an SM4 symmetric encryption algorithm to encrypt the plaintext data content, and uses an SM2 asymmetric encryption algorithm to perform digital envelope signature. The receiving end first uses an SM2 asymmetric encryption algorithm to perform digital envelope signature verification, and after successful signature verification, anti-repudiation is achieved. In addition, the SM4 symmetric encryption algorithm requires the same key for encryption and decryption, and the same key can be generated and exchanged through the digital envelope and used for SM4 symmetric encryption. The application utilizes the decryption performance of the SM4 symmetric encryption algorithm and the signature speed and anti-repudiation characteristics of the SM2 digital envelope, and the receiving party can quickly perform signature verification when receiving a large amount of SM2 ciphertext sent by multiple sending parties, and data channel congestion does not occur. The SM4 data encryption key can be used to decrypt the ciphertext data, that is, the first ciphertext, sent by the sending party using the SM4 data encryption key, to obtain the plaintext data sent by the sending party.

[0082] The digital envelope encryption method provided by the embodiment of the application first uses an SM4 data encryption key to perform symmetric encryption on to-be-uploaded plaintext data to obtain first ciphertext, and generates a random SM4 symmetric key according to the ID of the plaintext data; secondly, the random SM4 symmetric key is asymmetrically encrypted using an SM2 public key of a receiving party to obtain second ciphertext; and thirdly, the SM4 data encryption key is symmetrically encrypted using the random SM4 symmetric key to obtain third ciphertext. The plaintext data is encrypted, and the SM4 data encryption key used for encrypting the plaintext data is encrypted, so that double password protection is formed on each batch of ciphertext data, that is, the first ciphertext and the data encryption key. The data exchange key table and the ciphertext table are uploaded to the receiving party, so that the digital envelope content and the batch of ciphertext data, that is, the first ciphertext, are sent to the receiving party through a secure data channel. Therefore, the confidentiality, integrity, authenticity and non-repudiation of data transmission are ensured, and the "SM2+SM4" combined encryption scheme is implemented on the basis of the SM2 data encryption process. After the scheme is completed and tested successfully, data pushing is completed through the SM4 encryption channel.

[0083] In a specific embodiment, the SM4 data encryption key A can be symmetrically encrypted in ECB mode in step S103, and data padding can be performed in PKCS5 padding mode. The symmetric encryption of the SM4 data encryption key A using the random SM4 symmetric key K specifically includes the following steps.

[0084] The SM4 data encryption key A is symmetrically encrypted in ECB mode using the random SM4 symmetric key K, and data padding is performed in PKCS5 padding mode to obtain the third ciphertext C.

[0085] The encrypted data is divided into several groups in ECB mode in the embodiment of the application, each group has the same size as the encryption key, and the insufficient part is padded. The calculated data is connected together in sequence, and the data in each segment does not affect each other. When PKCS5 padding is used, the last byte is definitely the length of the padded data, so the padded data can be accurately deleted after decryption.

[0086] In a specific embodiment, the method for asymmetrically encrypting the random SM4 symmetric key K in step S102 can be a first SM2 cryptographic algorithm. The asymmetric encryption of the random SM4 symmetric key K using the SM2 public key of the receiving party to obtain the second ciphertext B specifically includes the following steps.

[0087] The random SM4 symmetric key K is asymmetrically encrypted using the first SM2 cryptographic algorithm based on the SM2 public key of the receiving party to obtain the second ciphertext B.

[0088] The first SM2 cryptographic algorithm is an SM2 cryptographic algorithm in compliance with the SM2 cryptographic algorithm usage specification of GM / T 0009-2012. The specific implementation process of encryption can be referred to the detailed description in the prior art, and will not be described here.

[0089] In a specific embodiment, in step S105, when the second ciphertext B, the third ciphertext C, and the signature value S are encapsulated, a preset signature digital envelope structure can be used. The above-mentioned encapsulation of the second ciphertext B, the third ciphertext C, and the signature value S into a digital envelope and the random generation of the digital envelope identifier of the digital envelope specifically include:

[0090] The second ciphertext B, the third ciphertext C, and the signature value S are encapsulated using a preset signature digital envelope structure to obtain the digital envelope, and the digital envelope identifier of the digital envelope is randomly generated.

[0091] The above-mentioned preset signature digital envelope structure can be any one of the signature digital envelope structures in compliance with the signature digital envelope structure of GB / T 35275-2017. The specific implementation process of encapsulation can be referred to the detailed description in the prior art, and will not be described here.

[0092] In a specific embodiment, in step S105, when the second ciphertext B, the third ciphertext C, and the signature value S are encapsulated, a preset digital envelope format can be used. The above-mentioned encapsulation of the second ciphertext B, the third ciphertext C, and the signature value S into a digital envelope and the random generation of the digital envelope identifier of the digital envelope include:

[0093] The second ciphertext B, the third ciphertext C, and the signature value S are encapsulated using a preset digital envelope format to obtain the digital envelope, and the digital envelope identifier of the digital envelope is randomly generated. The specific implementation process of encapsulation can be referred to the detailed description in the prior art, and will not be described here.

[0094] The above-mentioned preset digital envelope format can be any one of the digital envelope formats in compliance with the SM2 cryptographic algorithm encryption signature message syntax specification. The digital envelope format complies with the SM2 cryptographic algorithm encryption signature message syntax specification of GM / T 0010-2012, and is associated with the digital certificate format specification based on the SM2 cryptographic algorithm of GM / T 0009-2012. Details can be referred to the standard description by those skilled in the art. The digital envelope format can be viewed through an online tool, for example:

[0095] SEQUENCE (2 elem)

[0096] OBJECT IDENTIFIER 1.2.156.10197.6.1.4.2.4

[0097] [0] (1 elem)

[0098] SEQUENCE (6 elem)

[0099] INTEGER 1

[0100] SET (1 elem)

[0101] SEQUENCE (4 elem)

[0102] INTEGER 0

[0103] SEQUENCE (2 elem)

[0104] SEOUENCE (6 elem)

[0105] INTEGER (70bit) 1011001200000000107619

[0106] SEQUENCE (1 elem)

[0107] OBJECT IDENTIFIER 1.2.156.10197.1.301.3 sm2-3PublicKeyEncryption (China GM Standards Committee)

[0108] OCTET STRING(123byte) 3079022018750BC8DEF960595B7E3EBE266983CFA6F6FE00B5458B6FC8EA2E24C5926…

[0109] SEQUENCE (4 elem)

[0110] INTEGER (253 bit) 1106231080725852864992129558815555083733613320543623942900584570936908

[0111] INTEGER (256 bit) 1156049063616548758252191234714033199562284764290105668125981033257494

[0112] OCTET STRING (32 byte) 77FF9AD928CF49AB528EA3B839E8AAB29919977A3B5B4654BC05F7BC3AA7D944

[0113] OCTET STRING (16 bvte) F94C4C98D5BC642E0EF30B4F3047F342

[0114] SET (1 elem)

[0115] SEQUENCE (1 elem)

[0116] OBJECT IDENTIFIER 1.2.156.10197.1.401 sm3Hash (China M Standards Committee)

[0117] SEQUENCE (3 elem)

[0118] OBJECT IDENTIFIER: 1.2.156.10197.6.1.4.2.1

[0119] SEQUENCE (1 elem)

[0120] OBJECT IDENTIFIER 1.2.156.10197.1.104 sm4Cipher (China GM Standards Committee

[0121] [0] (1 elem)

[0122] SET (1 elem)

[0123] SEQUENCE (5 elem)

[0124] INTEGER 1

[0125] SEQUENCE (2 elem)

[0126] SEQUENCE (1 elem)

[0127] OBJECT IDENTIFIER 1.2.156.10197.1.401 sm3Hash (China GM Standards Committee)

[0128] SEQUENCE (1 elem)

[0129] OBJECT IDENTIFIER 1.2.156.10197.1.301.1 sm2-1 Digital Signature (China GM Standards Committee)

[0130] OCTET STRING (72 byte) 3046022100DD2EFF6DE270DD7A04362F40BE171EDF1BFFEA3B331FCB1B6771B2D7F3D0

[0131] SEQUENCE (2 elem)

[0132] INTEGER (256 hit) 1000441774096813037667673850519256869543422038698066786389168727596888

[0133] INTEGER (256bit) 1128494419749451010780959401705132349082121059154789023200088901693579

[0134] The digital envelope format defines the format and encryption method of the key protection key ciphertext (SM2), the data encryption key ciphertext (SM4) and the signature value (SM2).

[0135] Embodiment two

[0136] The embodiment of the application provides a digital envelope decryption method, referring to Figure 3 As shown in the figure, the digital envelope encrypted by the digital envelope encryption method described in embodiment one is decrypted through the following steps:

[0137] S201, obtaining the data exchange key table and the ciphertext table sent by the sender;

[0138] S202, obtaining the digital envelope identifier from the data exchange key table, and obtaining the corresponding digital envelope from the data exchange key table according to the digital envelope identifier;

[0139] S203, unsealing the digital envelope to obtain the second ciphertext B, the third ciphertext C and the signature value S;

[0140] S204, using the SM2 public key of the sender to decrypt the signature value S to obtain the first SM4 data encryption key A1;

[0141] S205, decrypting the second ciphertext B using the receiver SM2 private key to obtain a random SM4 symmetric key K based on the ID generated by the plaintext data;

[0142] S206, decrypting the third ciphertext C using the random SM4 symmetric key K to obtain a second SM4 data encryption key A2;

[0143] S207, if the first SM4 data encryption key A1 and the second SM4 data encryption key A2 are consistent, obtaining a first ciphertext A from the ciphertext table based on the digital envelope identifier, and decrypting the first ciphertext A using the first SM4 data encryption key A1 or the second SM4 data encryption key A2 to obtain the plaintext data sent by the sender.

[0144] Embodiment three

[0145] The embodiment of the application provides a digital envelope encryption device, referring to Figure 4 as shown, comprising:

[0146] A random SM4 symmetric key generation module 301 is configured to use an SM4 data encryption key to symmetrically encrypt plaintext data to be uploaded to obtain a first ciphertext, and generate a random SM4 symmetric key according to the ID of the plaintext data;

[0147] A first encryption module 302 is configured to use a receiver SM2 public key to asymmetrically encrypt the random SM4 symmetric key to obtain a second ciphertext;

[0148] A second encryption module 303 is configured to use the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain a third ciphertext;

[0149] A signature module 304 is configured to use a sender SM2 private key to sign the SM4 data encryption key to obtain a signature value;

[0150] An encapsulation module 305 is configured to encapsulate the second ciphertext, the third ciphertext, and the signature value into a digital envelope, and randomly generate a digital envelope identifier of the digital envelope;

[0151] A data storage module 306 is configured to obtain a sender identifier and a receiver identifier, and store the digital envelope identifier, the sender identifier, the receiver identifier, and the digital envelope into a data exchange key table;

[0152] A sending module 307 is configured to store the first ciphertext and the digital envelope identifier into a ciphertext table, and send the data exchange key table and the ciphertext table to the receiver.

[0153] The digital envelope encryption device provided by the embodiment of the present application has similar implementation principles and technical effects to the digital envelope encryption method of any one of the preceding method embodiments, and details are not repeated here.

[0154] Embodiment four

[0155] The embodiment of the present application provides a digital envelope decryption device, as shown in the figure, comprising: Figure 5

[0156] The receiving module 401 is configured to obtain the data exchange key table and the ciphertext table sent by the sender.

[0157] The digital envelope obtaining module 402 is configured to obtain the digital envelope identifier from the data exchange key table, and obtain the corresponding digital envelope from the data exchange key table according to the digital envelope identifier.

[0158] The envelope opening module 403 is configured to open the digital envelope to obtain the second ciphertext, the third ciphertext and the signature value.

[0159] The first decryption module 404 is configured to use the SM2 public key of the sender to decrypt the signature value to obtain the first SM4 data encryption key.

[0160] The second decryption module 405 is configured to use the SM2 private key of the receiver to decrypt the second ciphertext to obtain the random SM4 symmetric key generated based on the ID of the plaintext data.

[0161] The third decryption module 406 is configured to use the random SM4 symmetric key to decrypt the third ciphertext to obtain the second SM4 data encryption key.

[0162] The signature verification module 407 is configured to obtain the first ciphertext from the ciphertext table based on the digital envelope identifier if the first SM4 data encryption key and the second SM4 data encryption key are consistent, and use the first SM4 data encryption key or the second SM4 data encryption key to decrypt the first ciphertext to obtain the plaintext data sent by the sender.

[0163] The digital envelope decryption device provided by the embodiment of the present application has similar implementation principles and technical effects to the digital envelope decryption method of any one of the preceding method embodiments, and details are not repeated here.

[0164] Embodiment five

[0165] The computer readable storage medium provided by the embodiment of the present application stores a computer program, and the program is executed by a processor to realize the digital envelope encryption method of any one of the preceding method embodiments and / or the digital envelope decryption method of any one of the preceding method embodiments. ​

[0166] The computer readable storage medium can be included in the device / apparatus described in the above embodiments; or can exist separately without being assembled into the device / apparatus. The computer readable storage medium carries one or more programs when the one or more programs are executed, the method according to the embodiments of the present application is implemented.

[0167] According to the embodiments of the present application, the computer readable storage medium can be a non-volatile computer readable storage medium, which can include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer readable storage medium can be any tangible medium containing or storing a program, which can be used by or in conjunction with an instruction execution system, device or apparatus.

[0168] Embodiment six

[0169] The embodiments of the present application provide an electronic device, referring to Figure 6 As shown in the figure, it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112 and the memory 113 complete the communication among each other through the communication bus 114,

[0170] The memory 113 is used to store computer programs;

[0171] The processor 111 is used to execute the programs stored in the memory 113, and realize the digital envelope encryption method as described in any one of the preceding method embodiments and / or the digital envelope decryption method as described in any one of the preceding method embodiments.

[0172] The electronic device provided by the embodiments of the present application has similar implementation principles and technical effects to any one of the preceding method embodiments, and will not be described here.

[0173] The memory 113 described above can be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. The memory 113 has a storage space for program codes for executing any of the method steps described above. For example, the storage space for program codes can include individual program codes for implementing individual steps in the above methods, respectively. The program codes can be read from or written to one or more computer program products. The computer program products include program code carriers such as hard disks, compact discs (CDs), memory cards, or floppy disks. Such computer program products are typically portable or stationary storage units. The storage units can have storage sections or storage spaces, etc., arranged similarly to the memory 113 in the electronic device described above. The program codes can be compressed in a suitable form, for example. Typically, the storage units include programs for performing the method steps according to the embodiments of the application, i.e., codes that can be read by the processor 111, which, when executed by the electronic device, cause the electronic device to perform the individual steps in the methods described above.

[0174] In this document, relational terms such as first and second, and the like can be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. The terms "upper," "lower," and the like refer to directions or positions in the drawings to which reference is made, and are for convenience not necessarily for describing absolute reference or orientation. Thus, terms such as "upper," "lower," "front," "back," "right," "left," are used for convenience and are disclaimed herein.

[0175] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. It should be noted that the embodiments in the present specification and the features in the embodiments can be combined with each other without conflict. The present application is not limited to any single aspect or embodiment, and is not limited to any single combination or permutation of aspects and / or embodiments. Each aspect and / or embodiment can stand on its own, or can be combined with one or more other aspects and / or embodiments.

[0176] Finally, it should be noted that the above-described embodiments are merely specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit the same. The protection scope of the present application is not limited thereto. Although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any person skilled in the art can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some of the technical features, within the technical scope disclosed by the present application. The modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A digital envelope encryption method, characterized by, The method comprises the following steps: using an SM4 data encryption key to symmetrically encrypt plaintext data to be uploaded to obtain first ciphertext, and generating a random SM4 symmetric key according to an ID of the plaintext data; using a receiver SM2 public key to asymmetrically encrypt the random SM4 symmetric key to obtain second ciphertext; using the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain third ciphertext; using a sender SM2 private key to sign the SM4 data encryption key to obtain a signature value; encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope; obtaining a sender identifier and a receiver identifier, and storing the digital envelope identifier, the sender identifier, the receiver identifier and the digital envelope into a data exchange key table; storing the first ciphertext and the digital envelope identifier into a ciphertext table, and sending the data exchange key table and the ciphertext table to the receiver.

2. The digital envelope encryption method of claim 1, wherein, The step of using the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain third ciphertext comprises the following steps: using the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key in ECB mode, and using a PKCS5 padding mode to fill data to obtain the third ciphertext.

3. The digital envelope encryption method of claim 1, wherein, The step of using the receiver SM2 public key to asymmetrically encrypt the random SM4 symmetric key to obtain second ciphertext comprises the following steps: based on the receiver SM2 public key, using a first SM2 cryptographic algorithm to asymmetrically encrypt the random SM4 symmetric key to obtain the second ciphertext.

4. The digital envelope encryption method of claim 1, wherein, The step of encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope comprises the following steps: using a preset signature digital envelope structure to encapsulate the second ciphertext, the third ciphertext and the signature value to obtain the digital envelope, and randomly generating the digital envelope identifier of the digital envelope.

5. The digital envelope encryption method according to any of claims 1 to 4, characterized in that, The step of encapsulating the second ciphertext, the third ciphertext and the signature value into a digital envelope, and randomly generating a digital envelope identifier of the digital envelope comprises the following steps: using a preset digital envelope format to encapsulate the second ciphertext, the third ciphertext and the signature value to obtain the digital envelope, and randomly generating the digital envelope identifier of the digital envelope.

6. A digital envelope decryption method characterized by comprising: The digital envelope encrypted by the digital envelope encryption method according to any one of claims 1-5 is decrypted through the following steps: obtaining a data exchange key table and a ciphertext table sent by a sender; obtaining a digital envelope identifier from the data exchange key table, and obtaining a corresponding digital envelope from the data exchange key table according to the digital envelope identifier; decapsulating the digital envelope to obtain second ciphertext, third ciphertext and a signature value; using a sender SM2 public key to decrypt the signature value to obtain a first SM4 data encryption key; using a receiver SM2 private key to decrypt the second ciphertext to obtain a random SM4 symmetric key generated based on an ID of plaintext data. decrypt the third ciphertext using the random SM4 symmetric key to obtain a second SM4 data encryption key; if the first SM4 data encryption key and the second SM4 data encryption key are consistent, then based on the digital envelope identifier, the first ciphertext is obtained from the ciphertext table, and the first ciphertext is decrypted using the first SM4 data encryption key or the second SM4 data encryption key to obtain the plaintext data sent by the sender.

7. A digital envelope encryption apparatus characterized by comprising: The method comprises the steps of: a random SM4 symmetric key generation module is configured to use an SM4 data encryption key to symmetrically encrypt plaintext data to be uploaded to obtain a first ciphertext, and generate a random SM4 symmetric key based on the ID of the plaintext data; a first encryption module is configured to use a receiver SM2 public key to asymmetrically encrypt the random SM4 symmetric key to obtain a second ciphertext; a second encryption module is configured to use the random SM4 symmetric key to symmetrically encrypt the SM4 data encryption key to obtain a third ciphertext; a signature module is configured to use a sender SM2 private key to sign the SM4 data encryption key to obtain a signature value; an encapsulation module is configured to encapsulate the second ciphertext, the third ciphertext, and the signature value into a digital envelope, and randomly generate a digital envelope identifier of the digital envelope; a data storage module is configured to obtain a sender identifier and a receiver identifier, and store the digital envelope identifier, the sender identifier, the receiver identifier, and the digital envelope into a data exchange key table; a sending module is configured to store the first ciphertext and the digital envelope identifier into a ciphertext table, and send the data exchange key table and the ciphertext table to the receiver.

8. A digital envelope decryption apparatus characterized by comprising: The method comprises the steps of: a receiving module is configured to obtain a data exchange key table and a ciphertext table sent by a sender; a digital envelope obtaining module is configured to obtain a digital envelope identifier from the data exchange key table, and obtain a corresponding digital envelope from the data exchange key table based on the digital envelope identifier; an unsealing module is configured to unseal the digital envelope to obtain a second ciphertext, a third ciphertext, and a signature value; a first decryption module is configured to use a sender SM2 public key to decrypt the signature value to obtain a first SM4 data encryption key; a second decryption module is configured to use a receiver SM2 private key to decrypt the second ciphertext to obtain a random SM4 symmetric key generated based on the ID of the plaintext data; a third decryption module is configured to use the random SM4 symmetric key to decrypt the third ciphertext to obtain a second SM4 data encryption key; a signature verification module is configured to, if the first SM4 data encryption key and the second SM4 data encryption key are consistent, then based on the digital envelope identifier, the first ciphertext is obtained from the ciphertext table, and the first ciphertext is decrypted using the first SM4 data encryption key or the second SM4 data encryption key to obtain the plaintext data sent by the sender.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by a processor to implement the digital envelope encryption method of any one of claims 1-5 and / or the digital envelope decryption method of claim 6.

10. An electronic device, comprising: The digital envelope encryption method and / or the digital envelope decryption method as claimed in any one of claims 1-5 are realized when the processor executes the program stored in the memory. The memory is used for storing a computer program. The processor is used for executing the program stored in the memory, and realizes the digital envelope encryption method and / or the digital envelope decryption method as claimed in any one of claims 1-5.

Citation Information

Patent Citations

  • Traffic sensor network data transmission method and system based on hybrid encryption, and medium

    CN112469003A

  • Method for loading website security information and browser apparatus

    US20170359185A1