A method and system for secure storage of patient medical data
By encrypting patient medical data in blocks and dynamically determining the encryption step sequence and round key, the problem of easily analyzeable encryption patterns in medical data using the AES algorithm is solved, thus achieving highly secure data storage.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN ZHONGHUI HI-TECH DIGITAL CONSTRUCTION CO LTD
- Filing Date
- 2025-08-29
- Publication Date
- 2026-06-09
AI Technical Summary
Existing AES encryption algorithms have problems when processing common medical data, such as easily analyzable encryption patterns and insufficient security, failing to meet high-level secure storage requirements.
By dividing patient medical data into multiple data blocks and dynamically determining the encryption step order and round key based on the index information of the data blocks and the current round key, a dynamic key selection rule and permutation index mechanism are adopted to break the fixed transformation structure of traditional encryption algorithms and enhance the complexity and randomness of the encryption process.
It effectively resists cryptographic attacks such as differential analysis and linear analysis, significantly improves the storage security of patient medical data, and enhances the complexity and nonlinearity of the encryption process, making it difficult to crack.
Smart Images

Figure CN121093380B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method and system for securely storing patient medical data. Background Technology
[0002] With the development of medical informatization, patient medical data, such as medical records, test reports, and imaging data, are stored and transmitted electronically. This data provides doctors with comprehensive patient information and is a key basis for developing precise treatment plans. However, medical data often contains a large amount of sensitive personal information. Once data leakage occurs, it will seriously infringe on patients' privacy rights and may even lead to malicious incidents such as medical fraud. Therefore, efficient and secure encrypted storage of patient medical data is crucial.
[0003] Currently, the Advanced Encryption Standard (AES) is a commonly used encryption algorithm internationally. AES protects data through a multi-round iterative encryption process, with each round consisting of four fixed basic steps: byte substitution, row shifting, column mixing, and round key addition. While this encryption process is efficient, it also has certain security vulnerabilities.
[0004] In light of the above, patient medical data from the same hospital or department often exhibits high similarity and regularity in text format, data structure, and the distribution of commonly used vocabulary. When this data is encrypted using the standard AES algorithm, the fixed sequence of encryption steps and the fixed order of round key usage in each round of encryption create a deterministic and predictable encryption pattern. Attackers may exploit the commonalities in the data content and, through cryptanalysis, more easily discover this encryption pattern, thereby reducing the difficulty of cracking the ciphertext. This compromises the security of the encrypted medical data, failing to meet high-level secure storage requirements. Summary of the Invention
[0005] To address the technical problem that the fixed order of encryption steps and round key usage in the standard AES algorithm leads to easily analyzable encryption patterns and insufficient security when processing common medical data, this invention provides solutions in the following aspects.
[0006] In a first aspect, the present invention provides a method for securely storing patient medical data, the method comprising the steps of:
[0007] The process involves: acquiring patient medical data to be encrypted; dividing the patient medical data into multiple data blocks and determining the index information of each data block; acquiring an initial key and generating a set of round keys containing multiple round keys based on the initial key; performing at least one round of encryption operation on each data block to generate an encrypted data block; wherein, in any round of encryption operation on the data block: determining the current round key from the set of round keys according to a preset key selection rule; determining a permutation index based on the index information of the data block and the current round key; determining the current encryption step order from a preset encryption step mapping table based on the permutation index, the encryption step mapping table containing multiple preset permutations and combinations of at least two encryption operations from byte substitution, row shifting, column mixing, and round key addition; performing the encryption operations contained in the current encryption step order on the data block sequentially using the current round key according to the current encryption step order; and combining all the encrypted data blocks to obtain the encrypted patient medical data.
[0008] This invention achieves significant technological advancements by introducing a dual dynamic mechanism. First, by dynamically determining the execution order of encryption steps based on the data block's own index information and the current round key, it breaks away from the fixed transformation structure of traditional encryption algorithms, resulting in different encryption paths for different data blocks and significantly increasing the complexity and non-linearity of the encryption process. Second, by dynamically determining the current round key through preset key selection rules, it disrupts the conventional and predictable order of round key usage. The combination of these two dynamic mechanisms makes the encryption process closely related to the data content and key state, effectively resisting cryptographic attacks targeting fixed structures, such as differential analysis and linear analysis, thereby greatly improving the security of patient medical data storage.
[0009] Preferably, determining the current round key from the round key set according to the preset key selection rule includes: using the round key in the round key set corresponding to the current encryption round as the reference round key; calculating the similarity between the reference round key and each other round key in the round key set; when the maximum value of the similarity is greater than a preset threshold, the current round key is the round key corresponding to the maximum value; otherwise, the current round key is the round key corresponding to the reference round key.
[0010] This invention introduces an adaptive selection mechanism based on the similarity between round keys. By calculating the similarity between the base round key and the remaining round keys and comparing it to a preset threshold, it determines whether to use the base key or replace it with the key with the highest similarity. This design makes the actual sequence of round keys involved in the computation unpredictable. Even if an attacker knows the key expansion algorithm, it is difficult to deduce the real key used in each round of encryption, thus effectively enhancing the ability to resist key-related attacks and further improving encryption security.
[0011] Preferably, the method for determining the preset threshold includes: extracting a bit sequence of consecutive preset bits at a preset position from the base round key, converting the bit sequence into a floating-point number, and using the floating-point number as the preset threshold.
[0012] The preset threshold of this invention is dynamically extracted and transformed from the current baseline round key. This makes the key selection criterion itself a dynamic variable related to the key, avoiding potential attack weaknesses caused by a fixed preset threshold. This design enhances the integrity and internal coherence of the algorithm, making the entire key selection mechanism more difficult to predict and analyze externally, thereby improving the robustness of the encryption system.
[0013] Preferably, the similarity is cosine similarity.
[0014] Preferably, the permutation index satisfies the following relation: ;in, It is the data block to perform the first The substitution index during round encryption operations; It is the index information of the data block in the patient's medical data; It is the first step to perform the data block The decimal form of the current round key during round encryption operations; The operators are determined from a pre-defined table of operation rules; It is the modulo operator; It represents the total number of permutations and combinations of encryption operations in the encryption step mapping table.
[0015] This approach calculates the permutation index using a formula that includes the data block index, the current round key, and variable operators. This effectively integrates the data block location information and key information to jointly determine the order of encryption steps. This design ensures that the generation of the permutation index is both data-dependent and key-dependent, and maps it to a valid index range through modulo operations. This guarantees the validity and diversity of encryption step selection, enhancing the randomness and resistance to attacks in the encryption transformation.
[0016] Preferably, the determination of the operator includes: selecting the corresponding operator from the preset operation rule table as the operator based on the remainder result of the decimal form of the current round key and the number of rules in the preset operation rule table.
[0017] This invention defines a dynamic method for determining operators. It ensures that the mathematical operators used to calculate the permutation index are no longer fixed, but are dynamically selected from a preset rule table based on the value of the current round key. Compared to schemes using fixed operators, this design introduces a third layer of dynamism into the encryption process: the dynamism of the computation rules. This means that the key affects not only the numerical value of the operation but also the logic of the operation itself, further increasing the complexity of the encryption transformation and making it more difficult for attackers to crack the algorithm model through mathematical analysis.
[0018] Preferably, the determination of the current encryption step order includes: if the current encryption round is not the final encryption round, the current encryption step order is composed of byte substitution, row shifting, column mixing and round key addition operations; if the current encryption round is the final encryption round, the current encryption step order is composed of byte substitution, row shifting and round key addition operations.
[0019] Preferably, the method further includes a data decryption operation, which includes: generating the round key set based on the initial key; for each encrypted data block, in each decryption round: determining the current round key and the permutation index according to the same key selection rules and determination method as each round of encryption operation; determining the current encryption step order based on the permutation index; and performing the inverse operation of each encryption operation on the encrypted data block in the reverse order of the current encryption step order.
[0020] Preferably, the step of dividing the patient's medical data into multiple data blocks includes: encoding the patient's medical data into binary form to obtain encoded medical data; and dividing the encoded medical data to obtain multiple data blocks.
[0021] In a second aspect, the present invention provides a patient medical data secure storage system, which includes a memory and a processor. The memory stores computer program instructions, which, when executed by the processor, implement the patient medical data secure storage method of the first aspect of the present invention.
[0022] By adopting the above technical solution, a patient medical data secure storage method of the first aspect of the present invention is generated into a computer program and stored in a memory so that it can be loaded and executed by a processor, thereby creating a terminal device based on the memory and the processor for convenient use.
[0023] The beneficial effects of this invention are:
[0024] 1. This invention introduces a preset key selection rule, so that the round keys used in each round of encryption are no longer selected in a fixed order, but are dynamically determined based on the similarity between the round keys. This uncertain key selection mechanism breaks the fixed usage pattern of round keys in the traditional AES algorithm, making it difficult for attackers to deduce the encryption rules by analyzing the generation and usage order of the round keys, thereby significantly enhancing the encryption algorithm's resistance to cryptanalysis.
[0025] 2. This invention introduces a permutation index and an encryption step mapping table to dynamically determine the execution order of encryption steps for each round of encryption operations. The permutation index is determined by the data block's own index information and the current round key, meaning that the order of encryption steps used for different data blocks or different encryption rounds is dynamically changing. This breaks the fixed four-step operation flow of the AES algorithm, greatly increasing the complexity and randomness of the encryption process, making the difficulty of cracking the ciphertext increase exponentially.
[0026] 3. The encryption transformation rules of this invention are associated with the index information of the data block itself. For different data blocks, even if their contents are exactly the same, the order of encryption steps and the sequence of round keys used during the encryption process will be different. This encryption mechanism ensures that even if an attacker successfully cracks one data block, they cannot apply the cracking experience to other data blocks, effectively preventing the spread of the crack and greatly improving the overall security of the entire medical data. Attached Figure Description
[0027] Figure 1 A flowchart illustrating a method for securely storing patient medical data provided in an embodiment of the present invention;
[0028] Figure 2 This is a schematic diagram illustrating how the current round key is determined in an embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of the operation rule table in an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram of the encryption step mapping table in an embodiment of the present invention;
[0031] Figure 5 This is a schematic diagram of the overall encryption process of a method for securely storing patient medical data provided in an embodiment of the present invention;
[0032] Figure 6 This is a schematic diagram of the overall decryption process of a method for securely storing patient medical data provided in an embodiment of the present invention;
[0033] Figure 7This is a structural block diagram of a patient medical data secure storage system provided in an embodiment of the present invention. Detailed Implementation
[0034] The first aspect of this invention provides a method for securely storing patient medical data, such as... Figure 1 As shown, the method includes steps S100-S500:
[0035] Step S100: Obtain the patient's medical data to be encrypted.
[0036] It should be noted that to encrypt and store patient medical data, it is first necessary to collect the patient's medical data. This patient medical data can be structured data, such as basic patient information, test results, and medical records, or it can be unstructured data, such as medical images, doctor's diagnosis texts, and gene sequence data.
[0037] Specifically, the patient's medical data to be encrypted is first obtained from the medical database of the hospital information system or from the data stream of a real-time data acquisition terminal such as a monitor.
[0038] At this point, the patient's medical data to be encrypted was obtained.
[0039] Step S200: Divide the patient's medical data into multiple data blocks and determine the index information of each data block.
[0040] It should be noted that the data processed by the computer system is in binary form. In order for the patient's medical data to be encrypted to be suitable for subsequent encryption algorithm processing, it must first be converted into a binary data stream of a unified format.
[0041] Specifically, the acquired patient medical data to be encrypted is first encoded, converting it into a unified binary data stream, denoted as the converted binary data stream. Commonly used encoding formats can be used, such as UTF-8, GB2312, and UTF-16. Implementers can choose according to their needs. These encoding formats are existing technologies and will not be elaborated upon here.
[0042] It should be noted that AES, as a block encryption algorithm, operates on data units of fixed length, i.e., data blocks. Therefore, it is necessary to standardize the original data stream of variable length.
[0043] Specifically, the converted binary data stream is divided into blocks, with each block being a standard 128-bit unit. If the last data block is shorter than 128 bits, it is padded using a standard padding scheme to ensure that all data blocks are of the same length. The specific padding method is existing technology and will not be elaborated upon here.
[0044] Furthermore, the present invention needs to be associated with the location of the data block during the encryption process, therefore a unique location identifier needs to be established for each data block.
[0045] Specifically, while dividing the data into blocks, an index is assigned to each data block. This index is an integer that increments from 1. The index corresponds one-to-one with the data block, and the position of the data block in the original data can be accurately traced through the index.
[0046] At this point, the patient's medical data has been converted into multiple standardized data blocks with unique index information.
[0047] Step S300: Obtain the initial key, and based on the initial key, generate a set of round keys containing multiple round keys.
[0048] It should be noted that in a symmetric encryption system, the initial key is the foundation of the entire encryption and decryption process, and its confidentiality is a prerequisite for ensuring data security. All subsequent encryption transformations originate from this key.
[0049] Specifically, an initial key of a preset length is typically generated using a certified secure random number generator. Depending on the security requirements of the application scenario, the length of this initial key can be 128 bits, 192 bits, or 256 bits. This embodiment will use 128 bits as an example.
[0050] It should be noted that in traditional AES encryption algorithms, to increase the complexity of the encryption algorithm and effectively resist various cryptanalysis attacks, a single initial key is not used directly in all encryption rounds. Instead, a key expansion algorithm is employed, using the obtained initial key as input and generating the round key for each round of encryption through a series of preset transformations and iterative operations. To prevent attackers from exploiting patterns in subsequent round key selections, this invention imposes restrictions on the selection of the initial key.
[0051] Specifically, the 128-bit key generated by the secure random number generator is designated as the candidate key. The round keys corresponding to the candidate key are obtained through the AES orchestration function. The cosine similarity between the round keys is calculated. If the standard deviation of the cosine similarity between the round keys is greater than a threshold, the candidate key is used as the initial key. If the standard deviation is less than the threshold, a new candidate key is generated. This process continues until the standard deviation of the cosine similarity between the round keys corresponding to the candidate key is greater than the threshold. This threshold can be set to 0.6, or it can be set according to requirements.
[0052] Understandably, this key expansion mechanism is existing technology. Its core purpose is to provide a different key for each round of encryption, but related to the initial key, thereby reducing the regularity and correlation of encryption transformations between different rounds and enhancing the security of the entire encryption scheme. The specific method of generating this key is existing technology and will not be elaborated upon here.
[0053] It should be noted that similarity calculation requires first constructing a sequence of each bit of the candidate key or generated round key, and then using these sequences as vectors to calculate their similarity. Cosine similarity calculation is an existing technique and will not be elaborated upon here.
[0054] Regarding the threshold setting, it should be noted that a threshold of 0.6 is suitable for medical data of moderate sensitivity, such as outpatient medical records and routine laboratory reports like blood and urine tests. When the threshold is 0.6, the standard deviation of the cosine similarity between round keys needs to be greater than 0.6. This means that the dispersion of the round key sequence is moderate, avoiding both the regularity caused by excessive similarity of round keys and the increased computational overhead of key expansion due to excessive dispersion. If the standard deviation is too low, such as a threshold < 0.4, the round keys are highly correlated and easily attacked by differential analysis. If the standard deviation is too high, such as a threshold > 0.8, the key generation failure rate increases, requiring multiple retries. For encryption of low-sensitivity medical data, such as anonymized medical statistics and publicly available health education materials, the threshold can be set to 0.5. For encryption of highly sensitive medical data, such as gene sequencing data, diagnostic records of infectious diseases such as AIDS, and medical histories of mental illness, the threshold can be set to 0.7.
[0055] After obtaining the initial key using the above method, the round keys corresponding to the initial key are used to construct a round key set, generating a set containing... The set of round keys, where, This represents the total number of rounds of subsequent encryption operations.
[0056] At this point, a set of round keys containing multiple round keys has been obtained.
[0057] Step S400: For each of the data blocks, perform at least one round of encryption operations to generate an encrypted data block.
[0058] This is the core encryption step of the present invention. For each data block, a predetermined number of rounds of encryption operations will be performed, for example, 10 rounds. Unlike existing technologies, the present invention introduces dynamism and uncertainty within each round of encryption operations. The following section uses index information as an example... Data blocks are processed in the first Taking round encryption as an example, the encryption operation steps are explained in detail.
[0059] Specifically, the encryption operation includes steps S410-S430:
[0060] Step S410: Determine the current round key for the current encryption round from the set of round keys according to the preset key selection rules.
[0061] It should be noted that since the key arrangement function of the traditional AES encryption algorithm is public knowledge, and the order in which the round keys are used is fixed, knowing the initial key allows the determination of the round key used in each round of encryption. Attackers could exploit this pattern to crack the ciphertext. This embodiment designs a dynamic key selection mechanism, making the actual round key used in each round of encryption uncertain.
[0062] For plaintext data blocks, processing requires initial round key addition, which involves adding the initial state matrix of the plaintext data block to the initial key matrix using round key addition to obtain the first round of data blocks to be encrypted. Then, the encryption operation is performed using the following steps.
[0063] Specifically, when performing the first step on any data block... During round encryption, firstly, from the round key set, the key that should be used in the standard order is selected. The round key is used as the baseline round key. Then, the cosine similarity between this baseline round key and all other round keys in the round key set is calculated. The maximum similarity value and its corresponding round key are found and denoted as the similar round key. This maximum similarity value is compared with a preset threshold. If the maximum similarity value is greater than the preset threshold, the corresponding similar round key is selected as the next round key. The current round key for the round encryption operation; otherwise, if the maximum similarity value is less than or equal to the preset threshold, the original baseline round key is still used as the current round key.
[0064] It should be noted that the calculation of the similarity between round keys is the same as the method described above. It also requires constructing each bit of the round key into a sequence, and then using the sequences formed by each key as vectors to calculate their similarity.
[0065] Using similar round keys can guide attackers to crack the ciphertext in the wrong direction, inducing them to invest more samples and computing power in the wrong direction and go deeper into more rounds before collapsing, thus increasing the difficulty of cracking the ciphertext. Since not every round of encryption uses similar round keys as the round keys used for encryption, attackers cannot predict which rounds will be replaced, nor can they construct error correction strategies based on the fixed assumption that every round must be replaced or never replaced.
[0066] For example, such as Figure 2As shown, the data block to be encrypted is denoted as the data to be encrypted. Assuming the data to be encrypted requires three rounds of encryption, the encrypted data blocks correspond to the first round of encryption, the second round of encryption, and the third round of encryption, respectively. In Figure 2, key1, key2, and key3 in the first row are the round keys used in each round of encryption, generated sequentially based on the initial key. During the third round of encryption, assuming the base round key is key3, if the calculation shows that the cosine similarity between key3 and key2 is the largest, and this value is greater than a preset threshold, then the current round key for the third round of encryption is key2, not key3. If the calculation shows that the cosine similarity between key3 and key2 is the largest, and this value is less than or equal to the preset threshold, then the current round key for the third round of encryption is key3, not key2. Therefore, it can be observed that... Figure 2 The key3, key2, and key1 in the second line are the keys actually used in each round.
[0067] It should be noted that there are multiple ways to determine the preset threshold.
[0068] In one feasible implementation, the preset threshold can be a fixed empirical value, such as 0.9. The selection of this empirical value is directly related to the security requirements of medical data encryption scenarios: medical data needs to strike a balance between encryption flexibility and key stability. If the preset threshold is too high, such as 0.95, it will make it difficult for similar round keys to be selected, and the selection of round keys will tend to be in a fixed order, reducing dynamism; if the preset threshold is too low, such as 0.8, it may lead to frequent switching of round keys, increasing the risk of key association being cracked. Setting it to 0.9, in medical data encryption scenarios, this value can ensure that the probability of selecting similar round keys is controlled at 30%-40%, avoiding both complete fixation and excessive randomness.
[0069] In one feasible implementation, to further enhance dynamism, the preset threshold can be extracted from the baseline round key. For example, from the first... From the binary sequence of the base round key, extract the 16 consecutive bits starting from the 8th bit, convert them into a decimal integer between 0 and 65535, and then normalize the converted integer by dividing it by 65535. The range ensures that the preset threshold range is effective.
[0070] In another feasible implementation, the preset threshold can be extracted from the current round key. For example, from the first round key... In the binary sequence of the current round key, extract the 16 consecutive bits starting from the 8th bit, convert them to a decimal integer between 0 and 65535, and then normalize the converted integer by dividing it by 65535. The range ensures that the preset threshold range is effective.
[0071] Thus, the data used for the first... The current round key, which is uncertain, is used for round encryption operations.
[0072] Step S420: Determine the permutation index based on the index information of the data block and the current round key.
[0073] It should be noted that, since the traditional AES encryption algorithm uses a fixed round function for each round of encryption, it is easy for attackers to find the encryption pattern. In order to enhance the security of medical data, this invention uses a round function with a different operation order for each round of encryption. That is, the order of byte substitution (SB), row shift (SR), column mixing (MC), and round key addition (ARK) is not fixed during the encryption process. This step aims to dynamically generate an index for each round of encryption to determine the operation order of the round function.
[0074] Specifically, first, construct an operation rule table, such as Figure 3 As shown in the diagram, the arithmetic rule table includes various arithmetic rules, including addition, subtraction, multiplication, and division. In actual use, implementers can also adjust the arithmetic rule table according to their needs.
[0075] Secondly, since the current round key is binary, it needs to be converted to decimal form first. Then, based on the decimal form of the current round key and the index information of the data block in the data, the permutation index of the data block in each round of encryption is obtained.
[0076] Based on the above logic, the replacement index satisfies the following relation:
[0077] ;
[0078] in, It is the data block to perform the first The substitution index during round encryption operations; It is the index information of the data block in the patient's medical data; It is the first step to perform the data block The decimal form of the current round key during round encryption operations; The operators are determined from a pre-defined table of operation rules; It is the modulo operator; It represents the total number of permutations and combinations of encryption operations in the encryption step mapping table.
[0079] Because different data blocks have different positional orders in medical data, i.e., different index information, and the round keys are complex, this invention aims to increase the difficulty of cracking by ensuring that the permutation index used in different encryption rounds is different when encrypting each data block. and Perform the operation to obtain the replacement index. Operation rules. Obtain from the operation rule table. The calculation is performed according to the number of operation rules in the operation rule table. , In this embodiment, the total number of operation rules in the operation rule table is [number]. ,For example If the value is 3, and the third operation rule in the operation rule table is addition, then... For multiplication, at this time .
[0080] It should be further explained that, since the round function includes four steps—byte substitution (SB), row shift (SR), column mixing (MC), and round key addition (ARK)—these four steps can be combined in 24 different orders. =24.
[0081] At this point, the data block has been acquired for the first... The substitution index during round encryption operations.
[0082] Step S430: Based on the permutation index, determine the current encryption step order from the preset encryption step mapping table; according to the current encryption step order, use the current round key to sequentially execute the encryption operations contained in the current encryption step order on the data block.
[0083] It should be noted that the permutation index obtained in step S430 is the bridge connecting the calculation result and the actual encryption process, and it will directly determine the specific execution method of this round of encryption.
[0084] Specifically, such as Figure 4 The table shown is a mapping table of encryption steps consisting of permutations and combinations of four steps: byte substitution (SB), row shift (SR), column mixing (MC), and round key addition (ARK). A specific sequence of encryption steps is obtained by searching this encryption step mapping table based on the obtained permutation index.
[0085] For example, if the replacement index is 4, the order obtained from the table lookup is: Subsequently, strictly following this order, using the current round key determined in step S410, the current data block will be subjected to byte substitution (SB), column mixing (MC), round key addition (ARK), and row shift (SR) operations in sequence. For the final round of encryption, the AES standard can be adapted, and the encryption order after removing the column mixing operation can be used as the execution order for encryption operations.
[0086] For each data block, repeat steps S410 to S430 for a total of 10 rounds to complete the encryption of that data block.
[0087] This completes the multi-round dynamic encryption of a data block, generating the corresponding encrypted data block.
[0088] Step S500: Combine all the encrypted data blocks to obtain encrypted patient medical data.
[0089] It should be noted that after all the individual data blocks have been encrypted, they need to be reassembled to form a complete ciphertext file that corresponds to the original data structure.
[0090] Specifically, after all data blocks have undergone the complete encryption process in step S400, these encrypted data blocks are concatenated according to the order of their original index information. The resulting data stream is the final, encrypted patient medical data. This data can be securely stored in a database or transmitted over a network.
[0091] This completes the secure encrypted storage of the entire patient's medical data.
[0092] Finally, combining Figure 5 The complete encryption process is explained. Figure 5 In this context, key1, key2, and key3 are round keys generated based on the initial key. The current round key determined in each round has already been explained in step S410, and... Figure 5 Examples and Figure 2 The examples in the table are exactly the same, so I won't go into detail here. Index1, Index1, and Index3 are the permutation indices calculated according to the operation rule table.
[0093] Taking key1 as an example, we obtain the current round key key3 used in the first round of encryption. Using the current round key key3 and the operation rule table, we obtain the permutation index Index1. Then, we obtain the encryption step order by mapping Index1 to the encryption step mapping table. For example, the obtained order is... The data block is referred to as the data to be encrypted. The first round of data to be encrypted is processed by byte substitution, round key addition, row shifting and column mixing operations to obtain the second round of data to be encrypted. This process is repeated for several rounds to obtain the ciphertext.
[0094] For an encryption algorithm, what's more important is that the encrypted ciphertext data can be decrypted to obtain the plaintext data before encryption. The decryption process will be explained below.
[0095] Decryption requires an initial key, an operation rule table, an encryption step mapping table, etc. Therefore, the initial key, operation rule table, and encryption step mapping table need to be transmitted as keys in a data transmission method agreed upon by both parties, so that both parties can obtain the keys. Then, the decryption operation is performed, such as... Figure 6The diagram shows the complete decryption process. The decryption process of this invention is the exact inverse operation of the encryption process. The receiver must possess the same initial key, operation rule table, and encryption step mapping table. During decryption, the ciphertext is also divided into blocks, and decryption is performed in reverse order starting from the last round. In each round of decryption, the current round key and permutation index are recalculated using the exact same method steps S410 and S420 as during encryption, thereby determining the order of steps used during encryption. Then, the inverse operations of each step are performed in reverse order of encryption.
[0096] For example, if the encryption order is The decryption order is as follows: ,in, , , , The decryption operations are for MC, SR, ARK, and SB respectively. This part uses well-known technology. The first round of data to be encrypted is obtained through the encryption steps corresponding to the ciphertext in each round of encryption. The first round of data to be encrypted is processed to obtain plaintext.
[0097] The second aspect of this embodiment provides a secure storage system for patient medical data, such as... Figure 7 As shown, the patient medical data secure storage system includes a memory and a processor. The memory stores computer program instructions, which, when executed by the processor, implement the first aspect of the present invention: a patient medical data secure storage method.
[0098] The patient medical data secure storage system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the setup and functions of which are known in the art and will not be described in detail here.
[0099] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.
[0100] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for securely storing patient medical data, characterized in that, Including the following steps: Obtain patient medical data to be encrypted; The patient's medical data is divided into multiple data blocks, and the index information for each data block is determined. Obtain the initial key, and based on the initial key, generate a set of round keys containing multiple round keys; For each data block, at least one round of encryption operations is performed to generate an encrypted data block. In any round of encryption operations on the data block: according to a preset key selection rule, the current round key is determined from the round key set for the current encryption round; a permutation index is determined based on the data block's index information and the current round key; based on the permutation index, the current encryption step order is determined from a preset encryption step mapping table, which contains multiple preset permutations and combinations of at least two encryption operations from byte substitution, row shifting, column mixing, and round key addition; according to the current encryption step order, using the current round key, the encryption operations included in the current encryption step order are executed sequentially on the data block. Determining the current round key includes: using the round key in the round key set corresponding to the current encryption round as the base round key; calculating the similarity between the base round key and each other round key in the round key set; when the maximum value in the similarity is greater than a preset threshold, the current round key is the round key corresponding to the maximum value; otherwise, the current round key is the round key corresponding to the base round key. By combining all the encrypted data blocks, the encrypted patient medical data is obtained.
2. The method for securely storing patient medical data according to claim 1, characterized in that, The method for determining the preset threshold includes: From the base round key, extract a sequence of consecutive bits at a preset position, convert the bit sequence into a floating-point number, and use the floating-point number as a preset threshold.
3. The method for securely storing patient medical data according to claim 1, characterized in that, The similarity is cosine similarity.
4. The method for securely storing patient medical data according to claim 1, characterized in that, The permutation index satisfies the following relation: ; in, It is the data block to perform the first The substitution index during round encryption operations; It is the index information of the data block in the patient's medical data; It is the first step to perform the data block The decimal form of the current round key during round encryption operations; The operators are determined from a pre-defined table of operation rules; It is the modulo operator; It represents the total number of permutations and combinations of encryption operations in the encryption step mapping table.
5. The method for securely storing patient medical data according to claim 4, characterized in that, The determination of the operator includes: Based on the remainder of the decimal form of the current round key and the number of rules in the preset operation rule table, the corresponding operator is selected from the preset operation rule table as the operator.
6. The method for securely storing patient medical data according to claim 1, characterized in that, The determination of the current encryption step order includes: If the current encryption round is not the final encryption round, the current encryption steps are arranged in the order of byte substitution, row shifting, column mixing and round key addition operations; If the current encryption round is the final encryption round, the current encryption steps are arranged in sequence as byte substitution, row shifting, and round key addition.
7. The method for securely storing patient medical data according to claim 1, characterized in that, The method further includes a data decryption operation, which includes: The round key set is generated based on the initial key; For each encrypted data block, in each decryption round: the current round key and the permutation index are determined according to the same key selection rules and determination method as in each round of encryption operation; Based on the permutation index, the current encryption step order is determined; Perform the inverse operations of each encryption operation on the encrypted data block in the reverse order of the current encryption steps.
8. The method for securely storing patient medical data according to claim 1, characterized in that, The process of dividing patient medical data into multiple data blocks includes: The patient's medical data is encoded into binary form to obtain the encoded medical data; The encoded medical data is segmented into multiple data blocks.
9. A patient medical data secure storage system, characterized in that, The patient medical data secure storage system includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a patient medical data secure storage method according to any one of claims 1-8.