Key derivation method and device and storage medium

By extending the key derivation type and introducing a hybrid key derivation mode in the session recovery request, the problem of insufficient flexibility caused by the singleness of the key derivation mechanism in the prior art is solved, and dynamic response to the scenario and good TLS protocol are achieved. Compatibility, improves the stability and efficiency of secure connections.

CN119094114APending Publication Date: 2024-12-06HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310658496.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-05
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

The singularity of the key derivation mechanism in the prior art during session recovery leads to insufficient flexibility, and the inability to dynamically adjust the key derivation method according to the scenario, affecting the stability and efficiency of secure connections.

Method used

By extending the key derivation type in the session recovery request, the communication device allows the communication device to select a one-sided key derivation mechanism or interactive key derivation mechanism according to the scenario, realize the flexibility of key derivation, and introduce a hybrid key derivation mode in the TLS protocol. To enhance compatibility.

Benefits of technology

Improves the flexibility and security of key derivation, avoids the use of the same mechanism in multiple session recovery after the first handshake, enhances the responsiveness to the scene, and is well compatible with the TLS protocol.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094114A_ABST
    Figure CN119094114A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a key derivation method and device and a storage medium, and belongs to the technical field of communication. The method comprises the following steps: a first communication device receives a session recovery request from a second communication device, wherein the session recovery request carries a key derivation type; determining a target key derivation mechanism from a unilateral key derivation mechanism and an interactive key derivation mechanism based on the key derivation type; a key is derived based on a target key derivation mechanism to encrypt application data based on the derived key. The mechanism used by the first communication device to derive the key can be flexibly indicated through the key derivation type. Therefore, the first communication device and the second communication device can be prevented from using the same mechanism to derive the key in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive the key when the session is recovered according to different scenes, so that the flexibility of key derivation is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of communication technology, and in particular to a key derivation method, device and storage medium. Background Art

[0002] Currently, the transport layer security (TLS) protocol supports the client and server to resume the session based on the pre-shared key (PSK) of the most recent session after the first handshake, so as to reduce the interaction between the client and the server when the session is resumed. When the client and the server resume the session based on the PSK of the most recent session, the client and the server derive a key based on the PSK of the most recent session to encrypt the subsequent application data according to the derived key. Summary of the invention

[0003] The embodiments of the present application provide a key derivation method, device and storage medium, which can improve the flexibility of key derivation. The technical solution is as follows:

[0004] In a first aspect, a key derivation method is provided, in which a first communication device receives a session resumption request from a second communication device, the session resumption request carrying a key derivation type; the first communication device determines a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type; the first communication device derives a key based on the target key derivation mechanism to encrypt application data based on the derived key.

[0005] Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

[0006] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0007] Based on the method provided by the first aspect, in some possible implementations, when the value of the key derivation type is a first bit value, the target key derivation mechanism is a one-sided key derivation mechanism; when the value of the key derivation type is a second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0008] The different bit values ​​in the key derivation type can indicate that the first communication device adopts different key derivation mechanisms. This method is simple to implement.

[0009] Based on the method provided in the first aspect, in some possible implementations, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries a key derivation type.

[0010] In the embodiment of the present application, in the scenario where the session resumption request is a session resumption request based on the TLS protocol, the pre-shared key field included in the session resumption request can be extended to carry the key derivation type through the pre-shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0011] Based on the method provided in the first aspect, in some possible implementations, the first communication device derives a key based on a target key derivation mechanism, and the implementation process of encrypting application data based on the derived key can be: when the target key derivation mechanism is a one-sided key derivation mechanism, the first communication device derives a second slave key based on a first slave key through a one-sided key derivation mechanism, so as to encrypt application data based on the second slave key, the first slave key is a slave key derived from a first master key, and the first master key is the master key most recently derived by the first communication device through an interactive key derivation mechanism; when the target key derivation mechanism is an interactive key derivation mechanism, the first communication device derives a second master key based on the first master key through an interactive key derivation mechanism, and derives a third slave key based on the second master key, so as to encrypt application data based on the third slave key.

[0012] In the embodiment of the present application, in order to further improve the forward and backward security of data, two key derivation chains are provided, a master key derivation chain and a slave key derivation chain. The master key derivation chain consists of multiple master keys, each of which is obtained through an interactive key derivation mechanism. Each master key on the master key chain corresponds to a slave key derivation chain, and each slave key on the slave key derivation chain is obtained through a unilateral key derivation mechanism. The application data after session recovery is encrypted based on the slave key on the slave key derivation chain.

[0013] Based on the method provided in the first aspect, in some possible implementations, the session resumption request also carries a key derivation parameter, and the key derivation parameter indicates the slave key most recently derived by the second communication device. In this scenario, the implementation process of the first communication device deriving the second slave key based on the first slave key through a one-sided key derivation mechanism may be: the first communication device derives the second slave key based on the key derivation parameter and the first slave key through a one-sided key derivation mechanism, so that the second slave key is synchronized with the slave key most recently derived by the second communication device.

[0014] The second communication device may also carry a key derivation parameter in the session resumption request, and the key derivation parameter is used to indicate the slave key most recently derived by the second communication device. In this way, when the first communication device subsequently derives a key through a one-sided key derivation mechanism, it can ensure that the key derived by itself and the key derived by the second communication device are synchronized based on the key derivation parameter.

[0015] Based on the method provided in the first aspect, in some possible implementations, the key derivation parameter includes a first index, and the first index indicates the number of times the second communication device derived a slave key based on the first master key before the current time. In this scenario, the implementation process of the first communication device deriving the second slave key based on the key derivation parameter and the first slave key through a one-sided key derivation mechanism can be: the first communication device obtains a second index, and the second index indicates the number of times the first communication device derived a slave key based on the first master key before the current time; if the first index is greater than or equal to the sum of the second index and 1, the first communication device determines the difference between the first index and the second index to obtain n; the first communication device performs n key derivation operations based on the first slave key through a one-sided key derivation mechanism to obtain the second slave key.

[0016] If the first index is equal to the sum of the second index and 1, n is 1, indicating that the keys on the slave key derivation chain on the first communication device side and the second communication device side are well synchronized, and the first communication device only needs one key derivation operation to obtain the second slave key synchronized with the second communication device side. If the first index is greater than the sum of the second index and 1, n is an integer greater than 1, indicating that the keys on the slave key derivation chain on the first communication device side and the second communication device side cannot be synchronized through one key derivation operation, so it is necessary to perform key derivation operations multiple times to obtain the second slave key synchronized with the second communication device side. That is, in the scenario where the first index is greater than or equal to the sum of the second index and 1, the first communication device can repair its own slave key derivation chain through a unilateral key derivation mechanism so that the repaired slave key derivation chain is synchronized with the slave key derivation chain on the second communication device side.

[0017] Based on the method provided in the first aspect, in some possible implementations, after the first communication device obtains the second index, in this method, if the first index is less than the sum of the second index and 1, the first communication device derives the second master key based on the first master key through an interactive key derivation mechanism, and derives the third slave key based on the second master key to encrypt the application data based on the third slave key.

[0018] In the embodiment of the present application, when the key derivation type indicates that the target key derivation mechanism is a one-sided key derivation mechanism, since the second communication device sends the session resumption request only after it has derived the slave key, that is, the second communication device derives the key first and the first communication device derives the key later, when the first communication device receives the session resumption request, the second index stored on the first communication device side is in principle smaller than the first index carried in the session resumption request. Therefore, if the first index is smaller than the sum of the second index and 1, it indicates that the slave key derivation chains on the second communication device side or the first communication device side cannot be synchronized through the one-sided key derivation mechanism. Therefore, in this scenario, both parties need to derive a new master key through the interactive key derivation mechanism, thereby opening a new slave key derivation chain based on the master key to ensure synchronization of the slave key derivation chains of both parties.

[0019] Based on the method provided in the first aspect, in some possible implementations, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the first exponent.

[0020] In the embodiment of the present application, in the scenario where the session resumption request is a session resumption request based on the TLS protocol, the pre-shared key field included in the session resumption request can be extended to carry the first exponent through the pre-shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0021] Based on the method provided in the first aspect, in some possible implementations, the implementation process of the first communication device deriving the second master key based on the first master key through the interactive key derivation mechanism can be: the first communication device obtains its own first key negotiation parameter and the second key negotiation parameter sent by the second communication device; the first communication device derives the second master key based on the first key negotiation parameter, the second key negotiation parameter and the first master key.

[0022] When deriving a key through the interactive key derivation mechanism, the first communication device needs to obtain the key negotiation parameters of the second communication device, and then derive the second master key based on the key negotiation parameters of both parties.

[0023] Based on the method provided in the first aspect, in some possible implementations, the session resumption request also carries the second key negotiation parameter. In this scenario, after the first communication device receives the session resumption request from the second communication device, the first communication device also sends a session resumption response to the second communication device, and the session resumption response carries the first key negotiation parameter.

[0024] In a scenario where the key derivation type carried in the session resumption request indicates that the first communication device uses the interactive key derivation mechanism as the target key derivation mechanism, the first communication device and the second communication device can obtain each other's key negotiation parameters through the interactive session resumption request and the session resumption response to derive the key through the interactive key derivation mechanism.

[0025] Based on the method provided in the first aspect, in some possible implementations, the session resumption request is a session resumption request based on the transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry the second key negotiation parameter; the session resumption response is a session resumption response based on the TLS protocol, the session resumption response includes a second shared key field, the second shared key field carries a second RV, and the second RV is used to carry the first key negotiation parameter.

[0026] In an embodiment of the present application, in a scenario where a first communication device and a second communication device communicate based on the TLS protocol, the shared key field included in the session resumption request and the session resumption response can be extended to carry the second key negotiation parameter and the first key negotiation parameter through the RV in the shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0027] Based on the method provided in the first aspect, in some possible implementations, before the first communication device receives a session resumption request from the second communication device, the first communication device may also receive a session creation request from the second communication device, and the session creation request carries a hybrid key derivation mode; wherein the hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried by the session resumption request.

[0028] Based on the relevant content of the TLS1.3 protocol, it is known that the key derivation mode used for subsequent session resumption needs to be specified when the client and the server shake hands for the first time. Since the key derivation mode provided in the embodiment of the present application is different from the two key derivation modes provided in the existing TLS1.3 protocol, a third key derivation mode is extended in the embodiment of the present application. For the sake of convenience, the third key derivation mode is called a hybrid key derivation mode.

[0029] Based on this, during the first handshake, that is, when creating a session, the second communication device can specify that a hybrid key derivation mode be used when the subsequent session is resumed. In this way, the second communication device and the first communication device can derive a key based on the key derivation method provided in the embodiment of the present application when resuming the session. This improves the compatibility of the embodiment of the present application with existing protocols.

[0030] In a second aspect, a key derivation method is provided, in which a second communication device sends a session resumption request to a first communication device, the session resumption request carries a key derivation type, and the key derivation type is used to instruct the first communication device to determine a target key derivation mechanism from a unilateral key derivation mechanism and an interactive key derivation mechanism based on the key derivation type, and derive a key based on the target key derivation mechanism to encrypt application data based on the derived key; wherein the unilateral key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

[0031] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0032] Based on the method provided by the second aspect, in some possible implementations, when the value of the key derivation type is a first bit value, the target key derivation mechanism is a one-sided key derivation mechanism; when the value of the key derivation type is a second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0033] The different bit values ​​in the key derivation type can indicate that the first communication device adopts different key derivation mechanisms. This method is simple to implement.

[0034] Based on the method provided in the second aspect, in some possible implementations, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries a key derivation type.

[0035] In the embodiment of the present application, in the scenario where the session resumption request is a session resumption request based on the TLS protocol, the pre-shared key field included in the session resumption request can be extended to carry the key derivation type through the pre-shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0036] Based on the method provided by the second aspect, in some possible implementations, before the second communication device sends a session resumption request to the first communication device, the second communication device also derives a key through a one-sided key derivation mechanism and generates a session resumption request, wherein the key derivation type is used to indicate that the first communication device uses the one-sided key derivation mechanism as the target key derivation mechanism; or, the second communication device generates a session resumption request, wherein the key derivation type is used to indicate that the first communication device uses an interactive key derivation mechanism as the target key derivation mechanism; after the second communication device sends the session resumption request to the first communication device, the method also includes: the second communication device derives a key through an interactive key derivation mechanism.

[0037] When the second communication device derives the key by a unilateral key derivation mechanism, the key derivation type indicates that the first communication device also derives the key by a unilateral key derivation mechanism. When the second communication device derives the key by an interactive key derivation mechanism, the key derivation type indicates that the first communication device also derives the key by an interactive key derivation mechanism. This ensures that the key on the first communication device side is synchronized with the key on the second communication device side.

[0038] In addition, since the one-sided key derivation mechanism does not require the exchange of key negotiation parameters between the two parties, the second communication device can send a session resumption request to the first communication device after deriving the key. This can ensure that early data in the 0RTT technology of the TLS1.3 protocol is not attacked, and improve the forward security of early data in the 0RTT technology.

[0039] Based on the method provided in the second aspect, in some possible implementations, the implementation process of the second communication device deriving a key through a one-sided key derivation mechanism may be: the second communication device derives a second slave key based on a first slave key through a one-sided key derivation mechanism, wherein the first slave key is a slave key derived from a first master key, and the first master key is a master key most recently derived by the second communication device through an interactive key derivation mechanism. Accordingly, the implementation process of the second communication device deriving a key through an interactive key derivation mechanism may be: the second communication device derives a second master key based on the first master key through an interactive key derivation mechanism, and derives a third slave key based on the second master key.

[0040] In the embodiment of the present application, in order to further improve the forward and backward security of data, two key derivation chains are provided, a master key derivation chain and a slave key derivation chain. The master key derivation chain consists of multiple master keys, each of which is obtained through an interactive key derivation mechanism. Each master key on the master key chain corresponds to a slave key derivation chain, and each slave key on the slave key derivation chain is obtained through a unilateral key derivation mechanism. The application data after session recovery is encrypted based on the slave key on the slave key derivation chain.

[0041] Based on the method provided in the second aspect, in some possible implementations, the session resumption request further carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communication device.

[0042] The second communication device may also carry a key derivation parameter in the session resumption request, and the key derivation parameter is used to indicate the slave key most recently derived by the second communication device. In this way, when the first communication device subsequently derives a key through a one-sided key derivation mechanism, it can ensure that the key derived by itself and the key derived by the second communication device are synchronized based on the key derivation parameter.

[0043] Based on the method provided in the second aspect, in some possible implementations, the key derivation parameter includes a first index, and the first index indicates the number of times the second communication device derives the slave key based on the first master key before the current time.

[0044] Through the first index, the first communication device can subsequently determine the number of times currently required to derive the secondary key, so as to ensure that its own secondary key derivation chain and the secondary key derivation chain of the second communication device are synchronized.

[0045] Based on the method provided in the second aspect, in some possible implementations, the implementation process of the second communication device deriving the second master key based on the first master key through the interactive key derivation mechanism can be: the second communication device obtains its own second key negotiation parameters and the first key negotiation parameters sent by the first communication device; the second communication device derives the second master key based on the first key negotiation parameters, the second key negotiation parameters and the first master key.

[0046] When deriving a key through the interactive key derivation mechanism, the second communication device needs to obtain the key negotiation parameters of the first communication device, and then derive the second master key based on the key negotiation parameters of both parties.

[0047] Based on the method provided in the second aspect, in some possible implementations, the session resumption request also carries a second key negotiation parameter of the second communication device; in this scenario, the second communication device can also receive a session resumption response sent by the first communication device, and the session resumption response carries the first key negotiation parameter of the first communication device.

[0048] In a scenario where the key derivation type carried in the session resumption request indicates that the first communication device uses the interactive key derivation mechanism as the target key derivation mechanism, the first communication device and the second communication device can obtain each other's key negotiation parameters through the interactive session resumption request and the session resumption response to derive the key through the interactive key derivation mechanism.

[0049] Based on the method provided in the second aspect, in some possible implementations, the session resumption request is a session resumption request based on the transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry the second key negotiation parameter; the session resumption response is a session resumption response based on the TLS protocol, the session resumption response includes a second shared key field, the second shared key field carries a second RV, and the second RV is used to carry the first key negotiation parameter.

[0050] In an embodiment of the present application, in a scenario where a first communication device and a second communication device communicate based on the TLS protocol, the shared key field included in the session resumption request and the session resumption response can be extended to carry the second key negotiation parameter and the first key negotiation parameter through the RV in the shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0051] Based on the method provided in the second aspect, in some possible implementations, before the second communication device sends a session resumption request to the first communication device, the second communication device may also send a session creation request to the first communication device, and the session creation request carries a hybrid key derivation mode; wherein the hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

[0052] Based on the relevant content of the TLS1.3 protocol, it is known that the key derivation mode used for subsequent session resumption needs to be specified when the client and the server shake hands for the first time. Since the key derivation mode provided in the embodiment of the present application is different from the two key derivation modes provided in the existing TLS1.3 protocol, a third key derivation mode is extended in the embodiment of the present application. For the sake of convenience, the third key derivation mode is called a hybrid key derivation mode.

[0053] Based on this, during the first handshake, that is, when creating a session, the second communication device can specify that a hybrid key derivation mode be used when the subsequent session is resumed. In this way, the second communication device and the first communication device can derive a key based on the key derivation method provided in the embodiment of the present application when resuming the session. This improves the compatibility of the embodiment of the present application with existing protocols.

[0054] In a third aspect, a key derivation device is provided, which is deployed in a first communication device, and has the function of implementing the key derivation method in the first aspect. The key derivation device includes at least one module, and the at least one module is used to implement the key derivation method provided in the first aspect.

[0055] In a fourth aspect, a key derivation device is provided, which is deployed in a second communication device, and has the function of implementing the key derivation method in the second aspect. The key derivation device includes at least one module, and the at least one module is used to implement the key derivation method provided in the second aspect.

[0056] In a fifth aspect, a key derivation device is provided, wherein the structure of the key derivation device includes a processor and a memory, wherein the memory is used to store a program that supports the key derivation device to execute the key derivation method provided in the first aspect, and to store data involved in implementing the key derivation method provided in the first aspect. The processor is configured to execute the program stored in the memory. The operating device of the storage device may also include a communication bus, which is used to establish a connection between the processor and the memory.

[0057] In a sixth aspect, a key derivation device is provided, wherein the structure of the key derivation device includes a processor and a memory, wherein the memory is used to store a program that supports the key derivation device to execute the key derivation method provided in the second aspect, and to store data involved in implementing the key derivation method provided in the second aspect. The processor is configured to execute the program stored in the memory. The operating device of the storage device may also include a communication bus, which is used to establish a connection between the processor and the memory.

[0058] In a seventh aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the key derivation method described in the first aspect.

[0059] In an eighth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the key derivation method described in the second aspect.

[0060] In a ninth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the key derivation method described in the first aspect.

[0061] In a tenth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the key derivation method described in the second aspect.

[0062] The technical effects obtained in the above-mentioned third to tenth aspects are similar to the technical effects obtained by the corresponding technical means in the first or second aspect, and will not be repeated here.

[0063] The beneficial effects brought by the technical solution provided by the embodiments of the present application include at least the following technical effects:

[0064] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a schematic diagram of the architecture of a key derivation system provided in an embodiment of the present application;

[0066] Figure 2 This is a schematic diagram of a process for exchanging application data between a client and a server based on the TLS 1.3 protocol, provided in an embodiment of the present application;

[0067] Figure 3 This is a flowchart of a one-round key derivation operation provided by an embodiment of the present application;

[0068] Figure 4 is a flow chart of a key derivation method provided in an embodiment of the present application;

[0069] Figure 5 is a flow chart of another key derivation method provided in an embodiment of the present application;

[0070] Figure 6 is a flow chart of another key derivation method provided in an embodiment of the present application;

[0071] Figure 7 It is a schematic diagram of improving the forward security of early data provided by an embodiment of the present application;

[0072] Figure 8 It is a schematic diagram of a master key derivation chain and a slave key derivation chain provided in an embodiment of the present application;

[0073] Fig. 9 This is a schematic diagram of a scenario where n is greater than 1 provided in an embodiment of the present application;

[0074] Fig.10 It is a schematic diagram of a process of deriving a second slave key based on a first index and a second index provided by an embodiment of the present application;

[0075] Fig.11 It is another schematic diagram of a process of deriving a key based on a first index and a second index provided in an embodiment of the present application;

[0076] Fig.12 This is another schematic diagram of a key derivation process provided by an embodiment of the present application;

[0077] Fig.13 is a schematic diagram comparing a dual-key derivation chain and a single-key derivation chain provided in an embodiment of the present application;

[0078] Fig.14 It is a schematic diagram of the format of an extended client access message and a server access message provided in an embodiment of the present application;

[0079] Fig.15 It is a structural schematic diagram of a key derivation device provided in an embodiment of the present application;

[0080] Fig.16 It is a structural schematic diagram of a key derivation device provided in an embodiment of the present application;

[0081] Fig.17 It is a structural schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0082] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0083] It should be understood that the "multiple" mentioned herein refers to two or more. In the description of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit them to be necessarily different.

[0084] Before explaining the embodiments of the present application in detail, the application scenarios of the embodiments of the present application are first introduced.

[0085] In cryptography, a key derivation function (KDF) uses a pseudo-random function to derive one or more other keys from a secret value such as a key or a key. For example, after obtaining key negotiation parameters through a key negotiation process, KDF is applied to the obtained key negotiation parameters to derive the required key. For another example, KDF can also be used to extend a key into a longer key or to convert a key into a key in a required format.

[0086] KDF needs to call a cryptographic hash function, namely a hash function. The hash value calculated by the hash function has the property of being irreversible (it is impossible to reversely calculate the original value). Assuming the hash function is H(X), its output K=H(X), and X cannot be reversely calculated from K, so X can be effectively protected and has good forward security.

[0087] KDF is widely used in various security protocols, such as authentication key exchange (AKE) protocol. In most security protocols, such as Internet Protocol Security (IPSEC) protocol and TLS protocol, the client and server use the key negotiation parameters as the input of KDF, call KDF to perform key derivation operation and output a common key. Subsequently, the key is used as the input of KDF, and KDF is called to complete the key update, thereby achieving key security. In the process of continuously updating the key, a key derivation chain can be formed.

[0088] In the process of forming a key derivation chain, lightweight key updates are usually used between the client and the server. The so-called lightweight key update can be understood as the two parties do not need to exchange key negotiation parameters, and directly call the KDF to derive the key, so as to achieve the effect of reducing interaction by using calculation instead of transmission. Therefore, the biggest advantage of lightweight key update is that the two parties can complete the fast key update without renegotiating the key. However, in lightweight key update, in order to ensure the synchronization of the derived keys of both parties, both parties need to store the status of the derived keys, such as storing the position of the derived keys in the key derivation chain. And once the derived keys are out of sync, the secure connection between the server and the client will be destroyed. In this scenario, both parties need to derive the keys again through key negotiation, which will incur additional overhead.

[0089] Based on this, an embodiment of the present application provides a key derivation method, the purpose of which is to be able to flexibly derive keys based on needs.

[0090] The key derivation system, key derivation method and related devices provided in the embodiments of the present application are explained in detail below.

[0091] Figure 1 Schematic diagram of the architecture of a key derivation system provided in an embodiment of the present application. Figure 1 As shown, the system includes a first communication device 10 and a second communication device 20. The first communication device 10 and the second communication device 20 are connected to each other via a wired or wireless manner for communication.

[0092] The second communication device 20 may initiate a session creation request to the first communication device 10, so as to establish a secure connection between the second communication device 20 and the first communication device 10. The so-called establishment of a secure connection can be understood as a common key generated by the interaction between the first communication device 10 and the second communication device 20, and the application data transmitted between the two in the subsequent session process is encrypted by the key to prevent the application data transmitted between the two from being attacked.

[0093] Furthermore, the second communication device 20 can also initiate a session recovery request to the first communication device 10, so that the second communication device 20 and the first communication device 10 continue to derive new keys based on the key used in the most recent session, and the application data transmitted between the two during subsequent sessions is encrypted by the new key.

[0094] The key derivation method provided in the embodiment of the present application is applied to the scenario of how the two derive a key after the second communication device 20 initiates a session resumption request to the first communication device 10.

[0095] Among them, the first communication device 10 and the second communication device 20 can communicate through a variety of protocols. For example, the transport layer security (TLS) protocol, the 802.1X protocol (a network access control protocol), the datagram transport layer security (DTLS) protocol, the quick user datagram protocol internet connections (QUIC) protocol based on the user data protocol, etc. The embodiment of the present application does not limit the protocol for communication between the first communication device 10 and the second communication device 20, and any communication protocol that can be used to derive a key can be applied in the embodiment of the present application.

[0096] The following takes the communication between the first communication device 10 and the second communication device 20 via the TLS 1.3 protocol as an example to illustrate how the two create and restore a session.

[0097] In the TLS 1.3 protocol, the end that initiates the session can be called the client, and the other end that exchanges application data with the client can be called the server. Figure 1 The first communication device 10 in the example is used as a server, and the second communication device 20 is used as a client. The client example may be a terminal device or the like, and the server example may be an authentication server or the like.

[0098] Figure 2 This is a schematic diagram of a process for exchanging application data between a client and a server based on the TLS 1.3 protocol provided in an embodiment of the present application. Figure 2 As shown in FIG. 1 , the process of exchanging application data between the client and the server includes the following two processes: the first handshake (i.e., creating a session) and the subsequent handshake (i.e., session recovery). The following describes these two processes separately.

[0099] 1. First handshake.

[0100] like Figure 2 As shown in the figure, during the first handshake between the client and the server, the two parties complete the exchange of key negotiation parameters through the shared key (key_share) field. The two parties generate PSK based on the exchanged key negotiation parameters. For the convenience of subsequent explanation, the PSK generated by both parties during the first handshake is marked as PSK 0 Then both parties authenticate each other's identities. After the identity authentication is passed, the first handshake process ends and the two parties establish a secure connection. The application data exchanged in subsequent sessions can be based on PSK. 0 encryption.

[0101] like Figure 2 As shown, in the final stage of the first handshake, the server sends a new session ticket (NewSessionTicket) message to the client, and the client can subsequently restore the session through the session ticket carried in the new session ticket (NewSessionTicket) message.

[0102] By way of example, the first handshake may be implemented through the following steps.

[0103] 1) The client sends a ClientHello message carrying a shared key (key_share) field to the server. The shared key field in the ClientHello message is used to carry the key negotiation parameters to be exchanged, that is, the key negotiation parameters of the client.

[0104] In addition, the client access message may also carry an empty session ticket (session_ticket) field to indicate that the current client supports a session recovery mechanism based on session tickets.

[0105] 2) The server returns a ServerHello message carrying a shared key field to the client. The shared key field in the ServerHello message is used to carry the key negotiation parameters to be exchanged, that is, the key negotiation parameters of the server.

[0106] In addition, the server access message may also carry an empty session ticket field to indicate that the server will send a new session ticket later.

[0107] After the two parties exchange key negotiation parameters, the server and client can generate PSK based on the key negotiation parameters exchanged by the other party and their own key negotiation parameters. 0 , and then based on the PSK 0 Encrypt application data.

[0108] 3) The server sends its server parameters to the client. The server parameters may indicate the current state of the server. For example, the server parameters are carried in an EncryptedExtentions message.

[0109] 4) The server and client exchange authentication messages to authenticate each other's identities.

[0110] In some embodiments, Figure 2 As shown, the server and the client can authenticate their identities through digital certificates.

[0111] Optionally, in some other embodiments, the server and the client can authenticate each other through other means. For example, the identity can be authenticated through the PSK method. In this scenario, the PSK for authenticating the identity can be pre-configured on the client and the server, respectively. The PSK and the PSK determined by the two parties based on the key negotiation parameters are 0 It can be the same or different.

[0112] For example, during the first handshake, the client can add a pre-shared key (Pre_shared_key) field in the client access message, and the pre-shared key field contains a PSK encryption suite, and the PSK encryption suite includes a psk_id, so that the server can find a pre-configured PSK based on the psk_id, and then authenticate the identity of the client based on the PSK. Correspondingly, the server replies with a corresponding PSK encryption suite in the server access message, so that the client can authenticate the identity of the server based on the found PSK.

[0113] 5) The server sends a NewSessionTicket message to the client. The NewSessionTicket message carries a new session ticket issued by the server. The client can use the new session ticket for subsequent handshakes (ie, session recovery).

[0114] The new session ticket is used to transmit the relevant information of the most recently generated PSK. For example, the new session ticket contains information such as the PSK initial value, PSK name, PSK validity period, and PSK usage restrictions.

[0115] Illustratively, the new session ticket message includes the following fields.

[0116] ticket_lifetime_hint. This field is used to indicate the lifetime of the new session ticket issued by the server. The lifetime starts from the time the client receives the session ticket, and the client can determine the timeout of the session ticket based on the lifetime. For example, the unit of the lifetime is seconds, and the lifetime can usually be set to 24 hours, and optionally can also be set to 7 days.

[0117] ticket. This field is used to indicate the specific content of the new session ticket issued by the server, which can be encrypted.

[0118] key_name. This field is used to indicate which group of keys are used to encrypt and authenticate the session ticket. Through this field, the server can easily determine whether the session ticket is issued by itself. Among them, this field is usually randomly generated when the server starts.

[0119] It should be noted that the above is used to illustrate the structure of the new session ticket message. Optionally, the new session ticket message may include more or fewer fields, which will not be illustrated one by one here.

[0120] It should be noted that regardless of whether the client accepts the session ticket sent by the server, as long as the server feels that a new session ticket needs to be issued, the server will send a new session ticket. After receiving the new session ticket, the client can update the locally stored session ticket.

[0121] 6) The client and server exchange encrypted application data.

[0122] It should be noted that in step 1) and step 2), the server and the client generate their own PSK based on the interactive key negotiation parameters. 0 Afterwards, you can use PSK 0A session key is further generated, and the session key is used to encrypt application data. The process of generating the session key is described in detail in the subsequent key derivation chain and will not be introduced here.

[0123] 2. Subsequent handshake.

[0124] After the session ends after the initial handshake, when the client needs to re-establish a secure connection with the server, the client and server can directly resume the session through the stored session ticket without the need for both parties to exchange certificates and negotiate keys, thereby quickly rebuilding the secure connection.

[0125] By way of example, the subsequent handshake may be implemented through the following steps.

[0126] 7) In the subsequent handshake, the client sends a client access message with a pre-shared key field to the server. The pre-shared key field contains information indicating the session ticket and the most recently generated PSK to inform the server that the client currently wishes to resume the session.

[0127] In addition, during the subsequent handshake process, the client access message can also optionally carry a shared key field. This is because the subsequent derived key mode can be PSK mode and PSK with Diffie-Hellman ephemeral (PSK with DHE) mode. When the subsequent derived key mode is PSK mode, the client access message does not carry a shared key field. When the subsequent derived key mode is PSK with DHE mode, the client access message carries a shared key field, and the shared key field is used to carry the key negotiation parameters required for the derived key.

[0128] For ease of understanding, the PSK with DHE mode is explained here. In the PSK with DHE mode, the client and server select a new DH parameter and send part of their own DH parameter as a key negotiation parameter in the shared key field to the other party. When both parties receive part of the DH parameter sent by the other party, they combine part of the DH parameter with their own private key and finally derive the same new PSK.

[0129] In other words, the PSK mode can be simply understood as a mode in which keys can be derived without exchanging key negotiation parameters, and the PSK with DHE mode can be simply understood as a mode in which keys can be derived only when both parties exchange key negotiation parameters.

[0130] It should be noted that in the TLS1.3 protocol, during the first handshake between the client and the server, the client will specify the derived key mode to be used when resuming subsequent sessions. For example, during the first handshake, if the client specifies that the mode to be used when resuming subsequent sessions is the PSK mode, then any session resumption after the first handshake will require the key to be derived using the PSK mode. Accordingly, if during the first handshake, the client specifies that the mode to be used when resuming subsequent sessions is the PSKwith DHE mode, then any session resumption after the first handshake will require the key to be derived using the with DHE mode.

[0131] 8) After receiving the client access message, the server searches for the most recently generated PSK based on the information indicating the most recently generated PSK in the pre-shared key field in the client access message, searches for the most recently issued session ticket based on the information indicating the session ticket in the pre-shared key field, and derives a new PSK based on the most recently generated PSK and the most recently issued session ticket to the client, so as to encrypt subsequent interactive application data based on the new PSK.

[0132] The server then returns a server access message to the client with a pre-shared key field. The pre-shared key field in the server access message contains information indicating the PSK agreed to be used by the server (that is, the new PSK derived by the server in response to the client access message) and information indicating the session ticket used by the server to derive the PSK.

[0133] Similarly, the server access message may also optionally carry a shared key field. The function of the shared key field can refer to the above explanation and will not be repeated here.

[0134] After receiving the server access message sent by the server, the client queries the locally stored session ticket based on the information in the pre-shared key field in the server access message indicating the session ticket used by the server to derive the PSK, and continues to derive a new PSK based on the found session ticket and the most recently derived PSK to encrypt subsequent interactive application data based on the new PSK.

[0135] After deriving a new PSK, the client can compare the indication information of the PSK with the information indicating the PSK agreed to be used by the server in the pre-shared key field in the received server access message. If the two are consistent, it indicates that the new PSKs derived by both parties are synchronized.

[0136] 9) The server sends its server parameters to the client, where the server parameters are used to indicate the current status of the server.

[0137] 10) The server and client send handshake completion messages to each other, indicating that the security connection has been reestablished.

[0138] 11) The client and server encrypt and exchange application data based on the newly derived PSK.

[0139] Based on the above steps, we can see that in the subsequent handshake process, since the new PSK is derived based on the session ticket and PSK in the most recent secure connection, it is equivalent to binding the currently rebuilt secure connection to the previous secure connection. Therefore, there is no need to perform the authentication phase between the client and the server, thus shortening the session recovery process.

[0140] In the above-mentioned process of exchanging application data, when the client or the server encrypts the application data based on the newly derived PSK, it does not directly encrypt the application data with the newly derived PSK, but continues to derive a new key based on the latest derived PSK to encrypt the application data based on the new key. Among them, deriving a new key based on the newly derived PSK usually includes multiple derivation operations, so deriving a new PSK based on the most recently generated PSK and deriving the key required for the current session based on the new PSK can be called a round of key derivation operations.

[0141] Figure 3 1 is a flow chart of a one-round key derivation operation provided by an embodiment of the present application. Since the operations of deriving keys on the client and the server are the same, the following embodiment is described by taking the client-derived key as an example.

[0142] like Figure 3 As shown, the client generates a PSK based on the first handshake after the first handshake. 0 The resume secret is derived and stored. The process of deriving the resume secret at this time is the same as the subsequent process of deriving the resume secret, so it will not be explained in detail.

[0143] When session recovery is required, a new PSK is derived based on the recovery key and session ticket corresponding to the most recently generated PSK. An early secret is further derived based on the new PSK, and the early secret is used to encrypt application data in early interactions, thereby achieving zero roundtrip time (RTT) in the session recovery process. For example, application data can be carried in the client access message during the session recovery process, and the application data can be encrypted using the early secret. This technology is also called 0RTT technology.

[0144] The client continues to derive the handshake secret based on the early key. Whether the handshake secret is derived based on the early key depends on whether the PSK mode or the PSK with DHE mode is currently adopted. If the PSK mode is currently adopted, the handshake secret is derived only from the early key. If the PSK with DHE mode is currently adopted, the handshake secret is derived from the early key and part of the DH parameters sent by the server, where the part of the DH parameters sent by the server can be carried in the server access message. Figure 3 Some DH parameters are labeled elliptic curve diffie-hellman (ECDH) or DH.

[0145] The client continues to derive a session key (master Secret) based on the handshake key, which is used to encrypt application data for subsequent interactions. It also derives a new resumption key based on the session key and stores the resumption key for use when the next session is resumed.

[0146] Since each time a session is restored, a new PSK is derived based on the recovery key corresponding to the last derived PSK. Therefore, it can be considered that each time a session is restored, a new PSK is derived based on the last derived PSK. In this way, a key derivation chain can be formed during multiple session restorations. In order to facilitate the subsequent comparison of whether the keys on both the client and server sides are synchronized, an index is configured for the key derivation chain on the client side. The index is used to indicate the position of the most recently generated PSK on the key derivation chain. After each round of key derivation operation, the client updates the index and stores the recovery key obtained based on the most recently generated PSK. For example, after the client performs a round of key derivation operation, it updates the index to 2, indicating that the most recently generated PSK is the second key on the key derivation chain.

[0147] It should be noted that in Figure 3 In the round of key derivation operations shown, the function used for each key derivation is the KDF function, so the derived key has forward security capability but does not have backward security capability.

[0148] Based on the above content, it can be seen that the TLS1.3 protocol supports 0RTT during the session resumption process. In addition, the TLS1.3 protocol also supports 0RTT during the first handshake.

[0149] For example, during the initial handshake process, the early data is encrypted with the early key and transmitted to the client through the new session ticket message to achieve the 0RTT of the initial handshake process. When the client later starts the session recovery, the early data is encrypted with the early key and sent to the server through the first message (client access message).

[0150] The above uses the TLS1.3 protocol as an example to illustrate how to derive keys during session recovery, and does not constitute a limitation on the key derivation method provided in the embodiments of the present application.

[0151] Figure 4 is a flowchart of a key derivation method provided in an embodiment of the present application. The method is applied to Figure 1 The first communication device shown. Figure 4 As shown, the method includes the following steps.

[0152] Step 401: A first communication device receives a session resumption request from a second communication device, where the session resumption request carries a key derivation type.

[0153] Step 402: The first communication device determines a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type. The one-sided key derivation mechanism refers to a mechanism for performing key derivation without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for performing key derivation by exchanging key negotiation parameters between the first communication device and the second communication device.

[0154] Step 403: The first communication device derives a key based on the target key derivation mechanism to encrypt the application data based on the derived key.

[0155] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0156] in, Figure 4 The implementation method of each step in the embodiment will be described in detail in subsequent embodiments and will not be described in detail here.

[0157] Figure 5 is another key derivation method flow chart provided in the embodiment of the present application. The method is applied to Figure 1The second communication device shown. Figure 5 As shown, the method includes the following steps.

[0158] Step 501: The second communication device sends a session resumption request to the first communication device, and the session resumption request carries a key derivation type, where the key derivation type is used to instruct the first communication device to determine a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type, and to derive a key based on the target key derivation mechanism to encrypt application data based on the derived key.

[0159] Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

[0160] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0161] in, Figure 5 The implementation method of each step in the embodiment will be described in detail in subsequent embodiments and will not be described in detail here.

[0162] Figure 6 is another key derivation method flow chart provided in the embodiment of the present application. The method is applied to Figure 1 The key derivation system shown in Figure 6 As shown, the method includes the following steps.

[0163] Step 601: The second communication device sends a session resumption request to the first communication device, where the session resumption request carries a key derivation type.

[0164] Accordingly, the first communication device receives a session resumption request from the second communication device.

[0165] During the communication between the second communication device and the first communication device, if the second communication device needs to resume the session, the second communication device may send a session resumption request to the first communication device to trigger the first communication device to resume the session.

[0166] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0167] Among them, the mechanisms used to derive the key include a one-sided key derivation mechanism and an interactive key derivation mechanism. The one-sided key derivation mechanism refers to a mechanism for deriving the key without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving the key by exchanging key negotiation parameters between the first communication device and the second communication device.

[0168] For example, in a scenario where the first communication device and the second communication device communicate based on the TLS 1.3 protocol, the one-sided key derivation mechanism can be understood as a mechanism for deriving keys through the aforementioned PSK mode. The interactive key derivation mechanism can be understood as a mechanism for deriving keys through the aforementioned PSK with DHE mode.

[0169] by Figure 3 For example, a one-sided key derivation mechanism can be understood as a mechanism that can derive a key without ECDH / DH parameters (i.e., key negotiation parameters). An interactive key derivation mechanism can be understood as a mechanism that requires ECDH / DH parameters to derive a key.

[0170] In some embodiments, when the value of the key derivation type is a first bit value, the session resumption request is used to instruct the first communication device to determine the one-sided key derivation mechanism as the target key derivation mechanism. When the value of the key derivation type is a second bit value, the session resumption request is used to instruct the first communication device to determine the interactive key derivation mechanism as the target key derivation mechanism.

[0171] In other words, when the value of the key derivation type is the first bit value, the target key derivation mechanism is a one-sided key derivation mechanism; when the value of the key derivation type is the second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0172] The different bit values ​​in the key derivation type can indicate that the first communication device adopts different key derivation mechanisms. This method is simple to implement.

[0173] For example, the key derivation type includes one bit. In this scenario, when the value of the key derivation type is 0, that is, the first bit value is 0, the session resumption request is used to instruct the first communication device to determine the unilateral key derivation mechanism as the target key derivation mechanism. When the value of the key derivation type is 1, that is, the first bit value is 1, the session resumption request is used to instruct the first communication device to determine the interactive key derivation mechanism as the target key derivation mechanism.

[0174] Optionally, the key derivation type may also indicate the target key derivation mechanism adopted by the first communication device in other ways. For example, the target key derivation mechanism adopted by the first communication device may be indicated in a string, which will not be described one by one here.

[0175] In addition, in some embodiments, the session resumption request is a session resumption request based on the TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries a key derivation type.

[0176] In the embodiment of the present application, in the scenario where the session resumption request is a session resumption request based on the TLS protocol, the pre-shared key field included in the session resumption request can be extended to carry the key derivation type through the pre-shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0177] For example, a type field may be extended in the pre-shared key field included in the session resumption request, and the type field is used to carry the key derivation type.

[0178] For example, in the TLS1.3 protocol, the first communication device is the server and the second communication device is the client. The client sends a client access message to the server, which includes a pre-shared key field. The pre-shared key field carries information indicating the session ticket. At this time, the client access message is used to request the server to resume the session, that is, the client access message is used as a session resumption request. In this scenario, the pre-shared key field also carries a key derivation type to indicate the mechanism used by the server to derive the key.

[0179] In addition, before the second communication device sends a session resumption request to the first communication device, when the second communication device detects that it is currently necessary to derive a key through a one-sided key derivation mechanism, the second communication device derives a key through the one-sided key derivation mechanism and generates a session resumption request. At this time, the key derivation type carried in the session resumption request is used to instruct the first communication device to use the one-sided key derivation mechanism as the target key derivation mechanism. Alternatively, when the second communication device detects that it is currently necessary to derive a key through an interactive key derivation mechanism, the second communication device generates a session resumption request. At this time, the key derivation type carried in the session resumption request is used to instruct the first communication device to use the interactive key derivation mechanism as the target key derivation mechanism. In this scenario, after the second communication device sends a session resumption request to the first communication device, the second communication device derives a key through the interactive key derivation mechanism.

[0180] That is, when the second communication device derives the key by a unilateral key derivation mechanism, the key derivation type indicates that the first communication device also derives the key by a unilateral key derivation mechanism. When the second communication device derives the key by an interactive key derivation mechanism, the key derivation type indicates that the first communication device also derives the key by an interactive key derivation mechanism. This ensures that the key on the first communication device side is synchronized with the key on the second communication device side.

[0181] Among them, the embodiment of the present application does not limit the scenario in which the second communication device currently selects a unilateral key derivation mechanism or an interactive key derivation mechanism to derive a key.

[0182] In addition, since the one-sided key derivation mechanism does not require the exchange of key negotiation parameters between the two parties, the second communication device can send a session resumption request to the first communication device after deriving the key. This can ensure that early data in the 0RTT technology of the TLS1.3 protocol is not attacked, and improve the forward security of early data in the 0RTT technology.

[0183] Figure 7 Schematic diagram of improving the forward security of early data provided by an embodiment of the present application. Figure 7 As shown, if the second communication device sends early data through a session resumption request before the key derivation operation is completed, during the transmission of the early data, if the key derivation process of the second communication device has not been completed, the second communication device still stores the recovery key generated in the previous session locally, and marks the recovery key as located in Figure 7The recovery key on the left side of PSKn-1 in the example above represents the pre-shared key generated when the current session is restored. In this scenario, if an attacker cracks the recovery key on the left side of PSKn-1 and intercepts the early data, the attacker can derive the early key from the recovery key on the left side of PSKn-1 and crack the encrypted early data using the early key.

[0184] like Figure 7 As shown, if the second communication device sends early data through a session resumption request after the derivation key operation is completed, the derivation key operation on the second communication device side has been completed during the transmission of the early data in the network. At this time, the recovery key generated during this session stored on the second communication device side is marked as Figure 7 In this scenario, even if the attacker cracks the recovery key on the right side of PSKn-1 and intercepts the early data, the early data cannot be cracked because the early key cannot be reverse analyzed through the recovery key on the right side of PSKn-1.

[0185] In addition, the interactive key derivation mechanism requires interactive key negotiation parameters between the two parties, so the second communication device can only derive the key based on the key negotiation parameters returned by the first communication device after sending the session resumption request.

[0186] For the interactive key derivation mechanism, since the interactive key derivation mechanism itself has forward and backward security, any Figure 7 An attacker who recovers the key to the left of PSKn-1 in the forward security guarantee cannot guess the early key, thus ensuring the forward security of the early data.

[0187] In addition, in the embodiment of the present application, in order to further improve the forward and backward security of data, two key derivation chains are provided, a master key derivation chain and a slave key derivation chain. The master key derivation chain consists of multiple master keys, each of which is obtained through an interactive key derivation mechanism. Each master key on the master key chain corresponds to a slave key derivation chain, and each slave key on the slave key derivation chain is obtained through a unilateral key derivation mechanism. The application data after session recovery is encrypted based on the slave key on the slave key derivation chain.

[0188] Based on this, in some embodiments, the second communication device may derive a key through a one-sided key derivation mechanism in the following manner: the second communication device derives a second slave key based on a first slave key through a one-sided key derivation mechanism, wherein the first slave key is a slave key derived from a first master key, and the first master key is a master key most recently derived by the second communication device through an interactive key derivation mechanism. Accordingly, the second communication device may derive a key through an interactive key derivation mechanism in the following manner: the second communication device derives a second master key based on a first master key through an interactive key derivation mechanism, and derives a third slave key based on the second master key.

[0189] In some embodiments, in a scenario where the second communication device and the first communication device communicate via the TLS protocol, the implementation method for the second communication device to derive the second slave key based on the first slave key via a one-sided key derivation mechanism may be: the second communication device uses the first slave key as a recovery key, and calls KDF with the recovery key and a stored session ticket to obtain the second slave key. Optionally, the implementation method for the second communication device to derive the second slave key based on the first slave key via a one-sided key derivation mechanism may be: the second communication device obtains the most recent recovery key derived based on the first slave key, and calls KDF with the obtained recovery key and the stored session ticket to obtain the second slave key. The most recent recovery key derived based on the first slave key may refer to Figure 3 The one-round key derivation operation shown is not repeated here.

[0190] In addition, the second communication device derives the second master key based on the first master key through an interactive key derivation mechanism, and derives the third slave key based on the second master key. It can be understood that the second communication device uses the first master key as a recovery key, calls KDF through the recovery key, the key negotiation parameters interacted with the first communication device, and the stored session ticket to obtain the second master key, and continues to call KDF through the second master key to obtain the third slave key.

[0191] In other embodiments, in a scenario where the second communication device and the first communication device do not communicate via the TLS protocol, the second communication device may derive the second slave key based on the first slave key via a one-sided key derivation mechanism by directly calling KDF via the first slave key to obtain the second slave key. Accordingly, the second communication device may derive the second master key based on the first master key via an interactive key derivation mechanism, and may derive the third slave key based on the second master key, which may be understood as: the second communication device may directly call KDF via the first master key and the key negotiation parameters interacted with the first communication device to obtain the second master key, and may directly continue to call KDF via the second master key to obtain the third slave key.

[0192] In other words, when updating the master key on the master key derivation chain, the first communication device and the second communication device need to exchange key negotiation parameters. However, when deriving the slave key based on the master key and updating the slave key on the slave key derivation chain, the first communication device and the second communication device do not need to exchange key negotiation parameters.

[0193] Figure 8 Schematic diagram of a master key derivation chain and a slave key derivation chain provided in an embodiment of the present application. Figure 8 As shown, it is assumed that the pre-shared key negotiated by the first communication device and the second communication device during the first handshake (ie, establishing a session) is S 0 The process of deriving the key by the first communication device and the second communication device is: 0 As the first master key in the master key derivation chain, based on the first master key S 0 Derive a key sk 00 , from the key sk 00 As the first master key S 0 The corresponding slave key derives the first slave key in the chain. And based on the slave key sk 00 Derive the second key sk 01 , through the slave key sk 01 Continue to derive a session key mk 01 Used to encrypt application data in the current session.

[0194] When the first communication device and the second communication device perform session recovery for the first time, the second communication device can indicate the key derivation mechanism used for this session recovery through the key derivation type. When the key derivation mechanism used for this session recovery is a one-sided key derivation mechanism, the process of deriving the key by the first communication device and the second communication device is as follows: based on the second slave key sk 01 Derive the third key sk 02 , through the slave key sk 02 Continue to derive a session key mk 02 Used to encrypt application data across current session resumes.

[0195] When the key derivation mechanism used for the session recovery is an interactive key derivation mechanism, the process of deriving keys by the first communication device and the second communication device is as follows: 0 Derive the second master key S 1 , through the second master key S 1 Derive a key sk 10 , from the key sk 10 As the second master key S 1 The first slave key in the corresponding slave key derivation chain. And based on the slave key sk 10Derive the second key sk 11 , through the slave key sk 11 Continue to derive a session key mk 11 Used to encrypt application data across current session resumes.

[0196] Figure 8 The derivation process of other master keys in the master key derivation chain and the derivation process of each slave key in the slave key derivation chain corresponding to each other master key can refer to the above content and will not be explained one by one here.

[0197] Wherein, in some embodiments, Figure 8 The implementation of encrypting application data based on a session key mk derived from the key sk can be referred to Figure 3 In the process, a key derivation operation of ECDH / DH parameters is not required. For example, the slave key sk is used as Figure 3 The PSK on which the key derivation operation is based in the first round n-1 , thus completing a round of key derivation operation. The specific implementation method will not be described in detail here.

[0198] Optionally, the session key mk for encrypting the application data may be derived from a slave key sk in other ways. For example, assuming that the slave key sk includes 256 bits, the last 128 bits of the slave key sk may be used as the session key mk for encrypting the application data.

[0199] It should be noted that Figure 8 The structure of the master key derivation chain and the slave key derivation chain provided by the embodiment of the present application is illustrated. The structure of the master key derivation chain and the slave key derivation chain provided by the embodiment of the present application may not be limited to Figure 8 For example, the first slave key in the slave key derivation chain corresponding to each master key can also be used directly to derive a session key, instead of Figure 8 The session key is derived starting from the second slave key in the key derivation chain as shown.

[0200] In addition, in the scenario where the second communication device and the first communication device communicate via the TLS protocol, the session resumption request sent by the second communication device may also carry a portion of application data to implement the 0RTT technology during session resumption. The application data carried in the session resumption request is encrypted using an early key.

[0201] When the key is derived through a one-sided key derivation mechanism, in some embodiments, the second communication device may generate a key based on the second slave key. Figure 3 The key derivation method shown in the figure obtains the early key. That is, the second slave key is used as the input of KDF, and KDF outputs the early key.

[0202] When deriving a key through an interactive key derivation mechanism, in some embodiments, the second communication device may generate a key based on a third slave key. Figure 3 The key derivation method shown in the figure obtains the early key. That is, the third slave key is used as the input of KDF, and KDF outputs the early key.

[0203] In addition, in some embodiments, the second communication device may also carry a key derivation parameter in the session resumption request, and the key derivation parameter is used to indicate the slave key most recently derived by the second communication device. In this way, when the first communication device subsequently derives a key through a one-sided key derivation mechanism, it can ensure that the key derived by itself and the key derived by the second communication device are synchronized based on the key derivation parameter.

[0204] For example, the key derivation parameter includes a first index indicating the number of times the second communication device derived a slave key based on the first master key before the current time. That is, the first index indicates the position of the slave key most recently derived by the second communication device in the corresponding slave key derivation chain.

[0205] By using the first index, the first communication device can subsequently determine the number of times the secondary key is currently required to be derived, so as to ensure that its secondary key derivation chain is synchronized with the secondary key derivation chain of the second communication device. The specific implementation method is referred to the subsequent step 603, which will not be described in detail here.

[0206] For example, Figure 8 The slave key derivation chain corresponding to S1 shown is used as an example for explanation. If the key derivation type carried by the session recovery request indicates that the first communication device uses the one-sided key derivation mechanism as the target key derivation mechanism, the first index is assumed to be 2, which indicates that the number of times the second communication device derived the slave key based on the first master key before the current time is 2. At this time, the second communication device has derived the slave key sk11 through the one-sided key derivation mechanism before sending the session recovery request, that is, the slave key derivation chain on the second communication device side currently grows to the position of sk11. The first index can indicate that the slave key derivation chain on the first communication device side has also grown to the position of sk11.

[0207] In some embodiments, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the first exponent.

[0208] In the embodiment of the present application, in the scenario where the session resumption request is a session resumption request based on the TLS protocol, the pre-shared key field included in the session resumption request can be extended to carry the first exponent through the pre-shared key field. In this way, the key derivation method provided in the embodiment of the present application can be well compatible with the TLS protocol, thereby improving the application flexibility of the embodiment of the present application.

[0209] In addition, in a scenario where the key derivation type carried in the session recovery request indicates that the first communication device uses the interactive key derivation mechanism as the target key derivation mechanism, the implementation method for the second communication device to derive the second master key based on the first master key through the interactive key derivation mechanism may be: the second communication device obtains its own second key negotiation parameters and the first key negotiation parameters sent by the first communication device, and the second communication device derives the second master key based on the first key negotiation parameters, the second key negotiation parameters and the first master key.

[0210] That is, when deriving a key through the interactive key derivation mechanism, the second communication device needs to obtain the key negotiation parameters of the first communication device, and then derive the second master key based on the key negotiation parameters of both parties.

[0211] Furthermore, the session resumption request sent by the second communication device may also carry a second key negotiation parameter, so that the first communication device can quickly derive a key based on the second key negotiation parameter and its own first key negotiation parameter. Accordingly, the second communication device receives a session resumption response sent by the first communication device, and the session resumption response carries the first key negotiation parameter of the first communication device.

[0212] That is, in the scenario where the key derivation type carried by the session resumption request indicates that the first communication device uses the interactive key derivation mechanism as the target key derivation mechanism, the first communication device and the second communication device can obtain each other's key negotiation parameters through the interactive session resumption request and the session resumption response to derive the key through the interactive key derivation mechanism.

[0213] For example, the session resumption request is a session resumption request based on the TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable (random variable, RV), and the first RV is used to carry the second key negotiation parameter; the session resumption response is a session resumption response based on the TLS protocol, the session resumption response includes a second shared key field, the second shared key field carries a second RV, and the second RV is used to carry the first key negotiation parameter.

[0214] In the embodiments of the present application, in a scenario where a first communication device and a second communication device communicate based on the TLS protocol, the shared key field included in the session resumption request and the session resumption response can be extended to carry a second key negotiation parameter and a first key negotiation parameter through the RV in the shared key field. In this way, the key derivation method provided by the embodiments of the present application can be well compatible with the TLS protocol, improving the application flexibility of the embodiments of the present application.

[0215] For example, in TLS 1.3, the first communication device is a server, and the second communication device is a client. The client sends a client access message to the server. The client access message includes a pre-shared key field that carries information indicating a session ticket. At this time, the client access message is used to request the server to resume the session, that is, the client access message serves as a session resumption request. And the pre-shared key field also carries a key derivation type, which is used to indicate that the target key derivation mechanism is an interactive key derivation mechanism. In this scenario, the client access message also carries a shared key field that carries an RV, and the RV is used to carry the second key negotiation parameter. Correspondingly, the server access message (serving as a session resumption response) returned by the server to the client also carries a shared key field that carries an RV, and the RV is used to carry the first key negotiation parameter.

[0216] The following uses an example to illustrate the generation process of the first key negotiation parameter and the second key negotiation parameter.

[0217] Suppose the first communication device is device A, the second communication device is device B, and device A and device B exchange key negotiation parameters based on an elliptic curve. Suppose the common parameters of the elliptic curve Ep(x,y) are: p and G. Where p is a large prime number, G is the base point of the elliptic curve, and the order of G is w.

[0218] The process for device A to generate the first key negotiation parameter X is: generate a random number x_seed, and x_seed < w; calculate the first key negotiation parameter X = x_seed * G * mod w;

[0219] The process for device B to generate the second key negotiation parameter Y is: generate a random number y_seed, and y_seed < w; calculate the second key negotiation parameter Y = y_seed * G * mod w;

[0220] Device A combines the second key negotiation parameter Y, and device B combines the first key negotiation parameter X, and both obtain the shared secret Secret_ab = Y * x_seed * mod w = X * y_seed * mod w. Based on this shared secret, both parties can derive the same key to complete the key negotiation.

[0221] Step 602: The first communication device determines a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type. The one-sided key derivation mechanism refers to a mechanism for performing key derivation without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for performing key derivation by exchanging key negotiation parameters between the first communication device and the second communication device.

[0222] In some embodiments, in a scenario where the first communication device adopts different key derivation mechanisms indicated by different bit values ​​in the key derivation type, the first communication device determines the target key derivation mechanism from the unilateral key derivation mechanism and the interactive key derivation mechanism based on the key derivation type in an implementation manner that: when the value of the key derivation type is a first bit value, the first communication device determines the unilateral key derivation mechanism as the target key derivation mechanism. When the value of the key derivation type is a second bit value, the first communication device determines the interactive key derivation mechanism as the target key derivation mechanism.

[0223] In other words, when the value of the key derivation type is the first bit value, the target key derivation mechanism is a one-sided key derivation mechanism; when the value of the key derivation type is the second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0224] The different bit values ​​in the key derivation type can indicate that the first communication device adopts different key derivation mechanisms. This method is simple to implement.

[0225] The following explanation of step 602 is given by taking the session resumption request as a session resumption request based on the TLS protocol, the session resumption request including a pre-shared key field, and the pre-shared key field carrying a key derivation type as an example.

[0226] In this scenario, the first communication device is a server and the second communication device is a client. When the first communication device receives a client access message sent by the second communication device, if the client access message carries information indicating a session ticket, the client access message is used as a session resumption request. The pre-shared key field in the session resumption request is parsed, and the key derivation type is obtained from the pre-shared key field.

[0227] When the value of the key derivation type is 0, the target key derivation mechanism is determined to be a one-sided key derivation mechanism. When the value of the key derivation type is 1, the target key derivation mechanism is determined to be an interactive key derivation mechanism.

[0228] Optionally, in a scenario where the second communication device indicates the key derivation mechanism adopted by the first communication device in other ways, the first communication device may also analyze the key derivation type to determine the target key derivation mechanism, which is not illustrated one by one here.

[0229] Step 603: The first communication device derives a key based on the target key derivation mechanism to encrypt application data based on the derived key.

[0230] In the scenario where an embodiment of the present application provides both a master key derivation chain and a slave key derivation chain, the first communication device derives a key based on a target key derivation mechanism, and the implementation method for encrypting application data based on the derived key can be: when the target key derivation mechanism is a one-sided key derivation mechanism, the first communication device derives a second slave key based on a first slave key through a one-sided key derivation mechanism, so as to encrypt application data based on the second slave key, the first slave key being a slave key derived based on the first master key, and the first master key being the master key most recently derived by the first communication device through an interactive key derivation mechanism; when the target key derivation mechanism is an interactive key derivation mechanism, the first communication device derives a second master key based on the first master key through an interactive key derivation mechanism, and derives a third slave key based on the second master key, so as to encrypt application data based on the third slave key.

[0231] In some embodiments, the session resumption request also carries a key derivation parameter, and the key derivation parameter indicates the slave key most recently derived by the second communication device. In this scenario, the first communication device derives the second slave key based on the first slave key through a one-sided key derivation mechanism in the following manner: the first communication device derives the second slave key based on the key derivation parameter and the first slave key through a one-sided key derivation mechanism, so that the second slave key is synchronized with the slave key most recently derived by the second communication device.

[0232] By carrying the key derivation parameter in the session resumption request, the first communication device can ensure that the key derived by itself and the key derived by the second communication device are synchronized based on the key derivation parameter when deriving the key through the one-sided key derivation mechanism.

[0233] For example, the key derivation parameter includes a first index, and the first index indicates the number of times the second communication device derived the slave key based on the first master key before the current time. In this scenario, the first communication device derives the second slave key based on the key derivation parameter and the first slave key through a one-sided key derivation mechanism in the following manner: the first communication device obtains a second index, and the second index indicates the number of times the first communication device derived the slave key based on the first master key before the current time; if the first index is greater than or equal to the sum of the second index and 1, the first communication device determines the difference between the first index and the second index to obtain n; the first communication device performs n key derivation operations based on the first slave key through the one-sided key derivation mechanism to obtain the second slave key.

[0234] If the first index is equal to the sum of the second index and 1, n is 1, indicating that the keys on the slave key derivation chain on the first communication device side and the second communication device side are well synchronized, and the first communication device only needs one key derivation operation to obtain the second slave key synchronized with the second communication device side. If the first index is greater than the sum of the second index and 1, n is an integer greater than 1, indicating that the keys on the slave key derivation chain on the first communication device side and the second communication device side cannot be synchronized through one key derivation operation, so it is necessary to perform key derivation operations multiple times to obtain the second slave key synchronized with the second communication device side. That is, in the scenario where the first index is greater than or equal to the sum of the second index and 1, the first communication device can repair its own slave key derivation chain through a unilateral key derivation mechanism so that the repaired slave key derivation chain is synchronized with the slave key derivation chain on the second communication device side.

[0235] Fig. 9 is a schematic diagram of a scenario where n is greater than 1 provided in an embodiment of the present application. Fig. 9 As shown, the second communication device is assumed to be a terminal device, and the first communication device is assumed to be an authentication server. Assume that the first index ( Fig. 9 The first index is marked as index c ) and the second index stored on the authentication server side ( Fig. 9 The second index is marked as index s ) are both i, that is, the slave key derived from the most recent session recovery between the two parties is located at the i-th slave key position in the slave key derivation chain. At this time, the slave key on the terminal device side and the slave key on the authentication server side are synchronized.

[0236] The terminal device subsequently initiates a session recovery request and derives the i+1th slave key in the key derivation chain before initiating the session recovery request. Therefore, the first index carried by this session recovery request is i+1. However, the session recovery request is not received by the authentication server due to packet loss or malicious blocking.

[0237] Subsequently, the terminal device initiates a session recovery request again, and derives the (i + 2)-th subordinate key in the key derivation chain before initiating the session recovery request. Therefore, the first exponent carried in this session recovery request is i + 2. When the session recovery request is received by the authentication server, since the second exponent stored on the authentication server side is still i, and the difference between the first exponent and the second exponent is greater than 1, it indicates that two key derivation operations are required to synchronize the subordinate key on the authentication server side with the subordinate key on the terminal device side.

[0238] In some embodiments, in a scenario where the first communication device communicates with the second communication device based on the TLS protocol, the implementation manner of the first communication device performing n key derivation operations based on the first subordinate key through the unilateral key derivation mechanism may be as follows: The first communication device sets j = 0, determines the recovery key based on the first subordinate key, derives a subordinate key based on the recovery key and the session ticket stored at the current time, and sets j = j + 1. Then, the derived subordinate key is used as the first subordinate key, and the operation of determining the recovery key based on the first subordinate key is returned and executed until j is the same as n. Then, the last derived subordinate key is used as the second subordinate key.

[0239] Among them, each time the first communication device determines the recovery key based on the first subordinate key and derives a subordinate key based on the recovery key and the session ticket stored at the current time, it can refer to the relevant content of the second communication device deriving the key through the unilateral key derivation mechanism described above, which will not be elaborated here.

[0240] Optionally, in some other embodiments, the first communication device may also adopt other methods to perform n key derivation operations based on the first subordinate key through the unilateral key derivation mechanism.

[0241] Fig.10 It is a schematic flowchart of a process for deriving a second subordinate key based on a first exponent and a second exponent provided by an embodiment of the present application. As Fig.10 shown, assume that the first exponent carried in the session recovery request is index`, and the second exponent locally stored by the first communication device is index s , and the first communication device determines the difference n between the first exponent and the second exponent, that is, n = index` - index s . If the difference is greater than 1, n key derivation operations are performed through the code in the right box. The last derived key sk is used as the second subordinate key.

[0242] Exemplarily, as Fig.10 shown in the right box in s , if n > 1, that is, index` - index s > 1, that is, 1 + index s+1 to each integer in index`, for each value of i, the last determined secondary key and i are input into KDF, and the value output by KDF is used as the currently derived secondary key. Fig.10 The code on the right can achieve synchronization of the slave key derivation chain on the first communication device side and the slave key derivation chain on the second communication device side through n key derivation operations.

[0243] It should be noted that Fig.10 The key derivation method in the right box is only used for illustration and does not constitute a limitation on the key derivation method provided in the embodiment of the present application.

[0244] like Fig.10 As shown, in some embodiments, after obtaining the second slave key sk, the second slave key sk and index` can be input into KDF, and the key output by KDF is used as the session key mk to encrypt application data of subsequent session processes.

[0245] In addition, after the first communication device obtains the second index, if the first index is less than the sum of the second index and 1, it indicates that the first communication device cannot derive a key synchronized with the second communication device through a one-sided key derivation mechanism. Therefore, the first communication device needs to derive the second master key based on the first master key through an interactive key derivation mechanism, and derive the third slave key based on the second master key to encrypt the application data based on the third slave key.

[0246] In the embodiment of the present application, when the key derivation type indicates that the target key derivation mechanism is a one-sided key derivation mechanism, since the second communication device sends the session resumption request only after it has derived the slave key, that is, the second communication device derives the key first and the first communication device derives the key later, when the first communication device receives the session resumption request, the second index stored on the first communication device side is in principle smaller than the first index carried in the session resumption request. Therefore, if the first index is smaller than the sum of the second index and 1, it indicates that the slave key derivation chains on the second communication device side or the first communication device side cannot be synchronized through the one-sided key derivation mechanism. Therefore, in this scenario, both parties need to derive a new master key through the interactive key derivation mechanism, thereby opening a new slave key derivation chain based on the master key to ensure synchronization of the slave key derivation chains of both parties.

[0247] Among them, the first communication device derives the second master key based on the first master key through an interactive key derivation mechanism, and derives the third slave key based on the second master key. The implementation method of encrypting application data through the third slave key can refer to the relevant content of the derived key of the aforementioned second communication device, which will not be repeated here.

[0248] By way of example, the implementation method in which the first communication device derives the second master key based on the first master key through an interactive key derivation mechanism may be: the first communication device obtains its own first key negotiation parameter and the second key negotiation parameter sent by the second communication device; the first communication device derives the second master key based on the first key negotiation parameter, the second key negotiation parameter and the first master key.

[0249] Among them, the implementation method of the first communication device deriving the second master key based on the first key negotiation parameter, the second key negotiation parameter and the first master key can refer to the relevant content of the second communication device deriving the key through the interactive key derivation mechanism, which will not be repeated here.

[0250] In addition, the relevant contents about the first key negotiation parameter and the second key negotiation parameter can also refer to the relevant contents about the key derivation by the second communication device through the interactive key derivation mechanism, which will not be repeated here.

[0251] In addition, in some embodiments, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the first exponent.

[0252] In this scenario, the first communication device is a server and the second communication device is a client. When the first communication device receives a client access message sent by the second communication device, if the client access message carries information indicating a session ticket, the client access message is used as a session resumption request. The pre-shared key field in the session resumption request is parsed, and the first index is obtained from the pre-shared key field.

[0253] Fig.11 FIG. 1 is another flow chart of deriving a key based on a first index and a second index provided in an embodiment of the present application. Fig.11 As shown, when the first communication device receives a session resumption request from the second communication device, as shown in Fig.11 As shown, the processing logic on the first communication device side is as follows:

[0254] 1) The first communication device first performs message integrity and authenticity verification on the session resumption request through an existing identity authentication method such as an identity authentication key. If the authentication fails, the session resumption request will be directly discarded. If the authentication succeeds, the process proceeds to step 2);

[0255] 2) The first communication device determines the key derivation type in the session resumption request:

[0256] If the value of the key derivation type is 0, take out the first index index in the session recovery request and compare it with the index maintained by itself s To compare. s+1 = index`, the key derivation chains on both sides are synchronized well. Unilateral self-synchronization is completed through one key derivation. At this time Figure 8 a new subordinate key is added to the subordinate key derivation chain corresponding to the rightmost master key in s This process can be called slave round drive. If index Figure 8 Figure 8 s +1 < index`, the key derivation chains on both sides are out of sync. Unilateral self-synchronization is completed through multiple key derivations. At this time

[0257] a number of subordinate keys are continuously added to the subordinate key derivation chain corresponding to the rightmost master key in

[0258] Fig.12 This process can also be called slave round drive. If index Fig.12 Fig.12 n +1 > index`, then the key derivation chains on both sides are abnormal. At this time, the synchronization of the key derivation chains on both sides cannot be achieved through the unilateral key derivation mechanism. Therefore, it is necessary to start the cooperative synchronization process. The cooperative synchronization process is to derive a new master key through the interactive key derivation mechanism to start a new subordinate key derivation chain. Therefore, this process can be called master round rotation and slave round initialization. n n

[0257] n n

[0258] n Fig.12

[0259] Fig.12 Fig.12As shown, the master key derivation chain and each slave key derivation chain are like a double-wheel structure. When a new slave key is derived from the slave key derivation chain, the slave wheel rotates. The derivation process can be completed through a one-sided key derivation mechanism. The cryptographic operations involved are all symmetric operations, which are fast and lightweight, and can achieve fast derivation. When a new master key is derived from the master key derivation chain, the two communication devices work together to start a new slave key chain. This process is similar to the rotation of the master wheel to drive the slave wheel to initialize.

[0260] Fig.13 is a schematic diagram comparing a dual key derivation chain and a single key derivation chain provided in an embodiment of the present application. Fig.13 As shown, in the scenario of a single key derivation chain, at each session resumption, the key ST derived from the last time is used. n-1 Derive the key ST required for the current session n , and whether parameters need to be negotiated during the key derivation process is directly specified during the first handshake.

[0261] However, in the scenario of dual key derivation chains, at each session resumption, the key derivation type in the session resumption request can be used to select whether to continue deriving a new slave key on the slave key chain through the unilateral key derivation mechanism, or to directly derive a new master key through the interactive key derivation mechanism and start a new slave key chain.

[0262] It should be noted that Fig.13 For other content, please refer to Fig.12 and Fig.10 The relevant content will not be repeated here.

[0263] The following is an explanation of the embodiments of the present application by taking the communication between the first communication device and the second communication device based on the TLS1.3 protocol as an example.

[0264] Fig.14 This is a schematic diagram of the format of an extended client access message and a server access message provided in an embodiment of the present application.

[0265] like Fig.14 As shown, the shared key field and the pre-shared key field in the client access message and the server access message in the existing TLS protocol 1.3 are extended. For example, the type field and the index field are extended in the pre-shared key field, the type field is used to carry the key derivation type, and the exponent field is used to carry the exponent on this side. The RV field is extended in the shared key field. When the key derivation type indicates that the target key derivation mechanism is a one-sided key derivation mechanism, the value in the RV field is a random number used to prevent replay attacks. When the key derivation type indicates that the target key derivation mechanism is an interactive key derivation mechanism, the value in the RV field is a key negotiation parameter.

[0266] The three extended fields described above can be used to derive a key to encrypt application data. Specifically, for each derived slave key, on the one hand, an early key can be derived based on the slave key to encrypt early data in a client access message or a server access message. On the other hand, a session key can be derived based on the slave key to encrypt subsequent application data exchanged between the two parties.

[0267] In addition, if Fig.14 As shown, the client access message and the server access message may also include a secure connection identifier, which is marked as SID. The secure connection identifier is used to uniquely identify the secure connection between the current client and the server. The secure connection identifier may be a session ID, or a client identifier and / or a server identifier. For the relevant content of SID, please refer to the TLS protocol, which will not be described in detail here.

[0268] At present, in the TLS protocol, attackers can use the client retry behavior to make the server receive multiple copies of the application message, forming a replay network attack. For example, suppose there are currently servers A and B, and servers A and B are used to provide the same service, and server B does not accept the session ticket from server A. In this scenario, the attacker can copy the client access message originally sent to server A (carrying early data for server A) to both server A and server B. On server A, the early data will be accepted, and then the server response message will be replied to the client. However, on server B, since the server cannot recognize the session ticket in the client access message, server B will reject the early data and force a full handshake with the client (that is, create a session). In this scenario, if the attacker also blocks the server access message from server A, the client will complete the handshake with server B, allowing the attacker to achieve a replay attack on server B, causing system disorder.

[0269] However, in the embodiment of the present application, if the attacker copies the client access message originally sent to server A (carrying early data for server A) to both server A and server B. At server A, the early data will be accepted, and then the server response message will be replied to the client. The index carried by the server response message is the index updated after the key is derived, that is, the increased index. If the attacker blocks the server access message from server A and synchronizes the server access message to server B, since the index in the server response message sent by server A has been increased, the index stored in server B will also be the increased index. In this scenario, if the client access message from server A is replayed on server B, server B will find that the index in the client access message does not meet the condition of being greater than the index stored locally, so server B will recognize that an attack has occurred in the network, thereby initiating an interactive synchronization operation with the master key derivation chain on the client side, causing the attacker's replay attack to fail.

[0270] In addition, based on the aforementioned relevant content about the TLS1.3 protocol, it is known that the key derivation mode used for subsequent session resumption needs to be specified when the client and the server shake hands for the first time. Since the key derivation mode provided in the embodiment of the present application is different from the two key derivation modes provided in the existing TLS1.3 protocol, a third key derivation mode is extended in the embodiment of the present application. Since the extended third key derivation mode is equivalent to a hybrid processing of the two key derivation modes provided in the existing TLS1.3 protocol, the third key derivation mode can be called a hybrid key derivation mode.

[0271] Based on this, during the first handshake, that is, when creating a session, the second communication device can specify that a hybrid key derivation mode be used when the subsequent session is resumed. In this way, the second communication device and the first communication device can derive a key based on the key derivation method provided in the embodiment of the present application when resuming the session.

[0272] Therefore, before the second communication device sends a session resumption request to the first communication device, the second communication device also sends a session creation request to the first communication device, the session creation request carrying the hybrid key derivation mode. Accordingly, the first communication device receives the session creation request from the second communication device.

[0273] The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

[0274] That is, when the first communication device and the second communication device have their first conversation, the second communication device specifies the key derivation mode. If the specified key derivation mode is the aforementioned PSK mode, then each time the session is resumed, the key is derived through a one-sided key derivation mechanism. If the specified key derivation mode is the aforementioned PSKwith DH mode, then each time the session is resumed, the key is derived through an interactive key derivation mechanism. If the specified key derivation mode is the aforementioned hybrid key derivation mode, then each time the session is resumed, a target key derivation mechanism is first selected based on the current scenario requirements, and then the key derivation type is used to specify the target key derivation mechanism currently used. This improves the flexibility of the embodiments of the present application.

[0275] In summary, in the embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, the key derivation type is extended in the session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0276] Fig.15 is a schematic diagram of the structure of a key derivation device provided in an embodiment of the present application. The device is deployed in the first communication device in the aforementioned embodiment, such as Fig.15 As shown, the device 1500 includes the following modules.

[0277] The receiving module 1501 is configured to receive a session resumption request from a second communication device, where the session resumption request carries a key derivation type. Figure 6 Step 601 in the embodiment.

[0278] The determination module 1502 is used to determine the target key derivation mechanism from the one-sided key derivation mechanism and the interactive key derivation mechanism based on the key derivation type. Figure 6 Step 602 in an embodiment.

[0279] The derivation module 1503 is used to derive a key based on the target key derivation mechanism to encrypt the application data based on the derived key. For specific implementation methods, please refer to Figure 6 Step 603 in the embodiment.

[0280] Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

[0281] Optionally, when the value of the key derivation type is a first bit value, the target key derivation mechanism is a one-sided key derivation mechanism; when the value of the key derivation type is a second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0282] Optionally, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries a key derivation type.

[0283] Optionally, the derived modules include:

[0284] a first derivation unit, configured to derive a second slave key based on a first slave key through a one-sided key derivation mechanism to encrypt application data based on the second slave key when the target key derivation mechanism is a one-sided key derivation mechanism, wherein the first slave key is a slave key derived from a first master key, and the first master key is a master key derived by the first communication device most recently through an interactive key derivation mechanism;

[0285] The second derivation unit is used to derive the second master key based on the first master key through the interactive key derivation mechanism when the target key derivation mechanism is an interactive key derivation mechanism, and to derive the third slave key based on the second master key to encrypt application data based on the third slave key.

[0286] Optionally, the session resumption request further carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communication device;

[0287] The first derived unit is used for:

[0288] The second slave key is derived based on the key derivation parameter and the first slave key through a one-sided key derivation mechanism, so that the second slave key is synchronized with the slave key most recently derived by the second communication device.

[0289] Optionally, the key derivation parameter includes a first index indicating the number of times the second communication device derived the slave key based on the first master key before the current time;

[0290] The first derived unit is used for:

[0291] Obtaining a second index, where the second index indicates the number of times before the current time that the first communication device derives a slave key based on the first master key;

[0292] If the first index is greater than or equal to the sum of the second index and 1, then the difference between the first index and the second index is determined to obtain n;

[0293] A second slave key is obtained by performing n key derivation operations based on the first slave key through a one-sided key derivation mechanism.

[0294] Optionally, the second deriving unit is further used for:

[0295] If the first exponent is less than the sum of the second exponent and 1, a second master key is derived based on the first master key through an interactive key derivation mechanism, and a third slave key is derived based on the second master key to encrypt application data based on the third slave key.

[0296] Optionally, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the first exponent.

[0297] Optionally, the second deriving unit is used to:

[0298] Acquire a first key negotiation parameter of the device and a second key negotiation parameter sent by the second communication device;

[0299] A second master key is derived based on the first key negotiation parameter, the second key negotiation parameter, and the first master key.

[0300] Optionally, the session resumption request further carries a second key negotiation parameter;

[0301] The device also includes a sending module, which is used to:

[0302] A session resumption response is sent to the second communication device, where the session resumption response carries the first key negotiation parameter.

[0303] Optionally, the session resumption request is a session resumption request based on a transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry a second key negotiation parameter;

[0304] The session resumption response is a session resumption response based on the TLS protocol. The session resumption response includes a second shared key field. The second shared key field carries a second RV. The second RV is used to carry the first key negotiation parameter.

[0305] Optionally, the receiving module is further used for:

[0306] receiving a session creation request from a second communication device, the session creation request carrying a hybrid key derivation mode;

[0307] The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

[0308] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0309] It should be noted that: the key derivation device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate when performing key derivation. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the key derivation device provided in the above embodiment and the key derivation method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0310] Fig.16 is a schematic diagram of the structure of a key derivation device provided in an embodiment of the present application, and the device is deployed in the second communication device in the aforementioned embodiment, such as Fig.16 As shown, the device 1600 includes the following modules.

[0311] The sending module 1601 is used to send a session resumption request to the first communication device. The session resumption request carries a key derivation type. The key derivation type is used to instruct the first communication device to determine a target key derivation mechanism from a unilateral key derivation mechanism and an interactive key derivation mechanism based on the key derivation type, and derive a key based on the target key derivation mechanism to encrypt application data based on the derived key. For specific implementation methods, please refer to Figure 6 Step 601 in the embodiment.

[0312] Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

[0313] Optionally, when the value of the key derivation type is a first bit value, the target key derivation mechanism is a one-sided key derivation mechanism;

[0314] In case the value of the key derivation type is the second bit value, the target key derivation mechanism is an interactive key derivation mechanism.

[0315] Optionally, the session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries a key derivation type.

[0316] Optionally, the device further comprises a derivation module and a generation module, the derivation module comprising a first derivation unit and a second derivation unit;

[0317] A first derivation unit is used to derive a key through a one-sided key derivation mechanism, and a generation module is used to generate a session resumption request, wherein the key derivation type is used to indicate that the first communication device uses the one-sided key derivation mechanism as a target key derivation mechanism; or,

[0318] A generating module is used to generate a session resumption request, wherein the key derivation type is used to instruct the first communication device to use the interactive key derivation mechanism as the target key derivation mechanism; and a second derivation unit is used to derive a key through the interactive key derivation mechanism.

[0319] Optionally, the first deriving unit is used to:

[0320] Deriving a second slave key based on the first slave key through a one-sided key derivation mechanism, wherein the first slave key is a slave key derived based on the first master key, and the first master key is a master key most recently derived by the second communication device through the interactive key derivation mechanism;

[0321] The second derived unit is used for:

[0322] A second master key is derived based on the first master key through an interactive key derivation mechanism, and a third slave key is derived based on the second master key.

[0323] Optionally, the session resumption request further carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communication device.

[0324] Optionally, the key derivation parameter includes a first index indicating the number of times the second communication device derives the slave key based on the first master key before the current time.

[0325] Optionally, the second deriving unit is used to:

[0326] Acquire its own second key negotiation parameter and the first key negotiation parameter sent by the first communication device;

[0327] A second master key is derived based on the first key negotiation parameter, the second key negotiation parameter, and the first master key.

[0328] Optionally, the session resumption request further carries a second key negotiation parameter of the second communication device; the device further includes:

[0329] The receiving module is used to receive a session resumption response sent by the first communication device, where the session resumption response carries a first key negotiation parameter of the first communication device.

[0330] Optionally, the session resumption request is a session resumption request based on a transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry a second key negotiation parameter;

[0331] The session resumption response is a session resumption response based on the TLS protocol. The session resumption response includes a second shared key field. The second shared key field carries a second RV. The second RV is used to carry the first key negotiation parameter.

[0332] Optionally, the sending module is further used for:

[0333] Sending a session creation request to the first communication device, where the session creation request carries a hybrid key derivation mode;

[0334] The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

[0335] In an embodiment of the present application, in order to improve the flexibility of deriving keys when resuming a session, a key derivation type is extended in a session resumption request, and the key derivation type can flexibly indicate the mechanism used by the first communication device to derive keys. This can avoid the first communication device and the second communication device using the same mechanism to derive keys in multiple session resumes after the first handshake. And through the key derivation type, the second communication device can flexibly indicate the mechanism used by the first communication device to derive keys when resuming the session according to different scenarios, thereby improving the flexibility of key derivation.

[0336] It should be noted that: the key derivation device provided in the above embodiment only uses the division of the above functional modules as an example to illustrate when performing key derivation. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the key derivation device provided in the above embodiment and the key derivation method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0337] Fig.17is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The first communication device or the second communication device in the aforementioned embodiment can be Fig.17 The computer device shown is implemented. Fig.17 The computer device includes a processor 1701, a communication bus 1702, a memory 1703 and at least one communication interface 1704.

[0338] The processor 1701 may be a general-purpose central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0339] The communication bus 1702 is used to transmit information between the above components.

[0340] The memory 1703 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a disk or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1703 may exist independently and be connected to the processor 1701 via the communication bus 1702. The memory 1703 may also be integrated with the processor 1701.

[0341] The memory 1703 is used to store the program code for executing the solution of the present application, and the execution is controlled by the processor 1701. The processor 1701 is used to execute the program code stored in the memory 1703. The program code may include one or more software modules. The first communication device or the second communication device in the aforementioned embodiment can determine the data for developing the application through the processor 1701 and one or more software modules in the program code in the memory 1703.

[0342] The communication interface 1704 uses any transceiver or other device to communicate with other devices or communication networks. The communication network can be Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.

[0343] In a specific implementation, as an embodiment, a computer device may include multiple processors, such as Fig.17 1701 and processor 1705 shown in FIG. Each of these processors may be a single-CPU processor or a multi-CPU processor. A processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0344] In a specific implementation, as an embodiment, the computer device may further include an output device 1706 and an input device 1707. The output device 1706 communicates with the processor 1701 and may display information in a variety of ways. For example, the output device 1706 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 1707 communicates with the processor 1701 and may receive user input in a variety of ways. For example, the input device 1707 may be a mouse, a keyboard, a touch screen device, or a sensor device.

[0345] The above-mentioned computer device can be a general-purpose computer device or a special-purpose computer device. In a specific implementation, the computer device can be a desktop computer, a portable computer, a network server, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device or an embedded device. The embodiment of the present application does not limit the type of computer device.

[0346] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0347] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0348] The above-described embodiments are provided for the present application and are not intended to limit the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application shall be included in the protection scope of the embodiments of the present application.

Claims

1. A key derivation method, characterized in that: The method comprises: The first communication device receives a session resumption request from the second communication device, wherein the session resumption request carries a key derivation type; The first communication device determines a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type; The first communication device derives a key based on the target key derivation mechanism to encrypt application data based on the derived key; Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

2. The method according to claim 1, characterized in that In a case where the value of the key derivation type is a first bit value, the target key derivation mechanism is the one-sided key derivation mechanism; In case the value of the key derivation type is the second bit value, the target key derivation mechanism is the interactive key derivation mechanism.

3. The method according to claim 1 or 2, characterized in that The session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the key derivation type.

4. The method according to any one of claims 1 to 3, characterized in that: The first communication device derives a key based on the target key derivation mechanism to encrypt application data based on the derived key, comprising: In the case where the target key derivation mechanism is the one-sided key derivation mechanism, the first communication device derives a second slave key based on a first slave key through the one-sided key derivation mechanism, so as to encrypt the application data based on the second slave key, wherein the first slave key is a slave key derived from a first master key, and the first master key is a master key most recently derived by the first communication device through the interactive key derivation mechanism; When the target key derivation mechanism is the interactive key derivation mechanism, the first communication device derives a second master key based on the first master key through the interactive key derivation mechanism, and derives a third slave key based on the second master key to encrypt the application data based on the third slave key.

5. The method according to claim 4, characterized in that The session resumption request also carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communication device; The first communication device derives a second slave key based on the first slave key through the one-sided key derivation mechanism, including: The first communication device derives the second slave key based on the key derivation parameter and the first slave key through the one-sided key derivation mechanism, so that the second slave key is synchronized with the slave key most recently derived by the second communication device.

6. The method according to claim 5, characterized in that The key derivation parameter includes a first index indicating the number of times before a current time that the second communication device derives a slave key based on the first master key; The first communication device derives the second slave key based on the key derivation parameter and the first slave key through the one-sided key derivation mechanism, including: The first communication device acquires a second index, where the second index indicates the number of times the first communication device derives a slave key based on the first master key before a current time; If the first index is greater than or equal to the sum of the second index and 1, the first communication device determines a difference between the first index and the second index to obtain n; The first communication device performs n key derivation operations based on the first slave key through the one-sided key derivation mechanism to obtain the second slave key.

7. The method according to claim 6, characterized in that After the first communication device acquires the second index, the method further includes: If the first exponent is less than the sum of the second exponent and 1, the first communication device derives the second master key based on the first master key through the interactive key derivation mechanism, and derives the third slave key based on the second master key to encrypt the application data based on the third slave key.

8. The method according to claim 6 or 7, characterized in that The session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the first index.

9. The method according to any one of claims 4 to 8, characterized in that: The first communication device derives a second master key based on the first master key through the interactive key derivation mechanism, including: The first communication device obtains its own first key negotiation parameter and a second key negotiation parameter sent by the second communication device; The first communication device derives the second master key based on the first key negotiation parameter, the second key negotiation parameter, and the first master key.

10. The method according to claim 9, characterized in that The session resumption request also carries the second key negotiation parameter; After the first communication device receives the session resumption request from the second communication device, the method further includes: The first communication device sends a session resumption response to the second communication device, where the session resumption response carries the first key negotiation parameter.

11. The method according to claim 10, characterized in that The session resumption request is a session resumption request based on the transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry the second key negotiation parameter; The session resumption response is a session resumption response based on the TLS protocol, and the session resumption response includes a second shared key field, the second shared key field carries a second RV, and the second RV is used to carry the first key negotiation parameter.

12. The method according to any one of claims 1 to 11, characterized in that: Before the first communication device receives the session resumption request from the second communication device, the method further includes: The first communication device receives a session creation request from the second communication device, the session creation request carrying a hybrid key derivation mode; The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

13. A key derivation method, characterized in that: The method comprises: The second communication device sends a session resumption request to the first communication device, wherein the session resumption request carries a key derivation type, and the key derivation type is used to instruct the first communication device to determine a target key derivation mechanism from a unilateral key derivation mechanism and an interactive key derivation mechanism based on the key derivation type, and derive a key based on the target key derivation mechanism, so as to encrypt application data based on the derived key; Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

14. The method according to claim 13, characterized in that In a case where the value of the key derivation type is a first bit value, the target key derivation mechanism is the one-sided key derivation mechanism; In case the value of the key derivation type is the second bit value, the target key derivation mechanism is the interactive key derivation mechanism.

15. The method according to claim 13 or 14, characterized in that The session resumption request is a session resumption request based on the Transport Layer Security TLS protocol, and the session resumption request includes a pre-shared key field, and the pre-shared key field carries the key derivation type.

16. The method according to any one of claims 13 to 15, characterized in that: Before the second communication device sends a session resumption request to the first communication device, the method further includes: The second communication device derives a key through the one-sided key derivation mechanism and generates the session resumption request, wherein the key derivation type is used to indicate that the first communication device uses the one-sided key derivation mechanism as the target key derivation mechanism; or, The second communication device generates the session resumption request, wherein the key derivation type is used to instruct the first communication device to use the interactive key derivation mechanism as the target key derivation mechanism; after the second communication device sends the session resumption request to the first communication device, the method also includes: the second communication device derives a key through the interactive key derivation mechanism.

17. The method according to claim 16, characterized in that The second communication device derives a key through the one-sided key derivation mechanism, including: The second communication device derives a second slave key based on the first slave key through the one-sided key derivation mechanism, wherein the first slave key is a slave key derived based on the first master key, and the first master key is the master key most recently derived by the second communication device through the interactive key derivation mechanism; The second communication device derives a key through the interactive key derivation mechanism, including: The second communication device derives a second master key based on the first master key through the interactive key derivation mechanism, and derives a third slave key based on the second master key.

18. The method according to claim 17, characterized in that The session resumption request also carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communications device.

19. The method according to claim 18, characterized in that The key derivation parameter includes a first index indicating the number of times before a current time that the second communication device has derived a slave key based on the first master key.

20. The method according to any one of claims 17 to 19, characterized in that: The second communication device derives a second master key based on the first master key through the interactive key derivation mechanism, including: The second communication device obtains its own second key negotiation parameter and the first key negotiation parameter sent by the first communication device; The second communication device derives the second master key based on the first key negotiation parameter, the second key negotiation parameter, and the first master key.

21. The method according to claim 20, characterized in that The session resumption request also carries a second key negotiation parameter of the second communication device; and the method further includes: The second communication device receives a session resumption response sent by the first communication device, where the session resumption response carries a first key negotiation parameter of the first communication device.

22. The method according to claim 21, characterized in that The session resumption request is a session resumption request based on the transport layer security TLS protocol, the session resumption request includes a first shared key field, the first shared key field carries a first random variable RV, and the first RV is used to carry the second key negotiation parameter; The session resumption response is a session resumption response based on the TLS protocol, and the session resumption response includes a second shared key field, the second shared key field carries a second RV, and the second RV is used to carry the first key negotiation parameter.

23. The method according to any one of claims 13 to 22, characterized in that: Before the second communication device sends a session resumption request to the first communication device, the method further includes: The second communication device sends a session creation request to the first communication device, wherein the session creation request carries a hybrid key derivation mode; The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

24. A key derivation device, characterized in that: The device is deployed in a first communication device, and the device includes: A receiving module, configured to receive a session resumption request from a second communication device, wherein the session resumption request carries a key derivation type; A determination module, configured to determine a target key derivation mechanism from a one-sided key derivation mechanism and an interactive key derivation mechanism based on the key derivation type; a derivation module, configured to derive a key based on the target key derivation mechanism to encrypt application data based on the derived key; Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

25. The device according to claim 24, characterized in that The derived module includes: a first derivation unit, configured to, when the target key derivation mechanism is the one-sided key derivation mechanism, derive a second slave key based on a first slave key through the one-sided key derivation mechanism, so as to encrypt the application data based on the second slave key, wherein the first slave key is a slave key derived based on a first master key, and the first master key is a master key most recently derived by the first communication device through the interactive key derivation mechanism; The second derivation unit is used to derive a second master key based on the first master key through the interactive key derivation mechanism when the target key derivation mechanism is the interactive key derivation mechanism, and to derive a third slave key based on the second master key, so as to encrypt the application data based on the third slave key.

26. The device according to claim 25, characterized in that The session resumption request also carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communication device; The first derivation unit is used for: The second slave key is derived based on the key derivation parameter and the first slave key through the one-sided key derivation mechanism, so that the second slave key is synchronized with the slave key most recently derived by the second communication device.

27. The device according to claim 26, characterized in that The key derivation parameter includes a first index indicating the number of times before a current time that the second communication device derives a slave key based on the first master key; The first derivation unit is used for: Obtaining a second index, where the second index indicates the number of times before a current time that the first communication device derives a slave key based on the first master key; If the first index is greater than or equal to the sum of the second index and 1, determining a difference between the first index and the second index to obtain n; The second slave key is obtained by performing n key derivation operations based on the first slave key through the one-sided key derivation mechanism.

28. The device according to claim 27, characterized in that The second deriving unit is further used for: If the first exponent is less than the sum of the second exponent and 1, the second master key is derived based on the first master key through the interactive key derivation mechanism, and the third slave key is derived based on the second master key to encrypt the application data based on the third slave key.

29. The device according to any one of claims 24 to 28, characterized in that: The receiving module is also used for: receiving a session creation request from the second communication device, wherein the session creation request carries a hybrid key derivation mode; The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

30. A key derivation device, characterized in that: The device is deployed in a second communication device, and the device includes: a sending module, configured to send a session resumption request to a first communication device, wherein the session resumption request carries a key derivation type, wherein the key derivation type is used to instruct the first communication device to determine a target key derivation mechanism from a unilateral key derivation mechanism and an interactive key derivation mechanism based on the key derivation type, and to derive a key based on the target key derivation mechanism, so as to encrypt application data based on the derived key; Among them, the one-sided key derivation mechanism refers to a mechanism for deriving keys without exchanging key negotiation parameters between the first communication device and the second communication device, and the interactive key derivation mechanism refers to a mechanism for deriving keys by exchanging key negotiation parameters between the first communication device and the second communication device.

31. The device according to claim 30, characterized in that The device further comprises a derivation module and a generation module, wherein the derivation module comprises a first derivation unit and a second derivation unit; The first derivation unit is used to derive a key through the one-sided key derivation mechanism, and the generation module is used to generate the session resumption request, wherein the key derivation type is used to indicate that the first communication device uses the one-sided key derivation mechanism as the target key derivation mechanism; or, The generating module is used to generate the session resumption request, wherein the key derivation type is used to instruct the first communication device to use the interactive key derivation mechanism as the target key derivation mechanism; and the second derivation unit is used to derive the key through the interactive key derivation mechanism.

32. The device according to claim 31, characterized in that The first derivation unit is used for: Deriving a second slave key based on a first slave key through the one-sided key derivation mechanism, wherein the first slave key is a slave key derived based on a first master key, and the first master key is a master key most recently derived by the second communication device through the interactive key derivation mechanism; The second deriving unit is used for: A second master key is derived based on the first master key through the interactive key derivation mechanism, and a third slave key is derived based on the second master key.

33. The device according to claim 32, characterized in that The session resumption request also carries a key derivation parameter, where the key derivation parameter indicates a slave key most recently derived by the second communications device.

34. The device according to claim 33, characterized in that The key derivation parameter includes a first index indicating the number of times before a current time that the second communication device has derived a slave key based on the first master key.

35. The device according to any one of claims 30 to 34, characterized in that: The sending module is also used for: Sending a session creation request to the first communication device, wherein the session creation request carries a hybrid key derivation mode; The hybrid key derivation mode is used to enable the first communication device to derive a key through a unilateral key derivation mechanism or an interactive key derivation mechanism based on the key derivation type carried in the session resumption request.

36. A key derivation device, characterized in that: The device includes a memory and a processor; The memory is used to store a program that supports the device to execute the method described in any one of claims 1 to 12, and to store data involved in implementing the method described in any one of claims 1 to 12; The processor is configured to execute the program stored in the memory.

37. A key derivation device, characterized in that: The device includes a memory and a processor; The memory is used to store a program that supports the device to execute the method described in any one of claims 13 to 23, and to store data involved in implementing the method described in any one of claims 13 to 23; The processor is configured to execute the program stored in the memory.

38. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in any one of claims 1 to 12, or to execute the method described in any one of claims 13 to 23.