Encryption method and device, electronic equipment and storage medium
Through signature encryption and hash encryption of SBOM, combined with twin neural network detection, the problem of easy cracking of hash algorithm encryption is solved, the security and transparency of SBOM are improved, and the integrity and authenticity of the software supply chain are ensured.
Patent Information
- Application Number
- CN202410939785.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-19
AI Technical Summary
The existing hashing algorithms are easy to crack on the encryption method of software bill of materials (SBOM), resulting in low security of SBOM and inability to effectively ensure the integrity and authenticity of SBOM.
By encrypting the SBOM signature, an encrypted string is generated, combined with preset information and hash encryption, writing it to the SBOM, using a twin neural network to detect tampering, calculate the similarity to determine the tampering SBOM, and enhance the SBOM Security and transparency.
It improves the difficulty of decryption of SBOM, enhances its security, ensures the authenticity and integrity of SBOM, and improves the transparency and security of the software supply chain.
Smart Images

Figure CN118981798A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software supply chain security technology, and in particular to an encryption method, device, electronic device and storage medium. Background Art
[0002] The Software Bill of Materials (SBOM) increases the transparency of software delivery by including a list of software components and dependencies. In order to ensure the comprehensiveness and accuracy of the SBOM, software suppliers at every link in the supply chain are required to provide a comprehensive SBOM and update and distribute it in a timely manner. At the same time, the SBOM itself is also a digital document that needs to be protected. The integrity and authenticity of the SBOM must be guaranteed in the software supply chain to prevent the SBOM from being tampered with. Once the SBOM is tampered with, the component-related information it provides will lose credibility and cannot effectively support the security and compliance management of the software. Therefore, the SBOM needs to be encrypted.
[0003] Currently, the commonly used encryption method is to use a hash algorithm to encrypt the SBOM. However, this method can crack the SBOM by simply using the same hash algorithm, resulting in low security of the SBOM. Summary of the invention
[0004] The present application provides an encryption method, device, electronic device and storage medium, which can solve the problem that the current method of encrypting SBOM using a hash algorithm is easily decrypted, resulting in low security of the SBOM.
[0005] In a first aspect, the present application provides an encryption method, the method comprising:
[0006] Get the first software bill of materials SBOM of the software;
[0007] Setting the signature of the first SBOM, and encrypting the signature of the first SBOM to obtain an encrypted string;
[0008] Combining the encrypted string with the preset information in the first SBOM to obtain target information;
[0009] The hash value of the target information is calculated by using a first hash algorithm, and the hash value of the target information is written into the first SBOM to obtain a second SBOM.
[0010] By using the above method, the signature of the first SBOM is encrypted to obtain an encrypted string, and then the combined encrypted string and the preset information in the first SBOM are hashed, which can increase the difficulty of decryption and improve the security of the SBOM.
[0011] In a possible embodiment, obtaining the first SBOM of the software includes:
[0012] Obtaining a source code package of the software;
[0013] Scanning the dependency package management configuration file of the source code package to generate an initial SBOM;
[0014] The hash value of the source code package is determined by a second hash algorithm, and the hash value of the source code package is written into the initial SBOM to obtain the first SBOM.
[0015] Through the above method, an initial SBOM can be generated based on the dependency package management configuration file of the software source code package, and the hash value of the source code package is written into the initial SBOM to achieve a unique correspondence between the software source code package and the SBOM.
[0016] In a possible embodiment, encrypting the signature of the first SBOM to obtain an encrypted string includes:
[0017] Receiving user account information and a user key, and verifying the user account information and the user key;
[0018] In response to successful verification of the user account information and the user key, a token JWT corresponding to the signature of the first SBOM is generated based on the user account information and the user key, and the JWT is used as the encrypted string.
[0019] By using the above method, a JWT corresponding to the signature of the first SBOM is generated, which not only ensures the information security of the first SBOM but also does not occupy server resources.
[0020] In a possible embodiment, the method further includes:
[0021] Acquire the SBOM of the software to be detected, and preprocess the SBOM of the software to be detected to obtain the SBOM to be detected;
[0022] Inputting the SBOM to be detected and the preprocessed second SBOM into a twin neural network, outputting the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM;
[0023] The similarity between the tampered SBOM and the target SBOM is calculated, and the SBOM in the tampered SBOM whose similarity is less than a preset similarity is used as the target tampered SBOM.
[0024] Through the above method, the tampered SBOM in the SBOM to be detected is judged based on the twin neural network, and then the target tampered SBOM in the tampered SBOM is determined through similarity calculation. This can achieve fine-grained control of the SBOM, ensure the authenticity of the SBOM, and further enhance the transparency of the software supply chain.
[0025] In a possible embodiment, the step of inputting the SBOM to be detected and the preprocessed second SBOM into a twin neural network, and outputting the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM, includes:
[0026] Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM;
[0027] Calculating a difference score between the feature vector to be detected and the target feature vector;
[0028] The tampered SBOM is output as the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and the target SBOM in the preprocessed second SBOM is output.
[0029] By the above method, the difference score between the SBOM to be detected and the second SBOM after preprocessing is calculated, so that the tampered SBOM in the SBOM to be detected and the target SBOM corresponding to the tampered SBOM in the second SBOM after preprocessing can be determined based on the difference score.
[0030] In a possible embodiment, the calculating the similarity between the tampered SBOM and the target SBOM, and taking the SBOM in the tampered SBOM whose similarity is less than a preset similarity as the target tampered SBOM, includes:
[0031] Performing word segmentation processing on the tampered SBOM and the target SBOM respectively, generating a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM;
[0032] Calculate the similarity between the first word segmentation vector and the second word segmentation vector;
[0033] The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is used as the target tampering SBOM.
[0034] By using the above method, the similarity between the tampered SBOM and the target SBOM is calculated, so that the target tampered SBOM in the tampered SBOM can be further determined based on the similarity.
[0035] In a second aspect, the present application provides an encryption device, the device comprising:
[0036] An acquisition module, used for acquiring a first SBOM of the software;
[0037] A first encryption module, used for setting a signature of the first SBOM, and encrypting the signature of the first SBOM to obtain an encrypted string;
[0038] A combining module, used for combining the encrypted string with the preset information in the first SBOM to obtain target information;
[0039] The second encryption module is used to calculate the hash value of the target information by using the first hash algorithm, and write the hash value of the target information into the first SBOM to obtain a second SBOM.
[0040] In a possible embodiment, the acquisition module is specifically used to:
[0041] Obtaining a source code package of the software;
[0042] Scanning the dependency package management configuration file of the source code package to generate an initial SBOM;
[0043] The hash value of the source code package is determined by a second hash algorithm, and the hash value of the source code package is written into the initial SBOM to obtain the first SBOM.
[0044] In a possible embodiment, the first encryption module is specifically used for:
[0045] Receiving user account information and a user key, and verifying the user account information and the user key;
[0046] In response to successful verification of the user account information and the user key, a JWT corresponding to the signature of the first SBOM is generated based on the user account information and the user key, and the JWT is used as the encrypted string.
[0047] In a possible embodiment, the device further includes:
[0048] A preprocessing module, used for obtaining the SBOM of the software to be detected, and preprocessing the SBOM of the software to be detected to obtain the SBOM to be detected;
[0049] A first detection module is used to input the SBOM to be detected and the preprocessed second SBOM into a twin neural network, and output the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM;
[0050] The second detection module is used to calculate the similarity between the tampered SBOM and the target SBOM, and take the SBOM in the tampered SBOM whose similarity is less than a preset similarity as the target tampered SBOM.
[0051] In a possible embodiment, the first detection module is specifically used to:
[0052] Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM;
[0053] Calculating a difference score between the feature vector to be detected and the target feature vector;
[0054] The tampered SBOM is output as the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and the target SBOM in the preprocessed second SBOM is output.
[0055] In a possible embodiment, the second detection module is specifically used to:
[0056] Performing word segmentation processing on the tampered SBOM and the target SBOM respectively, generating a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM;
[0057] Calculate the similarity between the first word segmentation vector and the second word segmentation vector;
[0058] The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is used as the target tampering SBOM.
[0059] In a third aspect, the present application provides an electronic device, including:
[0060] Memory, used to store computer programs;
[0061] The processor is used to implement the encryption method of the first aspect when executing the computer program stored in the memory.
[0062] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the encryption method of the first aspect is implemented.
[0063] In a fifth aspect, the present application provides a computer program product, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the encryption method of the first aspect.
[0064] The technical effects that can be achieved in each of the above-mentioned second to fifth aspects and each of the above-mentioned aspects refer to the technical effects that can be achieved in the above-mentioned first aspect or various possible schemes in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A flowchart of an encryption method provided in an embodiment of the present application;
[0066] Figure 2 A flowchart of a SBOM tampering detection method provided in an embodiment of the present application;
[0067] Figure 3 A schematic diagram of a process for tampering detection based on a twin neural network provided in an embodiment of the present application;
[0068] Figure 4 A schematic diagram of a process flow of a SBOM fine-grained analysis method provided in an embodiment of the present application;
[0069] Figure 5 A schematic diagram of the structure of an encryption device provided in an embodiment of the present application;
[0070] Figure 6 A schematic diagram of the structure of another encryption device provided in an embodiment of the present application;
[0071] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The specific operating methods in the method embodiments can also be applied to device embodiments or system embodiments. It should be noted that in the description of the present application, "multiple" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, and A and B exist, and B exists alone. A is connected to B, which can represent: A is directly connected to B and A is connected to B through C. In addition, in the description of the present application, words such as "first" and "second" are only used to distinguish the purpose of description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0073] In order to facilitate understanding by those skilled in the art, the technical terms involved in the embodiments of the present application are first explained.
[0074] (1) Software Bill of Materials (SBOM) refers to the bill of materials of a software product, that is, the collection of all the "raw materials" related information used in the development process of the software and its upstream and downstream supply chain dependencies.
[0075] The commonly used SBOM file standards are the Software Package Data Exchange (SPDX) standard and the CycloneDX standard. Among them, SPDX is a standard data transmission format that captures key information related to provenance, licensing, and security. CycloneDX is a standard developed according to NTIA. CycloneDX can be described as a "lightweight SBOM standard" designed for application security environments and supply chain component analysis. CycloneDX SBOM can be represented as an XML file, a JSON file, or a protocol buffer.
[0076] (2) Hash algorithm, which maps a binary value string of any length to a binary value string of fixed length. The mapping rule is the hash algorithm, and the binary value string obtained after mapping the original data is the hash value. Typical hash algorithms include Message-Digest Algorithm 5 (MD5), SHA-1 and other algorithms.
[0077] (3) Token (JsonWeb Token, JWT) refers to the use of JavaScript Object Notation (JSON) as a token in Web applications. It is used to securely transmit information between parties as a JSON object. During the data transmission process, data encryption, signature and other related processing can also be completed.
[0078] (4) The twin neural network is like a "conjoined neural network". The "conjoined" nature of the neural network is achieved by sharing weights (sharing weights means that the weights of the two neural network branches are exactly the same). The twin neural network has two inputs, which are sent to the two neural network branches respectively. The two neural network branches map them to a new space respectively, forming a representation of the input in the new space (feature vector). Finally, the similarity of the two inputs is evaluated through loss calculation.
[0079] (5) Natural Language Processing (NLP) refers to the technology of using the natural language used by humans to communicate with machines. Through human processing of natural language, computers can read and understand it.
[0080] The following is a brief introduction to the background technology of the embodiments of the present application.
[0081] In order to ensure the comprehensiveness and accuracy of SBOM, software suppliers at every link in the supply chain are required to provide comprehensive SBOM and update and distribute it in a timely manner. At the same time, SBOM itself is also a digital document that needs to be protected. The integrity and authenticity of SBOM must be guaranteed in the software supply chain to prevent SBOM from being tampered with. Once SBOM is tampered with, the component-related information it provides will lose credibility and cannot effectively support software security and compliance management. Therefore, SBOM needs to be encrypted.
[0082] Currently, the commonly used encryption method is to use a hash algorithm to encrypt the SBOM. However, this method can crack the SBOM by simply using the same hash algorithm, resulting in low security of the SBOM.
[0083] In order to solve the above problems, an encryption method provided in an embodiment of the present application encrypts the signature of the first SBOM to obtain an encrypted string, and then hashes the combined encrypted string and the preset information in the first SBOM, which can increase the difficulty of decryption and improve the security of the SBOM. Among them, the method and device described in the embodiment of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can refer to each other, and the repeated parts will not be repeated.
[0084] To further illustrate the technical solution provided by the embodiment of the present application, this is described in detail below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiment of the present application provides the method operation steps as shown in the following embodiments or drawings, more or fewer operation steps may be included in the method based on routine or no creative labor. In the steps where there is no necessary causal relationship logically, the execution order of these steps is not limited to the execution order provided by the embodiment of the present application. The method may be executed or executed in parallel in the actual processing process or when the device is executed in accordance with the method sequence shown in the embodiment or drawings.
[0085] Figure 1 The flowchart of an encryption method provided in an embodiment of the present application can be executed by an encryption device, which can be implemented by software, hardware, or a combination of software and hardware. Figure 1 As shown, the process includes the following steps:
[0086] 101: Get the first SBOM of the software.
[0087] In an embodiment of the present application, a specific method for obtaining the first SBOM of the software may be: obtaining the source code package of the software, and scanning the dependency package management configuration file of the source code package to generate an initial SBOM, and then determining the hash value of the source code package through a second hash algorithm, and writing the hash value of the source code package into the initial SBOM to obtain the first SBOM.
[0088] The commonly used SBOM file standards are SPDX and CycloneDX. The description information of the software package itself in the standard generally only has the package name and version information, lacking a unique symmetric relationship to prevent tampering. Therefore, this application calculates the hash value of the source code package and writes it into the initial SBOM, so that the subsequent comparison of the hash value recorded in the SBOM can determine whether the software has been modified.
[0089] Optionally, when the initial SBOM standard is the SPDX standard, the hash value of the source code package can be written into the Documentcomment field of the initial SBOM in a string format. As shown in Table 1:
[0090]
[0091] Table 1 An initial SBOM
[0092] It should be noted that adding the above Documentcomment field value to the initial SBOM has no effect on the format of the initial SBOM and does not affect the machine readability of the SBOM. The specific location where the Documentcomment field is written into the initial SBOM in this application depends on the situation and is not limited here.
[0093] Optionally, when the initial SBOM standard is the CycloneDX standard, the hash value of the source code package can be written into the properties field of the initial SBOM, the name field is written as "Hash", and the value field is written into the hash value of the source code package. As shown in Table 2:
[0094]
[0095] Table 2 Another initial SBOM
[0096] It should be noted that adding the above properties field value to the initial SBOM has no effect on the format of the initial SBOM and does not affect the machine readability of the SBOM. The specific location where the properties field is written into the initial SBOM in this application depends on the situation and is not limited here.
[0097] 102: Set the signature of the first SBOM, and encrypt the signature of the first SBOM to obtain an encrypted string.
[0098] In the embodiment of the present application, the management party can randomly set the signature of the first SBOM, for example, SBOM_SIGN = "xxxxyyyy12335ba9534e5d8ce376543123456", and encrypt the signature of the first SBOM based on JWT to obtain an encrypted string. Specifically:
[0099] Receive user account information and user key, and verify the user account information and the user key. In response to successful verification of the user account information and the user key, generate a JWT corresponding to the signature of the first SBOM based on the user account information and the user key, and use the JWT as an encrypted string. Among them, JWT consists of three parts, namely, the header Header, the payload Payload, and the signature Signature, that is, the form of JWT is Header.Payload.Signature, and the signature can be set arbitrarily by the user.
[0100] 103: Combine the encrypted string with the preset information in the first SBOM to obtain target information.
[0101] In an embodiment of the present application, the management party may use the information corresponding to different fields in the first SBOM as preset information according to different needs, such as the software package information packages and associated relationships objects in the SPDX format, or the component information components and dependency objects in the Cyclonedx format, and obtain the encrypted string as: Header.Payload.Signature-packages-relations hips, or Header.Payload.Signature-packages-relationships.
[0102] 104: Calculate a hash value of the target information by using a first hash algorithm, and write the hash value of the target information into the first SBOM to obtain a second SBOM.
[0103] Optionally, the first hash algorithm may be an MD5 algorithm, and the hash value of the target information is determined by the MD5 algorithm, and the hash value of the target information is used as the summary information of the first SBOM, that is, the hash value of the target information is written into the first SBOM to obtain the second SBOM. The hash value of the target information can be stored by adding a new info object to the first SBOM and adding a filesingle field, for example, "info":{"filesingle":"eb53280bf7bf80547693a203ca238904"}.
[0104] It should be noted that the first hash algorithm and the second hash algorithm may be the same or different. The specific algorithm depends on the situation and is not specifically limited here.
[0105] In a possible embodiment, after the SBOM is encrypted by the above method, it is further possible to determine whether the SBOM has been tampered with. Figure 2 FIG. 1 is a flow chart of a SBOM tampering detection method provided in an embodiment of the present application. The flow chart includes the following steps:
[0106] 201: Obtain the SBOM of the software to be detected, and pre-process the SBOM of the software to be detected to obtain the SBOM to be detected.
[0107] In the embodiment of the present application, it is first determined whether the hash value of the SBOM of the software to be detected is consistent with the hash value of the second SBOM. If so, the SBOM of the software to be detected has not been tampered with; if not, the SBOM of the software to be detected has been tampered with.
[0108] Furthermore, before performing tampering detection on the SBOM of the software to be detected, the SBOM of the software to be detected and the second SBOM are preprocessed, for example, optional fields such as "filesingle" or "properties" in the SBOM are removed, thereby improving detection efficiency.
[0109] 202: Input the SBOM to be detected and the preprocessed second SBOM into the twin neural network, and output the tampered SBOM in the SBOM to be detected and the target SBOM corresponding to the tampered SBOM in the preprocessed second SBOM.
[0110] In an embodiment of the present application, the twin neural network includes two branches with shared weights. By inputting the SBOM to be detected and the second SBOM after preprocessing into the two branches respectively, the similarity between the SBOM to be detected and the second SBOM after preprocessing can be calculated.
[0111] like Figure 3As shown, it is a schematic diagram of a process of tampering detection based on a twin neural network provided in an embodiment of the present application, which specifically includes:
[0112] 301: Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM;
[0113] 302: Calculate the difference score between the feature vector to be detected and the target feature vector;
[0114] 303: Outputting the tampered SBOM as the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and outputting the target SBOM corresponding to the tampered SBOM in the preprocessed second SBOM.
[0115] The size of the preset threshold depends on the situation and is not specifically limited here.
[0116] 203: Calculate the similarity between the tampered SBOM and the target SBOM, and use the SBOM in the tampered SBOM whose similarity is less than the preset similarity as the target tampered SBOM.
[0117] In the embodiment of the present application, the similarity between the tampered SBOM and the target SBOM can be calculated by NLP technology, so as to perform fine-grained verification on the tampered SBOM, realize fine-grained control of the SBOM, and ensure the authenticity of the SBOM. Figure 4 FIG. 1 is a flow chart of a SBOM fine-grained analysis method provided in an embodiment of the present application, and the flow chart includes:
[0118] 401: Perform word segmentation processing on the tampered SBOM and the target SBOM respectively, and generate a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM;
[0119] 401: Calculate the similarity between the first word segmentation vector and the second word segmentation vector;
[0120] 402: The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is used as the target tampered SBOM.
[0121] Therefore, based on the target tampering SBOM, corresponding prompt information is generated and notified to the management party, so that the management party can understand the real situation of the software assets to be tested and effectively prevent potential security risks.
[0122] By using the above encryption method, the signature of the first SBOM is encrypted to obtain an encrypted string, and then the combined encrypted string and the preset information in the first SBOM are hashed, which can increase the difficulty of decryption and improve the security of the SBOM.
[0123] Based on the same inventive concept, an encryption device is also provided in the embodiment of the present application, such as Figure 5 FIG. 1 is a schematic diagram of a structure of an encryption device provided in an embodiment of the present application, the device comprising:
[0124] An acquisition module 501 is used to acquire a first SBOM of the software;
[0125] The first encryption module 502 is used to set the signature of the first SBOM and encrypt the signature of the first SBOM to obtain an encrypted string;
[0126] A combining module 503, used to combine the encrypted string with the preset information in the first SBOM to obtain target information;
[0127] The second encryption module 504 is used to calculate the hash value of the target information by using the first hash algorithm, and write the hash value of the target information into the first SBOM to obtain a second SBOM.
[0128] In a possible embodiment, the acquisition module 501 is specifically used for:
[0129] Get the source code package of the software;
[0130] Scan the dependency package management configuration file of the source code package to generate the initial SBOM;
[0131] The hash value of the source code package is determined by a second hash algorithm, and the hash value of the source code package is written into the initial SBOM to obtain a first SBOM.
[0132] In a possible embodiment, the first encryption module 502 is specifically used for:
[0133] Receive user account information and user key, and verify the user account information and user key;
[0134] In response to successful verification of the user account information and the user key, a JWT corresponding to the signature of the first SBOM is generated based on the user account information and the user key, and the JWT is used as an encrypted string.
[0135] In other embodiments, in addition to the above Figure 5 In addition to the modules shown in FIG. 1 , the system may further include a preprocessing module, a first detection module and a second detection module, such as Figure 6 , which is a schematic diagram of the structure of another encryption device provided in an embodiment of the present application. The device comprises: an acquisition module 501, a first encryption module 502, a combination module 503, a second encryption module 504, a preprocessing module 601, a first detection module 602 and a second detection module 603.
[0136] The preprocessing module 601 is used to obtain the SBOM of the software to be detected, and preprocess the SBOM of the software to be detected to obtain the SBOM to be detected;
[0137] The first detection module 602 is used to input the SBOM to be detected and the preprocessed second SBOM into the twin neural network, and output the tampered SBOM in the SBOM to be detected and the target SBOM corresponding to the tampered SBOM in the preprocessed second SBOM;
[0138] The second detection module 603 is used to calculate the similarity between the tampered SBOM and the target SBOM, and use the SBOM with a similarity less than a preset similarity among the tampered SBOMs as the target tampered SBOM.
[0139] In a possible embodiment, the first detection module 602 is specifically configured to:
[0140] Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM;
[0141] Calculate the difference score between the feature vector to be detected and the target feature vector;
[0142] The output tampered SBOM is the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and the target SBOM in the second SBOM after output preprocessing.
[0143] In a possible embodiment, the second detection module 603 is specifically configured to:
[0144] Perform word segmentation processing on the tampered SBOM and the target SBOM respectively, and generate a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM;
[0145] Calculate the similarity between the first word segmentation vector and the second word segmentation vector;
[0146] The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is taken as the target tampered SBOM.
[0147] It should be noted here that the above-mentioned device provided in the embodiment of the present application can implement all the method steps in the above-mentioned method embodiment and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0148] Based on the same inventive concept, an electronic device is also provided in the embodiment of the present application, and the electronic device can realize the function of the aforementioned encryption device, referring to Figure 7 , the electronic device comprises:
[0149] At least one processor 701, and a memory 702 connected to the at least one processor 701. The specific connection medium between the processor 701 and the memory 702 is not limited in the embodiment of the present application. Figure 7 In the example, the processor 701 and the memory 702 are connected via a bus 700. Figure 7 The connections between other components are shown in bold lines, and are not intended to be limiting. The bus 700 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, Figure 7 Only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. Alternatively, the processor 701 can also be called a controller, and there is no limitation on the name.
[0150] In the embodiment of the present application, the memory 702 stores instructions that can be executed by at least one processor 701. The at least one processor 701 can execute the encryption method discussed above by executing the instructions stored in the memory 702. The processor 701 can implement Figure 5 Or the functions of each module in the device shown in 6.
[0151] Among them, the processor 701 is the control center of the device, and can use various interfaces and lines to connect the various parts of the entire control device. By running or executing instructions stored in the memory 702 and calling data stored in the memory 702, the various functions of the device and process data, the device can be monitored as a whole.
[0152] In one possible design, the processor 701 may include one or more processing units, and the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 701. In some embodiments, the processor 701 and the memory 702 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on separate chips.
[0153] Processor 701 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the encryption method disclosed in the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.
[0154] The memory 702 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 702 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (Random Access Memory, RAM), a static random access memory (Static Random Access Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 702 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 702 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0155] By programming the processor 701, the code corresponding to the encryption method described in the above embodiment can be fixed into the chip, so that the chip can execute the encryption method when it is running. Figure 1 The steps of the encryption method of the embodiment shown are as follows: How to design and program the processor 701 is a technique known to those skilled in the art and will not be described in detail here.
[0156] Based on the same inventive concept, the embodiment of the present disclosure provides a computer storage medium, the computer storage medium includes: a computer program code, when the computer program code is executed on a computer, the computer executes any one of the encryption methods discussed above. Since the principle of solving the problem by the above computer storage medium is similar to that of an encryption method, the implementation of the above computer storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0157] In the specific implementation process, the computer storage medium may include: Universal Serial Bus Flash Drive (USB), mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and other storage media that can store program codes.
[0158] Based on the same inventive concept, the embodiment of the present disclosure also provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any one of the encryption methods discussed above. Since the principle of solving the problem by the above computer program product is similar to that of an encryption method, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0159] The computer program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more conductors, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0160] The method in the present application can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by 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 programs or instructions. When the computer program or instruction is loaded and executed on a computer, the process or function described in the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, a core network device, an OAM or other programmable device.
[0161] The computer program or 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 program or instructions may be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium may be a magnetic medium, such as a floppy disk, a hard disk, or a magnetic tape; it may also be an optical medium, such as a digital video disk; it may also be a semiconductor medium, such as a solid-state drive. The computer-readable storage medium may be a volatile or non-volatile storage medium, or may include both volatile and non-volatile types of storage media.
[0162] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0163] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that has the functions specified in one or more boxes.
[0164] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0165] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0166] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. An encryption method, characterized in that: The method comprises: Get the first software bill of materials SBOM of the software; Setting the signature of the first SBOM, and encrypting the signature of the first SBOM to obtain an encrypted string; Combining the encrypted string with the preset information in the first SBOM to obtain target information; The hash value of the target information is calculated by using a first hash algorithm, and the hash value of the target information is written into the first SBOM to obtain a second SBOM.
2. The method according to claim 1, characterized in that The step of obtaining a first software bill of materials (SBOM) of the software includes: Obtaining a source code package of the software; Scanning the dependency package management configuration file of the source code package to generate an initial SBOM; The hash value of the source code package is determined by a second hash algorithm, and the hash value of the source code package is written into the initial SBOM to obtain the first SBOM.
3. The method according to claim 1, characterized in that The step of encrypting the signature of the first SBOM to obtain an encrypted string includes: Receiving user account information and a user key, and verifying the user account information and the user key; In response to successful verification of the user account information and the user key, a token JWT corresponding to the signature of the first SBOM is generated based on the user account information and the user key, and the JWT is used as the encrypted string.
4. The method according to claim 1, characterized in that The method further comprises: Acquire the SBOM of the software to be detected, and preprocess the SBOM of the software to be detected to obtain the SBOM to be detected; Inputting the SBOM to be detected and the preprocessed second SBOM into a twin neural network, outputting the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM; The similarity between the tampered SBOM and the target SBOM is calculated, and the SBOM in the tampered SBOM whose similarity is less than a preset similarity is used as the target tampered SBOM.
5. The method according to claim 4, characterized in that The step of inputting the SBOM to be detected and the preprocessed second SBOM into a twin neural network, and outputting the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM, comprises: Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM; Calculating a difference score between the feature vector to be detected and the target feature vector; The tampered SBOM is output as the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and the target SBOM in the preprocessed second SBOM is output.
6. The method according to claim 4, characterized in that The calculating the similarity between the tampered SBOM and the target SBOM, and taking the SBOM in the tampered SBOM whose similarity is less than the preset similarity as the target tampered SBOM, includes: Performing word segmentation processing on the tampered SBOM and the target SBOM respectively, generating a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM; Calculate the similarity between the first word segmentation vector and the second word segmentation vector; The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is used as the target tampering SBOM.
7. An encryption device, characterized in that: The device comprises: An acquisition module, used for acquiring a first software bill of materials SBOM of the software; A first encryption module, used for setting a signature of the first SBOM, and encrypting the signature of the first SBOM to obtain an encrypted string; A combining module, used for combining the encrypted string with the preset information in the first SBOM to obtain target information; The second encryption module is used to calculate the hash value of the target information by using the first hash algorithm, and write the hash value of the target information into the first SBOM to obtain a second SBOM.
8. The device according to claim 7, characterized in that The acquisition module is specifically used for: Obtaining a source code package of the software; Scanning the dependency package management configuration file of the source code package to generate an initial SBOM; The hash value of the source code package is determined by a second hash algorithm, and the hash value of the source code package is written into the initial SBOM to obtain the first SBOM.
9. The device according to claim 7, characterized in that The first encryption module is specifically used for: Receiving user account information and a user key, and verifying the user account information and the user key; In response to successful verification of the user account information and the user key, a token JWT corresponding to the signature of the first SBOM is generated based on the user account information and the user key, and the JWT is used as the encrypted string.
10. The device according to claim 7, characterized in that The device also includes: A preprocessing module, used for obtaining the SBOM of the software to be detected, and preprocessing the SBOM of the software to be detected to obtain the SBOM to be detected; A first detection module is used to input the SBOM to be detected and the preprocessed second SBOM into a twin neural network, and output the tampered SBOM in the SBOM to be detected and the target SBOM in the preprocessed second SBOM corresponding to the tampered SBOM; The second detection module is used to calculate the similarity between the tampered SBOM and the target SBOM, and take the SBOM in the tampered SBOM whose similarity is less than a preset similarity as the target tampered SBOM.
11. The device according to claim 10, characterized in that The first detection module is specifically used for: Generate a feature vector to be detected corresponding to the SBOM to be detected, and a target feature vector corresponding to the preprocessed second SBOM; Calculating a difference score between the feature vector to be detected and the target feature vector; The tampered SBOM is output as the SBOM corresponding to the feature vector whose difference score is greater than a preset threshold in the feature vector to be detected, and the target SBOM in the preprocessed second SBOM is output.
12. The device according to claim 10, characterized in that The second detection module is specifically used for: Performing word segmentation processing on the tampered SBOM and the target SBOM respectively, generating a first word segmentation vector corresponding to the tampered SBOM and a second word segmentation vector corresponding to the target SBOM; Calculate the similarity between the first word segmentation vector and the second word segmentation vector; The SBOM corresponding to the word segmentation vector whose similarity in the first word segmentation vector is less than the preset similarity is used as the target tampering SBOM.
13. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method according to any one of claims 1 to 6 when executing the computer program stored in the memory.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
15. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 6.
