CN112367159B - A hybrid encryption and decryption method and system for safe storage of medical data - Google Patents
A hybrid encryption and decryption method and system for safe storage of medical data Download PDFInfo
- Publication number
- CN112367159B CN112367159B CN202011236546.9A CN202011236546A CN112367159B CN 112367159 B CN112367159 B CN 112367159B CN 202011236546 A CN202011236546 A CN 202011236546A CN 112367159 B CN112367159 B CN 112367159B
- Authority
- CN
- China
- Prior art keywords
- key
- encryption
- ciphertext
- rsa
- plaintext
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 99
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 237
- 238000012545 processing Methods 0.000 claims description 19
- 238000013507 mapping Methods 0.000 claims description 12
- 238000012216 screening Methods 0.000 claims description 8
- 238000003491 array Methods 0.000 claims description 4
- 238000013478 data encryption standard Methods 0.000 description 107
- 238000005516 engineering process Methods 0.000 description 16
- 238000010586 diagram Methods 0.000 description 11
- 238000005336 cracking Methods 0.000 description 10
- 238000004364 calculation method Methods 0.000 description 9
- 238000011160 research Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 230000009466 transformation Effects 0.000 description 6
- 238000011161 development Methods 0.000 description 5
- 238000000354 decomposition reaction Methods 0.000 description 4
- 238000004458 analytical method Methods 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 3
- 230000000295 complement effect Effects 0.000 description 3
- 230000007812 deficiency Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000002441 reversible effect Effects 0.000 description 2
- 238000011426 transformation method Methods 0.000 description 2
- 150000001875 compounds Chemical class 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000012353 t test Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000000844 transformation Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0861—Generation of secret information including derivation or calculation of cryptographic keys or passwords
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/602—Providing cryptographic facilities or services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- G—PHYSICS
- G16—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
- G16H—HEALTHCARE INFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR THE HANDLING OR PROCESSING OF MEDICAL OR HEALTHCARE DATA
- G16H10/00—ICT specially adapted for the handling or processing of patient-related medical or healthcare data
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
- H04L63/045—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply hybrid encryption, i.e. combination of symmetric and asymmetric encryption
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0618—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
- H04L9/0625—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation with splitting of the data block into left and right halves, e.g. Feistel based algorithms, DES, FEAL, IDEA or KASUMI
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/08—Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
- H04L9/0816—Key establishment, i.e. cryptographic processes or cryptographic protocols whereby a shared secret becomes available to two or more parties, for subsequent use
- H04L9/0819—Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s)
- H04L9/0822—Key transport or distribution, i.e. key establishment techniques where one party creates or otherwise obtains a secret value, and securely transfers it to the other(s) using key encryption key
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/30—Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy
- H04L9/3006—Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters
- H04L9/302—Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy underlying computational problems or public-key parameters involving the integer factorization problem, e.g. RSA or quadratic sieve [QS] schemes
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Computer Hardware Design (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- Bioethics (AREA)
- General Physics & Mathematics (AREA)
- Epidemiology (AREA)
- Medical Informatics (AREA)
- Primary Health Care (AREA)
- Public Health (AREA)
- Storage Device Security (AREA)
Abstract
Description
技术领域technical field
本发明涉及数据加密领域,特别是涉及一种面向医疗数据安全存储的混合加、解密方法及系统。The invention relates to the field of data encryption, in particular to a hybrid encryption and decryption method and system for safe storage of medical data.
背景技术Background technique
数据加密技术是保证网络信息安全最常用和最重要的一种技术,也是密码学中最重要的研究方向。密码学是研究数据信息加密、解密及其变换的一门新兴交叉学科。国外对密码学的研究较早,已经提出了很多实用的加密算法,如DES(Data EncryptionStandard)、RSA(Rivest-Shamir-Adleman)、AES(Advanced Encryption Standard)和ECC(Elliptic Curves Cryptography)算法等。国内比较著名的有刘氏加密算法等。密码系统的各种性能主要由密码算法所决定,不同的算法决定了不同的密码体制,而不同的密码体制又有不同的优缺点。有的算法高速简便,但加解密密钥相同,密钥管理困难;有的算法密钥管理方便、安全,但计算开销大、处理速度慢。Data encryption technology is the most commonly used and most important technology to ensure network information security, and it is also the most important research direction in cryptography. Cryptography is an emerging interdisciplinary subject that studies the encryption, decryption and transformation of data information. The study of cryptography abroad is earlier, and many practical encryption algorithms have been proposed, such as DES (Data Encryption Standard), RSA (Rivest-Shamir-Adleman), AES (Advanced Encryption Standard) and ECC (Elliptic Curves Cryptography) algorithms. The more famous ones in China are Liu's encryption algorithm and so on. The various performances of the cryptographic system are mainly determined by the cryptographic algorithm. Different algorithms determine different cryptosystems, and different cryptosystems have different advantages and disadvantages. Some algorithms are fast and simple, but the encryption and decryption keys are the same, and the key management is difficult; some algorithms have convenient and safe key management, but the calculation cost is large and the processing speed is slow.
数据加密技术被誉为信息安全的核心技术,其主要分为对称加密和非对称加密,分别以DES算法和RSA算法为典型代表。DES算法是分组加密算法,计算效率高、加密速度快,不过其安全性依赖于密钥,而RSA算法是基于大数分解的算法,采用公钥和私钥的双密钥体制,其破解难度等同于分解两个大质数之积,所以RSA算法安全性高,但是其计算开销大、加密速度慢。虽然目前还没有在短时间内破译它们的有效方法,但是随着计算机软硬件的不断发展使得计算机的性能日新月异,这些传统的数据加密算法已不再安全。Data encryption technology is known as the core technology of information security. It is mainly divided into symmetric encryption and asymmetric encryption, with DES algorithm and RSA algorithm as typical representatives respectively. The DES algorithm is a block encryption algorithm with high computational efficiency and fast encryption speed, but its security depends on the key, while the RSA algorithm is an algorithm based on the decomposition of large numbers, using a dual-key system of public key and private key, which is difficult to crack It is equivalent to decomposing the product of two large prime numbers, so the RSA algorithm has high security, but its calculation overhead is large and the encryption speed is slow. Although there is no effective method to decipher them in a short period of time, with the continuous development of computer software and hardware, the performance of computers is changing with each passing day, and these traditional data encryption algorithms are no longer safe.
数据加密技术是按确定的加密变换方法(加密算法)对需要保护的数据(也称为明文)作处理,使其变换成为难以识别的数据(密文)。数据加密的逆过程,即将密文按对应的解密变换方法(解密算法)恢复出明文的过程,称为数据解密。在加密技术中,基于密钥的加密算法不同可以分为两类:对称加密技术和非对称加密技术,其中最有影响的对称加密和非对称加密技术是数据加密DES算法和RSA算法。Data encryption technology is to process the data to be protected (also known as plaintext) according to a certain encryption transformation method (encryption algorithm), so that it can be transformed into unrecognizable data (ciphertext). The reverse process of data encryption, that is, the process of recovering plaintext from ciphertext according to the corresponding decryption transformation method (decryption algorithm), is called data decryption. In encryption technology, key-based encryption algorithms can be divided into two categories: symmetric encryption technology and asymmetric encryption technology, among which the most influential symmetric encryption and asymmetric encryption technology are data encryption DES algorithm and RSA algorithm.
目前国内外对DES和RSA算法研究较多,有单独针对DES算法和RSA算法进行改进的,也有对DES和RSA算法进行混合研究的,例如:基于三重DES的加密算法、基于RSA的快速加密算法以及基于DES与RSA的混合数据加密算法等等,但是这些算法要么只注重安全性忽略了计算的复杂度,要么加快了计算的效率但是安全性没法保证,即使安全性和计算复杂度都有兼顾但实现难度大,实用性低,因此,本领域亟需一种安全性能高、运算速度快的混合加密方案。At present, there are many researches on DES and RSA algorithms at home and abroad, some improve DES algorithm and RSA algorithm alone, and some do mixed research on DES and RSA algorithms, such as: encryption algorithm based on triple DES, fast encryption algorithm based on RSA And the mixed data encryption algorithm based on DES and RSA, etc., but these algorithms either only focus on security and ignore the complexity of calculation, or speed up the efficiency of calculation but the security cannot be guaranteed, even if there are both security and computational complexity Taking both into account, it is difficult to implement and has low practicability. Therefore, a hybrid encryption scheme with high security performance and fast operation speed is urgently needed in this field.
发明内容Contents of the invention
本发明的目的是提供一种面向医疗数据安全存储的混合加、解密方法及系统,解决当前对称加密技术和非对称加密技术中的重要算法DES和RSA存在的安全性不足、计算速度慢和实用性差的问题,从而提出了一种安全性能高、运算速度快、具有很好的实用性的混合加密方案。The purpose of the present invention is to provide a hybrid encryption and decryption method and system for safe storage of medical data, which solves the problems of insufficient security, slow calculation speed and practicality of the important algorithms DES and RSA in the current symmetric encryption technology and asymmetric encryption technology. Therefore, a hybrid encryption scheme with high security performance, fast operation speed and good practicability is proposed.
为实现上述目的,本发明提供了如下方案:To achieve the above object, the present invention provides the following scheme:
一种面向医疗数据安全存储的混合加密方法,所述方法包括:A hybrid encryption method for safe storage of medical data, said method comprising:
生成用于DES加密的密钥K;Generate a key K for DES encryption;
利用RSA加密所述密钥K,形成密文CK;Using RSA to encrypt the key K to form ciphertext CK;
获取RSA公开加密密钥Keb;Get the RSA public encryption key Keb;
利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;Using the RSA decryption key together with the public encryption key Keb to form a digital signature MA;
利用所述密钥K加密明文和所述数字签名MA;Using the key K to encrypt plaintext and the digital signature MA;
将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;Combining the encrypted plaintext and encrypted digital signature MA with the ciphertext CK to form ciphertext C;
发送密文C。Send ciphertext C.
可选的,所述密文CK的具体形式为:CK.Keb(K)=CK。Optionally, the specific form of the ciphertext CK is: CK.Keb(K)=CK.
可选的,所述密文C的具体形式为:C=K(明文,MA)+CK。Optionally, the specific form of the ciphertext C is: C=K(plaintext, MA)+CK.
一种面向医疗数据安全存储的混合加密系统,所述系统包括:A hybrid encryption system for safe storage of medical data, said system comprising:
DES密钥生成单元,用于生成用于DES加密的密钥K;DES key generation unit, is used for generating the key K that is used for DES encryption;
第一加密单元,用于利用RSA加密所述密钥K,形成密文CK;A first encryption unit, configured to encrypt the key K with RSA to form ciphertext CK;
公开加密密钥获取单元,用于获取RSA公开加密密钥Keb;A public encryption key acquisition unit, used to obtain the RSA public encryption key Keb;
第一数字签名生成单元,用于利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;A first digital signature generating unit, configured to use the RSA decryption key and the public encryption key Keb to form a digital signature MA;
第二加密单元,用于利用所述密钥K加密明文和所述数字签名MA;A second encryption unit, configured to use the key K to encrypt plaintext and the digital signature MA;
密文生成单元,用于将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;A ciphertext generation unit, configured to combine the encrypted plaintext and the encrypted digital signature MA with the ciphertext CK to form a ciphertext C;
发送单元,用于发送密文C。The sending unit is used to send the ciphertext C.
一种面向医疗数据安全存储的混合解密方法,所述方法包括:A hybrid decryption method for safe storage of medical data, said method comprising:
接收密文C;Receive ciphertext C;
用RSA解密密钥Kdb解密出所述密文C中的密钥K;Decrypt the key K in the ciphertext C with the RSA decryption key Kdb;
利用所述密钥K解密出所述明文和所述数字签名MA。The plaintext and the digital signature MA are decrypted by using the key K.
可选的,所述利用所述密钥K解密出所述明文和所述数字签名MA之后,还包括:Optionally, after decrypting the plaintext and the digital signature MA by using the key K, the method further includes:
获取公开密钥Kea;Get the public key Kea;
利用所述公开密钥Kea与所述解密密钥Kdb对签名信息进行身份确认;Using the public key Kea and the decryption key Kdb to confirm the identity of the signature information;
对所述签名信息进行数字化处理,形成接收方签名信息;digitally processing the signature information to form the receiver's signature information;
将所述接收方签名信息送往发送方,以确认收到信息。Send the receiver's signature information to the sender to confirm receipt of the information.
可选的,将所述接收方签名信息送往发送方,以确认收到信息之后,还包括:Optionally, after sending the receiver's signature information to the sender to confirm receipt of the information, further include:
发送方和接收方均删除所述密钥K。Both sender and receiver delete said key K.
一种面向医疗数据安全存储的混合解密系统,所述系统包括:A hybrid decryption system for safe storage of medical data, said system comprising:
接收单元,用于利用解密密钥Kdb解密出所述密文C中的所述密钥K;a receiving unit, configured to decrypt the key K in the ciphertext C by using the decryption key Kdb;
解密单元,利用所述密钥K解密出所述明文和所述数字签名MA。The decryption unit uses the key K to decrypt the plaintext and the digital signature MA.
可选的,还包括接收方处理单元,用于Optionally, it also includes a receiver processing unit for
获取发送方的公开密钥Kea;Get the sender's public key Kea;
利用所述公开密钥Kea与所述解密密钥Kdb对签名信息进行身份确认;Using the public key Kea and the decryption key Kdb to confirm the identity of the signature information;
对所述签名信息进行数字化处理,形成接收方签名信息;digitally processing the signature information to form the receiver's signature information;
将所述接收方签名信息送往发送方,以确认收到信息。Send the receiver's signature information to the sender to confirm receipt of the information.
一种面向医疗数据安全存储的混合加、解密方法,所述方法包括:A hybrid encryption and decryption method for safe storage of medical data, said method comprising:
发送方生成用于DES加密的密钥K;The sender generates the key K for DES encryption;
利用RSA加密所述密钥K,形成密文CK;Using RSA to encrypt the key K to form ciphertext CK;
获取RSA公开加密密钥Keb;Get the RSA public encryption key Keb;
利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;Using the RSA decryption key together with the public encryption key Keb to form a digital signature MA;
利用所述密钥K加密明文和所述数字签名MA;Using the key K to encrypt plaintext and the digital signature MA;
将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;Combining the encrypted plaintext and encrypted digital signature MA with the ciphertext CK to form ciphertext C;
将所述密文C发送给接收方;Send the ciphertext C to the receiver;
接收方用RSA解密密钥Kdb解密出密文C中的密钥K;The receiver uses the RSA decryption key Kdb to decrypt the key K in the ciphertext C;
利用所述密钥K解密出所述明文和所述数字签名MA。The plaintext and the digital signature MA are decrypted by using the key K.
根据本发明提供的具体实施例,本发明公开了以下技术效果:According to the specific embodiments provided by the invention, the invention discloses the following technical effects:
本发明对加密信息进行双重加密,加强了算法的安全强度,并且实现了局部独立性,避免密钥被暴力破解的威胁,两者相辅相成,并且由于只有双重加密,运行效率较高。The invention double-encrypts the encrypted information, strengthens the security strength of the algorithm, and realizes local independence, avoiding the threat of the key being cracked violently.
本发明所提供的混合加密方案继承了公钥加密体制的特性,所以不需要担心密钥管理相关问题,是面向医疗数据安全存储的一种理想的方案。The hybrid encryption scheme provided by the invention inherits the characteristics of the public key encryption system, so there is no need to worry about key management issues, and it is an ideal scheme for safe storage of medical data.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some of the present invention. Embodiments, for those of ordinary skill in the art, other drawings can also be obtained according to these drawings without paying creative labor.
图1为本发明实施例一提供的面向医疗数据安全存储的混合加密方法的控制流程图。FIG. 1 is a control flow diagram of a hybrid encryption method for safe storage of medical data provided by Embodiment 1 of the present invention.
图2为本发明实施例一提供的面向医疗数据安全存储的混合加密系统的组成示意图。Fig. 2 is a schematic diagram of the composition of the hybrid encryption system for safe storage of medical data provided by Embodiment 1 of the present invention.
图3为本发明实施例二提供的面向医疗数据安全存储的混合解密方法的控制流程图。Fig. 3 is a control flow diagram of the hybrid decryption method for safe storage of medical data provided by Embodiment 2 of the present invention.
图4为本发明实施例二提供的面向医疗数据安全存储的混合解密系统的组成示意图。Fig. 4 is a schematic diagram of the composition of the hybrid decryption system for safe storage of medical data provided by Embodiment 2 of the present invention.
图5为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的控制流程图。FIG. 5 is a control flow diagram of a hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图6为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的TDEA加、解密过程示意图。FIG. 6 is a schematic diagram of the TDEA encryption and decryption process of the hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图7为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的HDDES算法的加、解密过程示意图。FIG. 7 is a schematic diagram of the encryption and decryption process of the HDDES algorithm of the hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图8为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的DES和RSA算法加密时间对比图。Fig. 8 is a comparison diagram of the encryption time of the DES and RSA algorithms in the hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图9为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的基于HDDES和IPNRSA的混合加密方案示意图。FIG. 9 is a schematic diagram of a hybrid encryption scheme based on HDDES and IPNRSA for a hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图10为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的医疗电子病历数据的加密前后对比图。Fig. 10 is a comparison diagram before and after encryption of medical electronic medical record data according to the hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
图11为本发明实施例三提供的面向医疗数据安全存储的混合加、解密方法的医疗电子病历数据的解密前后对比图。Fig. 11 is a comparison diagram before and after decryption of medical electronic medical record data according to the hybrid encryption and decryption method for safe storage of medical data provided by Embodiment 3 of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
本发明的目的是提供一种面向医疗数据安全存储的混合加、解密方法及系统,解决当前对称加密技术和非对称加密技术中的重要算法DES和RSA存在的安全性不足、计算速度慢和实用性差的问题。The purpose of the present invention is to provide a hybrid encryption and decryption method and system for safe storage of medical data, which solves the problems of insufficient security, slow calculation speed and practicality of the important algorithms DES and RSA in the current symmetric encryption technology and asymmetric encryption technology. problem of poor sex.
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明作进一步详细的说明。In order to make the above objects, features and advantages of the present invention more comprehensible, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
实施例一:Embodiment one:
如图1所示,一种面向医疗数据安全存储的混合加密方法,设发送方为A(加密密钥为Kea,解密密钥为Kda),接收方为B(加密密钥为Keb,解密密钥为Kdb),上述加密方案实现步骤如下As shown in Figure 1, a hybrid encryption method for safe storage of medical data, assuming that the sender is A (the encryption key is Kea, the decryption key is Kda), and the receiver is B (the encryption key is Keb, and the decryption key is Kda). The key is Kdb), the implementation steps of the above encryption scheme are as follows
A1、生成用于DES加密的密钥K;A1, generate the key K for DES encryption;
发送方生成用于DES加密的密钥K,为了提高数据的安全性,每一个密钥K只用一次。DES密钥可以是任意的56位的数,所以用户可以随机生成,由于DES密钥的长度只有56bit,因此,其处理的效率极高。The sender generates the key K for DES encryption. In order to improve data security, each key K is only used once. The DES key can be any 56-bit number, so users can generate it randomly. Since the length of the DES key is only 56 bits, its processing efficiency is extremely high.
A2、利用RSA加密所述密钥K,形成密文CK;A2. Using RSA to encrypt the key K to form ciphertext CK;
发送方从密钥服务器中获取接收方的RSA的公开加密密钥Keb,并用Keb加密DES的密钥K,形成密文CK.Keb(K)=CK。公共加密密钥的优点是不需要经安全渠道传递密钥,这大大简化了密钥管理,但对实际传输的数据的加密解密则需专用密钥。The sender obtains the receiver's RSA public encryption key Keb from the key server, and encrypts the DES key K with Keb to form the ciphertext CK.Keb(K)=CK. The advantage of the public encryption key is that it does not need to pass the key through a secure channel, which greatly simplifies the key management, but the encryption and decryption of the actually transmitted data requires a dedicated key.
A3、获取RSA公开加密密钥Keb;A3. Obtain the RSA public encryption key Keb;
A4、利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;A4. Utilize the RSA decryption key and the public encryption key Keb to form a digital signature MA;
发送方生成需要签名的信息,并用自己的RSA解密密钥Kda和Keb共同形成数字签名MA。RSA算法研制的最初理念与目标是努力使互连网安全可靠,旨在解决DES算法密钥的利用公开信道传输的难题,它不但很好地解决了这个难题,且可以用来完成对电文的数字签名。The sender generates the information that needs to be signed, and uses its own RSA decryption key Kda and Keb to form a digital signature MA. The original concept and goal of the development of the RSA algorithm is to make the Internet safe and reliable, aiming to solve the problem of using the public channel transmission of the DES algorithm key. It not only solves this problem well, but also can be used to complete the digital signature of the message .
A5、利用所述密钥K加密明文和所述数字签名MA;A5, using the key K to encrypt plaintext and the digital signature MA;
A6、将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;A6. Combining the encrypted plaintext and encrypted digital signature MA with the ciphertext CK to form ciphertext C;
发送方用K加密明文和签名的信息之后,然后连同Ck一起形成密文C发往接收方。C=K(明文,MA)+CK。After the sender uses K to encrypt the plaintext and signed information, and then forms a ciphertext C together with Ck and sends it to the receiver. C=K(plaintext, MA)+CK.
A7、发送密文C。A7. Send ciphertext C.
DES算法和RSA算法是数据加密中久经考验的比较优秀的算法,但仍在处理效率、密钥管理等方面存在着不足,下面分别介绍这两种算法。The DES algorithm and the RSA algorithm are well-tested and excellent algorithms in data encryption, but there are still deficiencies in processing efficiency and key management. The following two algorithms are introduced separately.
数据加密标准(Data Encryption Standard,简称DES)算法是一个分组加密算法,它以64bit(byte)为分组对数据加密,其中有8bit奇偶校验,有效密钥长度为56bit。DES算法的加密和解密用的是同一算法(密钥顺序不同),它的安全性依赖于所用的密钥。The Data Encryption Standard (DES) algorithm is a block encryption algorithm, which uses 64bit (byte) as a packet to encrypt data, including 8bit parity, and the effective key length is 56bit. The encryption and decryption of the DES algorithm use the same algorithm (key sequence is different), and its security depends on the key used.
DES加密算法的具体过程是把64bit的数据分为左右各32bit的两部分(L,R),使用异或运算,用符号表示。加密过程可以概括如下:The specific process of the DES encryption algorithm is to divide the 64bit data into two parts (L, R) of 32bit on the left and right, use the XOR operation, and use the symbol express. The encryption process can be summarized as follows:
把64bit明文做初始变换,记为IP。The 64bit plaintext is initially transformed, and recorded as IP.
对初始变换后的明文进行16次迭代操作,分别记为T1,T2,…,T16。每次迭代都分为左右两部分,各32bit,表示为(Ln,Rn)。相邻二次迭代的关系如下式(1)和(2):Perform 16 iterative operations on the plaintext after the initial transformation, which are respectively marked as T 1 , T 2 ,...,T 16 . Each iteration is divided into left and right parts, each 32 bits, expressed as (L n , R n ). The relationship between adjacent two iterations is as follows (1) and (2):
Ln=Rn-1 (1)L n =R n-1 (1)
其中,Kn表示16次迭代中使用的16个48bit长度的子密钥。它们都是由56bit密钥通过变换产生而来的,每个子密钥都不相同。Among them, K n represents 16 subkeys with a length of 48 bits used in 16 iterations. They are all generated by transforming the 56bit key, and each subkey is different.
迭代操作后,经过一个末变换IP-1处理。末变换与初始变换互为逆变换,即满足条件:After the iterative operation, it is processed by an end transformation IP -1 . The final transformation and the initial transformation are inverse transformations, that is, the conditions are satisfied:
IPIP-1=1 (3)IPIP -1 = 1 (3)
所述DES加密过程可用如下公式(4)简单表达:Described DES encryption process can be expressed simply with following formula (4):
DES(m)=IP-1(T16(…(T2(T1IP(m))))) (4)DES(m)=IP -1 (T 16 (...(T 2 (T 1 IP(m))))) (4)
DES解密过程可用如下公式(5)简单表达:The DES decryption process can be simply expressed by the following formula (5):
DES(m)=IP-1(T1(···(T15(T16IP(m))))) (5)DES(m)=IP -1 (T 1 (···(T 15 (T 16 IP(m))))) (5)
RSA算法主要是基于大数分解困难这一基础所提出来的,因为求两个大质数的乘积十分容易,但是要想将乘积进行因式分解则十分困难。所以,可以将两个大质数的乘积公开作为公共密匙,而把素数作为私有密匙产生因子。那么想利用公开密钥和密文中破解出明文就相当于分解两个大质数之积,这是非常困难的,也就是说,RSA算法的安全性基于大质数乘积分解因子的难度。The RSA algorithm is mainly proposed based on the difficulty of large number decomposition, because it is very easy to find the product of two large prime numbers, but it is very difficult to factorize the product. Therefore, the product of two large prime numbers can be publicly used as the public key, and the prime number can be used as the private key generation factor. Then wanting to use the public key and the ciphertext to decipher the plaintext is equivalent to decomposing the product of two large prime numbers, which is very difficult, that is to say, the security of the RSA algorithm is based on the difficulty of decomposing the factors of the multiplication of large prime numbers.
RSA算法具体的加密解密方法概括如下:The specific encryption and decryption methods of the RSA algorithm are summarized as follows:
选取位数相近的两个大质数p和q,但是p和q两个数的值不能接近。Select two large prime numbers p and q with similar digits, but the values of p and q cannot be close.
计算乘积n=p×q和φ(n)=(p-1)×(q-1),其中n代表两个大质数的乘积。Calculate the product n=p×q and φ(n)=(p-1)×(q-1), where n represents the product of two large prime numbers.
任意选取加密密钥e1,使得e1和(p-1)×(q-1)互质,即gcd(e,φ(n))=1。The encryption key e 1 is chosen arbitrarily, so that e 1 and (p-1)×(q-1) are relatively prime, that is, gcd(e,φ(n))=1.
计算解密密钥e2,使得e1e2=1modφ(n),即e1与e2互逆,e2与n是互质的。Calculate the decryption key e 2 such that e 1 e 2 =1modφ(n), that is, e 1 and e 2 are mutually inverse, and e 2 and n are mutually prime.
加密函数为:解密函数为:/>其中m是明文,c是密文。{e1,n}为公共密钥,e2为私有密钥,一般n的长度是大于等于1024位的。The encryption function is: The decryption function is: /> where m is the plaintext and c is the ciphertext. {e 1 ,n} is the public key, e 2 is the private key, and generally the length of n is greater than or equal to 1024 bits.
RSA加密数据明文M时,首先会将明文M分成大小合适的数据分组,然后每个分组分别进行加密,每个分组的长度均应该比n的位要小。When RSA encrypts data plaintext M, it first divides the plaintext M into data packets of appropriate size, and then encrypts each packet separately. The length of each packet should be smaller than n bits.
在加密、解密的处理效率方面,DES算法优于RSA算法,因为DES密钥的长度只有56bit,所以RSA算法在多倍字长的处理时的处理速度明显慢于DES算法。In terms of encryption and decryption processing efficiency, the DES algorithm is superior to the RSA algorithm, because the length of the DES key is only 56 bits, so the processing speed of the RSA algorithm is significantly slower than the DES algorithm when processing multiple word lengths.
在密钥的管理方面,RSA算法比DES算法更加优越,因为RSA算法可采用公开形式分配加密密钥,其对加密密钥的更新也很容易,并且对不同的通信对象,RSA算法只需对自己的解密密钥保密即可;而DES算法要求通信前对密钥进行秘密分配,其密钥的更换困难,而且对不同的通信对象,DES算法需产生和保管不同的密钥。In terms of key management, the RSA algorithm is more superior than the DES algorithm, because the RSA algorithm can distribute the encryption key in a public form, and it is easy to update the encryption key, and for different communication objects, the RSA algorithm only needs to It is enough to keep your own decryption key secret; while the DES algorithm requires the secret distribution of the key before communication, the replacement of the key is difficult, and for different communication objects, the DES algorithm needs to generate and store different keys.
DES算法和RSA算法的安全性都较好,目前还没有在短时间内破译它们的有效方法。DES算法从原理上不可能实现数字签名和身份认证,但RSA算法则能够容易地进行。Both the DES algorithm and the RSA algorithm have better security, and there is currently no effective method to decipher them in a short time. It is impossible for the DES algorithm to implement digital signature and identity authentication in principle, but the RSA algorithm can be easily implemented.
总体来讲,DES算法与RSA算法各有短长,本发明据此设计出一种综合DES和RSA优点,同时又避免了它们各自不足的加密方案。其基本原理是:数据通信之前,用DES算法对消息明文加密,同时用RSA算法对DES密钥进行加密和实现数字签名。在传送机密信息的网络用户双方,如果使用对称密码体制DES,同时使用RSA非对称密钥密码体制来传DES的密钥,就可以综合发挥DES高速简便性和RSA密钥管理的方便和安全性。同时,针对上述方法,本发明还提供了一种面向医疗数据安全存储的混合加密系统,如图2所示,所述系统包括:Generally speaking, the DES algorithm and the RSA algorithm have their own advantages and disadvantages, so the present invention designs an encryption scheme that combines the advantages of DES and RSA while avoiding their respective disadvantages. The basic principle is: before data communication, use the DES algorithm to encrypt the plain text of the message, and at the same time use the RSA algorithm to encrypt the DES key and realize the digital signature. If both network users who transmit confidential information use the symmetric encryption system DES and the RSA asymmetric key encryption system to transmit the key of DES, the high-speed simplicity of DES and the convenience and security of RSA key management can be fully utilized. . At the same time, for the above method, the present invention also provides a hybrid encryption system for safe storage of medical data, as shown in Figure 2, the system includes:
DES密钥生成单元,用于生成用于DES加密的密钥K;DES key generation unit, is used for generating the key K that is used for DES encryption;
第一加密单元,用于利用RSA加密所述密钥K,形成密文CK;A first encryption unit, configured to encrypt the key K with RSA to form ciphertext CK;
公开加密密钥获取单元,用于获取RSA公开加密密钥Keb;A public encryption key acquisition unit, used to obtain the RSA public encryption key Keb;
第一数字签名生成单元,用于利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;A first digital signature generating unit, configured to use the RSA decryption key and the public encryption key Keb to form a digital signature MA;
第二加密单元,用于利用所述密钥K加密明文和所述数字签名MA;A second encryption unit, configured to use the key K to encrypt plaintext and the digital signature MA;
密文生成单元,用于将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;A ciphertext generation unit, configured to combine the encrypted plaintext and the encrypted digital signature MA with the ciphertext CK to form a ciphertext C;
发送单元,用于发送密文C。The sending unit is used to send the ciphertext C.
本发明实施例提供的面向医疗数据安全存储的混合加密方法及系统,在传统的DES和RSA算法的基础上,首先针对DES存在的优点和不足进行分析,并结合三重DES加密算法(Triple Data Encryption Algorithm,TDEA)以及独立子密钥DES加密算法(Independent Sub Key DES Algorithm,ISKDES)的优点,对DES算法进行改进,提出一种混合双重DES加密算法(Hybrid double DES encryption algorithm,HDDES),然后对影响RSA算法模幂运算速度的判断质数方法进行详细研究,在不影响RSA安全性的基础上,对原有的质数判断方法进行了改进,提出了一种基于改进质数判断的RSA算法(RSA algorithmbased on improved prime number decision,IPNRSA),最后将HDDES加密算法和IPNRSA加密算法相结合,形成一种基于HDDES和IPNRSA的混合加密方案,使其能有效地对医疗数据进行安全的存储,该方案具有运算速度快,安全性能高的优点,具有很好的实用性。The hybrid encryption method and system for safe storage of medical data provided by the embodiments of the present invention, on the basis of the traditional DES and RSA algorithms, first analyze the advantages and disadvantages of DES, and combine the triple DES encryption algorithm (Triple Data Encryption Algorithm, TDEA) and independent subkey DES encryption algorithm (Independent Sub Key DES Algorithm, ISKDES) advantages, the DES algorithm is improved, a hybrid double DES encryption algorithm (Hybrid double DES encryption algorithm, HDDES), and then The method of judging prime numbers that affects the speed of RSA algorithm modular exponentiation is studied in detail. On the basis of not affecting the security of RSA, the original prime number judging method is improved, and an RSA algorithm based on improved prime number judging (RSA algorithm based on improved prime number decision, IPNRSA), and finally combine HDDES encryption algorithm and IPNRSA encryption algorithm to form a hybrid encryption scheme based on HDDES and IPNRSA, which can effectively store medical data safely. It has the advantages of fast speed and high safety performance, and has good practicability.
实施例二:Embodiment two:
如图3所示,一种面向医疗数据安全存储的混合解密方法,所述方法包括:As shown in Figure 3, a hybrid decryption method for safe storage of medical data, said method comprising:
B1、接收密文C;接收方接收从发送方发来的密文C。B1. Receive ciphertext C; the receiver receives ciphertext C sent from the sender.
B2、用RSA解密密钥Kdb解密出所述密文C中的密钥K;B2, use the RSA decryption key Kdb to decrypt the key K in the ciphertext C;
接收方接收到密文C以后,先用自己的解密密钥Kdb解密出C中的DES密钥K。After receiving the ciphertext C, the receiver uses its own decryption key Kdb to decrypt the DES key K in C.
B3、利用所述密钥K解密出所述明文和所述数字签名MA。B3. Using the key K to decrypt the plaintext and the digital signature MA.
B4、获取公开密钥Kea;B4. Obtain the public key Kea;
B5、利用所述公开密钥Kea与所述解密密钥Kdb对签名信息进行身份确认;接收方用发送方的公开密钥Kea和自己的解密密钥Kdb对签名信息进行身份认证。B5. Use the public key Kea and the decryption key Kdb to confirm the identity of the signature information; the receiver uses the sender's public key Kea and its own decryption key Kdb to authenticate the signature information.
B6、对所述签名信息进行数字化处理,形成接收方签名信息;B6. Digitally process the signature information to form signature information of the receiver;
B7、将所述接收方签名信息送往发送方,以确认收到信息。B7. Send the receiver's signature information to the sender to confirm receipt of the information.
B8、发送方和接收方均删除所述密钥K。B8. Both the sender and the receiver delete the key K.
DES算法密钥长度过短,加密单元仅为64位二进制,并且有8位是应用于奇偶校验或其他通信开销,所以其有效密钥只有56位。因此这将不可避免地降低DES的安全性。随着计算机性能的发展,已经发现了暴力破解DES密钥的方法,并且随着计算机变得越来越强大,56位密钥的DES根本无法支持安全要求高的应用。The key length of the DES algorithm is too short, the encryption unit is only 64-bit binary, and 8 bits are used for parity check or other communication overhead, so the effective key is only 56 bits. So this will inevitably reduce the security of DES. With the development of computer performance, a method of brute force cracking the DES key has been found, and as computers become more and more powerful, DES with a 56-bit key cannot support applications with high security requirements.
而且DES算法存在弱密钥。DES算法中有12个半弱密钥和4个弱密钥。因为在生成子密钥的过程中将密钥分为两部分,所以若将这两部分分为全0或全1,则在每一轮中生成的子密钥都是一样的。当密钥全部为0或全部为l时,或者为l或0各半时,将生成弱密钥或半弱密钥,这将降低DES的安全性。And the DES algorithm has a weak key. There are 12 semi-weak keys and 4 weak keys in the DES algorithm. Because the key is divided into two parts during the process of generating the subkey, if the two parts are divided into all 0s or all 1s, the subkey generated in each round is the same. When the key is all 0 or all 1, or half of 1 or 0, a weak or semi-weak key will be generated, which will reduce the security of DES.
目前针对RSA算法攻击的方式主要有以下几种方式:At present, there are mainly the following ways to attack the RSA algorithm:
强制破解:尝试所有私钥;数学攻击:因式分解两个质数的乘积;定时攻击:取决于解密算法的执行时间。为了防止对RSA算法进行强制破解,必须使用一个超长密钥,所以选取的两个大质数p和q总的位数越多越好,不过这也使得密钥生成速度、加密和解密速度越来越慢。对于剩下的两种攻击,由于RSA的安全性是基于对大质数进行乘法和积分的难度,因此目前几乎无法进行破解或破解的代价很高。Brute force cracking: try all private keys; mathematical attack: factorize the product of two prime numbers; timing attack: depends on the execution time of the decryption algorithm. In order to prevent the forced cracking of the RSA algorithm, an extra-long key must be used, so the more digits of the two large prime numbers p and q selected, the better, but this also makes the key generation speed, encryption and decryption speed faster come slower. For the remaining two attacks, since the security of RSA is based on the difficulty of multiplying and integrating large prime numbers, it is currently almost impossible to crack or very expensive to crack.
但是RSA算法密钥产生繁琐。由于必须采用两个大质数p、q来产生RSA的密钥,所以局限于质数生成技术,几乎很难一次一密。而且其加密速度慢。RSA算法不仅具有DES没有的高安全性,而且算法过程也十分通俗易懂。不过高安全性的背后其实都是以牺牲加密速度为代价的,RSA的p、q等大质数都是使用确定性质数判断算法随机产生的,RSA与DES的加密时间几乎相差百倍。However, RSA algorithm key generation is cumbersome. Because two large prime numbers p and q must be used to generate the RSA key, it is limited to the prime number generation technology, and it is almost difficult to use one-time encryption. And its encryption speed is slow. The RSA algorithm not only has high security that DES does not have, but also the algorithm process is very easy to understand. However, behind the high security is actually at the expense of encryption speed. Large prime numbers such as p and q in RSA are randomly generated using a deterministic quality number judgment algorithm. The encryption time between RSA and DES is almost a hundred times different.
由此,本发明将两种加密算法相结合,取长补短,形成一种基于HDDES和IPNRSA的混合加密方案,使其能有效地对医疗数据进行安全的存储。此外,基于HDDES和IPNRS的混合加密方案继承了公钥加密体制的特性,所以不需要担心密钥管理相关问题,是面向医疗数据安全存储的一种理想的方案。同时,本发明实施例还提供了一种面向医疗数据安全存储的混合解密系统,如图4所示,所述系统包括:Therefore, the present invention combines the two encryption algorithms, learns from each other, and forms a hybrid encryption scheme based on HDDES and IPNRSA, so that it can effectively store medical data safely. In addition, the hybrid encryption scheme based on HDDES and IPNRS inherits the characteristics of the public key encryption system, so there is no need to worry about key management related issues, and it is an ideal scheme for the safe storage of medical data. At the same time, the embodiment of the present invention also provides a hybrid decryption system for safe storage of medical data, as shown in Figure 4, the system includes:
接收单元,用于利用解密密钥Kdb解密出所述密文C中的所述密钥K;a receiving unit, configured to decrypt the key K in the ciphertext C by using the decryption key Kdb;
解密单元,利用所述密钥K解密出所述明文和所述数字签名MA。The decryption unit uses the key K to decrypt the plaintext and the digital signature MA.
接收方处理单元,用于获取发送方的公开密钥Kea;The receiver processing unit is used to obtain the public key Kea of the sender;
利用所述公开密钥Kea与所述解密密钥Kdb对签名信息进行身份确认;Using the public key Kea and the decryption key Kdb to confirm the identity of the signature information;
对所述签名信息进行数字化处理,形成接收方签名信息;digitally processing the signature information to form the receiver's signature information;
将所述接收方签名信息送往发送方,以确认收到信息。Send the receiver's signature information to the sender to confirm receipt of the information.
本发明实施例提供的面向医疗数据安全存储的混合解密方法及系统首先将原64位密钥扩展至128位,减少了密钥过短被穷举攻击的风险,然后借鉴TDEA算法多重加密的优点,对加密信息进行双重加密,加强了算法的安全强度,最后参考ISKDES算法的特点将12位密钥进行映射,实现了局部独立性,避免密钥被暴力破解的威胁,两者相辅相成,并且由于只有双重加密,运行效率方面要比TDEA算法要高。The hybrid decryption method and system for safe storage of medical data provided by the embodiment of the present invention first expands the original 64-bit key to 128-bit, which reduces the risk of being attacked by exhaustion if the key is too short, and then draws on the advantages of multiple encryption of the TDEA algorithm , double-encrypt the encrypted information to strengthen the security strength of the algorithm. Finally, refer to the characteristics of the ISKDES algorithm to map the 12-bit key to achieve local independence and avoid the threat of the key being brute-forced. The two complement each other, and because Only double encryption is higher than the TDEA algorithm in terms of operating efficiency.
实施例三:Embodiment three:
如图5所示,一种面向医疗数据安全存储的混合加、解密方法,所述方法包括:As shown in Figure 5, a hybrid encryption and decryption method for safe storage of medical data, said method comprising:
发送方生成用于DES加密的密钥K;The sender generates the key K for DES encryption;
利用RSA加密所述密钥K,形成密文CK;Using RSA to encrypt the key K to form ciphertext CK;
获取RSA公开加密密钥Keb;Get the RSA public encryption key Keb;
利用RSA解密密钥与所述公开加密密钥Keb共同形成数字签名MA;Using the RSA decryption key together with the public encryption key Keb to form a digital signature MA;
利用所述密钥K加密明文和所述数字签名MA;Using the key K to encrypt plaintext and the digital signature MA;
将加密后的明文和加密后的数字签名MA与所述密文CK组合,形成密文C;Combining the encrypted plaintext and encrypted digital signature MA with the ciphertext CK to form ciphertext C;
发送密文C;Send ciphertext C;
接收方接收密文C,并用RSA解密密钥Kdb解密出密文C中的密钥K;The recipient receives the ciphertext C, and uses the RSA decryption key Kdb to decrypt the key K in the ciphertext C;
利用所述密钥K解密出所述明文和所述数字签名MA。The plaintext and the digital signature MA are decrypted by using the key K.
本发明首先对对称加密算法DES的缺点进行分析,DES的缺点分析具体如下:The present invention at first analyzes the shortcoming of symmetric encryption algorithm DES, and the shortcoming analysis of DES is specifically as follows:
1、密钥长度过短。DES算法的加密单元仅为64位二进制,并且有8位是应用于奇偶校验或其他通信开销,所以其有效密钥只有56位。因此这将不可避免地降低DES算法的安全性。随着计算机性能的发展,已经发现了暴力破解DES密钥的方法,并且随着计算机变得越来越强大,56位密钥的DES根本无法支持安全要求高的应用。由于DES这些明显的不足,美国国家标准与技术研究院在1997年不再对DES进行研究,而是研究其替代方法,即高级加密标准(Advanced Encryption Standard,AES)。1. The key length is too short. The encryption unit of the DES algorithm is only 64-bit binary, and 8 bits are used for parity check or other communication overhead, so its effective key is only 56 bits. So this will inevitably reduce the security of the DES algorithm. With the development of computer performance, a method of brute force cracking the DES key has been found, and as computers become more and more powerful, DES with a 56-bit key cannot support applications with high security requirements. Due to these obvious shortcomings of DES, the National Institute of Standards and Technology no longer conducted research on DES in 1997, but instead studied its alternative method, the Advanced Encryption Standard (AES).
2、存在弱密钥。DES算法中有12个半弱密钥和4个弱密钥。因为在生成子密钥的过程中将密钥分为两部分,所以若将这两部分分为全0或全1,则在每一轮中生成的子密钥都是一样的。当密钥全部为0或全部为l时,或者为l或0各半时,将生成弱密钥或半弱密钥,这将降低DES的安全性。2. Weak keys exist. There are 12 semi-weak keys and 4 weak keys in the DES algorithm. Because the key is divided into two parts during the process of generating the subkey, if the two parts are divided into all 0s or all 1s, the subkey generated in each round is the same. When the key is all 0 or all 1, or half of 1 or 0, a weak or semi-weak key will be generated, which will reduce the security of DES.
然后,调研国内外针对DES算法缺点进行改进的改进DES算法并加以分析,具体如下:Then, research and analyze the improved DES algorithm at home and abroad to improve the shortcomings of the DES algorithm, as follows:
改进DES算法仍然存在很多不足,例如其数据传输速率小,不适合做长久数据保护,并且容易受到差分密钥的破解。因此,国内外学者进行了许多尝试来改善DES算法,在此背景下,相继提出了更具影响力的三重DES算法(TDEA)和独立子密钥DES算法(ISKDES)。There are still many deficiencies in the improved DES algorithm, for example, its data transmission rate is low, it is not suitable for long-term data protection, and it is easy to be cracked by the differential key. Therefore, scholars at home and abroad have made many attempts to improve the DES algorithm. Under this background, the more influential triple DES algorithm (TDEA) and independent subkey DES algorithm (ISKDES) have been proposed successively.
三重DES算法:由于传统的DES算法密钥长度短且容易被破解,因此为了弥补该不足,研究人员提出了一种三重DES加密算法(TDEA),即让DES的密钥长度增加了三倍,并且三个不同的密钥用于三重加密和解密。加密过程是:首先用第一重密钥k1加密,然后用第二重密钥k2解密,最后用第三重密钥k3再次加密,即C=Ek3(DK2(Ek1M))。而解密则是逆序,即M=Dk1(EK2(Dk3C))。TDEA的核心就是利用k1、k2、k3对明文执行多次加密,密钥长度为DES的三倍。TDEA算法具体实现过程如图6所示,图6(a)为TDEA算法加密过程,图6(b)为TDEA算法解密过程,此方法虽然增加了密钥的长度,提高了算法的安全强度,有效避免了暴力破解,但是其计算时间却增加了f-1倍,f代表重数,例如三重加密时间复杂度增加3-1=2倍,同理解密时间复杂度也是增加3-1=2倍,因此运行效率很低。此外,尽管TDEA中的关键位数为168位,但对于当前的计算机算力而言,还是无法避免暴力破解的威胁。Triple DES algorithm: Because the traditional DES algorithm key length is short and easy to be cracked, in order to make up for this deficiency, researchers proposed a triple DES encryption algorithm (TDEA), which triples the key length of DES, And three different keys are used for triple encryption and decryption. The encryption process is: first encrypt with the first key k 1 , then decrypt with the second key k 2 , and finally encrypt again with the third key k 3 , that is, C=Ek 3 (DK 2 (Ek 1 M )). The decryption is in reverse order, that is, M=Dk 1 (EK 2 (Dk 3 C)). The core of TDEA is to use k 1 , k 2 , k 3 to perform multiple encryptions on the plaintext, and the key length is three times that of DES. The specific implementation process of the TDEA algorithm is shown in Figure 6. Figure 6(a) is the encryption process of the TDEA algorithm, and Figure 6(b) is the decryption process of the TDEA algorithm. Although this method increases the length of the key and improves the security strength of the algorithm, Brute force cracking is effectively avoided, but its calculation time is increased by f-1 times, and f represents a multiplicity. For example, the time complexity of triple encryption is increased by 3-1=2 times, and the time complexity of decryption is also increased by 3-1=2 times, so the operating efficiency is very low. In addition, although the key number of bits in TDEA is 168 bits, the threat of brute force cracking is still unavoidable for the current computing power.
独立子密钥的DES算法:ISKDES算法的关键取决于采用不同的随机生成的子密钥进行加密,也就是说,每次迭代中的子密钥不用相同的56位二进制密钥生成。由于16个迭代中的每轮都用48位密钥,所以ISKDES修改后的DES密钥长度变成768位。这种方法可以大大增加穷举解密的难度,从而提高了DES的加密强度,但是密钥长度过长,开销也变大。DES algorithm with independent subkeys: The key to the ISKDES algorithm depends on using different randomly generated subkeys for encryption, that is, the subkeys in each iteration are not generated with the same 56-bit binary key. Since each of the 16 iterations uses a 48-bit key, the modified DES key length of ISKDES becomes 768 bits. This method can greatly increase the difficulty of exhaustive decryption, thereby improving the encryption strength of DES, but the length of the key is too long, and the overhead becomes larger.
借鉴上述两种优秀的算法思路(三重DES算法和独立子密钥DES算法),设计一种混合双重DES加密算法(HDDES),具体如下:Drawing on the above two excellent algorithm ideas (triple DES algorithm and independent subkey DES algorithm), a hybrid double DES encryption algorithm (HDDES) is designed, as follows:
在TDEA算法和ISKDES算法的基础上,提出一种混合双重DES加密算法(HybridDouble DES Encryption Algorithm,HDDES)。该算法针对DES的密钥进行扩展,从64位扩展为128位,并通过映射表(如表1所示)进行映射后将其分为两个子密钥(每个子密钥64位),分别表示为key1和key2,然后利用key1生成的16个子密钥对明文进行加密操作生成密文1,紧接着利用key2生成的16个子密钥对密文1进行加密操作生成密文2,这样通过双重加密来增强安全强度。HDDES算法具体过程如图7所示,图7(a)为HDDES算法加密过程,图7(b)为HDDES算法解密过程。On the basis of TDEA algorithm and ISKDES algorithm, a hybrid double DES encryption algorithm (HybridDouble DES Encryption Algorithm, HDDES) is proposed. The algorithm expands the key of DES from 64 bits to 128 bits, and after mapping through the mapping table (as shown in Table 1), it is divided into two subkeys (each subkey is 64 bits), respectively Denoted as key1 and key2, then use the 16 subkeys generated by key1 to encrypt the plaintext to generate ciphertext 1, and then use the 16 subkeys generated by key2 to encrypt the ciphertext 1 to generate ciphertext 2, so that through double Encryption to enhance security strength. The specific process of the HDDES algorithm is shown in Figure 7, Figure 7(a) is the encryption process of the HDDES algorithm, and Figure 7(b) is the decryption process of the HDDES algorithm.
表1 TDEA的128位key映射表Table 1 128-bit key mapping table of TDEA
所述HDDES算法具体为:The HDDES algorithm is specifically:
输入:明文M,128位key映射表Input: plaintext M, 128-bit key mapping table
输出:双重加密的密文C,双重解密的明文MOutput: double encrypted ciphertext C, double decrypted plaintext M
1、扩充密钥长度:将原DES的64位密钥进行扩充,变为128位长度;1. Extended key length: expand the original DES 64-bit key to 128-bit length;
2、密钥映射处理:将128位密钥输入并按照图5的映射表进行映射,映射得到两个子密钥key1和key2,每个子密钥64位;2. Key mapping processing: input the 128-bit key and map it according to the mapping table in Figure 5, and get two sub-keys key1 and key2, each with 64 bits;
3、生成子密钥:将两个子密钥key1和key2进行密钥处理,分别得到各自的16个子密钥;3. Generate sub-keys: process the two sub-keys key1 and key2 to obtain 16 sub-keys respectively;
4、明文双重加密:输入明文后,先用key1加密一次后再用key2进行二次加密生成密文C;4. Double encryption of plaintext: After inputting the plaintext, encrypt once with key1 and then encrypt twice with key2 to generate ciphertext C;
5、输出双重加密的密文C;5. Output double-encrypted ciphertext C;
6、明文双重解密:输入密文后,先用key2解密一次后再用key1进行第二次解密还原成明文M;6. Double decryption of plaintext: After inputting the ciphertext, first decrypt it once with key2, and then use key1 for the second decryption to restore it to plaintext M;
7、输出双重解密的明文M;7. Output double decrypted plaintext M;
然后针对非对称加密算法RSA进行分析,RSA的缺点分析具体如下:Then analyze the asymmetric encryption algorithm RSA, the shortcomings of RSA are analyzed as follows:
目前针对RSA攻击的方式主要有以下几种方式:①强制破解:尝试所有私钥;②数学攻击:因式分解两个质数的乘积;③定时攻击:取决于解密算法的执行时间。为了防止对RSA算法进行强制破解,必须使用一个超长密钥,所以选取的两个大质数p和q总的位数越多越好,不过这也使得密钥生成速度、加密和解密速度也越来越慢。对于剩下的两种攻击,由于RSA的安全性是基于对大质数进行乘法和积分的难度,因此目前几乎无法进行破解或破解的代价很高。At present, there are mainly the following methods for attacking RSA: ①forced cracking: try all private keys; ②mathematical attack: factorize the product of two prime numbers; ③timing attack: depends on the execution time of the decryption algorithm. In order to prevent the forced cracking of the RSA algorithm, an extra-long key must be used, so the more digits of the two large prime numbers p and q selected, the better, but this also makes the key generation speed, encryption and decryption speed slower Slower and slower. For the remaining two attacks, since the security of RSA is based on the difficulty of multiplying and integrating large prime numbers, it is currently almost impossible to crack or very expensive to crack.
1、密钥产生繁琐。由于必须采用两个大质数p、q来产生RSA的密钥,所以局限于质数生成技术,几乎很难一次一密。1. Key generation is cumbersome. Because two large prime numbers p and q must be used to generate the RSA key, it is limited to the prime number generation technology, and it is almost difficult to use one-time encryption.
2、加密速度慢。RSA算法不仅具有DES没有的高安全性,而且算法过程也十分通俗易懂。不过高安全性的背后其实都是以牺牲加密速度为代价的,下面将DES算法和RSA算法对一组简单数据(2KB数据量)进行加密的时间进行对比来进一步说明它们的加密速度差距,具体如图8所示。其中,RSA的p、q等大质数都是使用确定性质数判断算法随机产生的,可以看出,RSA与DES的加密时间几乎相差百倍。2. The encryption speed is slow. The RSA algorithm not only has high security that DES does not have, but also the algorithm process is very easy to understand. However, behind the high security is actually at the expense of encryption speed. The following compares the encryption time of a set of simple data (2KB data volume) by the DES algorithm and the RSA algorithm to further illustrate their encryption speed gap. Specifically As shown in Figure 8. Among them, large prime numbers such as p and q of RSA are randomly generated by using a deterministic quality judgment algorithm. It can be seen that the encryption time of RSA and DES is almost a hundred times different.
调研国内外针对RSA缺点进行改进的RSA算法并加以分析,RSA的最新研究分析具体如下:Investigate and analyze the RSA algorithm improved at home and abroad for the shortcomings of RSA. The latest research and analysis of RSA is as follows:
RSA算法是一种基于大数分解的算法,由于大数分解是公认的数学难题,所以RSA的安全性很高。尽管现在计算机硬件的更新迅速,让计算机的性能不断突破极限,但是对大数分解仍需要大量时间才能破解。此外,RSA算法为了应付计算机算力的高速发展,逐渐增加密钥的长度,但是RSA算法加密速度恰恰是被密钥的生成速度所限制。为了解决RSA算法加密速度问题,国内外研究人员普遍采用两种方法。第一种方法是改进密钥算法的实现,并采取某些措施来加快其运算速度,本发明也是从这一方面着手,研究如何改进RSA密钥的生成,改善其运算速度。第二种方法是寻找替代RSA的新的公钥加密算法,例如基于椭圆曲线(ECC)的公钥加密算法,ECC的问世实现了效率上的重大突破,不过因尚未得到广泛使用,所以目前大量研究仍是基于理论上的。The RSA algorithm is an algorithm based on the decomposition of large numbers. Since the decomposition of large numbers is a recognized mathematical problem, the security of RSA is very high. Although the computer hardware is updated rapidly and the performance of the computer continues to break through the limit, it still takes a lot of time to decompose a large number. In addition, in order to cope with the rapid development of computer computing power, the RSA algorithm gradually increases the length of the key, but the encryption speed of the RSA algorithm is precisely limited by the key generation speed. In order to solve the problem of encryption speed of RSA algorithm, researchers at home and abroad generally adopt two methods. The first method is to improve the realization of the key algorithm and take certain measures to speed up its operation speed. The present invention also starts from this aspect and studies how to improve the generation of the RSA key and improve its operation speed. The second method is to find a new public key encryption algorithm to replace RSA, such as the public key encryption algorithm based on elliptic curve (ECC). Research is still theoretical.
由于RSA的核心算法是大质数的模幂运算,即大数自乘取模,所以要提高RSA算法的效率,就必须要解决RSA中模幂运算的运算速度问题,而模幂运算中核心复杂度取决于取模操作,取模操作又包含除法运算,对于计算机而言,进行一次除法运算需要进行数次加减乘运算,这是相当耗时的,所以假设能让RSA算法极力降低取模操作甚至避免取模操作,则RSA算法的性能会得到显著的提升。基于此,本发明在确保RSA算法安全性的前提下,对影响RSA算法模幂运算速度的判断质数方法进行详细研究,并仔细比较了确定性和概率性两种质数判断算法的优缺点,然后采用Montgomery快速幂算法对经典的概率性质数判断算法—Miller-Rabin算法进行优化,提出一种改进的快速质数判断算法(Improved fast primenumber judgment algorithm,IFPNJA),最后将IFPNJA应用于RSA算法,形成一种基于改进质数判断的RSA算法(RSA algorithm based on improved prime number decision,IPNRSA)。Since the core algorithm of RSA is the modular exponentiation operation of large prime numbers, that is, the self-multiplication of large numbers to obtain the modulus, so to improve the efficiency of the RSA algorithm, it is necessary to solve the problem of the operation speed of the modular exponentiation operation in RSA, and the core of the modular exponentiation operation is complicated. The degree depends on the modulo operation, and the modulo operation includes division operations. For a computer, a division operation requires several addition, subtraction, and multiplication operations, which is quite time-consuming, so it is assumed that the RSA algorithm can be used to reduce the modulus. operation or even avoid the modulo operation, the performance of the RSA algorithm will be significantly improved. Based on this, under the premise of ensuring the safety of the RSA algorithm, the present invention studies in detail the method for judging the prime number that affects the speed of the RSA algorithm modular exponentiation, and carefully compares the advantages and disadvantages of the deterministic and probabilistic two kinds of prime number judging algorithms, and then Using the Montgomery fast power algorithm to optimize the classic probabilistic quality number judgment algorithm—Miller-Rabin algorithm, an improved fast prime number judgment algorithm (Improved fast prime number judgment algorithm, IFPNJA) is proposed, and finally IFPNJA is applied to the RSA algorithm to form a An RSA algorithm based on improved prime number decision (IPNRSA).
质数的判断方法:质数的判断方法整体上分为两类:一是确定性质数判断算法,二是概率性质数判断算法。确定性质数判断算法意如其名,就是通过它生成的数百分百是质数,不过其却带有一定的限制。而概率性质数判断算法虽然无法保证百分百生成质数,却没有什么大的限制且生成质数的速度比确定性判断算法快。总的来说,实际生活中大多是采用概率性质数判断算法,虽不能保证百分百生成质数,但是生成非质数毕竟是小概率事件,而且概率性质数判断算法可以快速且不规则地生成伪素数,满足大多数需求。Judgment method of prime number: The method of judging prime number is generally divided into two categories: one is deterministic quality number judgment algorithm, and the other is probabilistic quality number judgment algorithm. Determining the quality number judgment algorithm is as its name suggests, that is, hundreds of percent of the numbers generated by it are prime numbers, but it has certain restrictions. Although the probabilistic quality and number judgment algorithm cannot guarantee 100% generation of prime numbers, it has no major restrictions and the speed of generating prime numbers is faster than the deterministic judgment algorithm. In general, probabilistic quality and number judgment algorithms are mostly used in real life. Although it cannot guarantee 100% prime numbers, generating non-prime numbers is a small probability event after all, and probabilistic quality and number judgment algorithms can quickly and irregularly generate false numbers. A prime number that meets most needs.
确定性质数判断算法中最常用的是整除性算法,即整除性检验,该算法原理就是用作除数的所有整数都小于n,n代表两个大质数的乘积,如果这些数中的某一个任意数可以整除n,那么n就是复合数。整除性算法的效率非常低,并且其比特运算复杂度是指数增长的。The divisibility algorithm is the most commonly used in determining the quality number judgment algorithm, that is, the divisibility test. The principle of the algorithm is that all integers used as divisors are smaller than n, and n represents the product of two large prime numbers. If any of these numbers is arbitrary If a number is divisible by n, then n is a compound number. The divisibility algorithm is very inefficient, and its bit operation complexity is exponential.
概率性质数判断算法中较著名的算法有:Miller-Rabin算法、Solovay-Strassen算法、Lehman算法等,由于本发明针对Miller-Rabin概率性质数判断算法进行改进且限于篇幅,所以仅对Miller-Rabin算法进行详细介绍,其他几种著名算法就不再详细展开叙述。Famous algorithms in the probabilistic property number judgment algorithm include: Miller-Rabin algorithm, Solovay-Strassen algorithm, Lehman algorithm, etc., because the present invention is improved at Miller-Rabin probability property number judgment algorithm and is limited in length, so only Miller-Rabin The algorithm is introduced in detail, and the other several famous algorithms will not be described in detail.
Miller-Rabin算法的介绍:如果n是一个奇质数,则n-1=2rm,r是非负整数,m是正奇数,a是和n互素的任何正整数,那么am≡1(mod n)或者对某个h(0≤h≤r-1),等式aw≡-1(mod n)成立,其中w=2hm。可以证明Miller-Rabin算法的错误概率至多为4-1。若n通过了t次检验,则n不是质数的概率将为4-t,而Solovay-Strassen算法和Lehman算法的错误概率均为2-t。Introduction to the Miller-Rabin algorithm: If n is an odd prime number, then n-1=2 r m, r is a non-negative integer, m is a positive odd number, and a is any positive integer that is prime to n, then a m ≡ 1(mod n) or for some h (0≤h≤r-1), the equation a w ≡-1(mod n) holds, where w=2 h m. It can be proved that the error probability of the Miller-Rabin algorithm is at most 4 -1 . If n passes t tests, the probability that n is not a prime number will be 4 -t , and the error probability of Solovay-Strassen algorithm and Lehman algorithm are both 2 -t .
由于确定性质数判断算法的效率非常低、复杂度高,不适合用于RSA算法的模幂运算,所以本发明直接采用概率性质数判断算法对RSA算法模幂运算进行改进。再由各概率性质数判断算法的原理可知,Miller-Rabin算法判断质数的概率要远高于其余两种主流的算法,因此本发明选择Miller-Rabin算法来进行改进,这里引入可以极大减少模幂运算的算法——Montgomery快速幂算法对Miller-Rabin算法进行优化,形成一种改进的快速质数判断算法(IFPNJA),具体过程如下:Since the efficiency of the deterministic property number judgment algorithm is very low and the complexity is high, it is not suitable for the modular exponentiation operation of the RSA algorithm, so the present invention directly adopts the probabilistic property number judgment algorithm to improve the modular exponentiation operation of the RSA algorithm. From the principles of each probabilistic quality and number judging algorithm, it can be seen that the probability of the Miller-Rabin algorithm judging the prime number is much higher than the other two mainstream algorithms, so the present invention selects the Miller-Rabin algorithm to improve, and the introduction here can greatly reduce the number of models. The algorithm of exponentiation—the Montgomery fast exponentiation algorithm optimizes the Miller-Rabin algorithm to form an improved fast prime number judgment algorithm (IFPNJA). The specific process is as follows:
输入:大数A、B,Miller-Rabin算法,模数N。Input: large numbers A, B, Miller-Rabin algorithm, modulus N.
输出:大数A、B的快速模乘结果。Output: the fast modular multiplication result of large numbers A and B.
初始输入:输入两个大数A、B和模数N。Initial input: input two large numbers A, B and modulus N.
选择基数:选择一个与N互质的正整数R作为基数,同时要求当R为2k时,N需满足:2k-1≤N≤2k,并且要求GCD(R,N)=1,这里R可以为任意的基底,本发明中为了方便处理,采用以2为基的幂次。Select the base: choose a positive integer R that is relatively prime to N as the base, and at the same time require that when R is 2 k , N must satisfy: 2 k-1 ≤ N ≤ 2 k , and require GCD(R, N) = 1, Here R can be any base, and in the present invention, for the convenience of processing, a power based on 2 is used.
Montgomery快速幂乘:利用Montgomery快速幂算法简化Miller-Rabin算法对大数A、B进行模乘运算,即Montgomery(A,B,N)=ABR-1(modN)。Montgomery's fast power multiplication: use Montgomery's fast power algorithm to simplify the Miller-Rabin algorithm to perform modular multiplication operations on large numbers A and B, that is, Montgomery(A,B,N)=ABR -1 (modN).
输出大数A、B的快速模乘结果。Output the fast modular multiplication result of large numbers A and B.
IFPNJA采用Montgomery快速幂算法的主要好处就是将除法化为移位运算,这样不仅简化了计算过程,还提高了大数幂乘运算的效率。The main advantage of IFPNJA adopting Montgomery's fast exponentiation algorithm is to convert division into shift operation, which not only simplifies the calculation process, but also improves the efficiency of large number exponentiation operation.
为了提高IFPNJA应用于RSA算法的判断效率,本发明在质数生成初始阶段直接剔除所有偶数以及被5整除的数,并选取53个小质数形成筛选数组进行深入筛选,然后才将IFPNJA应用于RSA算法的模幂运算进行快速筛选。所有筛选方法相辅相成形成一种基于改进质数判断的RSA算法(IPNRSA),IPNRSA具体的改进步骤如下:In order to improve the judgment efficiency of IFPNJA applied to the RSA algorithm, the present invention directly eliminates all even numbers and numbers divisible by 5 at the initial stage of prime number generation, and selects 53 small prime numbers to form a screening array for in-depth screening, and then applies IFPNJA to the RSA algorithm Modular exponentiation for quick screening. All screening methods complement each other to form an RSA algorithm (IPNRSA) based on improved prime number judgment. The specific improvement steps of IPNRSA are as follows:
输入:明文M,Miller-Rabin算法,随机大数组N。Input: plaintext M, Miller-Rabin algorithm, random large array N.
输出:加密的密文C,解密的明文M。Output: encrypted ciphertext C, decrypted plaintext M.
随机大数生成:随机生成一组除了偶数以及能被5整除的数之外的大数组N。Random large number generation: Randomly generate a set of large arrays N except even numbers and numbers divisible by 5.
大数组筛选:选取53个小质数用求余法对大数组N进行筛选。Large array screening: select 53 small prime numbers and use the remainder method to screen the large array N.
优化Miller-Rabin算法:利用Montgomery快速幂算法优化Miller-Rabin算法。Optimizing the Miller-Rabin algorithm: Optimizing the Miller-Rabin algorithm using Montgomery's fast power algorithm.
生成大质数p、q:结合上述步骤以及IFPNJA来生成两个大质数p、q。Generate large prime numbers p, q: Combine the above steps and IFPNJA to generate two large prime numbers p, q.
RSA加密明文:输入明文M,用两个大质数p、q生成RSA密钥对明文进行加密生成密文C。RSA encrypted plaintext: Input the plaintext M, use two large prime numbers p and q to generate an RSA key to encrypt the plaintext to generate ciphertext C.
输出加密的密文C。Output encrypted ciphertext C.
RSA解密明文:输入密文C,用两个大质数p、q生成RSA密钥对密文进行解密生成明文M。RSA decrypts the plaintext: Input the ciphertext C, use two large prime numbers p and q to generate an RSA key to decrypt the ciphertext to generate plaintext M.
输出解密的明文M。Output the decrypted plaintext M.
基于上述HDDES和IPNRSA两种改进的算法的优点,将它们利用医疗电子病例EMR数据的不同阶段(即进行混合加密),进而形成面向医疗数据安全存储的混合加密方案,具体如下:Based on the advantages of the above two improved algorithms, HDDES and IPNRSA, they use different stages of EMR data in medical electronic records (that is, perform hybrid encryption) to form a hybrid encryption scheme for safe storage of medical data, as follows:
因为对称加密算法的加密和解密的过程(如DES)是非常快的,加密效率非常高,非常适合更新频率快、数据量庞大的医疗电子病历数据EMR的加密,但是由于密钥传输的过程中容易被窃取,所以安全性不高,而非对称加密算法的加密和解密(如RSA)是非常缓慢的,加密效率非常低,不适合应用于医疗病历数据的加密,但是由于破解困难且密钥不怕被窃取,所以安全性极高,因此本发明为了解决该问题,采用对称加密和非对称加密相结合的混合加密方案,即采用HDDES和IPNRSA对医疗数据进选混合加密,具体过程如图9所示,概述如下:Because the encryption and decryption process of the symmetric encryption algorithm (such as DES) is very fast and the encryption efficiency is very high, it is very suitable for the encryption of medical electronic medical record data EMR with a fast update frequency and a large amount of data. It is easy to be stolen, so the security is not high, the encryption and decryption of asymmetric encryption algorithm (such as RSA) is very slow, the encryption efficiency is very low, and it is not suitable for the encryption of medical record data, but due to the difficulty of cracking and the key Not afraid of being stolen, so the security is extremely high. Therefore, in order to solve this problem, the present invention adopts a hybrid encryption scheme combining symmetric encryption and asymmetric encryption, that is, adopts HDDES and IPNRSA to select hybrid encryption for medical data. The specific process is shown in Figure 9 As shown, the overview is as follows:
发送方将医疗数据明文用HDDES密钥进行加密得到加密密文。The sender encrypts the plaintext of the medical data with the HDDES key to obtain the encrypted ciphertext.
发送方再用IPNRSA的公钥加密HDDES密钥信息得到加密密钥。The sender then encrypts the HDDES key information with the public key of IPNRSA to obtain the encryption key.
发送方将加密密文和加密密钥混合信息发送出去。The sender sends out the mixed information of encrypted ciphertext and encryption key.
接收方收到混合信息后,使用IPNRSA的私钥解密加密密钥得到HDDES密钥。After receiving the mixed information, the receiver uses the private key of IPNRSA to decrypt the encryption key to obtain the HDDES key.
接收方再用解密获得的HDDES密钥对加密密文进行解密得到医疗数据明文。The recipient then uses the decrypted HDDES key to decrypt the encrypted ciphertext to obtain the plaintext of the medical data.
上述基于HDDES和IPNRSA的混合加密策略不仅提升了加密医疗数据EMR的效率更是保证传输医疗数据EMR的安全性。The above hybrid encryption strategy based on HDDES and IPNRSA not only improves the efficiency of encrypted medical data EMR but also ensures the security of medical data EMR transmission.
本发明采用真实的医疗电子病历数据图片(EMR图片)进行加解密,实验结果如图10和图11所示,实验分析如下。The present invention uses real medical electronic medical record data pictures (EMR pictures) to encrypt and decrypt, and the experimental results are shown in Figures 10 and 11, and the experimental analysis is as follows.
医疗数据图片明文加密效果明显。从图10左半部分可以看出加密前的医疗数据图片文字部分清晰可见,然后执行加密操作后得出医疗数据图片密文(见图10右半部分),从图10右半部分中可以看出,几乎所有文字部分人眼都无法识别,而且其在后台再执行查看源文件操作时都以乱码的形式表现出来,这充分表明本发明提出的混合加密方案的加密有效性。The plaintext encryption effect of medical data pictures is obvious. From the left half of Figure 10, it can be seen that the text part of the medical data picture before encryption is clearly visible, and then the encrypted text of the medical data picture is obtained after the encryption operation (see the right half of Figure 10), as can be seen from the right half of Figure 10 It can be seen that almost all text parts cannot be recognized by human eyes, and they all appear in the form of garbled characters when the operation of viewing the source file is performed in the background, which fully demonstrates the encryption effectiveness of the hybrid encryption scheme proposed by the present invention.
医疗数据图片密文解密效果明显。从图11左半部分可以看出解密前的医疗数据图片整张模糊不清几乎不可识别,然后执行解密操作后得出医疗数据图片密文(见图11右半部分),与图10左半部分原图进行对比,明显看出加解密前后图片几乎无损,这充分表明本发明提出的混合加密方案的解密有效性。The ciphertext decryption effect of medical data pictures is obvious. From the left half of Figure 11, it can be seen that the medical data picture before decryption is blurred and almost unrecognizable, and then the ciphertext of the medical data picture is obtained after the decryption operation (see the right half of Figure 11), which is similar to the left half of Figure 10 Comparing some original images, it is obvious that the images before and after encryption and decryption are almost lossless, which fully demonstrates the decryption effectiveness of the hybrid encryption scheme proposed by the present invention.
本发明讨论了三重DES加密算法(Triple Data Encryption Algorithm,TDEA)以及独立子密钥DES加密算法(Independent Sub Key DES Algorithm,ISKDES)的优缺点,在TDEA算法和ISKDES算法的基础上,提出了一种混合双重DES加密算法(Hybrid Double DESEncryption Algorithm,HDDES),HDDES算法集结了TDEA和ISKDES两者的优点,HDDES首先将原64位密钥扩展至128位,减少了密钥过短被穷举攻击的风险,然后借鉴TDEA算法多重加密的优点,对加密信息进行双重加密,加强了算法的安全强度,最后参考ISKDES算法的特点将12位密钥进行映射,实现了局部独立性,避免密钥被暴力破解的威胁,两者相辅相成,并且由于只有双重加密,运行效率方面要比TDEA算法要高。The present invention discusses the advantages and disadvantages of triple DES encryption algorithm (Triple Data Encryption Algorithm, TDEA) and independent subkey DES encryption algorithm (Independent Sub Key DES Algorithm, ISKDES), on the basis of TDEA algorithm and ISKDES algorithm, proposes a A hybrid double DES encryption algorithm (Hybrid Double DESEncryption Algorithm, HDDES). The HDDES algorithm combines the advantages of both TDEA and ISKDES. HDDES first expands the original 64-bit key to 128-bit, which reduces the brute force attack when the key is too short. Then learn from the advantages of multiple encryption of the TDEA algorithm to double-encrypt the encrypted information to strengthen the security strength of the algorithm. Finally, refer to the characteristics of the ISKDES algorithm to map the 12-bit key to achieve partial independence and avoid the key being The threat of brute force cracking, the two complement each other, and because there is only double encryption, the operating efficiency is higher than that of the TDEA algorithm.
同时,本发明还讨论了确定性和概率性两种质数判断算法的优缺点,在Miller-Rabin概率性质数判断算法的基础上,提出了一种改进的快速质数判断算法(IFPNJA),IFPNJA采用Montgomery快速幂算法的主要好处就是将除法化为移位运算,这样不仅简化了计算过程,还提高了大数幂乘运算的效率。最后将IFPNJA应用于RSA算法,形成一种基于改进质数判断的RSA算法(RSA algorithm based on improved prime number decision,IPNRSA)。At the same time, the present invention also discusses the advantages and disadvantages of two kinds of prime number judging algorithms, deterministic and probabilistic, and proposes an improved fast prime number judging algorithm (IFPNJA) on the basis of the Miller-Rabin probabilistic prime number judging algorithm. The main advantage of Montgomery's fast exponentiation algorithm is to convert division into shift operation, which not only simplifies the calculation process, but also improves the efficiency of large number exponentiation operation. Finally, IFPNJA is applied to the RSA algorithm to form an RSA algorithm based on improved prime number decision (IPNRSA).
由于对称加密算法和非对称加密算法在面对更新频率快、数据量庞大的医疗电子病历数据EMR的优势和不足,本发明将HDDES加密算法和IPNRSA加密算法相结合,取长补短,形成一种基于HDDES和IPNRSA的混合加密方案,使其能有效地对医疗数据进行安全的存储。此外,基于HDDES和IPNRSA的混合加密方案继承了公钥加密体制的特性,所以不需要担心密钥管理相关问题,是面向医疗数据安全存储的一种理想的方案。Due to the advantages and disadvantages of the symmetric encryption algorithm and the asymmetric encryption algorithm in the face of fast update frequency and huge data volume of medical electronic medical record data EMR, the present invention combines the HDDES encryption algorithm and the IPNRSA encryption algorithm to learn from each other to form a HDDES-based The hybrid encryption scheme with IPNRSA enables it to effectively store medical data securely. In addition, the hybrid encryption scheme based on HDDES and IPNRSA inherits the characteristics of the public key encryption system, so there is no need to worry about key management related issues, and it is an ideal scheme for the safe storage of medical data.
本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。对于实施例公开的系统而言,由于其与实施例公开的方法相对应,所以描述的比较简单,相关之处参见方法部分说明即可。Each embodiment in this specification is described in a progressive manner, each embodiment focuses on the difference from other embodiments, and the same and similar parts of each embodiment can be referred to each other. As for the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and for the related information, please refer to the description of the method part.
本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处。综上所述,本说明书内容不应理解为对本发明的限制。In this paper, specific examples have been used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; meanwhile, for those of ordinary skill in the art, according to the present invention Thoughts, there will be changes in specific implementation methods and application ranges. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011236546.9A CN112367159B (en) | 2020-11-09 | 2020-11-09 | A hybrid encryption and decryption method and system for safe storage of medical data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011236546.9A CN112367159B (en) | 2020-11-09 | 2020-11-09 | A hybrid encryption and decryption method and system for safe storage of medical data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112367159A CN112367159A (en) | 2021-02-12 |
CN112367159B true CN112367159B (en) | 2023-08-29 |
Family
ID=74509335
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011236546.9A Active CN112367159B (en) | 2020-11-09 | 2020-11-09 | A hybrid encryption and decryption method and system for safe storage of medical data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112367159B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112863676A (en) * | 2021-04-23 | 2021-05-28 | 攀枝花市妇幼保健院(攀枝花市妇幼保健服务中心) | Doctor advice push management system based on multiple signature technology |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101262341A (en) * | 2008-02-22 | 2008-09-10 | 北京航空航天大学 | A Hybrid Encryption Method in Conference System |
WO2012152956A1 (en) * | 2011-05-09 | 2012-11-15 | PÉREZ I GIL, Antoni | Shannon security double symmetrical cryptogram method by coding information for telematic and electronic transmission |
CN110113340A (en) * | 2019-05-09 | 2019-08-09 | 程丁 | Based on distribution RSA in Hadoop platform and DES mixed encryption method |
CN110535868A (en) * | 2019-09-05 | 2019-12-03 | 山东浪潮商用系统有限公司 | Data transmission method and system based on Hybrid Encryption algorithm |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10333696B2 (en) * | 2015-01-12 | 2019-06-25 | X-Prime, Inc. | Systems and methods for implementing an efficient, scalable homomorphic transformation of encrypted data with minimal data expansion and improved processing efficiency |
-
2020
- 2020-11-09 CN CN202011236546.9A patent/CN112367159B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101262341A (en) * | 2008-02-22 | 2008-09-10 | 北京航空航天大学 | A Hybrid Encryption Method in Conference System |
WO2012152956A1 (en) * | 2011-05-09 | 2012-11-15 | PÉREZ I GIL, Antoni | Shannon security double symmetrical cryptogram method by coding information for telematic and electronic transmission |
CN110113340A (en) * | 2019-05-09 | 2019-08-09 | 程丁 | Based on distribution RSA in Hadoop platform and DES mixed encryption method |
CN110535868A (en) * | 2019-09-05 | 2019-12-03 | 山东浪潮商用系统有限公司 | Data transmission method and system based on Hybrid Encryption algorithm |
Non-Patent Citations (1)
Title |
---|
改进的RSA加密算法在智能药箱数据存储中的应用;陈菲;李少轩;;网络安全技术与应用(第04期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN112367159A (en) | 2021-02-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Orobosade et al. | Cloud application security using hybrid encryption | |
Gupta et al. | Cryptography algorithms: a review | |
Jirwan et al. | Review and analysis of cryptography techniques | |
JP2020052393A (en) | Post-quantum asymmetric key encryption system with one-to-many distributed key management based on double encapsulation of prime modulo | |
Iyer et al. | A novel idea on multimedia encryption using hybrid crypto approach | |
CN101262341A (en) | A Hybrid Encryption Method in Conference System | |
CN102025505A (en) | Advanced encryption standard (AES) algorithm-based encryption/decryption method and device | |
CN101383703A (en) | Dynamic Encryption System and Method Based on Generalized Information Domain | |
Mahesh et al. | Design of new security algorithm: Using hybrid Cryptography architecture | |
CN104519071A (en) | Group encryption and decryption method and system with selection and exclusion functions | |
Bhatele et al. | A novel approach to the design of a new hybrid security protocol architecture | |
CN116321129A (en) | Lightweight dynamic key-based power transaction private network communication encryption method | |
CN106549963A (en) | Safe storage system based on HDFS | |
CN117879833A (en) | Digital signature generation method based on improved elliptic curve | |
Patil et al. | Performance evaluation of hybrid cryptography algorithm for secure sharing of text & images | |
CN108270565A (en) | A kind of data mixing encryption method | |
CN116094716A (en) | Text encryption and decryption method, system and equipment based on elliptic curve cryptography | |
CN112367159B (en) | A hybrid encryption and decryption method and system for safe storage of medical data | |
CN107147626B (en) | Encrypted file transmission method combining AES algorithm and ElGamal algorithm | |
Shimal et al. | Extended of TEA: A 256 bits block cipher algorithm for image encryption | |
CN111835766B (en) | Re-random public key encryption and decryption method | |
Walia | Cryptography algorithms: A review | |
Hussein et al. | An enhanced ElGamal cryptosystem for image encryption and decryption | |
CN106973061B (en) | An Outgoing File Encryption Method Based on AES Based on Reversible Logic Circuit | |
Siva et al. | Hybrid cryptography security in public cloud using TwoFish and ECC algorithm |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |