Cryptographic protocol analysis method and device, computer equipment and readable storage medium
By constructing a dynamic field state graph and an attack prediction model, the problem of low accuracy in cryptographic protocol analysis was solved, enabling real-time and efficient security assessment of cryptographic protocols and improving the accuracy and reliability of the analysis.
Patent Information
- Application Number
- CN202511084003.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-04
- Publication Date
- 2025-11-21
AI Technical Summary
Existing cryptographic protocol analysis methods suffer from low accuracy and are insufficient to effectively counter cyberattacks.
By constructing a dynamic field state graph and obtaining the state characteristics and dependency characteristics of protocol fields, combined with an attack prediction model, a real-time, efficient, and accurate security assessment of cryptographic protocols can be achieved.
It improves the accuracy and environmental adaptability of cryptographic protocol analysis, enables real-time monitoring of protocol operation status, accurately predicts potential attack paths, and enhances the reliability and stability of analysis.
Smart Images

Figure CN121000646A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technology, and in particular to a cryptographic protocol analysis method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] With the rapid development of information technology, network communication has been widely used in various fields. Cryptographic protocols serve as a core technology for ensuring network communication security. In recent years, with the continuous evolution of network attack methods, techniques such as man-in-the-middle attacks, replay attacks, and denial-of-service attacks have been used to disrupt normal communication.
[0003] Traditional technologies primarily rely on static protocol models and fixed field states, using techniques such as formal verification and model monitoring for protocol analysis.
[0004] However, current protocol analysis methods suffer from low accuracy. Summary of the Invention
[0005] Therefore, it is necessary to provide a cryptographic protocol analysis method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the accuracy of analysis in response to the above-mentioned technical problems.
[0006] Firstly, this application provides a method for analyzing cryptographic protocols, including:
[0007] Obtain a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0008] Field state features and dependency features are extracted from the dynamic field state graph. Field state features are used to describe the state changes of protocol fields under different events and contexts, while dependency features are used to describe the state changes of the dependencies between protocol fields under different events and contexts.
[0009] By inputting field state features and dependency features into a pre-built attack prediction model, the potential attack probability and attack path of networks using cryptographic protocols can be obtained.
[0010] In one embodiment, the attack prediction model is constructed through the following steps:
[0011] Obtain historical execution data of the cryptographic protocol;
[0012] Historical operational data is input into the prediction module of the attack prediction model to be trained to obtain the corresponding predicted attack state. The predicted attack state is then input into the reinforcement learning module of the attack prediction model to be trained to obtain the predicted action-state value and the predicted reward signal.
[0013] Based on the predicted action-state value and the predicted reward signal, the parameters of the attack prediction model to be trained are trained to obtain the attack prediction model.
[0014] In one embodiment, historical operational data includes actual attack states; based on predicted action-state values and predicted reward signals, the attack prediction model to be trained is parameter-trained to obtain the attack prediction model, including:
[0015] Based on the predicted attack state and the actual attack state, obtain the corresponding attack state differences;
[0016] Obtain the next attack state and immediate reward after the response action, and obtain the actual action-state value based on the next attack state and immediate reward;
[0017] Based on the predicted action-state value and the actual action-state value, the corresponding action-state value difference is obtained;
[0018] Based on the differences in attack states, the differences in action-state values, and the loss function pre-set for the attack prediction model to be trained, the corresponding model loss value is obtained.
[0019] The parameters of the attack prediction model to be trained are trained based on the model loss value until the loss function converges. Then, the current attack prediction model to be trained is used as the attack prediction model.
[0020] In one embodiment, dependency features are constructed through the following steps:
[0021] Based on the pre-defined finite state machine and dynamic field state diagram, extract the field state features;
[0022] The depth-first search algorithm is used to traverse the dynamic field state graph to obtain the feature of the tightness of dependency relationships;
[0023] Obtain the importance information of the protocol fields, as well as the frequency information of their corresponding dependencies;
[0024] Based on the first weight corresponding to the field importance information and the second weight corresponding to the frequency of occurrence information, the field importance information and the dependency relationship are weighted and summed to obtain the dependency relationship weight feature;
[0025] The degree of dependency tightness and the dependency weight are used as dependency features.
[0026] In an exemplary embodiment, the dynamic field state graph is constructed through the following steps:
[0027] Obtain the field attribute information of the protocol fields and the relationship attribute information of the dependencies; the field attribute information includes the field type, the initial state of the field, and the current state of the field, and the relationship attribute information includes the dependency type and the dependency strength;
[0028] A dynamic field state graph is constructed by using a graph database as the storage architecture, protocol fields as nodes, dependencies between protocol fields as edges, field attribute information as node states, and relation attribute information as edge states.
[0029] In one embodiment, the method further includes:
[0030] Obtain the field state change logs of the cryptographic protocol during runtime through a lightweight detection agent;
[0031] Parse the field status change log to obtain the node identifier, new node status, and new edge status;
[0032] Based on the node identifier, the corresponding node and edge are determined from the dynamic field state graph, and the node state and edge state are updated to the new node state and the edge state respectively.
[0033] Secondly, this application also provides a cryptographic protocol analysis apparatus, comprising:
[0034] The graph acquisition module is used to acquire a dynamic field state graph constructed for the cryptographic protocol to be analyzed. The nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0035] The feature extraction module is used to extract field state features and dependency features from the dynamic field state graph. Field state features are used to describe the state changes of protocol fields under different events and contexts, and dependency features are used to describe the state changes of the dependencies between protocol fields under different events and contexts.
[0036] The protocol analysis module is used to input field state characteristics and dependency characteristics into a pre-built attack prediction model to obtain the potential attack probability and attack path of networks using cryptographic protocols.
[0037] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0038] Obtain a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0039] Field state features and dependency features are extracted from the dynamic field state graph. Field state features are used to describe the state changes of protocol fields under different events and contexts, while dependency features are used to describe the state changes of the dependencies between protocol fields under different events and contexts.
[0040] By inputting field state features and dependency features into a pre-built attack prediction model, the potential attack probability and attack path of networks using cryptographic protocols can be obtained.
[0041] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0042] Obtain a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0043] Field state features and dependency features are extracted from the dynamic field state graph. Field state features are used to describe the state changes of protocol fields under different events and contexts, while dependency features are used to describe the state changes of the dependencies between protocol fields under different events and contexts.
[0044] By inputting field state features and dependency features into a pre-built attack prediction model, the potential attack probability and attack path of networks using cryptographic protocols can be obtained.
[0045] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:
[0046] Obtain a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0047] Field state features and dependency features are extracted from the dynamic field state graph. Field state features are used to describe the state changes of protocol fields under different events and contexts, while dependency features are used to describe the state changes of the dependencies between protocol fields under different events and contexts.
[0048] By inputting field state features and dependency features into a pre-built attack prediction model, the potential attack probability and attack path of networks using cryptographic protocols can be obtained.
[0049] The aforementioned cryptographic protocol analysis method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire a dynamic field state graph constructed for the cryptographic protocol to be analyzed. Nodes in the dynamic field state graph represent the protocol fields included in the cryptographic protocol, and edges represent the dependencies between these protocol fields. Field state features and dependency features are extracted from the dynamic field state graph. Field state features describe the state changes of protocol fields under different events and contexts, while dependency features describe the state changes of dependencies between protocol fields under different events and contexts. These field state features and dependency features are input into a pre-built attack prediction model to obtain the potential attack probability and attack paths of the network using the cryptographic protocol. By acquiring the dynamic field state graph, extracting dynamic field state features and dependency features, and inputting these features into the attack prediction model for attack prediction, the analysis of the cryptographic protocols currently used by the network is achieved. Furthermore, the introduction of the dynamic graph enhances the accuracy and environmental adaptability of the analysis results. Attached Figure Description
[0050] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a diagram illustrating the application environment of a cryptographic protocol analysis method in one embodiment.
[0052] Figure 2 This is a flowchart illustrating a cryptographic protocol analysis method in one embodiment;
[0053] Figure 3 This is a schematic diagram of a cryptographic protocol analysis method in another embodiment;
[0054] Figure 4 This is a structural block diagram of a cryptographic protocol analysis device in one embodiment;
[0055] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0057] The cryptographic protocol analysis method provided in this application can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. A dynamic field state graph constructed for the cryptographic protocol to be analyzed is obtained. Nodes in the dynamic field state graph represent the protocol fields included in the cryptographic protocol, and edges represent the dependencies between these protocol fields. Field state features and dependency features are extracted from the dynamic field state graph. Field state features describe the state changes of protocol fields under different events and contexts, while dependency features describe the state changes of protocol fields under different events and contexts. The field state features and dependency features are input into a pre-built attack prediction model to obtain the potential attack probability and attack path of the network using the cryptographic protocol. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services.
[0058] In one exemplary embodiment, such as Figure 2 As shown, a cryptographic protocol analysis method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps S201 to S203. Wherein:
[0059] Step S201: Obtain the dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields.
[0060] In this context, the cryptographic protocol can be understood as the encryption key used in the communication process, such as a series of complex algorithms and steps. The dependency relationship can be understood as the relationship between protocol fields in the cryptographic protocol. The dynamic field state graph can be understood as an undirected graph structure with protocol fields as nodes and the dependencies between protocol fields as edges.
[0061] For example, server 104 obtains a dynamic field state graph constructed for the cryptographic protocol to be analyzed. This dynamic field state graph uses a graph database as its storage architecture, defining nodes to represent protocol fields within the cryptographic protocol. Node attributes include information such as field type, initial state, and current state. Edges represent dependencies between protocol fields, and edge attributes record the type and strength of these dependencies. This constructed dynamic field state graph visually presents the relationships and state changes among protocol fields within the cryptographic protocol. By obtaining the dynamic field state graph corresponding to the cryptographic protocol to be analyzed, a data foundation is laid for subsequent analysis of this cryptographic protocol, and the accuracy of the cryptanalysis is also improved.
[0062] Step S202: Extract field state features and dependency features from the dynamic field state graph; field state features are features used to describe the state changes of protocol fields under different events and contexts, and dependency features are features used to describe the state changes of the dependency relationships between protocol fields under different events and contexts.
[0063] Among them, the field state feature can be understood as the feature of the state change of each protocol field under different events and contexts, calculated by the state transition function defined by each protocol field. The dependency relationship feature can be understood as the feature of the dependency relationship between protocol fields analyzed by using a graph-based traversal algorithm. Starting from any protocol field node, the length and complexity of the dependency path are calculated. It is also the feature of the state change of the dependency relationship under different events and contexts.
[0064] Optionally, server 104 extracts field state features and dependency features from the dynamic field state graph—employing a state transition algorithm based on finite state machine theory to define a state transition function for each field, accurately calculating the state changes of the field under different events and contexts. Simultaneously, a graph-based traversal algorithm is used to analyze the dependencies between fields, calculating the length and complexity of dependency paths starting from the target field node, assessing the tightness of dependencies, and providing crucial information for security assessment. By extracting field state features and dependency features representing dynamic changes from the dynamic field state graph, a data foundation is laid for subsequent cryptographic protocol analysis, while simultaneously improving the accuracy of cryptographic protocol analysis.
[0065] Step S203: Input the field state features and dependency features into the pre-built attack prediction model to obtain the potential attack probability and attack path of the network using cryptographic protocols.
[0066] Among them, a potential attack can be understood as an attacker exploiting vulnerabilities and flaws in cryptographic protocols to steal sensitive information, compromise data integrity, or interfere with normal communication through man-in-the-middle attacks, replay attacks, denial-of-service attacks, and other means. An attack path can be understood as a series of steps and strategies by which an attacker moves laterally in the system, elevates privileges, or accesses sensitive data.
[0067] For example, server 104 inputs field state features and dependency features into a pre-built attack prediction model. The model outputs the potential attack probability and attack path of the network using the cryptographic protocol. The attack path prediction is based on the model's feature importance analysis. By analyzing the contribution of each field state feature to the attack prediction, possible attack paths are determined. For example, if the model predicts that the identity field state is abnormal and its dependency on the encryption key field has changed, combined with feature importance analysis, a possible man-in-the-middle attack path can be predicted. The accuracy of the potential attack probability and attack path of the network using the cryptographic protocol output in this way is higher, achieving real-time, efficient, and accurate security assessment of the cryptographic protocol, thereby improving the reliability and stability of cryptographic protocol analysis.
[0068] In the aforementioned cryptographic protocol analysis method, a dynamic field state graph is constructed for the cryptographic protocol to be analyzed. Nodes in the dynamic field state graph represent the protocol fields included in the cryptographic protocol, and edges represent the dependencies between these fields. Field state features and dependency features are extracted from the dynamic field state graph. Field state features describe the state changes of protocol fields under different events and contexts, while dependency features describe the state changes of dependencies between protocol fields under different events and contexts. These features are then input into a pre-built attack prediction model to obtain the potential attack probability and attack paths of the network using the cryptographic protocol. By acquiring the dynamic field state graph and extracting dynamic field state and dependency features, and inputting these features into the attack prediction model for attack prediction, the analysis of the cryptographic protocols currently used by the network is achieved. Furthermore, the introduction of the dynamic graph enhances the accuracy and environmental adaptability of the analysis results.
[0069] In one embodiment, the attack prediction model is constructed through the following steps: obtaining historical operational data of the cryptographic protocol; inputting the historical operational data into the prediction module of the attack prediction model to be trained to obtain the corresponding predicted attack state; inputting the predicted attack state into the reinforcement learning module of the attack prediction model to be trained to obtain the predicted action-state value and the predicted reward signal; and training the parameters of the attack prediction model to be trained based on the predicted action-state value and the predicted reward signal to obtain the attack prediction model.
[0070] Historical operational data can be understood as including field status data when the cryptographic protocol is executed normally, as well as field status data when it is attacked.
[0071] Optionally, server 104 selects a machine learning model. Considering the characteristics of field state reasoning in cryptographic protocol analysis, the Multilayer Perceptron (MLP) from deep neural networks and Q-learning from reinforcement learning algorithms are selected as the main machine learning models. The MLP, composed of multiple fully connected layers, can automatically learn complex feature representations of field states and is suitable for handling data with non-linear relationships; the Q-learning algorithm is suitable for handling protocol analysis problems with sequential decision-making characteristics and can learn the optimal strategy through interaction with the environment.
[0072] Model Training. Collect large-scale cryptographic protocol runtime data, including field state data during normal protocol execution and under attack. Preprocess the data, such as normalization and feature extraction, to convert it into a format suitable for model input. Use cross-validation to divide the training set into multiple subsets, alternating between training and validation to evaluate model performance and prevent overfitting. During training, use stochastic gradient descent to optimize the MLP model parameters and minimize the loss function.
[0073]
[0074] in, For loss function, For real labels, is the model's predicted value, and m is the number of training samples.
[0075] For the Q-learning algorithm, the Q-value (i.e., the aforementioned prediction-action value) is continuously updated through interaction with the environment. The Q-value update formula is:
[0076] Q(s,a)=Q(s,a)+α[r+γ*max(Q(s',a'))-Q(s,a)]
[0077] Where s is the current state, a is the current action, r is the reward value, γ is the discount factor, s' is the next state, and a' is the next action. Using Q and r as supervision signals, the parameters of the attack prediction model are trained to obtain the attack prediction model. MLP significantly improves the accuracy of field state prediction through deep feature learning, and the combination of Q-learning enables the model to respond to changes in the network environment in real time, ensuring the prediction accuracy and environmental adaptability of the trained model.
[0078] In one embodiment, historical operational data includes actual attack states; based on predicted action-state values and predicted reward signals, the attack prediction model to be trained is parameter-trained to obtain the attack prediction model, including:
[0079] Based on the predicted attack state and the actual attack state, obtain the corresponding attack state difference; obtain the next attack state and immediate reward after the response action, and obtain the actual action-state value based on the next attack state and immediate reward; obtain the corresponding action-state value difference based on the predicted action-state value and the actual action-state value; obtain the corresponding model loss value based on the attack state difference, the action-state value difference, and the loss function pre-set for the attack prediction model to be trained; train the parameters of the attack prediction model to be trained based on the model loss value until the loss function converges, and then use the current attack prediction model to be trained as the attack prediction model.
[0080] The reward can be understood as the difference between the predicted attack state and the actual attack state. If they are the same, it is a positive reward; if they are opposite, it is a negative reward.
[0081] For example, server 104 obtains the corresponding attack state difference based on the predicted attack state and the actual attack state contained in historical operational data. It then obtains the next attack state and immediate reward faced by the network using the cryptographic protocol after the response action, and obtains the actual action-state value based on the next attack state and immediate reward. Based on the predicted action-state value and the actual action-state value, it obtains the corresponding action-state value difference. Based on the attack state difference, the action-state value difference, and the loss function pre-set for the attack prediction model to be trained, it obtains the corresponding model loss value. The parameters of each layer of the MLP in the attack prediction model to be trained are adjusted using the model loss value until the loss function converges. The current attack prediction model to be trained is then used as the attack prediction model. By combining the current actual feedback and using backpropagation to return to the MLP layer for corresponding parameter adjustments, the prediction accuracy of the trained attack prediction model is significantly improved. When the model loss value converges, the corresponding attack prediction model is determined, ensuring the model's rationality and effectiveness in the face of real-world environmental fluctuations, thereby providing effective attack prediction.
[0082] In an exemplary embodiment, dependency features are constructed through the following steps: extracting field state features based on a pre-defined finite state machine and a dynamic field state graph; traversing the dynamic field state graph using a depth-first search algorithm to obtain dependency tightness features; acquiring the importance information of the protocol field and the frequency information of its corresponding dependency; performing a weighted summation of the field importance information and dependency based on the first weight corresponding to the field importance information and the second weight corresponding to the frequency information to obtain dependency weight features; and using the dependency tightness features and dependency weight features as dependency features.
[0083] Optionally, server 104 defines a state transition function for each field based on finite state machine theory. Taking the authentication field as an example, its state transition function can be expressed as: next_state = Auth_State_Transition(current_state, event, context), where current_state is the current state, event is the event that triggers the state transition, such as "authentication request received" or "authentication successful", and context is the context information of the protocol operation, such as network environment and protocol version. Through this function, the state changes of the field under different events and contexts can be accurately calculated, and the field state characteristics can be obtained.
[0084] Server 104 employs a depth-first search algorithm to analyze the dependencies between fields. Starting from the target field node, it traverses along the dependency edges, calculating the length and complexity of the dependency path. For example, when analyzing an encryption key negotiation protocol, starting from the key generation field node and traversing its dependency path, it can determine which prerequisite fields and operations key generation depends on, thereby assessing the tightness of the dependency and obtaining the dependency tightness feature.
[0085] Server 104 assigns weights to different dependencies based on the protocol's operational logic and the importance of the fields. The weight calculation formula is as follows:
[0086] weight=α*importance+β*frequency
[0087] Here, weight represents the weight, importance represents the field importance, frequency represents the frequency of dependency occurrence, and α and β are weight coefficients. Through weight calculation, the impact of dependencies on protocol security can be more accurately assessed, yielding dependency weight features. The dependency tightness feature and dependency weight feature are then used as the dependency feature itself. The state transition function accurately tracks changes in field states under various events and contexts, improving the accuracy of protocol state analysis. Depth-first search provides a clear view of the dependency features between fields, supporting security assessment. Furthermore, through dependency weight analysis, the contribution of each field to the overall protocol security can be more accurately assessed, thereby improving the accuracy of cryptographic protocol analysis.
[0088] In one embodiment, a dynamic field state graph is constructed through the following steps: obtaining field attribute information of protocol fields and relation attribute information of dependencies; field attribute information includes field type, initial state of field and current state of field, and relation attribute information includes dependency type and dependency strength; using a graph database as the storage architecture, protocol fields as nodes, dependencies between protocol fields as edges, field attribute information as node states, and relation attribute information as edge states, a dynamic field state graph is constructed.
[0089] For example, server 104 selects a graph database. Neo4j graph database (a database management system based on graph theory) is chosen as the storage architecture because it has efficient graph query and processing capabilities, adapting to real-time updates of dynamic field state graphs and complex query requirements. Nodes and edges are defined. In Neo4j, nodes represent fields in the protocol, and node attributes cover information such as field type, initial state, and current state. For example, for the identity field, node attributes include "Type: Identity," "Initial State: Unverified," and "Current State: Verifying." Edges represent dependencies between fields, and edge attributes record the type and strength of the dependency, such as "Type: Prerequisite" and "Strength: Strong Dependency."
[0090] Constructing a graph structure: Following the protocol specifications, all fields in the protocol are added to the Neo4j database as nodes. Then, based on the logical relationships between fields, corresponding edges are added to construct a complete dynamic field state graph. Once completed, the graph visually presents the relationships and state changes of the fields in the protocol, laying the foundation for subsequent analysis. Furthermore, Neo4j stores entities as nodes and the relationships between entities as relations. During queries, it is not necessary to traverse the entire data table; the required data can be quickly retrieved simply by directly referencing nodes and relations, greatly improving query efficiency.
[0091] In one embodiment, the method further includes: obtaining field state change logs of the cryptographic protocol during operation through a lightweight detection proxy; parsing the field state change logs to obtain node identifiers, new node states, and new edge states; determining the corresponding nodes and edges from the dynamic field state graph based on the node identifiers, and updating the node state of the node to the new node state and the edge state of the edge to the new edge state.
[0092] Optionally, server 104 embeds a lightweight monitoring agent in the network protocol stack. This agent is developed based on the open-source pcap library and utilizes the interfaces provided by the pcap library to capture network packets in real time, thereby parsing field state change events during protocol operation. ZeroMQ is selected as the data transmission protocol to send the monitored state change information to the graph update module. ZeroMQ features high performance, lightweight design, and ease of use, enabling efficient data transmission between different processes. During transmission, data is encapsulated in JSON format for easy parsing and processing. The graph update module modifies the state of corresponding nodes and edges in the dynamic field state graph in real time according to predefined update rules. The update rules are stored in configuration files and can be flexibly adjusted. For example, when the identity field is detected to be successfully verified, the update rule changes the "current state" attribute of the field from "verifying" to "verified," and simultaneously updates the state of its related dependent edges. The monitoring agent consumes minimal system resources and has negligible impact on network performance, ensuring real-time data capture. By updating the dynamic field state graph in real time using the methods described above, the timeliness of the dynamic field state graph is guaranteed, thereby improving the timeliness and accuracy of cryptographic protocol analysis.
[0093] In one exemplary embodiment, a specific implementation of a cryptographic protocol analysis method is provided, applicable to, for example... Figure 3 In the architecture shown, where:
[0094] Step 1: Construct a dynamic field state graph.
[0095] Step 1 specifically includes:
[0096] Step 1.1: Select a graph database. Neo4j graph database is chosen as the storage architecture because of its efficient graph query and processing capabilities, adapting to real-time updates of dynamic field state graphs and complex query requirements. Neo4j stores entities as nodes and relationships as relations. During queries, it is not necessary to traverse the entire data table; the required data can be quickly obtained simply by directly referencing nodes and relationships, greatly improving query efficiency.
[0097] Step 1.2: Define nodes and edges. In Neo4j, nodes represent fields in a protocol, and node attributes cover information such as field type, initial state, and current state. For example, for the identity field, node attributes include "Type: Identity", "Initial State: Unverified", and "Current State: Verifying". Edges represent dependencies between fields, and edge attributes record the type and strength of the dependency, such as "Type: Prerequisite" and "Strength: Strong Dependency".
[0098] Step 1.3: Construct the graph structure. According to the protocol specification, all fields in the protocol are added to the Neo4j database as nodes. Then, based on the logical relationships between the fields, corresponding edges are added to construct a complete dynamic field state graph. After construction, the graph can intuitively present the interrelationships and state changes of the fields in the protocol, laying the foundation for subsequent analysis.
[0099] Step 2: Real-time monitoring and updates.
[0100] Step 2 specifically includes:
[0101] Step 2.1: Embedding the Monitoring Agent. A lightweight monitoring agent is embedded into the network protocol stack. This agent is developed based on the open-source pcap library and utilizes the interfaces provided by the pcap library to capture network data packets in real time, thereby parsing out field state change events during protocol operation. The monitoring agent consumes minimal system resources and has negligible impact on network performance, ensuring real-time data capture.
[0102] Step 2.2: Data Transmission Protocol. ZeroMQ is selected as the data transmission protocol to send the monitored state change information to the graph update module. ZeroMQ features high performance, lightweight design, and ease of use, enabling efficient data transmission between different processes. During transmission, the data is encapsulated in JSON format for easy parsing and processing.
[0103] Step 2.3: Graph Update Rules. The graph update module modifies the state of corresponding nodes and edges in the dynamic field state graph in real time according to predefined update rules. The update rules are stored in configuration files and can be flexibly adjusted. For example, when the identity field is detected to be successfully verified, the update rule changes the "current state" attribute of the field from "verifying" to "verified", and at the same time updates the state of its related dependent edges.
[0104] Step 3: State transition and dependency analysis.
[0105] Step 3 specifically includes:
[0106] Step 3.1: State Transition Algorithm. Based on finite state machine theory, a state transition function is defined for each field. Taking the authentication field as an example, its state transition function can be expressed as: next_state = Auth_State_Transition(current_state, event, context), where current_state is the current state, event is the event that triggers the state transition, such as "authentication request received" or "authentication successful", and context is the context information of the protocol operation, such as network environment and protocol version. This function can accurately calculate the state changes of the field under different events and contexts.
[0107] Step 3.2: Dependency Analysis Algorithm. A depth-first search algorithm is used to analyze the dependencies between fields. Starting from the target field node, the algorithm traverses along the dependency edges, calculating the length and complexity of the dependency path. For example, when analyzing an encryption key negotiation protocol, starting from the key generation field node and traversing its dependency path, it is possible to determine which prerequisite fields and operations key generation depends on, thereby assessing the tightness of the dependencies.
[0108] Step 3.3: Dependency Weight Calculation. Based on the protocol's operational logic and the importance of the fields, assign weights to different dependencies. The weight calculation formula is:
[0109] weight=α*importance+β*frequency
[0110] Here, weight represents the weight, importance represents the importance of the field, frequency represents the frequency of the dependency, and α and β are weight coefficients. By calculating the weights, the impact of dependencies on protocol security can be assessed more accurately.
[0111] Step 4: Field state reasoning and attack prediction.
[0112] Step 4 specifically includes:
[0113] Step 4.1: Machine Learning Model Selection. Considering the characteristics of field state reasoning in cryptographic protocol analysis, the Multilayer Perceptron (MLP) from deep neural networks and Q-learning from reinforcement learning algorithms were selected as the main machine learning models. The MLP, composed of multiple fully connected layers, can automatically learn complex feature representations of field states and is suitable for handling data with non-linear relationships; the Q-learning algorithm is suitable for handling protocol analysis problems with sequential decision-making characteristics and can learn the optimal strategy through interaction with the environment.
[0114] Step 4.2: Model Training. Collect large-scale cryptographic protocol runtime data, including field state data during normal protocol execution and under attack. Preprocess the data, such as normalization and feature extraction, to convert it into a format suitable for model input. Use cross-validation to divide the training set into multiple subsets, alternating between training and validation to evaluate model performance and prevent overfitting. During training, use stochastic gradient descent to optimize the MLP model parameters and minimize the loss function.
[0115]
[0116] in, For loss function, For real labels, is the model's predicted value, and m is the number of training samples.
[0117] For the Q-learning algorithm, the Q-value is continuously updated through interaction with the environment. The formula for updating the Q-value is:
[0118] Q(s,a)=Q(s,a)+α[r+γ*max(Q(s',a'))-Q(s,a)]
[0119] Where s is the current state, a is the current action, r is the reward value, γ is the discount factor, s' is the next state, and a' is the next action.
[0120] The specific algorithm is shown in the pseudocode below:
[0121] #MLP model training
[0122] 1: def train_MLP(X_train, y_train, learning_rate=0.01, epochs=100):
[0123] 2: # Initialize model parameters
[0124] 3: weights_hidden = np.random.rand(X.shape[1], 64)
[0125] weights_output = np.random.rand(64, 1)
[0126] biases_hidden = np.random.rand(64)
[0127] biases_output = np.random.rand(1)
[0128] 4: for _ in range(epochs):
[0129] hidden = relu(np.dot(X, weights_hidden) + biases_hidden)
[0130] output = np.dot(hidden, weights_output) + biases_output
[0131] loss = ((output - y) ** 2).mean()
[0132] 5: # Backpropagation
[0133] grad_output = 2 * (output - y)
[0134] grad_weights_output = np.dot(hidden.T, grad_output)
[0135] grad_biases_output = grad_output.sum(axis=0)
[0136] 6: grad_hidden = np.dot(grad_output, weights_output.T) * relu_deriv(hidden)
[0137] grad_weights_hidden = np.dot(X.T, grad_hidden)
[0138] grad_biases_hidden = grad_hidden.sum(axis=0)
[0139] 7: # Update parameters
[0140] weights_hidden -= learning_rate * grad_weights_hidden
[0141] biases_hidden -= learning_rate * grad_biases_hidden
[0142] weights_output -= learning_rate * grad_weights_output
[0143] biases_output -= learning_rate * grad_biases_output
[0144] 8: return weights_hidden, biases_hidden, weights_output, biases_output
[0145] # Q-Learning training
[0146] 1: def train_Q_Learning(env, gamma=0.9, alpha=0.1, episodes=500):
[0147] 2: Q = defaultdict(lambda: defaultdict(float))
[0148] 3: for _ in range(episodes):
[0149] 4: state = env.reset()
[0150] 5: done = False
[0151] 6: while not done:
[0152] 7: action = select_action(Q, state)
[0153] 8: next_state, reward, done = env.step(action)
[0154] 9: best_next_value = max(Q[next_state].values()) if next_state in Q else 0
[0155] 10: Q[state][action] += alpha * (reward + gamma * best_next_value - Q[state][action])
[0156] 11: state = next_state
[0157] 12: return Q
[0158] Step 4.3: Attack Prediction. The field state results obtained from the inference are input into the trained model. The model outputs the probability of an attack occurring and possible attack paths. Attack path prediction is based on the model's feature importance analysis. By analyzing the contribution of each field state feature to the attack prediction, possible attack paths are determined. For example, if the model predicts that the identity field state is abnormal and its dependency on the encryption key field has changed, combined with feature importance analysis, a possible man-in-the-middle attack path can be predicted.
[0159] Compared with the prior art, this application has the following technical advantages:
[0160] 1. It not only considers the static attributes and fixed states of fields in cryptographic protocols, but also the dynamic changes and interdependencies of fields during actual operation. By focusing on the static attributes and dynamic changes of cryptographic protocols during operation, it analyzes cryptographic protocols and thus improves the accuracy of cryptographic protocol analysis.
[0161] 2. By constructing a dynamic field state graph and combining it with machine learning techniques, real-time, efficient and accurate security assessment of cryptographic protocols was achieved, thereby improving the reliability and stability of cryptographic protocol analysis.
[0162] 3. The method has been trained and tested under various complex network environments and protocol types, giving it strong adaptability and robustness, enabling it to accurately handle protocols with dynamic interactions and frequent state updates. It can monitor protocol operation status in real time and accurately predict potential attack paths, greatly improving the accuracy and real-time performance of cryptographic protocol analysis. This method is not limited to specific protocols or network environments and can be easily extended to different fields such as IoT protocols, blockchain consensus protocols, and dynamic web service protocols.
[0163] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0164] Based on the same inventive concept, this application also provides a cryptographic protocol analysis apparatus for implementing the cryptographic protocol analysis method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more embodiments of the cryptographic protocol analysis apparatus provided below can be found in the limitations of the cryptographic protocol analysis method described above, and will not be repeated here.
[0165] In one exemplary embodiment, such as Figure 4 As shown, a cryptographic protocol analysis device is provided, comprising: a graph acquisition module 401, a feature extraction module 402, and a protocol analysis module 403, wherein:
[0166] The graph acquisition module 401 is used to acquire a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependency relationships between the protocol fields.
[0167] The feature extraction module 402 is used to extract field state features and dependency features from the dynamic field state graph; the field state features are features used to describe the state changes of protocol fields under different events and different contexts, and the dependency features are features used to describe the state changes of the dependency relationships between protocol fields under different events and different contexts.
[0168] Protocol analysis module 403 is used to input field state features and dependency features into a pre-built attack prediction model to obtain the potential attack probability and attack path of a network using cryptographic protocols.
[0169] In one embodiment, the cryptographic protocol analysis apparatus further includes a model building module for acquiring historical operational data of the cryptographic protocol;
[0170] Historical operational data is input into the prediction module of the attack prediction model to be trained to obtain the corresponding predicted attack state. The predicted attack state is then input into the reinforcement learning module of the attack prediction model to be trained to obtain the predicted action-state value and the predicted reward signal.
[0171] Based on the predicted action-state value and the predicted reward signal, the parameters of the attack prediction model to be trained are trained to obtain the attack prediction model.
[0172] In one embodiment, historical operational data includes the actual attack state; the model building module is further configured to obtain the corresponding attack state difference based on the predicted attack state and the actual attack state; obtain the next attack state and immediate reward after the response action, and obtain the actual action-state value based on the next attack state and the immediate reward; obtain the corresponding action-state value difference based on the predicted action-state value and the actual action-state value; obtain the corresponding model loss value based on the attack state difference, the action-state value difference, and the loss function pre-set for the attack prediction model to be trained; train the parameters of the attack prediction model to be trained based on the model loss value until the loss function converges, and then use the current attack prediction model to be trained as the attack prediction model.
[0173] In an exemplary embodiment, the feature extraction module 402 is further configured to extract field state features based on a pre-defined finite state machine and a dynamic field state graph; traverse the dynamic field state graph using a depth-first search algorithm to obtain dependency tightness features; obtain the field importance information of the protocol field and the frequency information of its corresponding dependency; perform a weighted summation of the field importance information and dependency based on the first weight corresponding to the field importance information and the second weight corresponding to the frequency information to obtain dependency weight features; and use the dependency tightness features and dependency weight features as dependency features.
[0174] In one embodiment, the cryptographic protocol analysis device further includes a graph construction module for obtaining field attribute information of protocol fields and relation attribute information of dependencies; the field attribute information includes field type, initial state of field and current state of field, and the relation attribute information includes dependency type and dependency strength; a dynamic field state graph is constructed using a graph database as the storage architecture, protocol fields as nodes, dependencies between protocol fields as edges, field attribute information as node states, and relation attribute information as edge states.
[0175] In one embodiment, the graph construction module is also used to obtain the field state change log of the cryptographic protocol during operation through a lightweight detection agent; parse the field state change log to obtain the node identifier, the new node state, and the new edge state; determine the corresponding node and edge from the dynamic field state graph based on the node identifier, and update the node state of the node to the new node state and the edge state of the edge to the new edge state.
[0176] Each module in the aforementioned cryptographic protocol analysis device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0177] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores dynamic field graphs, field state characteristics, dependency characteristics, potential attack probabilities, and attack path data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements a cryptographic protocol analysis method.
[0178] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0179] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the cryptographic protocol analysis method of the above embodiment.
[0180] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the cryptographic protocol analysis method of the above embodiment.
[0181] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the cryptographic protocol analysis method of the above embodiments.
[0182] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0183] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0184] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0185] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for analyzing cryptographic protocols, characterized in that, The method includes: Obtain a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields. Field state features and dependency features are extracted from the dynamic field state graph; the field state features are features used to describe the state changes of the protocol fields under different events and different contexts, and the dependency features are features used to describe the state changes of the dependencies between the protocol fields under different events and different contexts. By inputting the field state features and the dependency relationship features into a pre-built attack prediction model, the potential attack probability and attack path of the network using the cryptographic protocol can be obtained.
2. The method according to claim 1, characterized in that, The attack prediction model is constructed through the following steps: Obtain the historical execution data of the cryptographic protocol; The historical running data is input into the prediction module of the attack prediction model to be trained to obtain the corresponding predicted attack state. The predicted attack state is then input into the reinforcement learning module of the attack prediction model to be trained to obtain the predicted action-state value and the predicted reward signal. Based on the predicted action-state value and the predicted reward signal, the parameters of the attack prediction model to be trained are trained to obtain the attack prediction model.
3. The method according to claim 2, characterized in that, The historical operational data includes the actual attack state; the step of training the attack prediction model to be trained based on the predicted action-state value and the predicted reward signal to obtain the attack prediction model includes: Based on the predicted attack state and the actual attack state, the corresponding attack state difference is obtained; Obtain the next attack state and immediate reward after the response action, and obtain the actual action-state value based on the next attack state and immediate reward; Based on the predicted action-state value and the actual action-state value, the corresponding action-state value difference is obtained; Based on the attack state difference, the action-state value difference, and the loss function pre-set for the attack prediction model to be trained, the corresponding model loss value is obtained. The attack prediction model to be trained is trained based on the model loss value until the loss function converges, at which point the current attack prediction model to be trained is used as the attack prediction model.
4. The method according to claim 1, characterized in that, The dependency features are constructed through the following steps: Based on the pre-defined finite state machine and the dynamic field state graph, the field state features are extracted; The dynamic field state graph is traversed using a depth-first search algorithm to obtain the feature of the tightness of dependency relationships; Obtain the importance information of the protocol fields and the frequency information of their corresponding dependencies; Based on the first weight corresponding to the importance information of the field and the second weight corresponding to the frequency of occurrence information, the importance information of the field and the dependency relationship are weighted and summed to obtain the dependency relationship weight feature; The dependency tightness feature and the dependency weight feature are used as the dependency feature.
5. The method according to claim 1, characterized in that, The dynamic field state graph is constructed through the following steps: Obtain the field attribute information of the protocol field and the relationship attribute information of the dependency relationship; the field attribute information includes the field type, the initial state of the field and the current state of the field, and the relationship attribute information includes the dependency relationship type and the dependency relationship strength; Using a graph database as the storage architecture, the protocol fields as nodes, the dependencies between the protocol fields as edges, the field attribute information as node states, and the relationship attribute information as edge states, a dynamic field state graph is constructed.
6. The method according to claim 5, characterized in that, The method further includes: Obtain the field state change logs of the cryptographic protocol during its operation through a lightweight detection agent; The state change log of the field is parsed to obtain the node identifier, the new node state, and the new edge state; Based on the node identifier, the corresponding node and edge are determined from the dynamic field state graph, and the node state of the node and the edge state of the edge are updated to the new node state and the edge state of the edge are updated to the new edge state.
7. A cryptographic protocol analysis device, characterized in that, The device includes: The graph acquisition module is used to acquire a dynamic field state graph constructed for the cryptographic protocol to be analyzed; the nodes in the dynamic field state graph are used to represent the protocol fields contained in the cryptographic protocol, and the edges in the dynamic field state graph are used to represent the dependencies between the protocol fields. The feature extraction module is used to extract field state features and dependency features from the dynamic field state graph; the field state features are features used to describe the state changes of the protocol fields under different events and different contexts, and the dependency features are features used to describe the state changes of the dependencies between the protocol fields under different events and different contexts. The protocol analysis module is used to input the field state features and the dependency relationship features into a pre-built attack prediction model to obtain the potential attack probability and attack path of the network using the cryptographic protocol.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
