Method and device for processing signature for software package and electronic equipment

By processing signatures for software packages and using national secret algorithms to generate and add signature data, the problem of software package information security risks and regulatory compliance is solved, and security and independent controllability are improved.

CN118740392APending Publication Date: 2024-10-01ZHONGKE FANGDE SOFTWARE CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410928412.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-11
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing software packages do not use national secret algorithms, resulting in increased information security risks, failure to comply with national regulatory requirements, limited international competitiveness, and risks of technology dependence.

Method used

Provide a method for processing signatures for software packages. By calling the signature interface of the first national secret algorithm and the second national secret algorithm, the signature data and signature summary information are generated, and these data are added to the software package to realize the national secret signature. Protect.

Benefits of technology

It improves the security of software packages, meets national information security policies and legal and regulatory requirements, reduces dependence on external technology, and enhances the independent controllability of information security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740392A_ABST
    Figure CN118740392A_ABST
Patent Text Reader

Abstract

The invention discloses a method and device for processing a signature for a software package and electronic equipment, and the method comprises the steps: obtaining file contents in the software package in response to a signature adding instruction; according to the file content, calling a first signature interface corresponding to a first cryptographic algorithm to obtain first signature data returned by the first signature interface; according to the first signature data, calling a second signature interface corresponding to a second cryptographic algorithm to obtain second signature data returned by the second signature interface; according to the first signature data and the second signature data, signature summary information is obtained, and the signature summary information at least represents the algorithm type of the first cryptographic algorithm and the algorithm type of the second cryptographic algorithm; and adding the signature summary information, the first signature data and the second signature data in the software package.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software security technology, and in particular to a method, device and electronic device for processing signatures for a software package. Background Art

[0002] The Internet is an open system for the public, and the security of information is not fully considered, resulting in increasingly serious information security issues.

[0003] Information security issues involve national security, social public security and major national interests. They are the commanding heights of the Internet economy and the key to promoting the development of the Internet, e-government and e-commerce. The development of information security technology is an urgent requirement currently faced.

[0004] However, most software packages currently do not use national encryption algorithms, which causes software projects to face higher information security risks. Summary of the invention

[0005] In view of the above problems, the present application provides a method, device and electronic device for processing signatures for software packages, so as to achieve the purpose of processing national secret signatures for software packages to improve information security. The specific scheme is as follows:

[0006] A first aspect of the present application provides a method for processing a signature for a software package, the method comprising:

[0007] In response to the signature adding instruction, obtaining the file content in the software package;

[0008] According to the file content, calling the first signature interface corresponding to the first national secret algorithm to obtain the first signature data returned by the first signature interface;

[0009] According to the first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the second signature data returned by the second signature interface;

[0010] Obtaining signature summary information according to the first signature data and the second signature data, wherein the signature summary information at least represents an algorithm type of the first national secret algorithm and an algorithm type of the second national secret algorithm;

[0011] The signature summary information, the first signature data, and the second signature data are added to the software package.

[0012] In a possible implementation, the method further includes:

[0013] According to the signature summary information, updating a field value in the software package for recording the number of signature summary entries, where the number of signature summary entries is the number of signature summary information included in the software package;

[0014] According to the first signature data and the second signature data, a field value for recording a signature length in the software package is updated, where the signature length is the length of the signature data included in the software package.

[0015] In a possible implementation, the method further includes:

[0016] In response to the software installation instruction, read the signature summary information corresponding to the first national encryption algorithm from the software package;

[0017] If the signature summary information corresponding to the first national encryption algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm;

[0018] If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm;

[0019] According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface;

[0020] Comparing the third signature data with the second signature data read from the software package;

[0021] If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result;

[0022] If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface;

[0023] If the signature verification result indicates that the file content in the software package and the first signature data in the software package have passed the verification, executing the installation process of the software package;

[0024] When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

[0025] In a possible implementation, the method further includes:

[0026] In response to the signature verification instruction, reading signature summary information corresponding to the first national encryption algorithm from the software package;

[0027] If the signature summary information corresponding to the first national encryption algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm;

[0028] If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm;

[0029] According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface;

[0030] Comparing the third signature data with the second signature data read from the software package;

[0031] If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result;

[0032] If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface;

[0033] When the signature verification result indicates that the file content in the software package has passed the verification with the first signature data in the software package, a second verification result is obtained, wherein the second verification result indicates that the software package has passed the signature verification of the national encryption algorithm;

[0034] When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

[0035] In a possible implementation, reading the signature summary information corresponding to the first national encryption algorithm from the software package includes:

[0036] The signature summary information whose algorithm type matches the first national encryption algorithm is read in the software package.

[0037] In a possible implementation, reading the first signature data corresponding to the first national encryption algorithm from the software package according to the signature summary information corresponding to the first national encryption algorithm includes:

[0038] The first signature data corresponding to the first national encryption algorithm is read from the software package at least according to the data address recorded in the signature summary information corresponding to the first national encryption algorithm.

[0039] In a possible implementation, the method further includes:

[0040] In response to the signature deletion instruction, the signature summary information corresponding to the first national encryption algorithm and the signature summary information corresponding to the second national encryption algorithm in the software package are deleted.

[0041] In a possible implementation, before obtaining the file content in the software package, the method further includes:

[0042] Determining that the software package satisfies a first condition;

[0043] The software package satisfies a first condition, including: the national encryption configuration item exists, and the software package does not contain signature summary information corresponding to the first national encryption algorithm.

[0044] A second aspect of the present application provides a device for processing a signature for a software package, the device comprising:

[0045] A content obtaining unit, configured to obtain the file content in the software package in response to the signature adding instruction;

[0046] A first signature unit is used to call a first signature interface corresponding to a first national secret algorithm according to the file content to obtain first signature data returned by the first signature interface;

[0047] A second signature unit is used to call a second signature interface corresponding to a second national secret algorithm according to the first signature data to obtain second signature data returned by the second signature interface;

[0048] A summary obtaining unit, configured to obtain signature summary information according to the first signature data and the second signature data, wherein the signature summary information at least represents an algorithm type of the first national secret algorithm and an algorithm type of the second national secret algorithm;

[0049] A signature adding unit is used to add the signature summary information, the first signature data and the second signature data to the software package.

[0050] A third aspect of the present application provides a computer program product, comprising computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the method for processing signatures for a software package according to the first aspect or any implementation of the first aspect.

[0051] A fourth aspect of the present application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:

[0052] The memory is used to store computer programs;

[0053] The processor is used to execute the computer program so that the electronic device can implement the method for processing a signature for a software package according to the first aspect or any implementation manner of the first aspect.

[0054] In a fifth aspect, the present application provides a computer storage medium, which carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can process signatures for a software package according to the first aspect or any implementation of the first aspect.

[0055] By means of the above technical solution, in a method, device and electronic device for processing signatures for a software package provided by the present application, when a national secret signature needs to be added to a software package, in response to a signature adding instruction, the file content in the software package is first obtained, and then the signature interface corresponding to the first national secret algorithm is called according to the file content to obtain the first signature data returned by the signature interface; thereafter, the signature interface corresponding to the second national secret algorithm is called according to the first signature data to obtain the second signature data returned by the signature interface, so that the signature summary information and the two signature data can be added to the software package after the corresponding signature summary information is obtained. It can be seen that in the present application, the signature interface provided by the national secret algorithm can be used to obtain signature data and corresponding signature summary information for the software package, so that after adding signature data and signature summary information to the software package, the software package can be protected by the national secret signature, thereby improving the security of the software package. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0057] Figure 1 This is the system architecture diagram applicable to this application;

[0058] Figure 2 A schematic diagram of the structure of the terminal to which this application is applicable;

[0059] Figure 3 A schematic diagram of the structure of a server in a system to which this application is applicable;

[0060] Figure 4 A flowchart of a method for processing a signature for a software package provided in an embodiment of the present application;

[0061] Figure 5 The schematic diagram of the composition structure of the software package is as follows;

[0062] Figure 6 Another flow chart of a method for processing signatures for a software package provided in an embodiment of the present application;

[0063] Figure 7 A partial flow chart of a method for processing signatures for a software package provided in an embodiment of the present application;

[0064] Figure 8 Another partial flow chart of a method for processing signatures for a software package provided in an embodiment of the present application;

[0065] Fig. 9 A schematic diagram of the structure of a device for processing signatures for a software package provided in an embodiment of the present application;

[0066] Fig.10 Another structural schematic diagram of a device for processing signatures for a software package provided in an embodiment of the present application;

[0067] Fig.11 Another structural schematic diagram of a device for processing signatures for a software package provided in an embodiment of the present application;

[0068] Fig.12 Another structural schematic diagram of a device for processing signatures for a software package provided in an embodiment of the present application;

[0069] Fig.13 Another structural schematic diagram of a device for processing signatures for a software package provided in an embodiment of the present application;

[0070] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0071] Fig.15 This is a sample diagram of the rpm package;

[0072] Fig.16 This is another example diagram of the rpm package;

[0073] Fig.17 This is a flowchart of executing rpm--addsign for rpm with the newly added national encryption algorithm in the embodiment of the present application;

[0074] Fig.18 This is a flowchart of executing the rpm-ivh command to install the rpm media package for the rpm with the newly added national encryption algorithm in the embodiment of the present application;

[0075] Fig.19 This is a flowchart of executing the rpm --checksig command for the rpm after the newly added national secret signature verification in the embodiment of the present application;

[0076] Fig. 20This is a flowchart of executing the rpm--delsign command for the rpm with the newly added national encryption algorithm in the embodiment of the present application. DETAILED DESCRIPTION

[0077] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0078] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0079] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0080] See also Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 In the example, a server is included in the description), the server 200 can provide a processing interface of the national secret algorithm for one or more terminals, such as a signature interface and a signature verification interface. The signature interface is used to implement the corresponding data signature for the terminal, and the signature verification interface is used to verify whether the signature data has passed the verification for the terminal. For example, the first signature interface is used to sign the file content of the software package using the private key corresponding to the first national secret algorithm to obtain the first signature data; for another example, the second signature interface is used to calculate the hash value of the first signature data using the private key corresponding to the second national secret algorithm to obtain the second signature data; for another example, the signature verification interface corresponding to the first national secret algorithm is used to verify whether the first signature data matches the file content in the software package. The first national secret algorithm here can be the SM2 national secret algorithm (hereinafter referred to as SM2), and the second national secret algorithm can be the SM3 national secret algorithm (hereinafter referred to as SM3).

[0081] Among them, the terminal 100 can be installed with an application that implements the embodiment of the present application. The above application can provide an operation interface. The terminal 100 can receive the input operations performed by the user on the operation interface and generate corresponding instructions, such as signature addition instructions, software installation instructions, signature verification instructions, signature deletion instructions, etc. The terminal 100 performs corresponding signature processing according to these instructions, and sends relevant data to the server 200 when it is necessary to call the processing interface of the server 200. The server 200 can obtain processing results such as signature data or signature verification results based on the received data, and return the processing results to the terminal 100.

[0082] It should be understood that in some optional implementations, the terminal 100 can also complete the signing and verification processing by itself to obtain the processing result without the need for the cooperation of the server, and the embodiments of the present application are not limited thereto.

[0083] Next describe Figure 1 The product form of the mid-terminal 100;

[0084] The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any limitation on this.

[0085] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.

[0086] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160 (optional), a speaker 161 (optional), a microphone 162 (optional), an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 These are merely examples of terminals or multi-function devices and do not constitute limitations on the terminals or multi-function devices, which may include more or fewer components than those shown in the figures, or combinations of certain components, or different components.

[0087] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the portable multifunctional device. Specifically, the input unit 130 may include a touch screen 131 (optional) and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0088] The input device 132 may receive input operations or data, etc.

[0089] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 may be used to display an operation interface and signature verification results, etc.

[0090] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.

[0091] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.

[0092] Among them, the memory 120 can be used to store software codes related to the method for processing signatures for software packages in the embodiment of the present application, the processor 170 can execute the steps of the method for processing signatures for software packages, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.

[0093] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.

[0094] In this embodiment of the present application, the RF unit 110 can send data to the server 200 and receive processing results sent by the server 200.

[0095] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.

[0096] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.

[0097] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .

[0098] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.

[0099] Next describe Figure 1 The product form of the server 200;

[0100] Figure 3 A structural diagram of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0101] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0102] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0103] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard drive (HDD), or a solid state drive (SSD).

[0104] The memory 204 may be used to store software codes related to implementing the signature interface and the visa interface, and the processor 202 may execute the implementation steps of the signature interface and the visa interface of the chip, and may also schedule other units to implement corresponding functions.

[0105] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0106] Taking the software package development scenario of Internet applications as an example, current software packages have the following security issues:

[0107] 1. Increased information security risks: The national cryptographic algorithm is a domestic cryptographic algorithm approved by the National Cryptography Administration, which is designed to protect national information security. If the national cryptographic algorithm is not adopted, the project may face higher information security risks, including data leakage, illegal acquisition or tampering.

[0108] 2. Failure to comply with national laws and regulations: In certain industries and fields, the use of national encryption algorithms may comply with national security laws and policies. If a project does not use national encryption algorithms, it may not comply with relevant laws and policies and face compliance risks.

[0109] 3. Limited international competitiveness: With the improvement of global information security awareness, the use of national secret algorithms has become an important means to enhance national information security capabilities and international competitiveness. Projects that do not use national secret algorithms may be subject to certain restrictions in the international market, affecting the project's international competitiveness.

[0110] 4. Technology dependence risk: Projects that do not adopt national cryptographic algorithms may be overly dependent on foreign cryptographic algorithms, which may lead to the risk of technology supply interruption in certain circumstances, such as tense international relations or technological blockades.

[0111] In order to solve the above problems, the embodiment of the present application provides a method for processing signatures for a software package. The method for processing signatures for a software package according to the embodiment of the present application is described in detail below in conjunction with the accompanying drawings.

[0112] Reference Figure 4 , Figure 4A flowchart of a method for processing a signature for a software package provided in an embodiment of the present application is provided. The method can be applied to electronic devices capable of performing data processing, such as Figure 1 The terminal 100 is shown. The technical solution in this embodiment is mainly used to improve the security of the software package.

[0113] Specifically, the method in this embodiment may include the following steps:

[0114] Step 401: In response to a signature adding instruction, obtain the file content in the software package.

[0115] The signature adding instruction may be generated in response to an input operation performed by a user on an operation interface of the electronic device, or the signature adding instruction may be automatically generated during the development process of the software package.

[0116] In one implementation, in this embodiment, based on the composition structure of the software package, the file content in the software package can be read according to the address where the file content is located.

[0117] Specifically, Figure 5 As shown in the figure, it is a schematic diagram of the composition structure of the software package, in which the software package mainly includes eight parts: n1-n8, as follows:

[0118] n1: the file header of the software package. For example, if the software package is an rpm software package, the file header of the software package is the first 96 bytes of the rpm file.

[0119] n2: the first tag information, which includes four fields: a1, a2, a3, and a4, with a total of 16 bytes. The first field (four bytes) is a1, which is a tag bit, indicating that the signature summary information is after n2. The second field (four bytes) is a2, which is a reserved bit. The third field (four bytes) is a3, which records the number of signature summary items, which is the number of signature summary information included in the software package. The last field (four bytes) is a4, which records the signature length, which is the length of the signature data included in the software package.

[0120] n3: signature summary information, where each signature summary information is 16 bytes, the number of signature summary information, i.e. the number of signature summary items, is recorded in a3 (decimal value) in n2, and the byte length of n3 is the product of a3 and 16; for example, the signature summary information includes: algorithm type, data type, data address, and data length; the algorithm type of gpg (GNU Privacy Guard) can be represented by RPMSIGTAG_GPG, RPMSIGTAG_PGP, RPMSIGTAG_DSA, RPMSIGTAG_RSA, RPMSIGTAG_PGP5, etc., the algorithm type of SM2 national secret algorithm can be represented by RPMSIGTAG_SM2, and the algorithm type of SM3 national secret algorithm can be represented by RPMSIGTAG_SM3;

[0121] n4: signature data. The length of the signature data, i.e. the signature length, is recorded in a4 (decimal value) in n2.

[0122] n5: The second tag information, which contains four fields: b1, b2, b3, b4, a total of 16 bytes; the first field (four bytes) is b1, b1 is the tag bit; the second field (four bytes) is b2, b2 is a reserved bit; the third field (four bytes) is b3, b3 records the number of summary information of the dependency relationship and file path information in the software package; the dependency relationship only expresses the currently installed software package file such as the rpm file that depends on other files; the file path information only indicates which files are installed after the current software package file is installed; for example, the file a.rpm can depend on File b.rpm, that is, before installing a.rpm, b.rpm must be installed first; for another example, a software package can include multiple files (such as / usr / bin / x1, / usr / bin / x2...), after installing a.rpm, / usr / bin / x1 and / usr / bin / x2 in a.rpm package are installed to the system, then / usr / bin / x1 and / usr / bin / x2 are the path information of the package; the last field (four bytes) is b4, which records the dependency relationship and the length of the file path information in the software package file;

[0123] n6: summary information of dependency and file path information; each summary information is 16 bytes, the number of summary information is recorded in b3 (decimal value) of n5, and the byte length of n6 is the product of b3 and 16;

[0124] n7: dependency relationship and file path information. The length of the dependency relationship and file path information is recorded in b4 of n5 (decimal value).

[0125] n8: The file contents of the software package, including multiple installation files and related contents.

[0126] based on Figure 5 The software package composition structure shown in the figure, in this embodiment, the starting address of the file content in the software package can be obtained according to formula (1), and then the corresponding file content can be read according to the starting address:

[0127] P1=n1+n2+a3*16+a4+4+n5+b3*16+b4 (1)

[0128] Wherein, P1 is the total number of bytes n1-n7 before the file content in the software package. Accordingly, the next byte of the P1 byte in the software package is the starting position of the data address of the file content. The next byte of the P1 byte in the software package is the data address of the file content. Based on this, in this embodiment, in the software package, reading starts from the next byte of P1, thereby reading the file content in the software package.

[0129] In one implementation, in this embodiment, before obtaining the file content in the software package, it can be determined whether the software package meets the first condition. Only when it is determined that the software package meets the first condition can the file content in the software package be obtained. If the software package does not meet the first condition, the subsequent process cannot be executed, that is, the national secret signature cannot be performed for the software package. For example, in a scenario where the use of national secret signatures is not allowed, the process in this embodiment cannot be executed.

[0130] Specifically, the software package meeting the first condition may include: the national encryption configuration item exists, and the software package does not contain signature summary information corresponding to the first national encryption algorithm.

[0131] Among them, the national secret configuration item is a configuration item that indicates that the software package needs to be signed by the national secret. Specifically, in this embodiment, it can be determined whether the / etc / nfssec.d / rpmconfig.cfg configuration file exists. If the configuration file exists, then check whether the specified field rpmgmkey in the configuration file exists. If the specified field rpmgmkey exists, then check the corresponding value. If the value of the specified field rpmgmkey is 0, it is determined that the national secret configuration item does not exist. If the value of the specified field rpmgmkey is 1, it is determined that the national secret configuration item exists.

[0132] If the software package contains signature summary information corresponding to the first national secret algorithm, it indicates that the software package has been signed by the national secret, and there is no need to sign the software package with the national secret; if the software package does not contain signature summary information corresponding to the first national secret algorithm, it indicates that the software package has not been signed with the national secret, and then the process in this embodiment can be executed when the national secret configuration item exists, that is, the file content in the software package and subsequent steps are obtained.

[0133] Step 402: According to the file content, call the first signature interface corresponding to the first national encryption algorithm to obtain the first signature data returned by the first signature interface.

[0134] Among them, the first signature interface corresponding to the first national secret algorithm can be deployed on the national secret service device connected to the electronic device, such as Figure 1 The server 200 shown. For example, the SM2 signature interface is deployed on the national secret server.

[0135] Specifically, in this embodiment, the first signature interface can be called with the file content as an interface parameter, and the first signature interface uses the private key corresponding to the first national encryption algorithm to sign the file content to obtain the first signature data. The first signature interface returns the first signature data to the electronic device in this embodiment.

[0136] For example, in this embodiment, the private key of SM2 is used to call the SM2 signature interface to sign the file content of the software package to obtain the SM2 signature data returned by the SM2 signature interface, that is, the first signature data.

[0137] Step 403: According to the first signature data, call the second signature interface corresponding to the second national encryption algorithm to obtain the second signature data returned by the second signature interface.

[0138] Among them, the second signature interface corresponding to the second national secret algorithm can be deployed on the national secret service device connected to the electronic device, such as Figure 1 The server 200 shown. For example, the SM3 signature interface is deployed on the national secret server.

[0139] Specifically, in this embodiment, the first signature data can be used as an interface parameter to call the second signature interface, and the second signature interface can perform a hash calculation on the first signature data to obtain the second signature data. The second signature data can be a hash value, and the second signature interface returns the second signature data to the electronic device in this embodiment.

[0140] For example, in this embodiment, the SM3 signature interface is called to perform hash calculation on the SM2 signature data to obtain the SM3 hash value returned by the SM3 signature interface, that is, the second signature data.

[0141] Step 404: Obtain signature summary information according to the first signature data and the second signature data.

[0142] The signature summary information obtained in step 404 includes the signature summary information corresponding to the first signature data and the signature summary information corresponding to the second signature data. The signature summary information corresponding to the first signature data at least represents the algorithm type of the first national secret algorithm. In addition, the signature summary information corresponding to the first signature data can also represent the data type, data address, and data length of the first signature data, wherein the data address of the first signature data is the data address to be written into the software package by the first signature data.

[0143] The signature summary information corresponding to the second signature data at least represents the algorithm type of the second national secret algorithm. In addition, the signature summary information corresponding to the second signature data can also represent the data type, data address, and data length of the second signature data, wherein the data address of the second signature data is the data address where the second signature data is to be written into the software package.

[0144] Step 405: Add the signature summary information, the first signature data and the second signature data to the software package.

[0145] Specifically, in this embodiment, the signature summary information, the first signature data and the second signature data can be written into the corresponding specific locations in the software package, respectively. The resulting software package contains the signature data and signature summary information of the national secret algorithm.

[0146] For example, Figure 5 Taking the software package composition structure shown in as an example, in this embodiment, the signature summary information is written at the n3 position of the software package, and the first signature data and the second signature data are written at the n4 position of the software package.

[0147] According to the above technical solution, in a method for processing signatures for a software package provided by an embodiment of the present application, when a national secret signature needs to be added to a software package, in response to a signature adding instruction, the file content in the software package is first obtained, and then the signature interface corresponding to the first national secret algorithm is called according to the file content to obtain the first signature data returned by the signature interface; thereafter, the signature interface corresponding to the second national secret algorithm is called according to the first signature data to obtain the second signature data returned by the signature interface, so that the signature summary information and the two signature data can be added to the software package after the corresponding signature summary information is obtained. It can be seen that in this embodiment, the signature interface provided by the national secret algorithm can be used to obtain signature data and corresponding signature summary information for the software package, so that after adding signature data and signature summary information to the software package, the software package can be protected by the national secret signature, thereby improving the security of the software package.

[0148] In one implementation, after step 405, the method in this embodiment may further include the following processing: Figure 6 As shown in:

[0149] Step 406: According to the signature summary information, update the field value for recording the number of signature summary entries in the software package.

[0150] The number of signature summary entries is the number of signature summary information contained in the software package. Figure 5 Taking the software package composition structure shown as an example, in this embodiment, the value of a3 in n2 is increased by 2, and the increase of 2 means that two signature summary information in n3 are added: the signature summary information of SM2 and the signature summary information of SM3.

[0151] Step 407: Update the field value for recording the signature length in the software package according to the first signature data and the second signature data.

[0152] The signature length is the length of the signature data contained in the software package. Figure 5 Taking the software package composition structure shown as an example, in this embodiment, the value of a4 in n2 is increased by a target value. Increasing the target value means that the signature data in n4 is increased by the signature data of SM2 and the signature data of SM3, and the target value is the total length of the signature data of SM2 and the signature data of SM3.

[0153] It should be noted that the execution order of step 406 and step 407 is not limited to the drawings. Step 407 can be executed first and then step 406, or step 406 and step 407 can be executed simultaneously. The different technical solutions realized by the different execution orders of step 406 and step 407 are all within the protection scope of this application.

[0154] In one implementation, the present embodiment can also perform signature verification on the software package with the national secret signature when installing to ensure the installation security of the software package. The specific processing is as follows: Figure 7 As shown in:

[0155] Step 701: In response to a software installation instruction, signature summary information corresponding to a first national encryption algorithm is read from a software package.

[0156] The software installation instruction may be automatically generated when a software package needs to be installed during the operation of the electronic device, or may be generated in response to an installation trigger operation performed after the user selects the software package. In this embodiment, the signature summary information corresponding to the first national secret algorithm may be searched and read according to the algorithm type at the address used to store the signature summary information in the software package.

[0157] Specifically, in this embodiment, the signature summary information whose algorithm type matches the first national encryption algorithm can be read in the software package.

[0158] For example, Figure 5Taking the software package composition structure shown as an example, in this embodiment, in n3 of the software package, the signature summary information of the algorithm type SM2 is searched, and thus the signature summary information of the algorithm type SM2 can be read according to the found address.

[0159] In one implementation, in this embodiment, before reading the signature summary information corresponding to the first national secret algorithm from the software package, it can be determined whether the software package meets the second condition. Only when it is determined that the software package meets the second condition, can the signature summary information corresponding to the first national secret algorithm be read from the software package, that is, the national secret signature verification of the software package be started; if the software package does not meet the second condition, then the national secret signature verification in this embodiment is not required, and other signature verifications can be performed on the software package at this time to ensure the installation security of the software package.

[0160] Specifically, the software package meeting the second condition may include: the national secret configuration item exists.

[0161] Step 702: Determine whether the signature summary information corresponding to the first national secret algorithm is read from the software package. If the signature summary information corresponding to the first national secret algorithm is not read in the software package, execute step 703; if the signature summary information corresponding to the first national secret algorithm is read in the software package, execute step 704.

[0162] Step 703: Obtain the first verification result and end the process.

[0163] The first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm. At this time, the installation process of the software package is not executed to avoid device damage and data leakage caused by the installation of illegal software packages, so as to protect the security of electronic devices.

[0164] Step 704: Read the first signature data corresponding to the first national encryption algorithm from the software package according to the signature summary information corresponding to the first national encryption algorithm.

[0165] In this embodiment, the first signature data corresponding to the first national encryption algorithm can be searched at the address for storing signature data in the software package and the data can be read.

[0166] Specifically, in this embodiment, in the software package, according to the data address recorded in the signature summary information corresponding to the first national secret algorithm, the first signature data corresponding to the first national secret algorithm can be read. Further, in this embodiment, in the software package, according to the data address and data address recorded in the signature summary information corresponding to the first national secret algorithm, the first signature data corresponding to the first national secret algorithm can be read.

[0167] For example, Figure 5Taking the software package composition structure shown as an example, in this embodiment, in n4 of the software package, the corresponding signature data, namely, the SM2 signature data, is read according to the data address and data length in the signature summary information of SM2.

[0168] Step 705: Based on the read first signature data, call the second signature interface corresponding to the second national encryption algorithm to obtain the third signature data returned by the second signature interface.

[0169] Specifically, in this embodiment, the read first signature data can be used as an interface parameter to call the second signature interface, and the second signature interface performs a hash calculation on the read first signature data to obtain third signature data. The third signature data can be a hash value, and the second signature interface returns the third signature data to the electronic device in this embodiment.

[0170] For example, in this embodiment, the SM3 signature interface is called to perform hash calculation on the SM2 signature data read from the software package to obtain the SM3 hash value returned by the SM3 signature interface, that is, the third signature data.

[0171] Step 706: Compare the third signature data with the second signature data read from the software package. If the third signature data is inconsistent with the second signature data read from the software package, execute step 703. If the third signature data is consistent with the second signature data read from the software package, execute step 707.

[0172] Step 707: According to the file content in the software package and the first signature data in the software package, the signature verification interface corresponding to the first national encryption algorithm is called to obtain the signature verification result returned by the signature verification interface.

[0173] The first signature data in the software package can be read from the software package in the manner of step 704. The file content in the software package can be read from the software package in the manner of step 401.

[0174] Based on this, in this embodiment, the first signature data in the software package and the file content in the software package can be used as interface parameters to call the signature verification interface, and the signature verification interface uses the private key corresponding to the first national secret algorithm to sign the file content in the software package to obtain intermediate signature data, and compares the intermediate signature data with the first signature data in the software package. If the comparison is consistent, the signature verification interface returns a signature verification result indicating that the file content in the software package and the first signature data in the software package have been verified successfully. If the comparison is inconsistent, the signature verification interface returns a signature verification result indicating that the file content in the software package and the first signature data in the software package have not been verified successfully.

[0175] Step 708: Determine whether the signature verification result indicates that the file content in the software package has been verified with the first signature data in the software package. If the signature verification result indicates that the file content in the software package has been verified with the first signature data in the software package, execute step 709. If the signature verification result indicates that the file content in the software package has not been verified with the first signature data in the software package, execute step 703.

[0176] In addition, if the signature verification result indicates that the file content in the software package has passed the verification with the first signature data in the software package, a second verification result may also be obtained, and the second verification result indicates that the software package has passed the signature verification of the national encryption algorithm.

[0177] Step 709: Execute the installation process of the software package.

[0178] It can be seen that in this embodiment, when installing a software package, the signature of the national secret algorithm of the software package is first verified. Only when the signature verification of the national secret algorithm passes, the software package installation is allowed, that is, the installation process of the software package is executed. If the signature verification of the national secret algorithm fails, the software package installation is not allowed, thereby avoiding device damage and data leakage caused by the installation of illegal software packages, so as to protect the security of electronic equipment.

[0179] In one implementation, the present embodiment can also perform signature verification on the software package with the national secret signature to ensure the security of the software package. The specific processing is as follows: Figure 8 As shown in:

[0180] Step 801: In response to a signature verification instruction, signature summary information corresponding to a first national encryption algorithm is read from a software package.

[0181] The signature verification instruction may be automatically generated when the national secret signature of the software package needs to be verified during the operation of the electronic device, or may be generated in response to a verification trigger operation performed after the user selects the software package. In this embodiment, the signature summary information corresponding to the first national secret algorithm may be searched and read according to the algorithm type at the address used to store the signature summary information in the software package.

[0182] Specifically, in this embodiment, the signature summary information whose algorithm type matches the first national encryption algorithm can be read in the software package.

[0183] For example, Figure 5 Taking the software package composition structure shown as an example, in this embodiment, in n3 of the software package, the signature summary information of the algorithm type SM2 is searched, and thus the signature summary information of the algorithm type SM2 can be read according to the found address.

[0184] In one implementation, in this embodiment, before reading the signature summary information corresponding to the first national secret algorithm from the software package, it can be determined whether the software package meets the third condition. Only when it is determined that the software package meets the third condition, can the signature summary information corresponding to the first national secret algorithm be read from the software package, that is, the national secret signature verification of the software package be started; if the software package does not meet the third condition, then the national secret signature verification in this embodiment is not required, and other signature verifications can be performed on the software package at this time to ensure the security of the software package.

[0185] Specifically, the software package meeting the third condition may include: the national secret configuration item exists.

[0186] Step 802: Determine whether the signature summary information corresponding to the first national secret algorithm is read from the software package. If the signature summary information corresponding to the first national secret algorithm is not read in the software package, execute step 803; if the signature summary information corresponding to the first national secret algorithm is read in the software package, execute step 804.

[0187] Step 803: Obtain the first verification result and end the process.

[0188] Among them, the first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm.

[0189] Step 804: Read the first signature data corresponding to the first national encryption algorithm from the software package according to the signature summary information corresponding to the first national encryption algorithm.

[0190] In this embodiment, the first signature data corresponding to the first national encryption algorithm can be searched at the address for storing signature data in the software package and the data can be read.

[0191] Specifically, in this embodiment, in the software package, according to the data address recorded in the signature summary information corresponding to the first national secret algorithm, the first signature data corresponding to the first national secret algorithm can be read. Further, in this embodiment, in the software package, according to the data address and data address recorded in the signature summary information corresponding to the first national secret algorithm, the first signature data corresponding to the first national secret algorithm can be read.

[0192] For example, Figure 5 Taking the software package composition structure shown as an example, in this embodiment, in n4 of the software package, the corresponding signature data, namely, the SM2 signature data, is read according to the data address and data length in the signature summary information of SM2.

[0193] Step 805: According to the read first signature data, call the second signature interface corresponding to the second national encryption algorithm to obtain the third signature data returned by the second signature interface.

[0194] Specifically, in this embodiment, the read first signature data can be used as an interface parameter to call the second signature interface, and the second signature interface performs a hash calculation on the read first signature data to obtain third signature data. The third signature data can be a hash value, and the second signature interface returns the third signature data to the electronic device in this embodiment.

[0195] For example, in this embodiment, the SM3 signature interface is called to perform hash calculation on the SM2 signature data read from the software package to obtain the SM3 hash value returned by the SM3 signature interface, that is, the third signature data.

[0196] Step 806: Compare the third signature data with the second signature data read from the software package. If the third signature data is inconsistent with the second signature data read from the software package, execute step 803. If the third signature data is consistent with the second signature data read from the software package, execute step 807.

[0197] Step 807: According to the file content in the software package and the first signature data in the software package, the signature verification interface corresponding to the first national encryption algorithm is called to obtain the signature verification result returned by the signature verification interface.

[0198] The first signature data in the software package can be read from the software package in the manner of step 804. The file content in the software package can be read from the software package in the manner of step 401.

[0199] Based on this, in this embodiment, the first signature data in the software package and the file content in the software package can be used as interface parameters to call the signature verification interface, and the signature verification interface uses the private key corresponding to the first national secret algorithm to sign the file content in the software package to obtain intermediate signature data, and compares the intermediate signature data with the first signature data in the software package. If the comparison is consistent, the signature verification interface returns a signature verification result indicating that the file content in the software package and the first signature data in the software package have been verified successfully. If the comparison is inconsistent, the signature verification interface returns a signature verification result indicating that the file content in the software package and the first signature data in the software package have not been verified successfully.

[0200] Step 808: Determine whether the signature verification result indicates that the file content in the software package has been verified with the first signature data in the software package. If the signature verification result indicates that the file content in the software package has been verified with the first signature data in the software package, execute step 809. If the signature verification result indicates that the file content in the software package has not been verified with the first signature data in the software package, execute step 803.

[0201] Step 809: Obtain a second verification result, where the second verification result indicates that the software package has passed the signature verification of the national encryption algorithm.

[0202] It can be seen that in this embodiment, the signature of the national secret algorithm of the software package can be verified. Only when the signature verification of the national secret algorithm passes can the software package be determined to be safe, and other processing can be performed subsequently.

[0203] In one implementation, in this embodiment, in response to the signature deletion instruction, the signature summary information corresponding to the first national encryption algorithm and the signature summary information corresponding to the second national encryption algorithm in the software package can be deleted.

[0204] The signature deletion instruction may be automatically generated when the national secret signature needs to be deleted during the operation of the electronic device, or may be generated in response to the user's deletion operation of the national secret signature. In addition, in this embodiment, the first signature data and the second signature data in the software package may not be deleted according to actual needs; in this embodiment, in a specific scenario, the first signature data and the second signature data in the software package may be deleted in response to the signature deletion instruction.

[0205] Furthermore, in this embodiment, after deleting the signature summary information corresponding to the first national encryption algorithm and the signature summary information corresponding to the second national encryption algorithm, the field value for recording the number of signature summary entries in the software package can be updated.

[0206] For example, Figure 5 Taking the software package composition structure shown in FIG. 1 as an example, in this embodiment, the signature summary information of SM2 and the signature summary information of SM3 in n3 are deleted, and the value of a3 in n2 is reduced by 2. Furthermore, in this embodiment, the SM2 signature data and the SM3 signature data in n4 can also be deleted, and the value of a4 in n2 is reduced by a target value, and the target value is the total length of the SM2 signature data and the SM3 signature data.

[0207] It should be noted that, in addition to deleting the signature summary information corresponding to the first national secret algorithm and the signature summary information corresponding to the second national secret algorithm, the signature summary information corresponding to other algorithm types such as GPG can also be deleted. At this time, all signature data can be retained.

[0208] A method for processing signatures for a software package provided in an embodiment of the present application is described above. A device for executing the method for processing signatures for a software package is described below.

[0209] See also Fig. 9 , Fig. 9 A schematic diagram of a device for processing signatures for a software package provided in an embodiment of the present application. The device can be configured in an electronic device capable of data processing, such as Figure 1 The terminal 100 is shown. The technical solution in this embodiment is mainly used to improve the security of the software package.

[0210] Specifically, the device in this embodiment may include the following units:

[0211] The content obtaining unit 901 is used to obtain the file content in the software package in response to the signature adding instruction;

[0212] The first signature unit 902 is used to call the first signature interface corresponding to the first national encryption algorithm according to the file content to obtain the first signature data returned by the first signature interface;

[0213] The second signature unit 903 is used to call the second signature interface corresponding to the second national secret algorithm according to the first signature data to obtain the second signature data returned by the second signature interface;

[0214] A summary obtaining unit 904 is used to obtain signature summary information according to the first signature data and the second signature data, where the signature summary information at least represents the algorithm type of the first national secret algorithm and the algorithm type of the second national secret algorithm;

[0215] The signature adding unit 905 is used to add the signature summary information, the first signature data and the second signature data to the software package.

[0216] According to the above technical solution, in a device for processing signatures for a software package provided by an embodiment of the present application, when a national secret signature needs to be added to a software package, in response to a signature adding instruction, the file content in the software package is first obtained, and then the signature interface corresponding to the first national secret algorithm is called according to the file content to obtain the first signature data returned by the signature interface; thereafter, the signature interface corresponding to the second national secret algorithm is called according to the first signature data to obtain the second signature data returned by the signature interface, so that the signature summary information and the two signature data can be added to the software package after the corresponding signature summary information is obtained. It can be seen that in this embodiment, the signature interface provided by the national secret algorithm can be used to obtain signature data and corresponding signature summary information for the software package, so that after adding the signature data and signature summary information to the software package, the software package can be protected by the national secret signature, thereby improving the security of the software package.

[0217] In a possible implementation, the signature adding unit 905 is further used to: update, according to the signature summary information, a field value for recording the number of signature summary entries in the software package, where the number of signature summary entries is the number of signature summary information included in the software package; and update, according to the first signature data and the second signature data, a field value for recording the signature length in the software package, where the signature length is the length of the signature data included in the software package.

[0218] In one implementation, this embodiment may also include the following units: Fig.10As shown in: Installation verification unit 906 is used to:

[0219] In response to the software installation instruction, read the signature summary information corresponding to the first national encryption algorithm from the software package;

[0220] If the signature summary information corresponding to the first national encryption algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm;

[0221] If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm;

[0222] According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface;

[0223] Comparing the third signature data with the second signature data read from the software package;

[0224] If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result;

[0225] If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface;

[0226] If the signature verification result indicates that the file content in the software package and the first signature data in the software package have passed the verification, executing the installation process of the software package;

[0227] When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

[0228] In one implementation, this embodiment may also include the following units: Fig.11 As shown in: Signature verification unit 907, used to:

[0229] In response to the signature verification instruction, reading signature summary information corresponding to the first national encryption algorithm from the software package;

[0230] If the signature summary information corresponding to the first national encryption algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national encryption algorithm;

[0231] If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm;

[0232] According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface;

[0233] Comparing the third signature data with the second signature data read from the software package;

[0234] If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result;

[0235] If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface;

[0236] When the signature verification result indicates that the file content in the software package has passed the verification with the first signature data in the software package, a second verification result is obtained, wherein the second verification result indicates that the software package has passed the signature verification of the national encryption algorithm;

[0237] When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

[0238] In one implementation, when the installation verification unit 906 or the signature verification unit 907 reads the signature summary information corresponding to the first national encryption algorithm from the software package, it is specifically used to: read the signature summary information whose algorithm type matches the first national encryption algorithm in the software package.

[0239] In one implementation, when the installation verification unit 906 or the signature verification unit 907 reads the first signature data corresponding to the first national secret algorithm from the software package according to the signature summary information corresponding to the first national secret algorithm, it is specifically used to: read the first signature data corresponding to the first national secret algorithm from the software package, at least according to the data address recorded in the signature summary information corresponding to the first national secret algorithm.

[0240] In one implementation, this embodiment may also include the following units: Fig.12 As shown in: the signature deletion unit 908 is used to: in response to the signature deletion instruction, delete the signature summary information corresponding to the first national encryption algorithm and the signature summary information corresponding to the second national encryption algorithm in the software package.

[0241] In one implementation, this embodiment may also include the following units: Fig.13 As shown in: the condition judgment unit 909 is used to: determine that the software package meets the first condition before the content acquisition unit 901 obtains the file content in the software package; wherein, the software package meets the first condition, including: the national encryption configuration item exists, and the software package does not contain the signature summary information corresponding to the first national encryption algorithm.

[0242] It should be noted that the specific implementation of each unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.

[0243] The present application also provides an electronic device, such as Figure 1 The terminal 100 is shown. Fig.14 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic device in the embodiments of the present application may include but is not limited to fixed terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Fig.14 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0244] like Fig.14 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 1401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1402 or a program loaded from a storage device 1408 into a random access memory (RAM) 1403. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 1403. The processing device 1401, the ROM 1402, and the RAM 1403 are connected to each other via a bus 1404. An input / output (I / O) interface 1405 is also connected to the bus 1404.

[0245] Typically, the following devices may be connected to the I / O interface 1405: an input device 1406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1408 including, for example, a memory card, a hard disk, etc.; and a communication device 1409. The communication device 1409 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Fig.14 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0246] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any method for processing a signature for a software package provided in the embodiment of the present application.

[0247] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any method for processing a signature for a software package provided in an embodiment of the present application.

[0248] Taking the rpm software package as an example, the technical solution of this application is described below:

[0249] In the face of RPM security issues, this application adopts the new SM2 and SM3 national secret signature verification methods in RPM, filling the gap of RPM signature verification without national secret algorithms, enhancing the robustness of RPM source code and the security, stability, and autonomous controllability of RPM installation. The specific advantages are as follows:

[0250] 1. Improve security: The national secret algorithm uses advanced encryption technology and algorithms, which can effectively prevent data leakage and tampering. This is crucial for protecting sensitive information and preventing hacker attacks and data theft.

[0251] 2. Autonomy and controllability: The national secret algorithm is independently developed by the country. Using the national secret algorithm means more autonomy and control in the field of information security. This helps reduce dependence on external technology and improve autonomy in the field of information security.

[0252] 3. Compatibility: The national encryption algorithm is compatible with other encryption algorithms and systems, which is convenient for users to migrate and upgrade. This ensures that when the national encryption algorithm is introduced, it will not cause too much impact on existing systems and technologies.

[0253] 4. Compliance with regulatory requirements: The use of national secret algorithms helps to comply with national information security policies and laws and regulations. Especially in areas involving financial transactions, e-government, mobile communications, the Internet of Things, etc., the application of national secret algorithms is of great significance for ensuring information security.

[0254] The specific plan includes the following aspects:

[0255] 1. Find the real file data of the rpm package (that is, the file content in the previous article), such as Figure 5 as shown in .

[0256] It should be noted that a1, a2, a3, a4, b1, b2, b3, and b4 are all hexadecimal and need to be converted to decimal for calculation.

[0257] Wherein, in formula (1), P1 is the data from the file header to the rpm file dependency and file path information. In the following embodiment of the present application, the next bit of P1 in the rpm file is used as the starting position of the real file data to be signed by sm2, that is, the data from the next bit of P1 to the end of the rpm file is used as the signed data of sm2. In the following formula (2), P2 is the data from the file header to the end of the signature information:

[0258] P2=n1+n2+a3*16+a4+4 (2)

[0259] The specific calculation rules are as follows, taking nfs-fprcheck-1.0-1.nfs4.x86_64.rpm as an example. Fig.15 and Fig.16 As shown in:

[0260] <1> Lines 1 to 6: n1 (96 bytes) is the file header in rpm format.

[0261] <2> Line 7: n2 (16 bytes) is the mark information: including four-byte mark bit a1, four-byte reserved bit a2, four-byte file signature number a3 (line 8 to line 16), and the last four bytes are the signature data length a4.

[0262] <3> The number of signatures is a3, where every sixteen bytes of data corresponds to the following data structure: four bytes for algorithm type, four bytes for data type, four bytes for data address, and four bytes for data length; Size corresponds to the header signature data, and the size in the example is a4, which is 0x1094 in hexadecimal and 4244 in decimal.

[0263] <4> Calculate from the rpm file header: refer to formula (2), where P2 = 96 + 16 + 9 * 16 + 4244 + 4 = 4504 (bytes), 4504 / 16 = 281.5, which means it ends at the 8th byte in the middle of the 282nd line.

[0264] <5> In line 282, the next marker of rpm appears, and the calculation is performed in the same way. There are b3 (0x3a), which is 58 16-byte paths and dependency numbers, and then b4 (size) is 0x0b4c, which is the file path data information and dependency data in the rpm package.

[0265] <6> The data after the dependency is the data information of the file in the rpm package, that is, the signed data of sm2. The calculation method refers to formula (1).

[0266] 2. Add the rpm signature for national secret signature verification (rpm--addsign):

[0267] After adding the national encryption algorithm, the rpm is processed as follows when executing rpm--addsign, such as Fig.17 As shown in:

[0268] 2.1. Check whether the national secret configuration item exists. If the national secret configuration item does not exist, directly use the conventional gpg signature; if the national secret configuration item exists, do not use the gpg signature, and execute the following steps 2.2-2.5;

[0269] Specifically, first determine whether the / etc / nfssec.d / rpmconfig.cfg configuration file exists. If the file exists, check whether the specified field rpmgmkey exists in the file. If the field rpmgmkey exists, check the corresponding value. If the value is 0, the configuration is not effective. If the value is 1, the configuration is effective.

[0270] 2.2. Calculate the data of the real file of the rpm package: obtain the header signature data of the rpm (i.e., n1 to n7), i.e., read n3, and determine whether there is the signature summary information of sm2 and sm3. If so, calculate the starting position of the real file data of the rpm data, i.e., the starting position of n8, according to the above public notice (1), and use the starting position to the end of the file as the sm2 signed data (i.e., the file content in the above text);

[0271] Specifically, refer to the section "Calculating the Real File Data of the RPM Package", calculate P1 according to formula (1), take the next bit of P1 in the RPM file as the starting position of the real file data, and take the data from the next bit of P1 to the end of the RPM file as the real file data of the RPM package, that is, the signed data of sm2;

[0272] 2.3. Use the calculated real file data of the rpm package as the signed data of the rpm package, use the private key generated by the sm2 algorithm, call the sm2 signature interface in GmSSL (i.e. the national secret server mentioned above), and obtain the sm2 signature data;

[0273] 2.4. After getting the signature data of sm2, call the sm3 signature interface of GmSSL to calculate the hash value of the sm2 signature data;

[0274] 2.5. Put the calculated sm2 signature data and sm3 hash value into RPMSIGTAG_SM2(274, hexadecimal is 00 00 01 12, such as Fig.15 Line 11), RPMSIGTAG_SM3 (275, hexadecimal is 00 00 01 13, such as Fig.15 The 12th line of the tag writes the signature summary information (each signature summary contains: four bytes of algorithm type, four bytes of data type, four bytes of data address, and four bytes of data length) into n3 in the header of rpm, and writes the sm2 signature data and the hash value of sm3 into n4 in rpm.

[0275] 3. Add rpm installation for national secret signature verification (rpm-ivh):

[0276] The rpm with the new national encryption algorithm, when executing the rpm-ivh command to install the rpm media package, after loading the rpm media package, there are the following processing, such as Fig.18 As shown in:

[0277] 3.1. First, determine whether the national secret configuration item exists (first determine whether the / etc / nfssec.d / rpmconfig.cfg configuration file exists. If the file exists, check whether the specified field rpmgmkey in the file exists. If the field rpmgmkey exists, check the corresponding value. If the value is 0, the configuration is not effective. If the value is 1, the configuration is effective).

[0278] 3.2. If the national secret configuration item exists, read the SM2 signature summary information from n3 in the header (n1-n7) of the aforementioned rpm and read the SM2 signature data in n4 accordingly;

[0279] Specifically, from the signature summary information of n3 in the header of the aforementioned rpm, find the algorithm type is RPMSIGTAG_SM2 (274, hexadecimal 0112, such as Fig.15 The signature summary information of line 11 in the figure is read, and the corresponding sm2 signature data is read accordingly;

[0280] 3.3. For the sm2 signature data in the rpm package header, call the sm3 interface of GmSSL to obtain the hash value of sm3;

[0281] 3.4. Read the hash value of sm3 in the header of the rpm package and compare it with the hash value of sm3 obtained in 3.3;

[0282] Specifically, from the signature summary information of n3 in the rpm header, find the algorithm type is RPMSIGTAG_SM3 (275, hexadecimal 0113, such as Fig.15 The signature summary information of line 12 in the figure is read in n4, and the corresponding hash value is compared with the sm3 hash value obtained in the previous step.

[0283] 3.5. If the two hash values ​​are consistent, the sm2 signature data in the rpm package header read in 3.2 is used to verify the public key generated by the sm2 algorithm, and the sm2 signature verification interface of GmSSL is called to verify the signature. If the verification passes, the rpm is installed.

[0284] 4. Add rpm signature verification (rpm--checksig) for national secret signature verification:

[0285] Added rpm after national secret signature verification, when executing rpm--checksig command, after loading rpm media package, there are the following processing, such as Fig.19 As shown in:

[0286] 4.1. First check whether the national secret configuration item exists (first determine whether the / etc / nfssec.d / rpmconfig.cfg configuration file exists. If the file exists, check whether the specified field rpmgmkey exists in the file. If the field rpmgmkey exists, then check the corresponding value. If the value is 0, the configuration is not effective. If the value is 1, the configuration is effective). If the national secret configuration item exists, gpg signature verification will not be performed;

[0287] 4.2. When the national secret configuration item exists, read the SM2 signature summary information from N3 in the header of the aforementioned RPM and read the SM2 signature data in N4 accordingly;

[0288] Specifically, from the signature summary information of n3 in the rpm header, find the algorithm type is RPMSIGTAG_SM2 (274, hexadecimal 0112, such as Fig.15 The signature summary information of line 11 in the table above is read in n4 based on the signature summary information of line 11 in the table above.

[0289] 4.3. For the sm2 signature data in the rpm package header, call the sm3 interface of GmSSL to obtain the hash value of sm3;

[0290] 4.4. Read the hash value of sm3 in the header of the rpm package and compare it with the hash value of sm3 obtained in 4.3;

[0291] Specifically, from the signature summary information of n3 in the rpm header, find the algorithm type is RPMSIGTAG_SM3 (275, hexadecimal 0113, such as Fig.15 The signature summary information of line 12 in the above table is read and the corresponding sm3 hash value is compared with the sm3 hash value obtained in 4.3.

[0292] 4.5. If the two hash values ​​are consistent, the sm2 signature data in the rpm package header read in 4.2 is used to verify the public key generated by the sm2 algorithm, and the sm2 signature verification interface of GmSSL is called to verify the signature. If the verification passes, the process ends.

[0293] 5. Add the deletion signature of the national secret signature verification (rpm--delsign):

[0294] After adding the national encryption algorithm, when executing the rpm--delsign command, such as Fig. 20 As shown in the figure, in addition to deleting the signature summary information of the RPMSIGTAG_GPG, RPMSIGTAG_PGP, RPMSIGTAG_DSA, RPMSIGTAG_RSA, and RPMSIGTAG_PGP5 algorithms specified in the rpm header, it also deletes RPMSIGTAG_SM2 (274, hexadecimal 0112, such as Fig.15 Line 11), RPMSIGTAG_SM3 (275, hexadecimal 0113, such as Fig.15 Line 12 of the National Security Code).

[0295] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0296] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0297] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0298] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A method for processing signatures for a software package, characterized in that: The method comprises: In response to the signature adding instruction, obtaining the file content in the software package; According to the file content, calling the first signature interface corresponding to the first national secret algorithm to obtain the first signature data returned by the first signature interface; According to the first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the second signature data returned by the second signature interface; Obtaining signature summary information according to the first signature data and the second signature data, wherein the signature summary information at least represents an algorithm type of the first national secret algorithm and an algorithm type of the second national secret algorithm; The signature summary information, the first signature data, and the second signature data are added to the software package.

2. The method according to claim 1, characterized in that The method further comprises: According to the signature summary information, updating a field value in the software package for recording the number of signature summary entries, where the number of signature summary entries is the number of signature summary information included in the software package; According to the first signature data and the second signature data, a field value for recording a signature length in the software package is updated, where the signature length is the length of the signature data included in the software package.

3. The method according to claim 1, characterized in that The method further comprises: In response to the software installation instruction, read the signature summary information corresponding to the first national encryption algorithm from the software package; If the signature summary information corresponding to the first national secret algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national secret algorithm; If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm; According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface; Comparing the third signature data with the second signature data read from the software package; If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result; If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface; If the signature verification result indicates that the file content in the software package and the first signature data in the software package have passed the verification, executing the installation process of the software package; When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

4. The method according to claim 1, characterized in that: The method further comprises: In response to the signature verification instruction, reading signature summary information corresponding to the first national encryption algorithm from the software package; If the signature summary information corresponding to the first national secret algorithm is not read in the software package, a first verification result is obtained, wherein the first verification result indicates that the software package has not passed the signature verification of the national secret algorithm; If the signature summary information corresponding to the first national secret algorithm is read in the software package, the first signature data corresponding to the first national secret algorithm is read from the software package according to the signature summary information corresponding to the first national secret algorithm; According to the read first signature data, call the second signature interface corresponding to the second national secret algorithm to obtain the third signature data returned by the second signature interface; Comparing the third signature data with the second signature data read from the software package; If the third signature data is inconsistent with the second signature data read from the software package, obtaining the first verification result; If the third signature data is consistent with the second signature data read from the software package, the signature verification interface corresponding to the first national secret algorithm is called according to the file content in the software package and the first signature data in the software package to obtain the signature verification result returned by the signature verification interface; When the signature verification result indicates that the file content in the software package has passed the verification with the first signature data in the software package, a second verification result is obtained, wherein the second verification result indicates that the software package has passed the signature verification of the national encryption algorithm; When the signature verification result indicates that the file content in the software package fails to pass the verification with the first signature data in the software package, the first verification result is obtained.

5. The method according to claim 3 or 4, characterized in that: Reading the signature summary information corresponding to the first national encryption algorithm from the software package includes: The signature summary information whose algorithm type matches the first national encryption algorithm is read in the software package.

6. The method according to claim 3 or 4, characterized in that: Reading the first signature data corresponding to the first national secret algorithm from the software package according to the signature summary information corresponding to the first national secret algorithm includes: The first signature data corresponding to the first national encryption algorithm is read from the software package at least according to the data address recorded in the signature summary information corresponding to the first national encryption algorithm.

7. The method according to claim 1, characterized in that The method further comprises: In response to the signature deletion instruction, the signature summary information corresponding to the first national encryption algorithm and the signature summary information corresponding to the second national encryption algorithm in the software package are deleted.

8. The method according to claim 1, characterized in that Before obtaining the file content in the software package, the method further includes: Determining that the software package satisfies a first condition; The software package satisfies a first condition, including: the national encryption configuration item exists, and the software package does not contain signature summary information corresponding to the first national encryption algorithm.

9. A device for processing signatures for software packages, characterized in that: The device comprises: A content obtaining unit, configured to obtain the file content in the software package in response to the signature adding instruction; A first signature unit is used to call a first signature interface corresponding to a first national secret algorithm according to the file content to obtain first signature data returned by the first signature interface; A second signature unit is used to call a second signature interface corresponding to a second national secret algorithm according to the first signature data to obtain second signature data returned by the second signature interface; A summary obtaining unit, configured to obtain signature summary information according to the first signature data and the second signature data, wherein the signature summary information at least represents an algorithm type of the first national secret algorithm and an algorithm type of the second national secret algorithm; A signature adding unit is used to add the signature summary information, the first signature data and the second signature data to the software package.

10. An electronic device, characterized in that: The method comprises at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program so that the electronic device can implement the method for processing signatures for a software package as claimed in any one of claims 1 to 8.

Citation Information

Cited By

  • Software package installation and operation control method and system based on digital signature

    CN121479749A

  • A method and system for installing and running software packages based on digital signatures

    CN121479749B