Multi-tenant oriented national secret level micro-service architecture and data isolation method
By using the root node key of the tenant organization tree to derive the isolation key of the data ownership node level by level in the multi-tenant business system, and combining it with the national cryptographic algorithm to generate access policy tags, the problems of insufficient data isolation granularity and imprecise cross-level access control in the multi-tenant business system are solved. Organizational-level data isolation and dynamic access control are realized, and the granularity and security of data access control are improved.
Patent Information
- Application Number
- CN202611690275.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-29
- Publication Date
- 2026-11-24
AI Technical Summary
In multi-tenant business systems, existing data isolation technologies are unable to achieve fine-grained isolation within the same tenant according to the hierarchical relationship of the organizational tree. Cross-level access control is imprecise, national cryptographic security links are incomplete, and dynamic access control and anti-tampering audit records are lacking.
By deriving isolation keys for data ownership nodes level by level from the root node key of the tenant organization tree, and combining them with national cryptographic algorithms to generate access policy labels, the ancestor relationship between the visitor and the data ownership node is verified in the tenant organization tree to achieve dynamic access control and anti-tampering auditing.
It achieves hierarchical data isolation and dynamic access control, improves the granularity and security of data access control, ensures the linkage between access policies and encryption keys, and provides tamper-proof audit logs.
Smart Images

Figure CN123158690A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of microservice data security technology, specifically to a national cryptographic-level microservice architecture and data isolation method for multi-tenant businesses. Background Technology
[0002] Multi-tenant business systems are mostly deployed in microservice environments, and their business organization data has a hierarchical tree structure, with differences in data ownership and access scope between different business branches. Existing data isolation technologies are mostly based on tenant identifiers for database sharding, table partitioning, or row-level filtering of shared tables, and key management typically uses tenant-unified keys or application-level fixed keys. These methods can only isolate data between different tenants, making it difficult to achieve fine-grained isolation of business data generated by different organizational nodes within the same tenant according to the hierarchical relationship of the organizational tree. Data access permissions between organizational nodes are mostly implemented through organizational hierarchy judgments in the business code or static role configurations. When the organizational tree is adjusted or cross-level sharing needs arise, access control rules require manual modification, and there is a lack of linkage between data ownership information, access policies, and encryption keys. While national cryptographic algorithms are mainly used for transmission channel encryption or identity authentication in some business systems, the encryption of business data storage, key derivation, and access policy protection have not formed a complete national cryptographic security chain. When routing access messages, microservice gateways typically only verify tenant identity, failing to match the organization node information in the national cryptographic certificate with the node depth in the tenant's organization tree, nor jointly verify the data ownership node identifier, visibility level, and operation permission bitmap carried in the access policy tag. In multi-level data sharing scenarios within business organizations, there is a lack of a mechanism to derive the root node key level by level from the organization tree to the data ownership node, and to dynamically determine whether decryption and return are allowed based on the ancestor relationship between the visitor and the data ownership node. Furthermore, it is difficult to generate tamper-proof audit records associated with the visitor's organization node, data ownership node, and operation type after data decryption. These deficiencies result in insufficient granularity of multi-tenant business data isolation, imprecise cross-level access control, and incomplete application of national cryptographic security capabilities in data isolation and access control. Summary of the Invention
[0003] This invention provides a national cryptographic-level microservice architecture and data isolation method for multi-tenant businesses, used to isolate business data at the organizational node granularity according to an organizational tree structure in a multi-tenant microservice environment. Data ownership node isolation keys are derived level by level from the root node key of the tenant's organizational tree. An access policy tag consisting of the data ownership node identifier, the number of visibility levels, and an operation permission bitmap is attached to the encrypted data. After national cryptographic signature verification and ancestor relationship verification, decryption is allowed. This ensures that data encryption, access policy, authentication, and decryption key derivation are executed within the same secure link, achieving organizational-level data isolation and dynamic access control.
[0004] To achieve the above objectives, the present invention provides the following technical solution: The present invention provides a national cryptographic-level data isolation method for multi-tenant services. The method includes: receiving a multi-tenant service access message; parsing the tenant's national cryptographic certificate, organization node identifier, and data to be operated from the access message; locating the data ownership node in the tenant organization tree based on the organization node identifier, obtaining the root node key of the tenant organization tree, and generating an isolation key for the data ownership node using the root node key through a national cryptographic derivation function; using the isolation key to encrypt the data to be operated using national cryptographic encryption to obtain ciphertext and an access policy label, wherein the access policy label includes the data ownership node identifier, the number of visibility levels, and an operation permission bitmap; performing national cryptographic verification on the access message using the tenant's national cryptographic certificate; after successful verification, determining whether to allow the access based on the ancestor relationship between the visitor's organization node identifier and the data ownership node identifier in the tenant organization tree and the access policy label; when allowing access, the data isolation service derives the visitor-side decryption key level by level according to the ancestor relationship, decrypts the ciphertext, and returns the plaintext data to the visitor.
[0005] When parsing access messages, preferably, the signature value can be extracted from the access message and verified using the national cryptographic algorithm SM2. After successful verification, the organization node identifier and organization level number are read from the extended fields of the tenant's national cryptographic certificate. The organization level number is then matched with the node depth in the tenant's organization tree to determine the visitor's organization level. In this way, the visitor's identity is bound to the hierarchical information of the tenant's organization tree, reducing the possibility of forged organization affiliation.
[0006] As a technical solution of the present invention, when generating the isolation key for the data ownership node, the root node key of the tenant organization tree can be read from the key management server, and the parent node identifier of the data ownership node can be obtained; the root node key, parent node identifier, data ownership node identifier, and node type flag are concatenated into a first input string; the national cryptographic SM3 hash operation is performed on the first input string to obtain a first hash value; the first hash value is concatenated with the current node identifier and the next-level node identifier, and the national cryptographic SM3 hash operation is repeated until the isolation key for the data ownership node is calculated. Through this hierarchical hash derivation method, the upper-level node can derive the key to the lower-level node, while the lower-level node has difficulty in deriving the upper-level key, thus achieving one-way key isolation between organizational levels.
[0007] When encrypting data to be operated on using national cryptographic standards, the data can be divided into multiple fixed-length segments, each assigned a segment number. Each segment is then encrypted using a subkey derived from the isolation key using the national cryptographic standard SM4. When generating the subkey, the segment number, the data ownership node identifier, and the isolation key are used as inputs to the national cryptographic standard SM3 hash function, with the hash function output as the subkey. The ciphertext of each data segment is then assembled sequentially into ciphertext, and the data ownership node identifier, the visibility level, and the operation permission bitmap are encapsulated as an access policy tag. This method ensures that different data segments have independent encryption subkeys, improving encryption strength while maintaining the ciphertext structure's assemblability and verifiability.
[0008] For the encapsulation of access policy labels, preferably, the data ownership node identifier, the number of visibility levels, and the operation permission bitmap can be serialized into policy text according to a predetermined field order; the isolation key of the data ownership node is used to perform SM3 operations on the policy text to generate a policy digest; the policy digest is written to the end of the policy text, and the policy text carrying the policy digest serves as the access policy label. The policy digest is bound to the isolation key, enhancing the integrity and tamper-proof capability of the access policy label.
[0009] When performing national cryptographic signature verification using a tenant's national cryptographic certificate, the timestamp, random number, and signature data can be extracted from the access message. The public key in the tenant's national cryptographic certificate is then used to perform SM2 signature verification on the message digest composed of the timestamp, random number, and organization node identifier. Upon successful verification, it is determined whether the difference between the timestamp and the current server time is within a preset time window. If it is, a national cryptographic session token is generated for the visitor, encrypted, and returned to the visitor. This signature verification mechanism can identify expired requests and replay requests, reducing the risk of unauthorized access.
[0010] During the access determination process, the lowest common ancestor (LCA) node between the visitor's organization node and the data owner node can be found in the tenant organization tree. The path depth from the data owner node to the LCA node is calculated and compared with the visibility level in the access policy label. If the path depth is less than or equal to the visibility level, the operation permission bitmap in the access policy label is further checked to see if it contains the visitor's operation type. If it contains the operation type, the access is allowed; otherwise, it is denied. This determination method jointly verifies the organization level, the visibility of the data owner node, and the operation type, improving the granularity of data access control.
[0011] When decrypting and returning data, if the visitor's organization node is an ancestor of the data owner node, the isolation key is derived level by level down the tenant organization tree using the national cryptographic standard (SM4) from the visitor's organization node's isolation key to calculate the data owner node's isolation key. The data ciphertext is then decrypted using the data owner node's isolation key using the national cryptographic standard SM4 to obtain the plaintext data. The plaintext data is then returned to the visitor through the microservice gateway, and an audit log containing the visitor's organization node identifier, the data owner node identifier, the access time, and the operation type is generated upon return. By deriving keys level by level down the organization tree, visitors with ancestor privileges can obtain the decryption capability of lower-level data while maintaining the strictness of the key derivation relationship.
[0012] When generating audit records, the fields in the audit record can be concatenated in sequence to form an audit string, and the audit string can be hashed using the national cryptographic standard SM3 to obtain the current audit hash value. The current audit hash value and the hash value of the previous audit record are then written into a new block of the audit log chain. The new block is broadcast to the audit service nodes to form a consistent audit log chain across multiple nodes. This enables tamper-proof tracking of access operations, facilitating security auditing and post-event traceability.
[0013] This invention also provides a national cryptographic-level microservice architecture for multi-tenant services, used to implement the aforementioned national cryptographic-level data isolation method for multi-tenant services. It includes a tenant access gateway, an organization key service, a policy management service, a data isolation service, an audit trail service, and a microservice registration and routing center. The tenant access gateway receives multi-tenant service access messages and parses the tenant's national cryptographic certificate, organization node identifier, and data to be operated on. The organization key service maintains the tenant organization tree and generates isolation keys for each organization node. The policy management service generates, stores, and verifies access policy tags. The data isolation service performs national cryptographic encryption and decryption on service data and derives decryption keys level by level based on the ancestor relationship between nodes in the tenant organization tree. The audit trail service records access operations and generates tamper-proof audit logs using a national cryptographic digest algorithm. The microservice registration and routing center routes service access messages to the corresponding service microservices based on the organization node identifier. The tenant access gateway, organization key service, policy management service, data isolation service, audit trail service, and microservice registration and routing center communicate via a national cryptographic secure transmission channel. This architecture combines national cryptographic certificate verification, organization tree key derivation, data encryption, access policy label verification, and audit trails to ensure encrypted isolation of multi-tenant business data across different tenants and organization nodes. Access control takes into account organizational hierarchy, visibility scope, and operation type, and audit logs have tamper-proof characteristics, thereby improving data security and traceability.
[0014] The technical effects and advantages provided by the present invention in the above technical solution are as follows:
[0015] This method uses the tenant organization tree root node key and data ownership node path information as inputs to a national cryptographic derivation function. It generates isolation keys for the data ownership nodes level by level through SM3 hash operations, and then uses subkeys derived from these isolation keys for segmented SM4 encryption of business data. The key derivation process binds the parent node identifier, data ownership node identifier, and node type flag, ensuring that the isolation keys of different organization nodes are unique. Lower-level nodes cannot deduce the key of their upper-level nodes from their own keys, while upper-level nodes can derive the keys of their lower-level nodes along the organization tree path. This approach achieves organizational-level isolation at the key management level, eliminating the need to store independent keys for each organization node, thus reducing key storage and distribution steps. By combining the data ownership node identifier and the isolation key to generate encryption subkeys, different data segments under the same organization node use different subkeys, reducing the risk of ciphertext segmentation replay and splicing. During decryption, the data isolation service derives the decryption key for the visitor side level by level according to the ancestor relationship between the visitor's organization node and the data owner node. This ensures that decryption capability is only granted to visitors with a legitimate ancestor relationship in the organization tree. Nodes that fail the policy verification or are not within the visible range cannot obtain a valid decryption key, thereby forming an isolation boundary for multi-tenant business data that is consistent with the organization hierarchy at the encryption level.
[0016] While generating encrypted data, access policy tags are encapsulated. These tags, serialized from the data owner node identifier, visibility level number, and operation permission bitmap, are then processed using the national cryptographic standard SM3 to generate a policy digest, forming a tamper-proof policy binding. During access determination, the lowest common ancestor (LCA) node between the visitor's organization node and the data owner node is found in the tenant organization tree. The path depth from the data owner node to the LCA node is calculated and compared with the visibility level number in the access policy tag. The operation permission bitmap is then checked to ensure it contains the visitor's operation type. This process combines the dynamic hierarchical relationship of the organization tree with the data's built-in policies, eliminating reliance on static role lists and enabling adaptation to organization tree adjustments and controlled sharing across levels. After successful verification with the national cryptographic certificate, the organization node identifier and organization level number in the certificate's extended fields are used to match the organization tree node depth, binding the visitor's identity to their organization location and preventing forgery of the organization node identifier. Once verification with the national cryptographic certificate, ancestor relationship judgment, and policy tag digest verification all pass, decryption is allowed. Data access is controlled from four dimensions: identity, level, visibility, and operation permissions, achieving integrated national cryptographic-level access control of encrypted data and access policies in multi-tenant applications. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0018] Figure 1 This is a flowchart of a national-level cryptographic data isolation method for multi-tenant businesses;
[0019] Figure 2 This is a flowchart of the data isolation encryption and access policy label generation process;
[0020] Figure 3 This is a flowchart of data access control and audit trail derived from tenant organization tree keys;
[0021] Figure 4 This is the total SM4 encryption time curve for data segments corresponding to different data ownership nodes. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] See Figure 1 This invention provides a national cryptographic-level data isolation method for multi-tenant services, comprising: receiving a multi-tenant service access message; parsing the tenant's national cryptographic certificate, organization node identifier, and data to be operated from the access message; locating the data ownership node in the tenant organization tree based on the organization node identifier, obtaining the root node key of the tenant organization tree, and generating an isolation key for the data ownership node using the root node key through a national cryptographic derivation function; using the isolation key to encrypt the data to be operated using national cryptographic encryption to obtain ciphertext and an access policy label, wherein the access policy label includes the data ownership node identifier, the number of visibility levels, and an operation permission bitmap; performing national cryptographic verification on the access message using the tenant's national cryptographic certificate; after successful verification, determining whether to allow the access based on the ancestor relationship between the visitor's organization node identifier and the data ownership node identifier in the tenant organization tree and the access policy label; when allowing access, the data isolation service derives a decryption key for the visitor side based on the ancestor relationship level by level, decrypts the ciphertext, and returns the plaintext data to the visitor.
[0024] In implementation, the tenant access gateway receives multi-tenant service access messages. These messages include a message header, message body, and signature value. The tenant access gateway extracts the signature value from the message header. The signature value is verified using the SM2 national cryptographic algorithm. The verification process uses the public key in the tenant's national cryptographic certificate. The tenant's national cryptographic certificate is issued by the certificate authority during tenant service initialization, and its extended fields contain the organization node identifier and organization level number. These extended fields use a preset object identifier to identify the organization node identifier and organization level number fields. After successful verification, the tenant access gateway reads the organization node identifier and organization level number from the extended fields of the tenant's national cryptographic certificate. The organization node identifier is a string that uniquely identifies an organization node in the tenant's organization tree. The organization level number indicates the organization node's level in the tenant's organization tree. The tenant access gateway matches the organization level number with the node depth in the tenant's organization tree. The node depth is the path length from the root node to the current organization node in the tenant's organization tree; the root node's depth is 0. When the organizational hierarchy number matches the node depth, the tenant access gateway determines the organizational hierarchy of the visitor. The data to be operated on is read from the message body of the multi-tenant service access message. The message body is transmitted through a national cryptographic security transmission channel. The data to be operated on can be plaintext business data or referenced business data.
[0025] In implementation, the organization key service locates the data ownership node in the tenant organization tree based on the organization node identifier. The tenant organization tree is stored as an adjacency list, with each organization node recording the organization node identifier, parent node identifier, organization hierarchy number, and node type flag. The organization key service reads the root node key of the tenant organization tree from the key management server. The key management server returns the root node key through a national cryptographic security transmission channel. The organization key service obtains the parent node identifier of the data ownership node. The parent node identifier of the data ownership node is read from the parent node record of the data ownership node in the tenant organization tree. The organization key service concatenates the root node key, the parent node identifier of the data ownership node, the data ownership node identifier, and the node type flag into the first input string. During concatenation, the root node key is a hexadecimal string, the parent node identifier of the data ownership node is a string of a preset length, and the node type flag is a 2-digit decimal number. The four fields are arranged in the order of root node key, parent node identifier of the data ownership node, data ownership node identifier, and node type flag, separated by quotation marks. Separate the first input string. Perform a Chinese national cryptographic SM3 hash operation on the first input string to obtain the first hash value. The Chinese national cryptographic SM3 hash operation outputs a 256-bit hash value.
[0026] In some embodiments, the organization key service obtains the path from the root node to the data home node. The path sequentially includes the root node, intermediate organization nodes, and the data home node. The organization key service uses each pair of adjacent nodes in the path as the current node identifier and the next-level node identifier, respectively. The current node identifier of the first pair of adjacent nodes in the path is the organization node identifier of the root node, and the next-level node identifier is the next-level node identifier of the root node. The current node identifier of the last pair of adjacent nodes in the path is the parent node identifier of the data home node, and the next-level node identifier is the data home node identifier. The organization key service uses the first hash value as the intermediate value for the 0th round of derivation. Round hashing uses the following formula:
[0027]
[0028] In the formula, This represents the round number of the hash operation. Starting from 0, after each hash operation... Increase by 1, The maximum value is the depth of the data's home node minus 1. For the first Derived intermediate values before round hash operation This is the first hash value. For the first The derived intermediate value after round hashing. For the first The current node identifier used in the round hash operation. For the first The identifier of the next-level node used in the round hash operation. and This identifies two adjacent nodes in the path. This indicates the SM3 hash operation. This indicates string concatenation.
[0029] Each time the organization's key service performs the hash operation shown in the formula, the output is used as the derived intermediate value for the next round of hash operations, and a pair of adjacent node identifiers are moved down the path from the root node to the data home node. This SM3 hash operation is repeated until all adjacent node identifier pairs in the path have been processed, resulting in the isolation key for the data home node. The isolation key for the data home node is a 256-bit hash value, written to the protected memory area of the organization's key service, and used by the data isolation service.
[0030] In specific implementation, please refer to Figure 2The data isolation service obtains the data to be operated on. This data is retrieved from the message body of the multi-tenant service access message. The data isolation service then divides the data into multiple fixed-length segments. The fixed length is set to 16 bytes, consistent with the block size of the SM4 national cryptographic algorithm. The total number of data segments is denoted as [missing information]. The data isolation service assigns a segment number to each data segment. Segment numbers are numbered consecutively starting from 0. Each segment number is represented by a 4-byte unsigned integer, which is then represented as a decimal string.
[0031] In some embodiments, the data isolation service generates a subkey corresponding to each data segment. When the subkey corresponding to the first data segment is obtained, the data isolation service will... The decimal string corresponding to the data segment sequence number, the data ownership node identifier, and the isolation key are used as inputs to the national cryptographic standard SM3 hash function. The data isolation service concatenates these three input fields in the order of data segment sequence number string, data ownership node identifier, and isolation key, separating the fields with quotation marks. "Separator. The first The formula for calculating the subkey corresponding to each data segment is as follows:
[0032]
[0033] In the formula, This is the data segment number, with values ranging from 0 to... integers, This represents the total number of data segments. For the first Each data segment corresponds to a subkey, which is 256 bits long. For the first The decimal string corresponding to each data segment number. This serves as the identifier for the data's originating node. This is the isolation key for the data's home node. This indicates the SM3 hash operation. This indicates string concatenation. The data isolation service uses the 256-bit hash value output by the formula as the first... The subkey corresponding to each data segment.
[0034] In practice, the data isolation service uses the first... The subkey pair corresponding to the data segment is the first Each data segment is encrypted using the national standard SM4 encryption. SM4 encryption takes a 16-byte data segment as input, uses a subkey as the encryption key, and outputs a 16-byte ciphertext segment. When the total number of data segments... When the value is greater than 1, the data isolation service performs the same national standard SM4 encryption operation on each data segment.
[0035] Optionally, the data isolation service concatenates the ciphertext segments corresponding to each data segment in ascending order of their segment numbers to obtain the ciphertext. The total number of 4-byte data segments written at the beginning of the ciphertext is... The binary form is then written sequentially into the 0th ciphertext segment, the 1st ciphertext segment, and so on, until the 1st ciphertext segment. Each encrypted segment has a fixed length of 16 bytes.
[0036] In implementation, the policy management service generates access policy labels. The policy management service obtains the data ownership node identifier, the number of visibility levels, and the operation permission bitmap. The number of visibility levels is an integer, and the operation permission bitmap is a fixed-length bit string. The policy management service serializes the data ownership node identifier, the number of visibility levels, and the operation permission bitmap into policy text according to a predetermined field order. The predetermined field order is: data ownership node identifier, number of visibility levels, and operation permission bitmap. The three fields in the policy text are separated by quotation marks. "Separator"
[0037] In some embodiments, the policy management service performs a national cryptographic standard SM3 operation on the policy text to generate a policy digest. When performing the SM3 operation, the policy management service concatenates the isolation key of the data home node with the policy text to obtain the string to be hashed. The concatenation order of the string to be hashed is the isolation key of the data home node, the delimiter, and the policy text. The policy management service performs a national cryptographic standard SM3 hash operation on the string to be hashed to obtain the policy digest. The policy digest is a 256-bit hash value.
[0038] Optionally, the policy management service will append a policy summary to the end of the policy text. The policy summary and policy text are separated by a quotation mark (""). Separated by a period. The policy management service uses the policy text, which carries a policy summary, as the access policy label.
[0039] See Figure 4 In the graph, the horizontal axis represents the total number M of data segments after the data to be operated on is divided, ranging from 0 to 100 data segments, with the unit being the number of segments; the vertical axis represents the total SM4 encryption time, with the unit being milliseconds. The graph contains five SM4 encryption time curves representing different data attribution node identifiers (1001 to 1005), with the curves represented by different colors and line styles.
[0040] As shown in the figure, with the increase of the total number of data segments M, the total SM4 encryption time for all data-owning nodes exhibits an approximately linear increasing trend, indicating a positive correlation between encryption time and the number of data segments. Specifically, the encryption time corresponding to data-owning node identifier 1001 is the lowest, starting from about 7 milliseconds and gradually increasing to about 18 milliseconds as M increases; the encryption time for data-owning node identifier 1002 is generally higher than that for 1001, starting at about 8 milliseconds and reaching a maximum of nearly 21 milliseconds; the trend for data-owning node identifier 1003 is similar to that of 1002 but slightly higher, starting at about 10 milliseconds and reaching a maximum of about 25 milliseconds; the encryption time for data-owning node identifier 1004 starts at about 12 milliseconds and reaches a maximum of nearly 30 milliseconds, generally higher than the aforementioned nodes; the encryption time for data-owning node identifier 1005 is the highest, starting at about 15 milliseconds and reaching a maximum of over 33 milliseconds.
[0041] This phenomenon reflects the process in the above embodiment where the data isolation service processes the data to be operated into 16-byte segments, derives corresponding subkeys based on the isolation key of the data ownership node, and performs SM4 encryption on each data segment. The encryption time varies between different data ownership nodes due to the complexity of the isolation key calculation and derivation process or differences in node hierarchy. The linear increase in the curve indicates that as the number of data segments increases, the computational load of subkey generation and independent segment encryption increases proportionally.
[0042] In practice, the tenant access gateway extracts the timestamp, random number, and signature data from the access message. The timestamp is the Coordinated Universal Time (UTC) value in milliseconds corresponding to the moment the access message was generated, the random number is the hexadecimal string corresponding to the 128-bit random number generated by the accessing party, and the signature data is the SM2 signature value generated by the accessing party using its private key on the message digest.
[0043] In practice, the tenant access gateway uses the public key in the tenant's national cryptographic certificate to perform SM2 signature verification on the message digest composed of the timestamp, random number, and organization node identifier. The message digest is generated by concatenating the decimal string corresponding to the timestamp, the hexadecimal string corresponding to the random number, and the string corresponding to the organization node identifier in the order of timestamp, random number, and organization node identifier, with the fields separated by quotation marks. The concatenated string is separated and subjected to a Chinese national cryptographic standard SM3 hash operation to obtain a message digest. The tenant access gateway inputs the message digest and signature data into the Chinese national cryptographic standard SM2 verification operation and uses the public key in the tenant's national cryptographic certificate for signature verification.
[0044] In some embodiments, after successful signature verification, the tenant access gateway determines whether the difference between the timestamp and the current server time is within a preset time window. The current server time is obtained from the time synchronization service of the microservice registration and routing center. The preset time window is set to 300,000 milliseconds. The tenant access gateway calculates the absolute difference between the timestamp and the current server time and compares the absolute difference with 300,000 milliseconds. If the absolute difference is less than or equal to 300,000 milliseconds, the timestamp is determined to be within the preset time window.
[0045] Optionally, if the timestamp falls within a preset time window, the tenant access gateway generates a national cryptographic session token for the visitor. The national cryptographic session token includes the visitor's organization node identifier, session start time, session random number, and token validity period. The session start time is the current server time when the national cryptographic session token is generated, the session random number is the hexadecimal string corresponding to a newly generated 128-bit random number, and the token validity period is set to 1,800,000 milliseconds. The tenant access gateway uses the visitor's public key to perform national cryptographic SM2 encryption on the national cryptographic session token, obtaining the ciphertext of the national cryptographic session token, and returns the ciphertext of the national cryptographic session token to the visitor through a national cryptographic secure transmission channel.
[0046] In practice, after successful signature verification, the policy management service searches for the lowest common ancestor (LCA) node between the visitor organization node and the data owner node in the tenant organization tree. The policy management service obtains the first ancestor path from the visitor organization node to the root node, which is a sequence of node identifiers starting from the visitor organization node, ascending through its parent nodes, and ending at the root node. The policy management service also obtains the second ancestor path from the data owner node to the root node, which is a sequence of node identifiers starting from the data owner node, ascending through its parent nodes, and ending at the root node. Both the first and second ancestor paths are stored as lists, with the root node identifier at the end of the list. The policy management service compares the node identifiers item by item, starting from the end of the list and working backwards, retaining the last identical node identifier. The organization node corresponding to this identical node identifier is the LCA node.
[0047] In some embodiments, the policy management service calculates the path depth from the data owner node to the lowest common ancestor node. The path depth is the number of edges traversed between the data owner node and the lowest common ancestor node in the tenant organization tree. When calculating the path depth, the position number of the lowest common ancestor node is recorded in the second ancestor path. The position number of the data owner node in the second ancestor path is 0, and the position number of the lowest common ancestor node in the second ancestor path is the number of edges traversed between the data owner node and the lowest common ancestor node; this position number is the path depth. The policy management service compares the path depth with the visibility level number in the access policy label. If the path depth is less than or equal to the visibility level number in the access policy label, the policy management service further checks whether the operation permission bitmap in the access policy label contains the visitor's operation type.
[0048] Optionally, the operation permission bitmap is a fixed-length bit string with a length of 8 bits. Bit 0 corresponds to read-only operations, bit 1 to add operations, bit 2 to modify operations, bit 3 to delete operations, bit 4 to approve operations, bit 5 to export operations, bit 6 to print operations, and bit 7 is reserved. The visitor's operation type is extracted from the access message, and the operation type corresponds to the bit sequence number in the operation permission bitmap. The policy management service performs a bitwise AND operation between the bit sequence number corresponding to the operation type in the operation permission bitmap and the bitmask corresponding to the visitor's operation type. If the bitwise AND result is not zero, it is determined that the operation permission bitmap contains the visitor's operation type. If the operation permission bitmap contains the visitor's operation type, the policy management service determines to allow the access. If the operation permission bitmap does not contain the visitor's operation type, or the path depth is greater than the visible range level number in the access policy label, the policy management service refuses to allow the access.
[0049] In specific implementation, please refer to Figure 3 Once the policy management service approves the access, the data isolation service derives the visitor-side decryption key level by level based on the ancestor relationship between the visitor organization node and the data owner node in the tenant organization tree. When the visitor organization node is an ancestor node of the data owner node, the data isolation service starts from the visitor organization node's isolation key and performs national cryptographic derivation level by level down the tenant organization tree. The visitor organization node's isolation key is generated by the organization key service based on the root node key of the tenant organization tree and the visitor organization node path. The data isolation service obtains the downward path from the visitor organization node to the data owner node, with nodes in the downward path sequentially being the visitor organization node, its subordinate nodes, and so on, until the data owner node. In the downward path, the data isolation service uses the visitor organization node's isolation key as the pre-derivation key for level 0. For the third level in the downward path... The nth adjacent node pair, the nth The nth adjacent node pair is determined by the nth The current organizational node at the derived level and the first The data isolation service will consist of the next organizational node at each derived level. The first derived level's pre-derivative key, the first The current organization node identifier at the derived level, the first The next organizational node identifier and node type flag of each derived level are concatenated in sequence to form the first... The derived input string, for the first Performing a national cryptographic SM3 hash operation on the derived input string yields the first... Each level of isolation key is derived. The above derivation operation is repeated until the isolation key for the data's home node is obtained.
[0050] In practice, the data isolation service uses the isolation key of the data home node to decrypt the ciphertext using the national standard SM4 cryptography, obtaining the plaintext data. The first 4 bytes of the ciphertext store the total number of data segments. The data isolation service reads the total number of data segments and divides the remaining part of the ciphertext into segments of 16 bytes each. The data isolation service generates a subkey for each ciphertext segment. When generating the subkey, the decimal string corresponding to the data segment sequence number, the data home node identifier, and the isolation key of the data home node are concatenated in sequence. The concatenation result is then subjected to a national standard SM3 hash operation to obtain the corresponding subkey. The data isolation service uses the corresponding subkey to decrypt each ciphertext segment using national standard SM4 cryptography, obtaining the plaintext data segment. The data isolation service then concatenates all plaintext data segments according to their sequence numbers to obtain the plaintext data.
[0051] In some embodiments, the data isolation service returns plaintext data to the visitor through the microservice gateway. After the plaintext data is returned, the audit trail service generates an audit record, which includes the visitor's organization node identifier, the data's home node identifier, the access time, and the operation type. The visitor's organization node identifier in the audit record is the organization node identifier parsed from the access message. The data's home node identifier is the organization node identifier corresponding to the data to be operated on. The access time is the current server time when the audit trail service generates the audit record, represented as a decimal string corresponding to a Coordinated Universal Time (UTC) millisecond value. The operation type is the operation type number carried in the access message.
[0052] Optionally, the audit trail service concatenates the fields in the audit log into an audit string in sequence. The field order is: visitor organization node identifier, data ownership node identifier, access time, and operation type, with fields separated by quotation marks. The audit trail service performs a SM3 hash operation on the audit string to obtain the current audit hash value. The formula for calculating the current audit hash value is as follows:
[0053]
[0054] In the formula, This is the sequence number of the audit record, starting from 1 and incrementing, indicating the position number of the current audit record in the audit log chain. For the first The current audit hash value corresponding to each audit record is 256 bits in length. A string representation of the visitor's organization node identifier. A string representation of the data's originating node. The access time is represented as a string, using a decimal string of Coordinated Universal Time (UTC) milliseconds. A string representation of the operation type. This indicates the SM3 hash operation. This indicates string concatenation.
[0055] In practice, the audit tracing service writes the current audit hash value and the hash value of the previous audit record together into a new block of the audit log chain. The hash value of the previous audit record is the current audit hash value recorded in the last block of the audit log chain. Each block in the audit log chain contains a block header, audit record content, and audit hash value. The block header of the new block contains the hash value of the previous audit record, the audit record content contains the original values of each field of the audit record, and the audit hash value field of the new block contains the current audit hash value. The audit tracing service broadcasts the new block to the audit service nodes through a national cryptographic secure transmission channel. Multiple audit service nodes communicate with each other through this national cryptographic secure transmission channel. After receiving a new block, the audit service node reads the hash value of the previous audit record in the block header of the new block, compares the hash value of the previous audit record with the audit hash value of the block at the end of the audit log chain stored locally by the audit service node, and if they match, appends the new block to the end of the audit log chain stored locally by the audit service node to form a consistent audit log chain across multiple nodes.
[0056] In practical implementation, the national cryptographic-grade microservice architecture for multi-tenant services includes a tenant access gateway, an organization key service, a policy management service, a data isolation service, an audit tracing service, and a microservice registration and routing center. A national cryptographic-grade secure transmission channel is established between the tenant access gateway and the microservice registration and routing center. Similarly, a national cryptographic-grade secure transmission channel is established between the organization key service, the policy management service, the data isolation service, and the audit tracing service.
[0057] In practice, the tenant access gateway receives multi-tenant service access messages. The gateway parses the tenant's national cryptographic certificate, organization node identifier, and data to be operated from these messages. It then encapsulates this information into a microservice internal access request. This request is then sent to the microservice registration and routing center via a secure national cryptographic transmission channel.
[0058] In implementation, the organization key service maintains the tenant organization tree. The tenant organization tree is stored in the organization key service's in-memory data structure, with each organization node containing an organization node identifier, parent node identifier, organization hierarchy number, and node type flag. The organization key service generates isolation keys for each organization node. The organization key service receives key derivation requests forwarded by the microservice registration and routing center, which include the organization node identifier. Based on the organization node identifier, the organization key service locates the organization node corresponding to the request in the tenant organization tree and reads the root node key of the tenant organization tree from the key management server. Using the root node key of the tenant organization tree, the organization key service generates the isolation key for the requested organization node through a national cryptographic derivation function. The organization key service returns the generated isolation key to the caller via a national cryptographic secure transmission channel.
[0059] In some embodiments, the policy management service generates access policy tags. The policy management service receives a policy generation request forwarded by the microservice registration and routing center. This request includes the data home node identifier, the visibility level number, and an operation permission bitmap. The policy management service serializes the data home node identifier, visibility level number, and operation permission bitmap into policy text according to a predetermined field order. The policy management service performs SM3 operations on the policy text using the data home node's isolation key to generate a policy digest. The policy management service writes the policy digest to the end of the policy text, forming an access policy tag. The policy management service stores the access policy tag and returns it to the caller via a secure SM3 transmission channel. When verifying an access policy tag, the policy management service receives the tag to be verified, recalculates the policy digest of the policy text in the tag, and compares the recalculated digest with the digest written to the end of the tag. If the two calculated digests match, the access policy tag verification passes. The policy management service returns the verification result to the caller via a secure SM3 transmission channel.
[0060] Optionally, the data isolation service performs Chinese cryptographic encryption and decryption on business data. The data isolation service receives data encryption requests forwarded by the microservice registration and routing center. These requests contain the data to be operated on and the isolation key of the data's home node. The data isolation service divides the data to be operated on into multiple fixed-length data segments and performs SM4 encryption on each data segment using a subkey derived from the data's home node's isolation key. The data isolation service then assembles the encrypted data segments into encrypted data. The data isolation service also receives data decryption requests forwarded by the microservice registration and routing center. These requests contain the encrypted data and the visitor-side decryption key. The data isolation service uses the visitor-side decryption key to perform SM4 decryption on the encrypted data, obtaining the plaintext data. The data isolation service derives the decryption key level by level based on the ancestor relationship between nodes in the tenant organization tree. When the visitor organization node is an ancestor node of the data's home node, the data isolation service starts from the visitor organization node's isolation key and performs Chinese cryptographic derivation level by level down the tenant organization tree to calculate the data's home node's isolation key. The data isolation service uses the data's home node's isolation key as the decryption key.
[0061] In some embodiments, the audit tracing service records access operations. The audit tracing service receives audit logging requests forwarded by the microservice registration and routing center. These requests include the visitor's organization node identifier, the data owner node identifier, the access time, and the operation type. The audit tracing service concatenates the visitor's organization node identifier, the data owner node identifier, the access time, and the operation type in sequence to form an audit string. The audit tracing service performs a national cryptographic digest algorithm on the audit string using SM3 hashing to generate the current audit hash value. The audit tracing service writes the current audit hash value and the hash value of the previous audit record together into a new block in the audit log chain. The audit tracing service broadcasts the new block to the audit service nodes. The audit service nodes store the complete audit log chain, and the audit log chain remains consistent across different audit service nodes. The audit tracing service generates tamper-proof audit logs.
[0062] In implementation, the microservice registration and routing center routes business access messages to the corresponding business microservices based on the organization node identifier. The microservice registration and routing center maintains a microservice registry, which records the mapping relationship between business microservice identifiers, organization node identifiers, and business service addresses. After receiving a business access message, the microservice registration and routing center extracts the organization node identifier from it. The center then queries the microservice registry based on the organization node identifier to obtain the business service address of the corresponding business microservice. Finally, the microservice forwards the business access message to the corresponding business microservice. The business microservice processes the business access message and returns the processing result through the microservice registration and routing center.
[0063] In practice, the tenant access gateway, organization key service, policy management service, data isolation service, audit trail service, and microservice registration and routing center communicate via a national cryptographic security transmission channel. When establishing the national cryptographic security transmission channel, the communicating parties negotiate a session key. In the request to establish a secure transmission channel using the national cryptographic standard, the initiator generates an initiator random number, the receiver generates a receiver random number, and the receiver provides the serial number of its national cryptographic standard certificate. The session key calculation formula is as follows:
[0064]
[0065] In the formula, The sequence number for establishing a national cryptographic security transmission channel. Starting from 1 and increasing, the... The request to establish a national cryptographic security transmission channel corresponds to the first A session key. For the first The session key generated for the establishment request of the national cryptographic secure transmission channel is 256 bits in length. For the first The random number generated by the initiator in the request to establish a secure transmission channel using the national cryptographic standard is a hexadecimal string corresponding to a 128-bit random number. For the first The random number generated by the receiver in the request to establish a secure transmission channel using the national cryptographic standard is a hexadecimal string corresponding to a 128-bit random number. For the first The serial number of the recipient's national cryptographic certificate in the request to establish a national cryptographic secure transmission channel is a decimal string assigned by the certificate issuing authority. This indicates the SM3 hash operation. This indicates string concatenation. The session key is used for subsequent message transmission between the two parties in SM4 symmetric encryption communication.
[0066] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A national-level cryptographic data isolation method for multi-tenant services, characterized in that: include: Receive multi-tenant service access messages, and parse the tenant's national cryptographic certificate, organization node identifier, and data to be operated from the access messages; Based on the organization node identifier, locate the data ownership node in the tenant organization tree, obtain the root node key of the tenant organization tree, and use the root node key to generate the isolation key of the data ownership node through the national cryptographic derivation function; The isolation key is used to encrypt the data to be operated using national cryptographic encryption to obtain the data ciphertext and access policy label. The access policy label includes the data ownership node identifier, the number of visible range levels, and the operation permission bitmap. The access message is verified using the tenant's national cryptographic certificate. After the verification is successful, the access is determined to allow the access based on the ancestor relationship between the visitor's organization node identifier and the data owner node identifier in the tenant organization tree, as well as the access policy label. When permission is granted, the data isolation service derives the decryption key for the visitor side based on the ancestor relationship, decrypts the encrypted data, and returns the plaintext data to the visitor.
2. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, The tenant's national cryptographic certificate, organization node identifier, and data to be operated on are parsed from the access message, including: Extract the signature value from the access message and verify the signature value using the national cryptographic SM2 algorithm; After the signature verification is successful, the organization node identifier and organization level number are read from the extended fields of the tenant's national cryptographic certificate; The organizational level number is matched with the node depth in the tenant organization tree to determine the organizational level of the visitor.
3. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, Obtain the root node key of the tenant organization tree, and use the root node key to generate the isolation key of the data ownership node through a national cryptographic derivation function, including: Read the root node key of the tenant organization tree from the key management server, and obtain the parent node identifier of the data ownership node; Concatenate the root node key, the parent node identifier, the data ownership node identifier, and the node type flag into a first input string; Perform a Chinese national cryptographic SM3 hash operation on the first input string to obtain the first hash value; The first hash value is concatenated with the current node identifier and the next-level node identifier, and the national cryptographic SM3 hash operation is repeated until the isolation key of the data-owning node is calculated.
4. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, The isolation key is used to encrypt the data to be operated on using national cryptographic standards to obtain the data ciphertext and access policy label, including: The data to be operated on is divided into multiple data segments of fixed length, and a data segment number is assigned to each data segment. Each data segment is encrypted using a subkey derived from the isolation key using the national cryptographic standard SM4. When generating the subkey, the data segment sequence number, the data ownership node identifier, and the isolation key are used together as inputs to the national cryptographic SM3 hash function, and the output value of the hash function is used as the subkey. The ciphertext of each data segment is assembled into a data ciphertext in sequence, and the data ownership node identifier, the number of visible range levels, and the operation permission bitmap are encapsulated into an access policy label.
5. The national-level cryptographic data isolation method for multi-tenant services according to claim 4, characterized in that, The data ownership node identifier, the number of visibility level levels, and the operation permission bitmap are encapsulated into an access policy tag, including: The data ownership node identifier, the number of visible range levels, and the operation permission bitmap are serialized into policy text according to a predetermined field order; The isolation key of the data ownership node is used to perform SM3 operations on the policy text to generate a policy digest; Write the policy summary at the end of the policy text, and use the policy text carrying the policy summary as the access policy tag.
6. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, Performing national cryptographic signature verification on the access message using the tenant's national cryptographic certificate includes: Extract the timestamp, random number, and signature data from the access message; The public key in the tenant's national cryptographic certificate is used to perform national cryptographic SM2 signature verification on the message digest composed of the timestamp, the random number, and the organization node identifier; After successful signature verification, determine whether the difference between the timestamp and the current server time is within a preset time window; If the visitor is within the preset time window, a national cryptographic session token will be generated for the visitor, and the national cryptographic session token will be encrypted and returned to the visitor.
7. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, The step of determining whether to allow the current access based on the ancestor relationship between the visitor's organization node identifier and the data owner's node identifier in the tenant organization tree, as well as the access policy label, includes: Find the lowest common ancestor node between the visitor organization node and the data ownership node in the tenant organization tree; Calculate the path depth from the data home node to the lowest common ancestor node, and compare the path depth with the number of visible range levels in the access policy label; If the path depth is less than or equal to the visible range level, then further check whether the operation permission bitmap in the access policy label contains the visitor's operation type; If the operation type is included, the access is allowed; otherwise, it is denied.
8. The national-level cryptographic data isolation method for multi-tenant services according to claim 1, characterized in that, The process of deriving the visitor-side decryption key by the data isolation service according to the ancestor relationship, decrypting the ciphertext data, and returning the plaintext data to the visitor includes: When the visitor organization node is the ancestor node of the data owner node, starting from the isolation key of the visitor organization node, the national cryptographic derivation is performed level by level down along the tenant organization tree to calculate the isolation key of the data owner node. The encrypted data is decrypted using the isolation key of the data ownership node using the national standard SM4 code to obtain the plaintext data. The plaintext data is returned to the visitor through the microservice gateway, and an audit record containing the visitor's organization node identifier, the data ownership node identifier, the access time, and the operation type is generated after the return.
9. The national cryptographic-level data isolation method for multi-tenant services according to claim 8, characterized in that, The process of generating an audit record upon return, including the visitor's organization node identifier, the data ownership node identifier, the access time, and the operation type, includes: The fields in the audit record are concatenated in order to form an audit string, and the national cryptographic SM3 hash operation is performed on the audit string to obtain the current audit hash value; Write the current audit hash value and the hash value of the previous audit record together into a new block in the audit log chain; The newly added block is broadcast to the audit service node to form a consistent audit log chain across multiple nodes.
10. A national-level cryptographic microservice architecture for multi-tenant services, used to implement the national-level cryptographic data isolation method for multi-tenant services as described in any one of claims 1 to 9, characterized in that, include: The tenant access gateway is used to receive multi-tenant service access messages and parse the tenant's national cryptographic certificate, organization node identifier, and data to be operated. Organization key service is used to maintain the tenant organization tree and generate isolation keys for each organization node; Policy management service, used to generate, store, and validate access policy labels; Data isolation service is used to encrypt and decrypt business data using national cryptographic standards, and derives decryption keys level by level based on the ancestor relationship between nodes in the tenant organization tree; The audit trail service records access operations and generates tamper-proof audit logs using the national cryptographic digest algorithm. The microservice registration and routing center is used to route the business access message to the corresponding business microservice based on the organization node identifier; The tenant access gateway, organization key service, policy management service, data isolation service, audit trail service, and microservice registration and routing center communicate through a national cryptographic security transmission channel.
