Software program upgrading method, computer equipment and computer storage medium
By binding upgrade data with media identifiers and media tokens, and combining encryption algorithms and key chains, the problem of insufficient media authentication in existing firmware upgrade schemes is solved, thereby achieving security of upgrade data and device access control, and improving the security and reliability of software program upgrades.
Patent Information
- Application Number
- CN202511030151.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-24
- Publication Date
- 2025-10-17
AI Technical Summary
Existing firmware upgrade solutions do not authenticate the media itself. Once the upgrade package is leaked, it can be flashed on any media. Furthermore, the use of a unified encryption key makes it vulnerable to reverse engineering, endangering all devices and making it difficult to guarantee the security of upgrade data.
Upgrade data is bound to a media identifier and a media token, encrypted using an encryption algorithm, and a device key and a device token are generated to form a key chain, ensuring that only authorized devices can read the media data.
It effectively prevents the media from being easily cracked, prevents upgrade data leakage, improves the security of upgrade data, prevents unauthorized devices from reading the data, and enhances the security and reliability of software program upgrades.
Smart Images

Figure CN120803498A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of software program upgrading, and in particular to a software program upgrading method, a computer device and a computer storage medium. BACKGROUND
[0002] With large-scale deployment of the Internet of Things and intelligent terminals, field devices (such as industrial controllers, vehicle-mounted ECUs, set-top boxes, intelligent transportation terminals, etc.) are often in an intranet or completely offline environment. Maintenance personnel usually manually upgrade firmware in the form of offline copying with a U disk.
[0003] Most solutions only perform signature verification on the upgrade package, without authenticating the medium itself. If the upgrade package is leaked, any medium can be programmed. Moreover, the upgrade package mostly uses a unified encryption key, which, once reversed, will endanger all devices. Therefore, the current firmware upgrade solution has great defects and cannot guarantee the data security of the upgrade data. SUMMARY
[0004] Embodiments of the present application provide a software program upgrading method, a computer device and a computer storage medium. By binding the upgrade data to the carrier medium and configuring the identity and authority of the carrier medium of the upgrade data, the medium can be easily cracked to cause the leakage of the upgrade data, and by using multiple keys to form a key chain and a device token, the data in the medium can be prevented from being read by a device without authority, further improving the security of the upgrade data.
[0005] A first aspect of embodiments of the present application provides a software program upgrading method, applied to a secure device, the method comprising:
[0006] generating a medium token of the target medium based on the characteristic information of the target medium;
[0007] encrypting the upgrade data based on an encryption algorithm to obtain encrypted upgrade data;
[0008] generating a master key, generating a device key for each target device to be upgraded, and encrypting the master key using the device key to obtain an encrypted master key;
[0009] for each target device to be upgraded, generating a device token of the target device based on the device key of the target device and the medium token;
[0010] writing the encrypted upgrade data, the encrypted master key, and the device token and the medium token into the target medium, so that the target device upgrades the software program based on the target medium.
[0011] The second aspect of the embodiment of the present application provides a software program upgrading method, which is applied to a target device to be upgraded, and the method comprises the following steps:
[0012] After detecting that the target medium accesses the target device, an encrypted master key and a device token matched with the target device stored in the target medium are read;
[0013] A device key and a medium identifier of the target medium stored in the target medium are read, and the device token is verified according to the device key and the medium identifier;
[0014] When the device token is verified, the encrypted master key is decrypted to obtain a master key;
[0015] The encrypted upgrading data stored in the target medium is decrypted using the master key to obtain upgrading data;
[0016] The software program of the target device is upgraded based on the upgrading data.
[0017] The third aspect of the embodiment of the present application provides a computer device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect or the second aspect when executing the computer program.
[0018] The fourth aspect of the embodiment of the present application provides a computer storage medium, and the computer storage medium stores instructions, which, when executed on a computer, cause the computer to execute the method of the first aspect or the second aspect.
[0019] From the above technical solution, it can be seen that the embodiment of the present application has the following advantages:
[0020] According to the characteristic information of the target medium, the medium identifier of the target medium is generated, and the medium token of the target medium is generated, the upgrading data is encrypted based on an encryption algorithm to obtain encrypted upgrading data, the master key is generated, the device key of each target device to be upgraded is generated, and the master key is encrypted using the device key to obtain the encrypted master key, the device token of the target device is generated according to the device key and the medium identifier of the target device, the encrypted upgrading data, the encrypted master key, the device token and the medium token are written into the target medium, and the target device can perform software program upgrading according to the target medium. Therefore, by binding the upgrading data with the carrier medium and configuring the identity and authority of the carrier medium of the upgrading data, the medium can be easily cracked to avoid the leakage of the upgrading data, and by using multiple keys to form a key chain and the device token, the data in the medium can be prevented from being read by a device without authority, thereby further improving the security of the upgrading data. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 FIG. 1 is a flowchart of a software program upgrading method according to an embodiment of the present application;
[0022] Figure 2 FIG. 2 is a flowchart of an exemplary scenario of a software program upgrading method performed by a security device according to an embodiment of the present application;
[0023] Figure 3 FIG. 3 is a flowchart of another software program upgrading method according to an embodiment of the present application;
[0024] Figure 4 FIG. 4 is a flowchart of an exemplary scenario of a software program upgrading method performed by a target device according to an embodiment of the present application;
[0025] Figure 5 FIG. 5 is a structural diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] The embodiments of the present application provide a software program upgrading method, a computer device and a computer storage medium. By binding the upgrading data with its carrier medium and configuring the identity and authority of the carrier medium of the upgrading data, the medium can be prevented from being easily cracked to cause the upgrading data to be leaked. Meanwhile, by using a plurality of keys to form a key chain and a device token, the data in the medium can be prevented from being read by a device without authority, and the security of the upgrading data is further improved.
[0027] The software program upgrading method according to the embodiments of the present application is described below.
[0028] Referring to FIG. 1, Figure 1 An embodiment of the software program upgrading method according to the embodiments of the present application includes the following steps.
[0029] 101. Generating a medium token of the target medium according to the characteristic information of the target medium.
[0030] The method of the present embodiment can be applied to a security device, which can be a terminal device such as a computer, a cloud terminal, a smart mobile device or a mobile internet device (MID), a server device such as a physical server, a cloud server, a server cluster composed of a plurality of physical servers or a distributed system, or other devices with data processing and computing capabilities. For example, in some optional embodiments, the security device can be a secure computer.
[0031] When upgrading multiple devices whose software programs are to be upgraded, the security device can generate a media identifier for the target medium and a media token for the target medium based on the target medium's characteristic information. The target medium can be any medium capable of recording and storing data, such as a USB flash drive, a mobile hard drive, or a cloud storage service. The target medium's characteristic information can include attributes of the target medium, unique identification information, and other characteristic information used to uniquely identify the medium. For example, it can include characteristic information such as a USB flash drive's hardware fingerprint, which can be used to uniquely identify the USB flash drive hardware.
[0032] The software program may be firmware or any other software program that needs to be upgraded, and the type of the software program is not limited here.
[0033] 102. Encrypt the upgrade data based on an encryption algorithm to obtain encrypted upgrade data;
[0034] The security device can also encrypt the upgrade data based on an encryption algorithm to obtain encrypted upgrade data, thereby ensuring the security of the upgrade data and improving its tamper-proof capability. The upgrade data can be used to upgrade the software program of the target device to be upgraded.
[0035] The encryption algorithm may be any encryption algorithm, such as AES-256 (Advanced Encryption Standard with 256-bit key), which is a symmetric block encryption algorithm. The encryption algorithm may be used to encrypt the upgrade data to obtain encrypted upgrade data.
[0036] 103. Generate a master key, generate a device key for each target device to be upgraded, and use the device key to encrypt the master key to obtain an encrypted master key;
[0037] The security device also generates a master key and a device key for each target device to be upgraded. The device key is used to encrypt the master key to produce an encrypted master key. This master key can be used to decrypt the encrypted upgrade data, allowing the target device to use the upgrade data to upgrade the software program. Encrypting the master key prevents easy access to the master key, thereby preventing upgrade data leakage and threats to its security.
[0038] 104. For each target device to be upgraded, generate a device token of the target device according to the device key and the medium identifier of the target device;
[0039] The security device can also generate a device token of the target device according to the device key of the target device and the medium identification, so that the target device obtains the right to use the upgrade data to upgrade the software program through the device token, and other devices without the device token can be restricted from using the upgrade data, thereby improving the security of the upgrade data.
[0040] 105. write the encrypted upgrade data, the encrypted master key, and the device token and the medium token into the target medium, so that the target device upgrades the software program according to the target medium;
[0041] The security device can write the encrypted upgrade data, the encrypted master key, and the device token and the medium token obtained above into the target medium, which can be accessed by the target device, so that the target device reads the data stored in the target medium to upgrade the software program.
[0042] In the embodiment, the medium identification of the target medium is generated according to the characteristic information of the target medium, the medium token of the target medium is generated, the upgrade data is encrypted based on an encryption algorithm to obtain encrypted upgrade data, the master key is generated, the device key of each target device to be upgraded is generated, the master key is encrypted using the device key to obtain the encrypted master key, the device token of the target device is generated according to the device key of the target device and the medium identification, the encrypted upgrade data, the encrypted master key, and the device token and the medium token are written into the target medium, and the target device can upgrade the software program according to the target medium. Therefore, by binding the upgrade data with its carrier medium and configuring the identity and authority of the carrier medium of the upgrade data, the medium can be prevented from being easily cracked to cause the leakage of the upgrade data, and through the key chain composed of multiple keys and the device token, the data in the medium can be prevented from being read by devices without authority, thereby further improving the security of the upgrade data.
[0043] Based on Figure 1 In an optional implementation of the embodiment shown in the figure, when the device token of the target device is generated according to the device key of the target device and the medium identification, the security device can generate a temporary key according to the message authentication code algorithm based on the device key and the medium identification, and generate the device token of the target device according to the temporary key, the encrypted master key, and the end time stamp of the validity period of the token based on the message authentication code algorithm.
[0044] For example, the message authentication code algorithm can be a key-dependent hash operation message authentication code (HMAC) algorithm, and specifically, an HMAC-SHA256 algorithm can be used to generate the device token (Token_Device_i) and the derived device key. The specific calculation process can be that first, a temporary key is derived from the device key (DeviceKey_i) and the USB unique identifier (USB_ID):
[0045] TempKey = HMAC-SHA256(DeviceKey_i, USB_ID);
[0046] Then, the Token_Device_i is calculated using the temporary key:
[0047] Token_Device_i = HMAC-SHA256(TempKey, EncryptedMaster_i || valid_to);
[0048] Wherein, EncryptedMaster_i is an encrypted master key, that is, an encrypted master key obtained by encrypting the master key MasterKey; and valid_to is an end timestamp of the validity period of the token.
[0049] Therefore, by generating the device token, the target device can obtain the right to use the upgrade data for software program upgrade through the device token, and other devices that do not obtain the device token, such as illegal devices or malicious user devices, cannot obtain the upgrade data through the device token, so that the security of the upgrade data can be improved.
[0050] Based on the embodiment shown in Figure 1 In another alternative implementation, when generating the device key of the target device, for each target device to be upgraded, the device key corresponding to the target device can be generated according to the message authentication code algorithm based on the device identifier of the target device and the preset root key.
[0051] For example, when generating the device key, the HMAC-SHA256 can be used based on the preset root key (RootKey) and the device identifier DeviceID_i to generate the exclusive device key of each device to be authorized (i.e., the device allowed to be upgraded):
[0052] DeviceKey_i = HMAC-SHA256(RootKey, DeviceID_i);
[0053] And, the device key DeviceKey_i can be used to encrypt the master key MasterKey as an AES-256 key to obtain an encrypted master key EncryptedMaster_i:
[0054] EncryptedMaster_i = AES-256-ECB(DeviceKey_i, MasterKey).
[0055] Therefore, by generating the device key and generating the encrypted master key, the encryption of the master key is achieved, and the authorized device to be upgraded verifies the device token based on the device key to determine the availability of the medium carrier and then obtains the upgrade data stored in the medium carrier, thereby improving the security of the medium carrier storing the upgrade data and preventing unauthorized devices from easily cracking and using.
[0056] Based on Figure 1 In another alternative embodiment of the embodiment shown in FIG. 8, the medium token can carry the validity period data of the medium token for the target device to confirm the timeliness of the medium token. In addition, the device token can also carry the validity period data of the device token for the target device to confirm the timeliness of the device token.
[0057] Therefore, by limiting the timeliness of the medium token and the device token through the validity period, the target device decrypts the medium data to obtain the upgrade data for software program upgrade only when the medium token and the device token meet the timeliness, which can avoid the target device using an expired upgrade package or an old upgrade package for software program upgrade, thereby avoiding the risk of software program rollback and improving the security and reliability of software program upgrade.
[0058] Figure 2 An exemplary scenario flow of the method for performing software program upgrade by the secure device is shown. The secure computer serves as a trusted certification center responsible for the encryption and packaging of the upgrade package and the management of security policies. It contains multiple functional modules such as a digital signature private key, a true random number generator, and a secure storage area. The digital signature private key is stored in a hardware security module (HSM) or a smart card and is used for signing the U disk hardware fingerprint to ensure that it cannot be forged. The true random number generator (TRNG) is used to generate a random number with cryptographic strength for deriving the master key (MasterKey) and the session key. The secure storage area stores the root key (RootKey) in isolation and only allows encrypted operation calls, prohibiting direct reading.
[0059] The U disk medium USB flash disk used has a unique identifier generated by a physical unclonable function (PUF) or a unique serial number (such as eFuse technology) fixed in the controller, such as a unique and unmodifiable hardware fingerprint (such as a controller serial number, a PUF signature, etc.).
[0060] And the target device to be upgraded, its unique identifier DeviceID_i is written in the OTP area (one-time programming area) of the security chip at the factory, which is bound to the device hardware and cannot be tampered with.
[0061] As shown in Figure 2 The physical characteristics of the U disk controller (such as serial number, PUF response value) are read through the driver during the upgrade package export process on the secure computer side, the U disk hardware fingerprint is extracted, and the U disk token Token_USB is generated.
[0062] Among them, the method for calculating the unique identifier of the U disk is: USB_ID= SHA3-256 (serial number || PUF response value), which can generate a 256-bit unique identifier.
[0063] The USB_ID and the validity period (such as Unix timestamp) are digitally signed using the private key of the secure computer, that is, the generation of the U disk token can be represented as:
[0064] Token_USB=Sign (private key, USB_ID || start time || end time).
[0065] Its encoding format is, ASN.1 DER encoding can be used, which contains the signature value and the plaintext validity period.
[0066] Token_USB adopts DER encoding, and the structure is as follows:
[0067] Token_USB::=SEQUENCE{
[0068] USB_ID / / OCTET STRING,
[0069] valid_from / / start timestamp (seconds)
[0070] valid_to / / end timestamp (seconds)
[0071] signature / / signature value
[0072] }
[0073] The secure computer can also bind the white list ID list of the device, and record the target device with software program upgrade permission through the white list ID list of the device, so as to issue the upgrade package to such devices.
[0074] Secondly, the secure computer can generate a 256-bit random number as the master key MasterKey through a true random number generator (TRNG): MasterKey = TRNG(256 bits). The secure computer encrypts the upgrade file using a symmetric encryption algorithm (for example, AES-256-GCM mode) to generate encrypted upgrade data EncryptedData.
[0075] Then, the device key can be derived and the master key can be encrypted. The secure computer generates a device key DeviceKey_i that is specific to each device to be authorized (i.e., a device that is allowed to be upgraded) using an HMAC-SHA256 algorithm based on a preset root key RootKey and a device identifier DeviceID_i:
[0076] DeviceKey_i = HMAC-SHA256(RootKey, DeviceID_i).
[0077] The master key MasterKey is encrypted using the device key DeviceKey_i as an AES-256 key:
[0078] EncryptedMaster_i = AES-256-ECB(DeviceKey_i, MasterKey).
[0079] A device-USB disk binding token is generated to prevent software program version replay. Specifically, a temporary key TempKey can be calculated:
[0080] TempKey = HMAC-SHA256(DeviceKey_i, USB_ID).
[0081] A device token Token_Device_i is generated:
[0082] Token_Device_i = HMAC-SHA256(TempKey, EncryptedMaster_i || valid_to).
[0083] Finally, the encrypted data of the upgrade package and the USB disk token, the device token, and other data are written to the USB disk, so that a secure USB disk is obtained, which can be used to upgrade the software program of an authorized target device.
[0084] The foregoing embodiments will be further described in detail below on the basis of the embodiments shown in Figure 1 FIG. 1. Please refer to Figure 3 Another embodiment of the software program upgrade method in the present application includes the following steps:
[0085] 301、after detecting that the target medium accesses the target device, reading an encrypted master key and a device token stored in the target medium and matched with the target device;
[0086] The method of the embodiment can be applied to a target device to be upgraded. When the target medium accesses the target device is detected, the target device can read an encrypted master key and a device token stored in the target medium and matched with the target device. The encrypted master key and the device token can be generated based on Figure 1 The method of the embodiment is generated by a secure device and written into the target medium. The specific generation manner can refer to the foregoing description and will not be described here.
[0087] 302、reading a device key and a medium identifier of the target medium stored in the target medium, and verifying the device token according to the device key and the medium identifier;
[0088] 303、when the device token is verified, decrypting the encrypted master key to obtain a master key;
[0089] The target device can also read a device key and a medium identifier of the target medium stored in the target medium, and verify the device token according to the device key and the medium identifier. When the device token is verified, the device key is used to decrypt the encrypted master key to obtain a master key. The device key and the medium identifier can be generated based on Figure 1 The method of the embodiment is generated by a secure device and written into the target medium. The specific generation manner can refer to the foregoing description and will not be described here.
[0090] 304、using the master key to decrypt encrypted upgrade data stored in the target medium to obtain upgrade data;
[0091] 305、upgrading a software program of the target device based on the upgrade data;
[0092] After the master key is obtained, the target device can also use the master key to decrypt encrypted upgrade data stored in the target medium to obtain upgrade data. The software program of the target device is upgraded based on the upgrade data. The software program can be firmware or any other software program that needs to be upgraded, and the type of the software program is not limited here.
[0093] Therefore, by verifying the media token and the device token, it can be ensured that the device to be upgraded has the use right of the upgrade data in the medium, avoiding that the upgrade data is easily obtained by the device without right, and also avoiding that the upgrade data of the software program is easily obtained and tampered by the illegal device or malicious user device, and the security of the upgrade data is improved. Meanwhile, by the key chain composed of the device key, the master key and the encrypted master key, even if one of the keys is cracked, it will not cause data leakage, and the security of the upgrade data can be further improved.
[0094] Based on Figure 3 In an optional implementation of the embodiment shown in the figure, after detecting that the target medium accesses the target device, the target device can also read the media identification of the target medium and the media token of the target medium stored by the target medium. The signature information of the target medium is verified according to the media identification, and the timeliness of the media token is verified according to the validity period data of the media token. When the media identification and the media token are both verified, the encrypted master key and the device token matching the target device stored by the target medium are read.
[0095] Therefore, by verifying the timeliness of the token, it can be avoided that the target device upgrades the software program based on the upgrade data that has expired, and the target device uses the expired upgrade package or the old upgrade package to upgrade the software program, thereby avoiding the risk of software program rollback, and improving the security and reliability of the software program upgrade.
[0096] Based on Figure 3 In another optional implementation of the embodiment shown in the figure, after the software program of the target device is upgraded based on the upgrade data, the target device can verify the signature information of the upgrade data and verify the version information of the upgrade data. When the signature information of the upgrade data is verified and the version information of the upgrade data is verified, the software program of the target device is upgraded based on the upgrade data.
[0097] By verifying the signature information of the upgrade data and verifying the version information of the upgrade data, it can be ensured that the upgrade data is from a trusted and secure device, ensuring the authority and reliability of the upgrade data, and also ensuring that the version of the upgrade data is the latest, avoiding the use of the old version upgrade data to update the software program, avoiding the risk of software program rollback, and improving the security and reliability of the software program upgrade.
[0098] Based on Figure 3 In another optional implementation of the embodiment shown in the figure, after the software program of the target device is upgraded based on the upgrade data, the target device can also update the version information of the software program, so as to determine whether to upgrade the software program according to the latest version information of the software program.
[0099] Therefore, time verification and rollback protection can be realized, the device token or the medium token contains absolute expiration time or monotonic count, the target device can store the latest version count of the software program, if the version count of the upgrade data is detected to be rolled back or expired, the upgrade is immediately rejected, and the software program version rollback is avoided, and the program running safety is affected. The secure computer can generate a revocation list of the upgrade data to record the revoked upgrade data, and update the revocation list synchronously in the next upgrade.
[0100] Figure 4 An exemplary scene flow of the target device performing the software program upgrade method is shown. As shown in the figure, in the upgrade verification process on the target device side, the target device reads the physical unique identifier of the U disk controller through the USB protocol instruction (such as SCSI READ_SERIAL), and the identifier includes: the controller serial number (32 bytes, fixed in the OTP area), the PUF response value (based on the physical unclonable feature of the SRAM startup state, 64 bytes). Then, the U disk identifier USB_ID = SHA3-256 (serial number || PUF response value) is calculated to generate a 256-bit unique identifier.
[0101] The public key of the secure computer is pre-stored in the security chip of the target device and stored in the write protection area. The target device performs signature verification on the U disk token Token_USB. After the verification is passed, the USB_ID, valid time and signature are parsed from Token_USB in the U disk. The current time T_now can be obtained from the device security clock chip (RTC with battery power supply), and it is verified whether valid_from ≤ T_now ≤ valid_to is satisfied, if not, the security log is recorded and the software program upgrade process is terminated. It is verified whether the USB_ID parsed from the U disk and the locally calculated USB_ID are consistent. If not, the upgrade process is terminated.
[0102] The target device can also traverse the directory (such as / SecurePartition / DeviceKeys / ) in which the device identifier DeviceID_i file is stored in the U disk, and find the encrypted file whose file name matches the own DeviceID_i (such as DEVID_0x1234.enc) in the file directory of the U disk. If not found, the upgrade process is stopped.
[0103] The target device can also read the pre-stored root key RootKey (256 bits, stored in the OTP area of the HSM, pre-stored at the factory, the same as the RootKey of the secure computer) from the security chip, and calculate the device key exclusive to the device according to the pre-stored root key:
[0104] DeviceKey_i = HMAC-SHA256(RootKey, DeviceID_i).
[0105] Combine USB_ID to generate a temporary key: TempKey = HMAC-SHA256(DeviceKey_i, USB_ID);
[0106] The target device can calculate the device token Token_Device_i in the same way as when exporting the upgrade package on the secure computer, and compare it byte by byte with the Token_Device_i saved in the USB flash drive. If they are consistent, the verification passes; if they are inconsistent, an abnormal end is triggered.
[0107] The target device can also use AES-256-ECB mode, with the key DeviceKey_i and the ciphertext as the encrypted master key EncryptedMaster_i. The ciphertext is decrypted to obtain the master key MasterKey:
[0108] MasterKey = AES-256-ECB_Decrypt(DeviceKey_i, EncryptedMaster_i).
[0109] The MasterKey is decrypted and stored only in the volatile register of the security chip, which is automatically erased after power failure.
[0110] Afterwards, the target device can use the decrypted master key to decrypt the upgrade package and use the decrypted upgrade package to upgrade the device.
[0111] In the embodiment of the present application, only a specific USB flash drive that is authorized to write the upgrade package can trigger the upgrade. The upgrade package can only be decrypted by the target whitelist device. Each device uses a different content key to prevent the key from spreading horizontally. The upgrade package has a validity period and automatically becomes invalid after it expires. Through the above settings, the upgrade package is bound to a single USB flash drive hardware and cannot be bypassed by simply copying ordinary files. Each device has an independent key chain, and single-point cracking does not spread. The dual restrictions of the version count and the expiration field of the upgrade package can avoid the replay of old packages. Moreover, the entire process of firmware upgrade has no network dependency and is suitable for isolated environments. The upgrade data is only encrypted once, the key encapsulation block is small in size, and the impact on the USB flash drive capacity is negligible.
[0112] The above describes the software program upgrade method in the embodiment of the present application. The following describes the security device in the embodiment of the present application. One embodiment of the security device in the embodiment of the present application includes:
[0113] The first generating unit is configured to generate a media token of the target media according to characteristic information of the target media, and generate a media token of the target media.
[0114] The encryption unit is configured to encrypt the upgrade data based on an encryption algorithm to obtain encrypted upgrade data.
[0115] The second generating unit is configured to generate a master key, generate a device key for each target device to be upgraded, and encrypt the master key using the device key to obtain an encrypted master key.
[0116] The third generating unit is configured to generate, for each target device to be upgraded, a device token of the target device according to the device key of the target device and the media token.
[0117] The storage unit is configured to write the encrypted upgrade data, the encrypted master key, and the device token and the media token into the target media, so that the target device performs software program upgrade according to the target media.
[0118] In a preferred embodiment of the present embodiment, the third generating unit is specifically configured to:
[0119] generate a temporary key according to the message authentication code algorithm and the device key and the media token;
[0120] generate the device token of the target device according to the message authentication code algorithm and the temporary key, the encrypted master key, and an expiration time stamp.
[0121] In a preferred embodiment of the present embodiment, the second generating unit is specifically configured to:
[0122] generate, for each target device to be upgraded, the device key corresponding to the target device according to the message authentication code algorithm and the device token of the target device and a preset root key.
[0123] In a preferred embodiment of the present embodiment, the media token carries validity data of the media token, which is used by the target device to confirm the timeliness of the media token.
[0124] The device token carries validity data of the device token, which is used by the target device to confirm the timeliness of the device token.
[0125] In the present embodiment, the operations performed by each unit in the secure device are similar to those described in the foregoing embodiments and various alternative embodiments thereof, and thus will not be described herein again. Figure 1
[0126] The target device to be upgraded in the embodiments of the present application is described below. One embodiment of the target device in the embodiments of the present application includes:
[0127] The first reading unit is configured to read the encrypted master key and the device token stored in the target medium and matched with the target device after detecting that the target medium accesses the target device.
[0128] The second reading unit is configured to read the device key and the medium identifier of the target medium stored in the target medium, and verify the device token according to the device key and the medium identifier.
[0129] The first decryption unit is configured to decrypt the encrypted master key to obtain a master key when the device token is verified.
[0130] The second decryption unit is configured to decrypt the encrypted upgrade data stored in the target medium using the master key to obtain upgrade data.
[0131] The first reading unit is configured to upgrade the software program of the target device based on the upgrade data.
[0132] In a preferred embodiment of the present application, the target device further includes a verification unit configured to:
[0133] read the medium identifier of the target medium and the medium token of the target medium stored in the target medium;
[0134] verify the signature information of the target medium according to the medium identifier, and verify the timeliness of the medium token according to the validity period data of the medium token;
[0135] read the encrypted master key and the device token stored in the target medium and matched with the target device when the medium identifier and the medium token are both verified.
[0136] In a preferred embodiment of the present application, the upgrade unit is specifically configured to:
[0137] verify the signature information of the upgrade data and the version information of the upgrade data;
[0138] upgrade the software program of the target device based on the upgrade data when the signature information of the upgrade data is verified and the version information of the upgrade data is verified.
[0139] In a preferred embodiment of the present application, the target device further includes an updating unit configured to:
[0140] updating version information of the software program, for determining whether to upgrade the software program according to the latest version information of the software program.
[0141] In the embodiment, the operations performed by the units in the target device are similar to those described in the foregoing Figure 2 embodiments and various alternative embodiments thereof, which will not be described herein again.
[0142] The computer device in the embodiments of the present application is described below. Please refer to Figure 5 An embodiment of the computer device in the embodiments of the present application includes:
[0143] The computer device 500 can include one or more central processing units (CPUs) 501 and a memory 505, which stores one or more application programs or data.
[0144] The memory 505 can be volatile storage or persistent storage. The programs stored in the memory 505 can include one or more modules, each of which can include a series of instruction operations in the computer device. Further, the central processing unit 501 can be configured to communicate with the memory 505 and execute the series of instruction operations in the memory 505 on the computer device 500.
[0145] The computer device 500 can further include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input / output interfaces 504, and / or one or more operating systems, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0146] The central processing unit 501 can execute the operations performed by the security device in the foregoing Figure 1 embodiments and various alternative embodiments thereof, and the operations performed by the target device in the foregoing Figure 2 embodiments and various alternative embodiments thereof, which will not be described herein again.
[0147] The embodiments of the present application further provide a computer storage medium, one embodiment of which includes: the computer storage medium stores instructions, which, when executed on a computer, cause the computer to perform the operations performed by the security device in the foregoing Figure 1 embodiments and various alternative embodiments thereof, and the operations performed by the target device in the foregoing Figure 2 embodiments and various alternative embodiments thereof.
[0148] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
[0149] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0150] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0151] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0152] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, read-only memory), a random access memory (RAM, random access memory), a magnetic disk or an optical disk, and various program code storage media.
Claims
1. A software program upgrade method, characterized in that: The method is applied to a security device and includes: generating a medium identification of the target medium according to characteristic information of the target medium, and generating a medium token of the target medium; Encrypting the upgrade data based on an encryption algorithm to obtain encrypted upgrade data; Generate a master key, generate a device key for each target device to be upgraded, and use the device key to encrypt the master key to obtain an encrypted master key; For each target device to be upgraded, generating a device token of the target device according to the device key and the medium identifier of the target device; The encrypted upgrade data, the encrypted master key, the device token, and the media token are written into the target medium, so that the target device performs a software program upgrade according to the target medium.
2. The method according to claim 1, characterized in that Generating a device token of the target device according to the device key and the medium identifier of the target device includes: Generate a temporary key for the device key and the medium identifier according to a message authentication code algorithm; The temporary key, the encryption master key and the validity end timestamp are used to generate a device token for the target device according to the message authentication code algorithm.
3. The method according to claim 1, characterized in that Generating a device key for each target device to be upgraded includes: For each target device to be upgraded, the device key corresponding to the target device is generated based on the device identifier of the target device and a preset root key according to a message authentication code algorithm.
4. The method according to any one of claims 1 to 3, characterized in that The media token carries validity data of the media token, so as to be used by the target device to confirm the validity of the media token; The device token carries validity data of the device token, so that the target device can confirm the validity of the device token.
5. A software program upgrade method, characterized in that: The method is applied to a target device to be upgraded, and the method includes: After detecting that the target medium is connected to the target device, reading the encryption master key and the device token stored in the target medium and matching the target device; Reading a device key stored in the target medium and a medium identification of the target medium, and verifying the device token according to the device key and the medium identification; When the device token is verified, the encrypted master key is decrypted to obtain the master key; Decrypting the encrypted upgrade data stored in the target medium using the master key to obtain the upgrade data; The software program of the target device is upgraded based on the upgrade data.
6. The method according to claim 5, characterized in that After detecting that the target medium is connected to the target device, the method further includes: Reading the medium identification of the target medium and the medium token of the target medium stored in the target medium; Verifying the signature information of the target medium on the medium identifier, and verifying the validity of the medium token according to the validity period data of the medium token; When both the medium identification and the medium token are verified, the step of reading the encryption master key and the device token stored in the target medium and matching the target device is performed.
7. The method according to claim 5, characterized in that The upgrading of the software program of the target device based on the upgrade data includes: Verifying the signature information of the upgrade data and the version information of the upgrade data on the upgrade data; When the signature information of the upgrade data passes verification and the version information of the upgrade data passes verification, the software program of the target device is upgraded based on the upgrade data.
8. The method according to claim 5, characterized in that After upgrading the software program of the target device based on the upgrade data, the method further includes: The version information of the software program is updated to determine whether to upgrade the software program according to the latest version information of the software program.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
10. A computer storage medium, characterized in that The computer storage medium stores instructions, which, when executed on a computer, enable the computer to perform the method according to any one of claims 1 to 8.