Data encryption method and system based on multi-terminal interaction
By constructing a hierarchical hash algorithm key derivation tree based on the master key seed, the problems of offline devices being unable to obtain keys and high key storage complexity in multi-device key management are solved. This enables key generation in offline device states and simplifies the addition of new devices, thereby reducing the complexity of key management.
Patent Information
- Application Number
- CN202511136859.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-14
- Publication Date
- 2025-11-18
AI Technical Summary
Existing multi-device key management solutions rely on centralized servers or direct synchronization between devices, resulting in offline devices being unable to obtain keys, high complexity in key storage and management, cumbersome process for adding new devices, and an exponential increase in key management overhead as the number of devices increases.
A deterministic key derivation tree based on the master key seed as the root node is adopted. The key derivation tree is constructed through a hierarchical hash algorithm. The key derivation is performed using three-level paths: device category, device identifier, and session identifier. This allows each device to independently calculate the key required for communication with other devices. The key is generated by the master password input by the user and the device attributes.
It enables offline devices to generate keys, simplifies the process of adding new devices, reduces the complexity of key storage and management, ensures forward security and independent key computation, and reduces reliance on network connectivity.
Smart Images

Figure CN120979633A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data encryption, and in particular to a data encryption method and system based on multi-end interaction. BACKGROUND
[0002] With the rapid development of the Internet of Things and mobile Internet technology, it has become a common practice for users to own and use multiple smart devices. According to statistical data, the average user owns 3-5 networked devices, including smartphones, tablets, laptops, smartwatches, etc. Frequent data synchronization and secure communication are required between these devices, such as password managers that need to synchronize password data across all devices, note applications that need to synchronize documents across devices, and health data that needs to be synchronized from a smartwatch to a phone. To protect user privacy data security, end-to-end encryption has become a basic requirement for data transmission between multiple devices.
[0003] In an end-to-end encryption system, key management is the most critical and complex technical link. Traditional multi-end device key management schemes mainly adopt two technical paths:
[0004] The first is a centralized key distribution scheme. This scheme deploys a key distribution center (KDC) to generate and distribute device keys uniformly by the server. When device A needs to communicate with device B, both devices request a session key from the KDC, and the KDC generates a session key and encrypts it with the long-term key of device A and device B. The main technical defects of this scheme are: (1) KDC becomes a single point of failure and attack target, once KDC is compromised, the security of all device communications will be threatened; (2) devices must be online to obtain keys from KDC, offline devices cannot participate in secure communication; (3) KDC needs to maintain all device key information, and the complexity of key storage and management increases linearly with the number of devices.
[0005] The second is a direct synchronization scheme between devices. This scheme establishes a secure channel between devices to exchange keys directly, such as using the Diffie-Hellman key exchange protocol. In specific implementation, a new device needs to perform key exchange with each existing device to generate shared keys between each pair of devices. This scheme has the following technical problems: (1) key exchange requires devices to be online at the same time, offline devices cannot complete key negotiation; (2) n devices need to maintain n(n-1) / 2 shared keys, and the key storage overhead increases quadratically with the number of devices; (3) when a new device joins, it needs to perform key exchange with all existing devices one by one, the configuration process is complex and time-consuming; (4) when a device is lost or stolen, all other devices need to be notified to update the relevant keys, and the key revocation mechanism is complex.
[0006] The fundamental problem of the existing scheme is that the key is regarded as static data that needs to be stored and transmitted, rather than a dynamic result that can be derived by a deterministic algorithm. This leads to the key management having to rely on real-time network connection and complex synchronization mechanism. In particular, in the following typical scenarios, the existing scheme shows obvious technical limitations:
[0007] (1) Offline scenario: When a user uses a notebook computer on an airplane, he or she cannot obtain the key required for decrypting the synchronization data of other devices due to the inability to connect to a server or other devices;
[0008] (2) New device initialization: After a user purchases a new mobile phone, he or she needs to wait for the completion of key exchange with all existing devices to access the synchronization data, which is cumbersome and prone to errors;
[0009] (3) Temporary device use: When a user temporarily logs in at a public place such as an Internet cafe, the existing scheme either cannot provide security protection or needs a complex temporary key distribution mechanism;
[0010] (4) Device quantity expansion: With the popularity of smart home devices, the number of devices of a user can reach dozens, and the key storage and management overhead of the existing scheme will become unacceptable.
[0011] Therefore, there is an urgent need for a new key management scheme that can generate keys for devices in an offline state, simplify the joining process of new devices, and reduce the complexity of key storage and management while ensuring security. SUMMARY
[0012] In view of the fact that the key management of multiple terminal devices in the prior art needs to rely on a centralized server for key distribution or direct synchronization between devices, resulting in offline devices being unable to obtain the required key, the present application provides a data encryption method and system based on multi-terminal interaction, which constructs a deterministic key derivation tree with a master key seed as the root node, and uses a hierarchical hash algorithm to derive keys along a three-layer path of device category, device identifier, and session identifier, so that each device can independently calculate the key required for communication with any other device only by using the master password and the derivation path information.
[0013] One aspect of the present application provides a multi-end interaction-based data encryption method, comprising: S1, when a user registers for the first time, obtaining the master password data input by the user, and generating master key seed data through a key derivation function according to the master password data; S2, based on the master key seed data, constructing a key derivation tree data structure using a hierarchical hash algorithm, the key derivation tree data structure taking the master key seed data as a root node, and expanding layer by layer to form a tree-shaped derivation path according to device categories and device identifiers; S3, when a new device requests authorization, calculating a derivation path according to the key derivation tree data structure in combination with attribute data of the corresponding new device, and generating exclusive key data corresponding to the new device from the master key seed data along the derivation path; S4, according to the exclusive key data of the sending device in S3, combining the path data of the receiving device in the key derivation tree, and performing encryption processing on the data to be transmitted between devices to generate an encrypted data stream.
[0014] The hierarchical hash algorithm is a multi-level key derivation mechanism in the present scheme, which generates keys at different levels from a single master key seed through the application of hash functions (such as HKDF-SHA256) at different levels. Specifically, it contains three levels - device category level, device level, and session level; the upper layer key can derive the lower layer key, but cannot be reversely derived; the same input always produces the same output, ensuring key reproducibility. The first layer: using the HKDF algorithm, taking the master key seed and device category information as input to generate a device category key; the second layer: taking the device category key and the specific device identifier as input to generate a device exclusive key; the third layer: taking the device key and the session counter as input to generate a session key.
[0015] The key derivation tree is a tree-shaped data structure used to organize and manage the multi-device key relationship in the present scheme, taking the master key seed as the root node, and forming a key hierarchy system through hierarchical hash algorithm step by step, the structure composition is:
[0016] Root node (0th layer): master key seed
[0017] ├── First layer node: device category key (mobile phone class, computer class, tablet class, etc.)
[0018] │├── Second layer node: specific device key (iPhone15, MacBookPro, etc.)
[0019] ││└── Third layer node: session key (session1, session2, session3, etc.)
[0020] Deduced path is the complete node sequence and deduced parameter set from the root node (master key seed) of the key derivation tree to a specific leaf node (target key), for example: master key seed → mobile phone category → iPhone15 → session #1234; including identifiers, hash inputs, and context data at each level.
[0021] Path data is a set of metadata that describes the specific location and deduced parameters of a device in the key derivation tree, containing all non-sensitive information required to reconstruct the device key. For example:
[0022] Path data = { device category: "mobile phone",
[0023] device name: "my iPhone15",
[0024] session counter: 1234};
[0025] session counter: 1234};
[0026] session counter: 1234};
[0027] session counter: 1234};
[0028] session counter: 1234};
[0029] New device uses path data to calculate its own deduced path; sender: uses its own path data to locate the exclusive key; receiver: verifies the sender's identity by exchanging path data; path data is part of the encryption context.
[0030] Further, it also includes: S5, by adding timestamp data as an additional deduced parameter in the key derivation tree data structure in step S2, so that the exclusive key data generated in S3 and S4 is periodically updated over time. Wherein, the additional deduced parameter is a variable parameter introduced in addition to the necessary key material and identification information in the basic key derivation process, used to enhance the dynamicity and security of the key, in this application specifically refers to the timestamp data.
[0031] Further, S1 generates the master key seed data by a key derivation function, including: receiving the user input master password data, normalizing the master password data to generate standard format password data; obtaining the user's unique identity data; performing a hash operation on the unique identity data to generate the corresponding user's deterministic salt value data; wherein the deterministic salt value data refers to the fixed salt value with reproducibility generated by the hash operation on the user's unique identity. Unlike the traditional random salt value, the deterministic salt value remains the same for the same user, ensuring that the same master key seed can be generated on different devices at different times. The standard format password data and the deterministic salt value data are combined to form combined data.
[0032] The combined data is input into a key derivation function based on PBKDF2 (Password-Based Key Derivation Function 2) or Argon2, the number of iterations and the output length are set, and the key derivation operation is performed to obtain the master key seed data.
[0033] In particular, in the traditional key derivation scheme, in order to prevent rainbow table attacks, a randomly generated salt value is usually used. However, the random salt value must be stored and synchronized between devices, which results in the fact that a new device or an offline device needs to obtain the salt value to generate the key, but obtaining the salt value itself requires establishing a secure communication channel. This makes it impossible for an offline device to independently complete key generation.
[0034] The present application generates a deterministic salt value by performing a hash operation on the user's unique identity (such as user email, mobile phone number, etc.). Any device can obtain the same salt value by performing the same hash operation on the user input identity and master password, and then generate the same master key seed through the key derivation function. The entire process does not rely on any external data source, and truly realizes the generation by calculation.
[0035] Even if the device is completely offline, as long as the user can input the correct identity and master password, the device can independently reconstruct the entire key derivation tree. This fundamentally solves the problem that offline devices cannot participate in secure communication in existing schemes. When the user replaces a new device or the device is lost, there is no need to restore any key data from backup, nor is there a need to synchronize keys with other devices. The new device can completely independently reconstruct the key system required for communication with all other devices.
[0036] Further, S2, based on the master key seed data, adopts a hierarchical hash algorithm to construct a key derivation tree data structure, including: taking the master key seed data as the initial input data of the root node; receiving the device category name input by the user, performing a hash operation on each device category name to generate corresponding category index data; generating the device category key data of the first layer through a hash operation according to the master key seed data and the category index data; when a device requests to join, receiving the custom device name set by the user for the corresponding device, and performing standardization processing on the custom device name; generating the device key data of the second layer through a hash operation according to the standardized device name and the device category key data; when a session key needs to be generated, taking the device key data and the session counter value as input, generating the session key data through a hash operation, so as to form a three-layer derivation path from the master key seed data to the session key data.
[0037] In particular, the traditional device key generation scheme usually relies on hardware identifiers (such as MAC address, device serial number, hardware fingerprint, etc.) as input parameters for key derivation. However, when the device replaces the network card, repairs the motherboard, re-installs the system, or restores the factory settings, the hardware identifier may change, resulting in the inability to regenerate the same device key. The user will permanently lose the ability to access the historical encrypted data of the device.
[0038] The present application adopts a deterministic key derivation mechanism based on user semantic input, which completely gives the control of device category and device name to the user, fundamentally solving the problem of key irrecoverability caused by hardware dependency in traditional schemes.
[0039] The user can set meaningful and easy-to-remember names for the device (such as "My iPhone", "Office Computer", "Living Room iPad", etc.). These names are completely controlled by the user and are not affected by hardware changes. Even if the device is completely replaced, as long as the user inputs the same device name, the same device key can be derived.
[0040] Instead of being limited to a predefined set of device categories, it receives any device category name input by the user. This not only supports existing common categories such as "phone" and "computer", but also adapts to new device types that may appear in the future (such as "smart glasses" and "brain-computer interface") or user-specific needs for custom categories (such as "development device" and "test device").
[0041] Further, a hash operation is performed on each device category name to generate corresponding category index data, including: receiving a device category name string input by a user; performing Unicode NFC normalization processing on the device category name string, converting the processed string to lowercase form to obtain a standardized device category name; wherein the device category includes mobile phone, computer, watch, and tablet; converting the standardized device category name into a byte sequence in UTF-8 encoding; performing SHA-256 hash operation on the byte sequence to generate a 256-bit hash value as the category index data, and through the determinacy of the hash function, it is ensured that the same device category name input always generates the same category index data.
[0042] Wherein, Unicode NFC (Normalization Form Canonical Composition) normalization is a string normalization form defined by Unicode standard, which converts character sequences into standard composition form to ensure that visually identical strings have the same binary representation. UTF-8 (8-bit Unicode Transformation Format) is a variable-length character encoding method for converting Unicode characters into byte sequences. SHA-256 (Secure Hash Algorithm 256-bit) is a member of the SHA-2 family, which is a cryptographically secure one-way hash function that converts inputs of arbitrary length into fixed 256-bit (32-byte) outputs.
[0043] In particular, through Unicode NFC normalization and case conversion, it is ensured that the same semantic text input by the user in different input methods and different language environments can generate the same key. For example, “Office Computer”, “officecomputer”, and “OFFICE COMPUTER” will all generate the same device key.
[0044] Different device categories and device names generate completely independent key branches through hash operation, so even if an attacker obtains the key of a certain device, he cannot derive the keys of other devices. At the same time, users can achieve semantic-level security isolation through reasonable naming strategies (such as using different naming rules for devices of different security levels).
[0045] In addition, through standardization processing (Unicode normalization and lowercase conversion), consistency of different expressions is ensured, and the problem of scalability limitation is solved.
[0046] Further, the first layer of device category key data is generated by a hash operation, including: taking the master key seed data as the input key material of the HKDF algorithm; constructing a fixed domain separation tag string as the salt value of the HKDF; defining the hierarchical identifier 0x01 to represent the device category layer, and defining the separator 0x00 for splitting different data segments to prevent boundary ambiguity when data splicing; concatenating the hierarchical identifier, separator, domain separation tag string, and category index data in sequence as the first layer context information; performing the HKDF-Extract operation to perform entropy processing on the master key seed data using the salt value to generate a pseudo-random key; and performing the HKDF-Expand operation to generate the device category key data corresponding to the corresponding device category by hash iteration using the pseudo-random key and the context information.
[0047] The HKDF algorithm (HMAC-based Key Derivation Function) is a key derivation function based on HMAC, which complies with the RFC5869 standard and is used to derive a cryptographically secure key from high-entropy key material. It adopts the Extract-then-Expand paradigm and completes the key derivation in two steps;
[0048] In the present application, the input structure is:
[0049] ├──IKM (input key material): master key seed (32 bytes)
[0050] ├──Salt (salt value): hash value of domain separation tag (16 bytes)
[0051] └──Info (context information): hierarchical identifier + category index, etc. (variable length)
[0052] Output:
[0053] └──OKM (output key material): device category key (32 bytes);
[0054] The hierarchical identifier 0x01 is a single-byte fixed value used to uniquely identify the level at which the current derivation operation is located in the key derivation tree. 0x01 specifically represents the device category layer. In the present application, 0x01 represents the device category layer (first layer); 0x02 represents the device key layer (second layer); and 0x03 represents the session key layer (third layer). This ensures that the key derivation of different levels is independent of each other, and an attacker cannot impersonate another layer with data from one layer. For example, the category layer derivation is 0x01||0x00||“mobile phone”→ category key A; the device layer derivation is 0x02||0x00||“mobile phone”→ device key B; and the result is A≠B (even if other parameters are the same).
[0055] Separator 0x00 is a null byte (NULL byte) used to explicitly mark the boundary of different data segments when concatenating data, preventing concatenation ambiguity attacks. For example, without separator: Data1: "AB" + Data2: "CD" = "ABCD"; Data1: "ABC" + Data2: "D" = "ABCD"; Result: Different inputs produce the same concatenated result. In this application, set the separator: Data1: "AB" + 0x00 + Data2: "CD" = "AB\0CD"; Data1: "ABC" + 0x00 + Data2: "D" = "ABC\0D"; Result: Different inputs remain different.
[0056] Context information is an input parameter (Info) of the HKDF-Expand stage, containing all relevant information specific to this key derivation, to ensure that the derived key is bound to a specific use.
[0057] HKDF-Extract is the first stage of the HKDF algorithm, responsible for extracting a uniformly distributed pseudo-random key (PRK) from the input key material (IKM), even if the randomness of the input key material is imperfect. Specifically, PRK = HMAC-Hash (Salt, IKM); Where: Hash: underlying hash function (this solution uses SHA-256); Salt: salt value (hash value of domain separation label); IKM: input key material (master key seed).
[0058] HKDF-Expand is the second stage of the HKDF algorithm, which uses the PRK generated by the Extract stage and specific context information to generate the required length of output key material through iterative HMAC operations. Specifically, OKM = T(1) || T(2) ||... || T(N); Where: T(0) = empty string; T(i) = HMAC-Hash (PRK, T(i-1) || Info || i); For 32-byte output (this solution): T(1) = HMAC-SHA256 (PRK, Info || 0x01); OKM = first 32 bytes of T(1);
[0059] In particular, in a hierarchical key derivation system, how to ensure that keys of different levels and different uses are completely independent in cryptography. If multiple parameters are simply concatenated, ambiguity may occur. For example, category "ABC" plus device "def" and category "AB" plus device "cdef" will produce the same concatenated result "abcdef", resulting in the same key generated by different devices. If different levels use similar derivation parameters, it may cause the key of a certain layer to accidentally equal the key of another layer, disrupting the secure isolation of the key hierarchy.
[0060] The application introduces a hierarchical identifier and a structured context information construction mechanism. By defining data boundary division and hierarchical markers, the complete isolation of different hierarchical keys is ensured from the perspective of cryptography, and the risk of key confusion and cross-layer attacks in the hierarchical key derivation system is completely solved.
[0061] A unique identifier is used for each layer (0x01 for device category layer, 0x02 for device layer, and 0x03 for session layer), which is the first byte of the context information and distinguishes the key derivation processes of different layers from the source. Even if other parameters are exactly the same, different layers will generate completely different keys because of the different identifiers.
[0062] In addition, in UTF-8 encoding, 0x00 is a null character and will not appear in normal text encoding. Using it as a separator completely eliminates the ambiguity of parameter concatenation. For example, the structure of “0x01\x00abc\x00def” clearly identifies three independent data segments and cannot conflict with other combinations.
[0063] By defining a clear structure (hierarchical identifier | separator | domain separation tag | separator | business data), the derivation of each key is unique and unforgeable: keys of different levels will generate different results even if the same business data is used; different uses of the same level are distinguished by domain separation tags; attackers cannot misuse one key as another by manipulating input parameters.
[0064] Further, a fixed domain separation tag string is constructed as the salt value of HKDF, including: defining the identification string “MultiDeviceEncryption-CategoryLayer-v1”; wherein MultiDeviceEncryption is used to identify the application domain of the key derivation system, CategoryLayer is used to identify the key derivation of the device category layer, and v1 is used to identify the version number.
[0065] The identification string is converted into a UTF-8 encoded byte sequence; a SHA-256 hash operation is performed on the UTF-8 encoded byte sequence to generate a 256-bit hash value; the first 128 bits of data are extracted from the 256-bit hash value as the salt value of the HKDF algorithm.
[0066] The domain separation tag string is a fixed string identifier used in cryptography to distinguish different key derivation contexts. In this application, it is a constant string used to ensure that key derivation processes for different uses are independent of each other and prevent key misuse or confusion between different security domains.
[0067] Further, the second layer of device key data is generated by a hash operation, including: standardizing the user-defined device name and performing a hash operation to obtain a device identification hash value; taking the device category key data as input key material of the HKDF algorithm; defining a hierarchical identifier 0x02 to represent the device layer, constructing second layer context information including the hierarchical identifier 0x02, a separator 0x00, and the device identification hash value; performing an HKDF-Extract operation to perform entropy processing on the device category key data using the generated salt value to generate a second layer pseudo-random key; performing an HKDF-Expand operation to generate 256-bit device key data by hash iteration using the second layer pseudo-random key and the second layer context information, as the exclusive key of the corresponding device.
[0068] Further, the session key data is generated by a hash operation to form a three-layer derivation path from the master key seed data to the session key data, including: obtaining a session counter value of the current session; taking the device key data as input key material of the HKDF algorithm; defining a hierarchical identifier 0x03 to represent the session layer; concatenating the hierarchical identifier 0x03, the separator 0x00, and the session counter value in sequence to form third layer context information; performing an HKDF-Extract operation to perform entropy processing on the device key data using the generated salt value to generate a third layer pseudo-random key;
[0069] performing an HKDF-Expand operation to generate 256-bit session key data by hash iteration using the third layer pseudo-random key and the third layer context information; wherein the session counter value is incremented at each session establishment to ensure that a unique session key is used for each session, forming a complete three-layer derivation path from the master key seed data through the device category key and the device key to the session key.
[0070] Another aspect of the present application also provides a multi-end interaction-based data encryption system, comprising: a master key generation module, which acquires master password data input by a user when the user registers for the first time, and generates master key seed data by a key derivation function according to the master password data; a key derivation tree module, which constructs a key derivation tree data structure by a hierarchical hash algorithm based on the master key seed data, the key derivation tree data structure taking the master key seed data as a root node and expanding layer by layer to form a tree-shaped derivation path according to device categories and device identifiers; a device key module, which calculates a derivation path according to the key derivation tree data structure in combination with attribute data of a corresponding new device when the new device requests authorization, and generates exclusive key data of the corresponding new device from the master key seed data along the derivation path; a data encryption module, which encrypts data to be transmitted between devices according to exclusive key data of a sending device in combination with path data of a receiving device in the key derivation tree, and generates an encrypted data stream; and a key update module, which periodically updates the exclusive key data with time by adding timestamp data as an additional derivation parameter in the key derivation tree data structure.
[0071] Compared with the prior art, the present application has the following advantages:
[0072] In view of the problems in the prior art that multi-end device key management needs to rely on a centralized server for key distribution or direct synchronization between devices, resulting in that offline devices cannot obtain required keys and key management complexity increases exponentially with the increase of the number of devices, the present application provides a multi-end interaction-based data encryption method, which constructs a deterministic key derivation tree taking a master key seed as a root node, and performs key derivation along a three-layer path of device categories, device identifiers and session identifiers by a hierarchical hash algorithm, so that each device can independently calculate a required key for communication with any other device only by using a master password and derivation path information.
[0073] The present application can realize the following advantages: no actual key needs to be stored and transmitted, an offline device can also generate a correct communication key, a new device does not need to update key configurations of existing devices when it is added, forward security is realized by a session counter mechanism, etc. Each device can independently calculate a required key by hierarchical deterministic key derivation, without relying on the online state of other devices. This calculation and generation mode converts a distributed storage problem into a deterministic calculation problem, and fundamentally simplifies the complexity of multi-end key management. BRIEF DESCRIPTION OF DRAWINGS
[0074] The present application will be further described in the form of exemplary embodiments, which will be described in detail with reference to the accompanying drawings. These embodiments are not limiting, and in these embodiments, the same reference numbers represent the same structures, wherein:
[0075] Figure 1is an exemplary flowchart of a multi-end interaction based data encryption method according to some embodiments of the present application;
[0076] Figure 2 is an exemplary flowchart of generating master key seed data according to some embodiments of the present application;
[0077] Figure 3 is a three-layer derivation path schematic diagram according to some embodiments of the present application;
[0078] Figure 4 is a first-layer context information schematic diagram according to some embodiments of the present application;
[0079] Figure 5 is an exemplary flowchart of generating session key data according to some embodiments of the present application. DETAILED DESCRIPTION
[0080] The method and system provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0081] Embodiment 1
[0082] As shown in Figure 1 S1, when a user first registers, the master password data input by the user is obtained, and the master key seed data is generated by a key derivation function according to the master password data; S2, based on the master key seed data, a hierarchical hash algorithm is used to construct a key derivation tree data structure, and the key derivation tree data structure takes the master key seed data as a root node and expands layer by layer according to the device category and device identifier to form a tree-shaped derivation path; S3, when a new device requests authorization, the derivation path is calculated according to the key derivation tree data structure combined with the attribute data of the corresponding new device, and the exclusive key data of the corresponding new device is derived and generated from the master key seed data along the derivation path; S4, according to the exclusive key data of the sending device in S3, the path data of the receiving device in the key derivation tree is combined to encrypt the data to be transmitted between devices, and an encrypted data stream is generated; S5, by adding timestamp data as an additional derivation parameter in the key derivation tree data structure in step S2, the exclusive key data generated in S3 and S4 is periodically updated with time.
[0083] As shown in Figure 2 S1, the original password string input by the user through the keyboard may contain various character encodings, mixed cases, special characters, spaces, etc.
[0084] The input password string is uniformly converted to UTF-8 encoding format to ensure consistency on different system platforms. Invisible characters such as spaces, tabs, and line breaks at the beginning and end of the password are removed, but spaces in the middle of the password are preserved. Unicode NFC (Normalization Form C) normalization is applied to ensure consistent representation of combined characters.
[0085] The user's unique identity is usually an email address, a mobile phone number, or a username. If it is an email address, verify if it meets the email format specification; if it is a mobile phone number, verify if it meets the international phone number format. For email addresses, convert the domain name part to lowercase.
[0086] The identity string is converted to a UTF-8 byte sequence, and SHA-256 hash operation is performed on the byte sequence to generate a 256-bit (32-byte) hash value. The first 128 bits (16 bytes) of the 256-bit hash value are extracted as the salt value. Since SHA-256 is a deterministic function, the same input always produces the same output, so the same identity always generates the same salt value, which does not need to be stored.
[0087] The password byte sequence and the salt value byte sequence are directly concatenated to form a combined data structure: [password byte sequence][salt 16 bytes]. The combined data is input into a PBKDF2 or Argon2-based key derivation function, with the number of iterations and the output length set, and the key derivation operation is performed to obtain the master key seed data.
[0088] As shown in Figure 3 , S2, based on the master key seed data, uses a hierarchical hash algorithm to construct a key derivation tree data structure, including: taking the master key seed data as the initial input data of the root node; receiving user input device category name, performing hash operation on each device category name to generate corresponding category index data, including: receiving user input device category name string; performing Unicode NFC normalization on the device category name string, converting the processed string to lowercase to obtain the standardized device category name; wherein the device category includes mobile phone, computer, watch, and tablet; converting the standardized Unicode string to UTF-8 byte sequence; for example, "mobile phone" is converted to byte sequence: 0xE6 0x89 0x8B 0xE6 0x9C 0xBA (6 bytes); for example, "phone" is converted to byte sequence: 0x70 0x68 0x6F 0x6E 0x65 (5 bytes). Output the UTF-8 encoded byte sequence.
[0089] SHA-256 hash operation is performed on the byte sequence to generate a 256-bit hash value as the category index data, and the determinacy of the hash function ensures that the same device category name input always generates the same category index data.
[0090] According to the master key seed data and the category index data, the first layer of device category key data is generated by hash operation, including: taking the master key seed data as the input key material of the HKDF algorithm; constructing a fixed domain separation tag string as the salt value of HKDF, including: defining the identification string "MultiDeviceEncryption-CategoryLayer-v1"; converting the identification string into a UTF-8 encoded byte sequence; performing SHA-256 hash operation on the UTF-8 encoded byte sequence to generate a 256-bit hash value; extracting the first 128 bits of data from the 256-bit hash value as the salt value of the HKDF algorithm. Define the level identifier 0x01 to represent the device category layer, and define the separator 0x00 to separate different data segments to prevent boundary ambiguity when data splicing; concatenate the level identifier, separator, domain separation tag string, and category index data in order as the first layer context information, as shown in Figure 4 The HKDF-Extract operation is performed to perform entropy processing on the master key seed data using the salt value to generate a pseudo-random key; the HKDF-Expand operation is performed to generate the device category key data corresponding to the corresponding device category by hash iteration using the pseudo-random key and the context information.
[0091] The user sets a custom name for a specific device, for example: "My iPhone 15 Pro"; "Office MacBook"; "Bedroom iPad mini"; "Sports Apple Watch"; the user's custom name is standardized, and the standardized device name is converted into a UTF-8 byte sequence using the same processing method as the device level; for example, "My iPhone 15 Pro" is converted into the corresponding UTF-8 byte; SHA-256 hash operation is performed on the byte sequence; generate a 256-bit hash value as the device identifier;
[0092] The device category key (256 bits / 32 bytes) generated from the previous layer already contains the information of the master key seed and the device category, which is used as the input key material (IKM) of the HKDF of this layer, ensuring the hierarchical inheritance of key derivation and maintaining the structural integrity of the key tree.
[0093] Define the level identifier 0x02 to represent the device layer, and construct the second layer context information containing the level identifier 0x02, the separator 0x00, and the device identifier hash value.
[0094] The HKDF-Extract operation is performed to perform entropy processing on the device category key data using the generated salt value to generate a second layer pseudo-random key; the HKDF-Expand operation is performed to generate 256-bit device key data as the exclusive key of the corresponding device by hash iteration using the second layer pseudo-random key and the second layer context information. The keys of different devices are independent of each other, and the leakage of a device key does not affect other devices. The same device name always generates the same key, and key recovery is supported.
[0095] As shown in Figure 5 The session counter value of the current session is obtained; the device key data is taken as the input key material of the HKDF algorithm; the hierarchical identifier 0x03 is defined to represent the session layer; the hierarchical identifier 0x03, the separator 0x00 and the session counter value are concatenated in sequence to form the third layer context information; the HKDF-Extract operation is performed to perform entropy processing on the device key data using the generated salt value to generate a third layer pseudo-random key; the HKDF-Expand operation is performed to generate 256-bit session key data by hash iteration using the third layer pseudo-random key and the third layer context information; wherein the session counter value is incremented each time the session is established to ensure that a unique session key is used for each session, forming a complete three-layer derivation path from the master key seed data to the device category key, the device key and the session key.
[0096] S3, when a new device requests authorization, the derivation path is calculated according to the key derivation tree data structure combined with the attribute data of the corresponding new device, and the exclusive key data of the corresponding new device is derived from the master key seed data along the derivation path;
[0097] S4, according to the exclusive key data of the sending device in S3, the path data of the receiving device in the key derivation tree is combined to encrypt the data to be transmitted between the devices to generate an encrypted data stream;
[0098] S5, by adding timestamp data as an additional derivation parameter in the key derivation tree data structure in step S2, the exclusive key data generated in S3 and S4 is periodically updated with time.
[0099] Embodiment 2
[0100] In the specific embodiments of the present application, Mr. Zhang has an iPhone and now purchases a new iPad, which needs to be added to the password management system. The derivation path is calculated, the first step: generate a master key seed from the master password; the second step: calculate the hash index of the "tablet" category; the third step: along the path master key -> tablet category key; the fourth step: calculate the device identifier hash of "living room iPad Air"; the fifth step: along the path tablet category key -> iPad device key.
[0101] Mr. Zhang adds a bank password on iPhone, which needs to be synchronized to iPad. The data to be transmitted: { "site": "bank.com", "username": "zhangsan", "password": "SecretPass123"}; iPhone device key: already stored locally; current session counter: 1234.
[0102] Sending end (iPhone) processing:
[0103] Generate session key using iPhone device key and counter 1234; generate session key for this transmission (32 bytes); split into encryption key (first 16 bytes) and authentication key (last 16 bytes).
[0104] Perform data encryption, generate random initialization vector IV (16 bytes), encrypt data using AES-128-CBC mode, generate authentication tag using HMAC-SHA256.
[0105] Construct encrypted transmission data, version number: 1 byte (0x01); sending device category hash: 32 bytes; sending device identification hash: 32 bytes; session counter: 4 bytes; IV: 16 bytes; encrypted data: variable length; HMAC tag: 32 bytes.
[0106] Receiving end (iPad) processing:
[0107] Reconstruct key: extract device category hash and device identification hash from encrypted package; verify that the sender is a known device; use own device key to derive the same session key.
[0108] Data decryption: verify HMAC tag; decrypt data using session key; obtain original password data. Update local session counter and send confirmation message to iPhone.
[0109] Update context information at each level according to timestamp:
[0110] Device category layer: context = 0x01 + 0x00 + category index + 0x00 + time period value (4 bytes);
[0111] Device layer: context = 0x02 + 0x00 + device identification + 0x00 + time period value (4 bytes);
[0112] Session layer: context = 0x03 + 0x00 + session counter + 0x00 + time period value (4 bytes). This three-layer structure design realizes a complete key management system from user memory (password) to device management (category and name) to session security (temporary key), with clear security goals and isolation mechanisms for each layer.
[0113] The above description of the application and its embodiments is illustrative and not restrictive. Many variations of the application incorporating modifications without departing from the spirit of the application can be readily devised by those skilled in the art from the teachings herein. The application is therefore indicated not limited to the embodiments described above, which are presented only by way of example. Where technical features mentioned herein are followed by references to a number of embodiments, this is to be understood in that merely certain features of an embodiment are repeated in the specific embodiments that follow. As indicated above, a person of ordinary skill in the art would understand that the application is not limited to the embodiments described above, which are presented only by way of example. Other embodiments can be readily devised in accordance with the principles of the application, as would be understood by a person of ordinary skill in the art. In addition, the word "comprising" does not, without further qualification, exclude other elements or steps, and the word "a" or "an" does not exclude a plurality. The components of the described embodiments can generally be provided with any type of the arrangements of components thereof. It is specifically intended that different features or components described herein can be used in conjunction with each other or alternatively. The application is not limited to the embodiments described above, which are presented only by way of example.
Claims
1. A method for data encryption based on multi-party interaction, characterized in that, Comprise: S1, when the user first registers, obtain the master password data input by the user, generate the master key seed data according to the master password data through the key derivation function; S2, based on the master key seed data, a hierarchical hash algorithm is used to construct a key derivation tree data structure, the key derivation tree data structure takes the master key seed data as the root node, and expands layer by layer to form a tree-shaped derivation path according to the device category and device identification; S3, when a new device requests authorization, according to the key derivation tree data structure, the attribute data of the corresponding new device is combined to calculate the derivation path, and the exclusive key data of the corresponding new device is derived from the master key seed data along the derivation path; S4, according to the exclusive key data of the sending device in S3, combining the path data of the receiving device in the key derivation tree, the data to be transmitted between the devices is encrypted to generate an encrypted data stream.
2. The data encryption method based on multi-end interaction according to claim 1, characterized in that: Further comprising: S5, by adding timestamp data as an additional derivation parameter in the key derivation tree data structure of step S2, the exclusive key data generated in S3 and S4 is periodically updated with time.
3. The data encryption method based on multi-end interaction according to claim 2, characterized in that: S1, generating the master key seed data through the key derivation function, comprising: Receiving the master password data input by the user, normalizing the master password data to generate password data in standard format; Obtain the unique identity data of the user; Hash operation is performed on the unique identity data to generate the deterministic salt value data of the corresponding user; Combine the standard format password data and the deterministic salt value data to form combined data; Input the combined data into the key derivation function based on PBKDF2 or Argon2, set the iteration number and output length, execute the key derivation operation, and get the master key seed data.
4. The data encryption method based on multi-end interaction according to claim 2, characterized in that: S2, a hierarchical hash algorithm is used to construct a key derivation tree data structure, comprising: The master key seed data is used as the initial input data of the root node; Receive the device category name input by the user, perform hash operation on each device category name to generate corresponding category index data; According to the master key seed data and the category index data, the first layer of device category key data is generated through hash operation; When the device requests to join, receive the custom device name set by the user for the corresponding device, and perform standardization processing on the custom device name; According to the standardized device name and the device category key data, the second layer of device key data is generated through hash operation; When the session key needs to be generated, the device key data and the session counter value are used as input to generate the session key data through hash operation, so as to form a three-layer derivation path from the master key seed data to the session key data.
5. The data encryption method based on multi-end interaction according to claim 3, characterized in that: Generating corresponding category index data, comprising: Receive the device category name string input by the user; Perform Unicode NFC normalization processing on the device category name string, convert the processed string to lowercase form, and obtain the standardized device category name; wherein the device category includes mobile phone, computer, watch, and tablet; Convert the standardized device category name to a UTF-8 encoded byte sequence; Perform SHA-256 hash operation on the byte sequence to generate a 256-bit hash value as the category index data, which ensures that the same device category name input always generates the same category index data through the determinacy of the hash function.
6. The multi-end interaction-based data encryption method of claim 3, wherein: The first layer of device category key data is generated by hash operation, including: Taking the master key seed data as the input key material of the HKDF algorithm; Constructing a fixed domain separation tag string as the salt value of the HKDF; Defining a hierarchical identifier 0x01 to represent the device category layer, and a separator 0x00 to separate different data segments to prevent boundary ambiguity when data is spliced; Concatenating the hierarchical identifier, separator, domain separation tag string, and category index data in sequence as the first layer context information; Performing HKDF-Extract operation to perform entropy processing on the master key seed data using the salt value to generate a pseudo-random key; Performing HKDF-Expand operation to generate the device category key data corresponding to the corresponding device category by hash iteration using the pseudo-random key and the context information.
7. The multi-end interaction-based data encryption method of claim 6, wherein: The fixed domain separation tag string is constructed as the salt value of the HKDF, including: Defining an identification string "MultiDeviceEncryption-CategoryLayer-v1"; Converting the identification string to a UTF-8 encoded byte sequence; Performing SHA-256 hash operation on the UTF-8 encoded byte sequence to generate a 256-bit hash value; Extracting the first 128 bits of data from the 256-bit hash value as the salt value of the HKDF algorithm.
8. The multi-end interaction-based data encryption method of claim 7, wherein: The second layer of device key data is generated by hash operation, including: Standardizing the user-defined device name and performing hash operation to obtain a device identification hash value; Taking the device category key data as the input key material of the HKDF algorithm; Defining a hierarchical identifier 0x02 to represent the device layer, and constructing a second layer context information including the hierarchical identifier 0x02, the separator 0x00, and the device identification hash value; Performing HKDF-Extract operation to perform entropy processing on the device category key data using the generated salt value to generate a second layer pseudo-random key; Performing HKDF-Expand operation to generate 256-bit device key data as the exclusive key of the corresponding device by hash iteration using the second layer pseudo-random key and the second layer context information.
9. The multi-party interaction-based data encryption method of claim 7, characterized in that: Session key data is generated through a hash operation, comprising: Obtaining a session counter value of a current session; Taking the device key data as input key material of the HKDF algorithm; Defining a hierarchical identifier 0x03 to represent the session layer; Concatenating the hierarchical identifier 0x03, the separator 0x00, and the session counter value in sequence to form third-layer context information; Performing an HKDF-Extract operation to perform entropy processing on the device key data using the generated salt value, to generate a third-layer pseudo-random key; Performing an HKDF-Expand operation to generate 256-bit session key data through hash iteration using the third-layer pseudo-random key and the third-layer context information; wherein the session counter value is incremented at each session establishment to ensure that a unique session key is used for each session, forming a complete three-layer derivation path from the master key seed data to the device category key, the device key, and the session key.
10. A multi-party interaction based data encryption system, characterized by, Comprising: A master key generation module that, when a user first registers, obtains user-input master password data, and generates master key seed data from the master password data through a key derivation function; A key derivation tree module that, based on the master key seed data, constructs a key derivation tree data structure using a hierarchical hash algorithm, with the key derivation tree data structure taking the master key seed data as a root node and expanding layer by layer according to device categories and device identifiers to form a tree-shaped derivation path; A device key module that, when a new device requests authorization, calculates a derivation path according to the key derivation tree data structure in combination with attribute data of the corresponding new device, and generates exclusive key data for the corresponding new device along the derivation path from the master key seed data; A data encryption module that, according to the exclusive key data of the sending device, combines path data of the receiving device in the key derivation tree to encrypt data to be transmitted between devices, generating an encrypted data stream; A key update module that, by adding timestamp data as an additional derivation parameter in the key derivation tree data structure, causes the exclusive key data to be periodically updated over time.
Citation Information
Cited By
HTTP interaction method and system based on double-end automatic encryption and decryption
CN121509108A
Key management method and device for satellite communication, equipment and medium
CN122069512A