Method, device, equipment, storage medium and product for program running
By verifying the ternary encoding parameters and offset values of the telomere region, the legitimacy verification of the program's runtime environment is simplified, solving the problem of the complexity and high cost of hardware encryption, and enabling a wider range of application scenarios and resource savings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN UNIV
- Filing Date
- 2023-10-09
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, hardware encryption methods are complex and expensive, making them unsuitable for software developers or individual developers of all sizes. This results in complex software security verification processes and limited application scenarios.
By obtaining the ternary encoding parameters and offset values of the telomere region, accessing the information bit storage block in the telomere block, performing encoding conversion and hash value comparison, the legitimacy of the operating environment is verified, simplifying the verification process and expanding the application scenarios.
It simplifies the validation of the program's runtime environment, saves resources, and expands the application scenarios when there is no internet connection or access to the verification server.
Smart Images

Figure CN117272283B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software security technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for running a program. Background Technology
[0002] With the rapid development of computer technology, mobile storage devices are playing an increasingly important role in daily life and work. To meet users' convenience needs, software developers often store software programs on storage media, leveraging their portability and high capacity to allow users to install or access content on different devices. However, with the widespread use and expansion of storage media, issues such as unauthorized copying and distribution are increasingly threatening software security.
[0003] Several technologies, such as hardware encryption, already exist in the market and can improve software security to some extent. However, hardware encryption methods typically require the design of specific hardware encryption chips, which are overly complex and expensive, making them unsuitable for software developers or individual developers of all sizes. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product that can simplify the legality verification process of the environment and expand the application scenarios to address the above-mentioned technical problems.
[0005] In a first aspect, this application provides a method for running a program, the method comprising:
[0006] Obtain the radix encoding parameters corresponding to the telomere region, and extract the offset value from the head storage block of the telomere block in the telomere region; the telomere region is used to detect whether the running environment of the program to be run is a legal running environment; the program to be run is the program stored in the program area associated with the telomere region;
[0007] When the offset value indicates that the end granule block is not used, the information bit storage block in the end granule block is accessed to obtain the code information to be verified corresponding to the information bit storage block;
[0008] Based on the base encoding parameters, the encoding information to be verified is encoded and converted to obtain the number to be verified, and the hash value to be verified of the number to be verified is determined.
[0009] If the hash value to be verified is the same as the hash value stored in the header storage block, the verification result is that the running environment of the program to be run is a legitimate running environment.
[0010] Based on the verification results, run the program to be run.
[0011] In one embodiment, the telomere block includes at least a first telomere block and a second telomere block; the offset value includes at least a first offset value and a second offset value;
[0012] When the offset value indicates that the endgranulation block is not used, accessing the information bit storage block in the endgranulation block to obtain the unverified encoded information corresponding to the information bit storage block includes:
[0013] If the first offset value indicates that the first end-granule block has been used, the end-granule block to be jumped to is determined based on the first offset value and the number of storage blocks occupied by the first end-granule block, and the end-granule block to be jumped to is used as the second end-granule block.
[0014] When the second offset value of the second end block indicates that the second end block is not used, the information bit storage block of the second end block is accessed to obtain the code information to be verified corresponding to the information bit storage block.
[0015] In one embodiment, accessing the information bit storage block in the telomere block to obtain the verification-to-be-verified encoded information corresponding to the information bit storage block includes:
[0016] Each information bit storage block in the telomere block is accessed sequentially to obtain the number of erase / write cycles for each information bit storage block.
[0017] Based on the number of erase / write cycles corresponding to each of the information bit storage blocks, the theoretical maximum number of erase / write cycles pre-stored in the root storage block of the telomere region, and the base encoding parameters, the encoding information to be verified corresponding to the information bit storage block is determined.
[0018] In one embodiment, before obtaining the radix encoding parameters corresponding to the telomere region, the following steps are included:
[0019] Obtain the number of storage blocks occupied by the telomere region in the storage space, and determine the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region;
[0020] The number of storage blocks occupied by the telomere region in the storage space and the number of times the operation is to be performed are used to determine the number of storage blocks occupied by the telomere block in the storage space.
[0021] The base encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase and write cycles are stored in the root storage block of the telomere region.
[0022] Determine the random number corresponding to the telomere block, store the hash value corresponding to the random number and the offset value representing whether the telomere block is used in the header storage block of the telomere block, and store the encoded information corresponding to the random number in the information bit storage block;
[0023] The number of times the information bit storage block can be erased and written is determined based on the base encoding parameters, the theoretical maximum number of erase and write cycles, and the encoded information stored in the information bit storage block.
[0024] The information bit storage block is erased and rewritten based on the number of erase / write cycles to construct a telomere region for detecting whether the running environment of the program to be run is a legitimate running environment.
[0025] In one embodiment, storing the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles into the root storage block of the telomere region includes:
[0026] Symmetric encryption processing is performed on the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erasure and write operations, respectively, to obtain the number of encryption erasure and write operations, the number of encryption operations, and the encryption encoding parameters.
[0027] The number of encryption erase / write cycles, the number of encryptions, and the encryption encoding parameters are stored in the root storage block of the telomere region.
[0028] In one embodiment, obtaining the number of storage blocks occupied by the telomere region in the storage space includes:
[0029] Retrieve the storage space corresponding to a file that is filled with data and organized into storage blocks;
[0030] Based on the number of storage blocks occupied by the program to be run, the storage space is divided to obtain the program area and telomere area of the storage space;
[0031] The program to be run is used to replace the data in the program area;
[0032] The number of storage blocks occupied by the telomere region in the storage space is determined based on the difference between the number of storage blocks occupied by the program area where the program to be run is located and the total number of storage blocks in the storage space.
[0033] Secondly, this application provides a program execution apparatus, the apparatus comprising:
[0034] The data acquisition module is used to acquire the base encoding parameters corresponding to the telomere region and extract the offset value from the head storage block of the telomere block in the telomere region; the telomere region is used to detect whether the running environment of the program to be run is a legal running environment; the program to be run is the program stored in the program area associated with the telomere region;
[0035] The access module is used to access the information bit storage block in the end granule block when the offset value indicates that the end granule block is not used, and obtain the unverified encoded information corresponding to the information bit storage block.
[0036] The encoding conversion module is used to perform encoding conversion on the encoding information to be verified based on the base encoding parameters, to obtain the number to be verified, and to determine the hash value to be verified of the number to be verified;
[0037] The verification module is used to obtain a verification result that the running environment of the program to be run is a legitimate running environment if the hash value to be verified is the same as the hash value stored in the header storage block.
[0038] The running module is used to run the program to be run based on the verification results.
[0039] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0040] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0041] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0042] The aforementioned method, apparatus, computer device, storage medium, and computer program product, by obtaining the radix encoding parameters corresponding to the telomere region and retrieving the offset value from the head storage block of the telomere block in the telomere region, can determine whether the telomere block has been used. If the telomere block is not used, the information bit storage block in the telomere block is accessed to obtain the verification-to-be-verified encoding information corresponding to the information bit storage block. The verification-to-be-verified encoding information is then encoded using the radix encoding parameters corresponding to the telomere region to obtain the verification-to-be-verified number used to obtain the verification-to-be-verified hash value. Finally, the verification-to-be-verified hash value and the hash value stored in the head storage block are compared... By comparing the hash value to be verified with the hash value stored in the header block, the program is run based on the verification result indicating that the program's environment is legitimate. This simplifies the verification process, saves resources, and eliminates the need for interaction with third-party servers. It allows for successful environment legitimacy verification even without internet access or access to a verification server, broadening its application scenarios. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is an application environment diagram of the method for program execution in one embodiment;
[0045] Figure 2 This is a flowchart illustrating the method of program execution in one embodiment;
[0046] Figure 3 This is a flowchart illustrating the method of program execution in another embodiment;
[0047] Figure 4 This is a structural block diagram of the terminal block jump in one embodiment;
[0048] Figure 5 This is a structural block diagram illustrating the division of the telomere region and the program region in one embodiment;
[0049] Figure 6 This is a block diagram of the data storage structure in one embodiment;
[0050] Figure 7 This is a structural block diagram of a device for running a program in one embodiment;
[0051] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0053] The program execution method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 controls the program to be run to obtain the radix encoding parameters corresponding to the telomere region and extract the offset value from the header storage block of the telomere block in the telomere region. The telomere region is used to verify whether the runtime environment of the program to be run is a valid runtime environment, and the program to be run is the program stored in the program area associated with the telomere region. If the extracted offset value indicates that the telomere block is not used, terminal 102 controls the program to be run to access the information bit storage block in the telomere block to obtain the verification encoding information corresponding to the information bit storage block. Based on the obtained radix encoding parameters, terminal 102 controls the program to be run to perform encoding conversion on the verification encoding information to obtain the verification number and determine the verification hash value of the verification number. If the verification hash value is the same as the hash value stored in the header storage block of the telomere block, terminal 102 obtains a verification result that the runtime environment of the program to be run is a valid runtime environment. Based on the verification result, terminal 102 runs the program to be run. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and other devices with installed storage media. The storage media can be a USB flash drive, etc.
[0054] In one exemplary embodiment, such as Figure 2 As shown, a method for running a program is provided, which can be applied to... Figure 1 Taking the terminal in the example, the explanation includes the following steps 202 to 210. Wherein:
[0055] Step 202: Obtain the radix encoding parameters corresponding to the telomere region, and extract the offset value from the head storage block of the telomere block in the telomere region. The telomere region is used to detect whether the runtime environment of the program to be run is a valid runtime environment. The program to be run is the program stored in the program area associated with the telomere region.
[0056] In this context, telomeres and program areas can both be understood as regions within a USB flash drive or other storage medium. For example, if you create a file X on a USB flash drive and write random data into it until it fills the entire storage space, then divide the storage space containing file X into two distinct regions, using storage blocks as the basic unit, the region where the written data is not replaced with the program to be run is the telomere, and the other region is the program area. The telomere is a region composed of multiple storage blocks.
[0057] The radix encoding parameters corresponding to the telomere region are pre-stored in the first storage block within the telomere region, which is the root storage block. Examples include binary encoding parameters and octal encoding parameters. When retrieving radix encoding parameters, if the radix encoding parameters are encrypted, they need to be decrypted using the decryption key corresponding to the encryption key.
[0058] A telomere block is a region of storage space comprised of multiple storage blocks within a telomere region. A telomere region contains at least one telomere block, and each telomere block occupies approximately the same number of storage blocks. For example, if a telomere region consists of 50 storage blocks with a preset telomere block length of 13, then three telomere blocks will have the same length of 13, and the last telomere block will have a length of 12. Telomere blocks shorter than the preset length cannot be used for validity verification. The header storage block of a telomere block refers to the first storage block in the telomere block. Using the first storage block as the header storage block to store the offset value facilitates addressing, making it easier to find the storage location of the offset value. If the offset value were placed elsewhere, a value would need to be stored to record how many storage blocks need to be offset from the beginning of the telomere block to find the header storage block and thus obtain the offset value.
[0059] Offset values are numerical values that indicate whether an end-granule has been used or consumed. For example, an offset value of 0 indicates that the end-granule at that offset is currently active, meaning it has not yet been used or consumed; an offset value of -1 indicates that all end-granules are in use, so even if the program is running in a valid environment, it cannot run; an offset value greater than 0 indicates that the end-granule at that offset is currently a jump end-granule, which is an end-granule that has already been consumed, and its purpose is to help find the next nearest active end-granule.
[0060] The program to be run is a program stored in the program area associated with the telomere region. In other words, the program area and the telomere region belong to two regions within the same storage medium such as a USB flash drive, and the two regions do not overlap. For example, if program area A and telomere region B are two non-overlapping regions within the same USB flash drive, then program area A and telomere region B are interconnected.
[0061] The operating environment refers to the device environment to which the storage medium corresponding to the telomere area and program area is connected. For example, a USB flash drive that is divided into a program area and a telomere area, and whose program area stores the program to be run, can be understood as the operating environment of the program to be run.
[0062] Optionally, the terminal controls the program to be run to obtain the base encoding parameters for encoding conversion from the root storage block of the telomere region, and at the same time controls the program to be run to extract the offset value for characterizing whether the telomere block is used from the head storage block of the telomere block in the telomere region.
[0063] Step 204: If the offset value characterization end granular block is not used, access the information bit storage block in the end granular block to obtain the encoding information to be verified corresponding to the information bit storage block.
[0064] The phrase "the telomere block is not used" means that the program to be run can still be run in a legal environment, that is, the information bit storage block in the telomere block has not been damaged.
[0065] Information bit storage blocks are storage blocks arranged after the header storage block in the endgranular block. There is at least one information bit storage block in each endgranular block. For example, endgranular block A has a length of 13 storage blocks, where the first storage block is the header storage block, and the second to thirteenth storage blocks are the information bit storage blocks for endgranular block A. Each information bit storage block corresponds to a sub-encoding in the encoded information to be verified. For example, when the radix encoding parameter is binary, one information bit storage block will correspond to either a 0 or a 1. Concatenating the sub-encodings corresponding to each information bit storage block in sequence constitutes a string of encoded information to be verified. Accessing an information bit storage block means retrieving the encoded information to be verified corresponding to that information bit storage block.
[0066] Optionally, if the extracted offset value indicates that the end-granular block is not used, the terminal controls the program to be run to access each information bit storage block in the end-granular block to obtain the sub-encoding corresponding to each information bit storage block. Then, the obtained sub-encodings are concatenated according to the arrangement order of the information bit storage blocks to obtain the code information to be verified corresponding to the information bit storage block.
[0067] In a specific application, the terminal control program extracts the offset value from the head storage block of telomere block 1 in the telomere region. The extracted offset value is 0, indicating that telomere block 1 is not used. The terminal control program accesses the four information bit storage blocks in telomere block 1 to obtain sub-codes 1,0,0,1. The terminal control program concatenates the sub-codes according to the order of the information bit storage blocks in telomere block 1 to obtain the code information 1001 to be verified.
[0068] Step 206: Based on the base encoding parameters, perform encoding conversion on the encoding information to be verified to obtain the number to be verified, and determine the hash value to be verified of the number to be verified.
[0069] Encoding conversion involves transforming the encoded information to be verified according to the conversion rules of the base encoding parameters. For example, if the encoded information to be verified is 1001 and the base encoding parameter is binary, then the encoded information 1001 will be converted to the number to be verified as 9. The hash value to be verified is calculated using a strong hash algorithm and is mainly used for validity verification.
[0070] Optionally, based on the acquired hexadecimal encoding parameters, the terminal controls the program to be run to encode and convert the encoding information corresponding to the information bit storage block of the end-granular block to obtain the number to be verified. The terminal controls the program to be run to use a strong hash algorithm to calculate the hash value of the number to be verified, thereby obtaining the hash value of the number to be verified.
[0071] Step 208: If the hash value to be verified is the same as the hash value stored in the header storage block, the verification result is obtained that the running environment of the program to be run is a legitimate running environment.
[0072] Optionally, if the terminal detects that the hash value to be verified of the number to be verified is the same as the hash value stored in the header storage block of the end-granule block, it determines that the running environment of the program to be run is a legitimate running environment.
[0073] In a specific application, if the terminal detects that the hash value to be verified obtained from the information bit storage block corresponding to the information bit storage block of end-granule 1 is the same as the hash value stored in the header storage block of end-granule 1, it obtains the verification result that the running environment of the program to be run is a legitimate running environment.
[0074] Step 210: Based on the verification results, run the program to be run.
[0075] Optionally, the terminal runs the program in the program area based on the verification result that the runtime environment of the program to be run is a legitimate runtime environment. In the above program execution method, by obtaining the radix encoding parameters corresponding to the telomere region and obtaining the offset value from the header storage block of the telomere block in the telomere region, it can be determined whether the telomere block has been used; by accessing the information bit storage block in the telomere block when the telomere block is not used, the verification encoding information corresponding to the information bit storage block can be obtained; and by using the radix encoding parameters corresponding to the telomere region to perform encoding conversion processing on the verification encoding information, the verification number used to obtain the verification hash value can be obtained; then, by comparing the verification hash value with the hash value stored in the header storage block, the verification hash value can be obtained. The system verifies whether the runtime environment of the program to be run is a legitimate runtime environment. If the hash value to be verified is the same as the hash value stored in the header storage block, the program to be run is run based on the verification result indicating that the runtime environment of the program to be run is a legitimate runtime environment. This simplifies the verification process of whether the runtime environment of the program to be run is a legitimate runtime environment, thereby saving the resources used in the verification process. Furthermore, the verification process does not require interaction with a third-party server, meaning that the legitimacy verification of the environment can be successfully performed even when there is no internet connection or access to the verification server, making the application scenarios more extensive.
[0076] In one exemplary embodiment, the telomere block includes at least a first telomere block and a second telomere block. The offset value includes at least a first offset value and a second offset value.
[0077] If the offset value characterization end-granular block is not used, access the information bit storage block in the end-granular block to obtain the encoded information to be verified corresponding to the information bit storage block, including:
[0078] If the first offset value indicates that the first end-granule block has been used, the end-granule block to be jumped to is determined based on the first offset value and the number of storage blocks occupied by the first end-granule block, and the end-granule block to be jumped to is used as the second end-granule block.
[0079] When the second offset value of the second end block indicates that the second end block is not used, the information bit storage block of the second end block is accessed to obtain the code information to be verified corresponding to the information bit storage block.
[0080] The first offset value indicates that the first end-granular block has been used, meaning it has already been used for environmental validation and cannot be used for validation again; in other words, the number of times the program can be run has decreased by one. The second offset value indicates that the second end-granular block has not been used, meaning it has not yet been used for environmental validation; that is, the information bit storage block within the second end-granular block has not been corrupted, and the program can still be run. For example, if the second offset value in the header storage block of the second end-granular block is 0, it means the second end-granular block has not been used.
[0081] The second end-granule is determined based on the product of the first offset value stored in the first end-granule and the number of storage blocks occupied by the first end-granule. Specifically, it is the end-granule after jumping offset × (L+1) storage blocks, where offset is the specific value of the first offset, L+1 is the number of storage blocks occupied by the first end-granule, and L is the number of information bit storage blocks in the first end-granule. Jumping is accomplished using pointers. For example, define data pointers H1 and H2. H1 is used to find the end-granule block to jump to, and H2 is used to record the end-granule block that points to the end-granule block to jump to, i.e., the first end-granule block. The length of the first end-granule block is 20, and the first offset value offset in the header storage block of the first end-granule block is 1. Then H1 will be offset by 20 storage blocks. H1 originally pointed to the header storage block of the first end-granule block. After being offset by 20 blocks, it points to the next end-granule block. If the offset value offset in the header of the next end-granule block is 0, then the end-granule block is the second end-granule block, and the second offset value is 0. H2 will then record the position of the first end-granule block.
[0082] The information bit storage block is the storage block arranged after the header storage block in the second endgranular block. There is at least one information bit storage block in the second endgranular block. Accessing the information bit storage block of the second endgranular block means retrieving the encoded information to be verified corresponding to that information bit storage block.
[0083] Optionally, if the terminal determines that the first end-granular block has already been used for environmental legitimacy verification and cannot be used for legitimacy verification again, the terminal uses the program to be run to determine the end-granular block to jump to based on the product of the first offset value stored in the first end-granular block and the number of storage blocks occupied by the first end-granular block. That is, the end-granular block where the jump offset × (L+1) storage blocks are located. The terminal uses the end-granular block to be jumped to as the second end-granular block, and controls the program to be run to obtain the second offset value stored in the header storage block of the second end-granular block. If the second offset value indicates that the second end-granular block is not used, the terminal controls the program to be run to access each information bit storage block in the second end-granular block to obtain the sub-encoding corresponding to each information bit storage block. Then, the obtained sub-encodings are concatenated according to the arrangement order of the information bit storage blocks to obtain the verification encoding information corresponding to the information bit storage block.
[0084] In this embodiment, when the first offset value indicates that the first end-granule has been used, the end-granule to be jumped to can be determined based on the first offset value and the number of storage blocks occupied by the first end-granule. By taking the end-granule to be jumped to as the second end-granule, and when the second offset value of the second end-granule indicates that the second end-granule has not been used, the information bit storage block in the second end-granule is accessed, thereby obtaining the verification code information corresponding to the information bit storage block, and thus the legality of the environment can be verified through the verification code information.
[0085] In an exemplary embodiment, the information bit storage block in the access end granular block is used to obtain the verification-to-be-verified encoded information corresponding to the information bit storage block, including:
[0086] Access each information bit storage block in the end-granule block in turn to obtain the number of erase / write operations for each information bit storage block.
[0087] Based on the number of erase / write cycles corresponding to each information bit storage block, the theoretical maximum number of erase / write cycles pre-stored in the root storage block of the telomere region, and the base encoding parameters, the encoding information to be verified corresponding to the information bit storage block is determined.
[0088] The erase / write count refers to the number of times the information bit is repeatedly erased until the storage block is damaged and marked as a bad block. When an overwrite fails, it indicates that the block is damaged; or the BBT (bad block table) is read, which records which storage blocks are bad.
[0089] Considering the volatility, there will be some error between the number of erase / write cycles and the theoretical remaining number of erase / write cycles. Therefore, floating-point calculations are used, and the results are rounded to the nearest integer, i.e., r. i =ROUND((Pn i ()×Q / P), note the r obtained at this timei Belonging to Q-ary encoded parameters, after accessing all information bit storage blocks, all r... i (1≤i≤L-1) concatenation yields r1 r2…r (L-1) , where r i This represents the sub-encoding corresponding to the i-th information bit storage block, n i This represents the number of erase / write cycles for the i-th information bit storage block. P represents the theoretical maximum number of erase / write cycles for the storage block in the telomere region. The theoretical maximum number of erase / write cycles for a storage block is a physical property of the storage medium. This theoretical maximum number of erase / write cycles is relatively fixed and can be detected. Q represents the base encoding parameter; for example, if it is a binary encoding parameter, then Q is 2. When obtaining the theoretical maximum number of erase / write cycles, if the theoretical maximum number of erase / write cycles is encrypted, it needs to be decrypted using the decryption key corresponding to the encryption key.
[0090] Optionally, the terminal controls the program to be run to access each information bit storage block in the end-granule block sequentially to obtain the number of erase / write operations for each information bit storage block. Considering the volatility, there will be a certain error between the number of erase / write operations and the theoretical remaining number of erase / write operations. Therefore, floating-point numbers are used for calculation, and the calculation result is rounded to the nearest integer, i.e., using the formula r i =ROUND((Pn i The sub-code corresponding to each information bit storage block is calculated by multiplying Q by P. Then, the sub-codes corresponding to each information bit storage block are concatenated in order to obtain the encoded information corresponding to the information bit storage block.
[0091] In this embodiment, by sequentially accessing each information bit storage block in the end-granule block, the number of erase / write operations corresponding to each information bit storage block can be obtained. Thus, based on the number of erase / write operations corresponding to the information bit storage block, the theoretical maximum number of erase / write operations pre-stored in the root storage block, and the base encoding parameters, the encoding information to be verified corresponding to the information bit storage block can be obtained.
[0092] In one exemplary embodiment, such as Figure 3 As shown, steps 302 to 312 precede step 202. Wherein:
[0093] Step 302: Obtain the number of storage blocks occupied by the telomere region in the storage space, and determine the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region.
[0094] The number of storage blocks occupied by the telomere area can be set manually or determined based on the size of the program to be run. For example, the telomere area can be set to occupy half of the USB drive's storage space, and the program area can be set to occupy the other half, meaning the telomere area and the program area each occupy half of the USB drive's storage space. As another example, if the USB drive's storage space is divided into 100 storage blocks, and the program to be run requires 40 storage blocks, then the telomere area would occupy 60 storage blocks.
[0095] The number of times a program can be run refers to the number of times a program can be run in the program area associated with the telomere region. For example, if the number of times a program can be run is 10, after the program stored in the program area has been successfully run 10 times on the device, it cannot be run successfully again, even if the device environment is a valid environment, because the number of times the program can be run has been used up, that is, the telomere block in the telomere region has been used up or consumed.
[0096] The theoretical maximum number of write cycles for telomeres refers to the number of times a storage device can be erased from its manufacturing stage until it is damaged; it is an inherent property of the hardware. For example, once a USB flash drive is manufactured, the theoretical maximum number of write cycles for the telomeres built upon it is fixed. Generally, this value is fixed when the storage device is manufactured. The number of pending runs indicates the number of telomere blocks that need to be generated; this number can be determined by the user.
[0097] Optionally, the terminal determines the number of storage blocks occupied by the telomere region in the storage space based on the size of the program to be run. The terminal obtains the theoretical maximum number of erase / write cycles that the storage device can be erased from the time it is manufactured until it is damaged, and receives the number of programs to be run, which is a user-defined number of telomere blocks that need to be generated.
[0098] Step 304: Determine the number of storage blocks occupied by the telomere region in the storage space based on the number of storage blocks occupied by the telomere region in the storage space and the number of times it needs to be run.
[0099] The telomere region comprises at least one telomere block and one head storage block. The number of storage blocks occupied by each telomere block in the storage space is equal to the length of each telomere block. The number of storage blocks occupied by each telomere block in the storage space can be determined based on the formula T×(L+1)<=S, where L+1 represents the number of storage blocks occupied by a telomere block in the storage space, T represents the number of runs to be performed, and S represents the number of storage blocks occupied by the telomere region in the storage space.
[0100] Optionally, the terminal determines the number of storage blocks occupied by each telomere block in the storage space using T×(L+1)<=S, based on the number of storage blocks occupied by the telomere region in the storage space and the number of runs to be performed to characterize the number of telomere blocks to be generated.
[0101] Step 306: Store the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles into the root storage block of the telomere region.
[0102] The radix encoding parameters corresponding to the telomere region can be set randomly. For example, the corresponding radix encoding parameters can be set to binary encoding parameters, octal encoding parameters, etc.
[0103] The number system encoding parameters, the number of storage blocks occupied by the telomere block, and the theoretical maximum number of erase / write cycles can be encrypted before being stored in the root storage block. Encryption is optional; however, encryption ensures information security. The main encryption method is symmetric encryption. For example, the AES (Advanced Encryption Standard) algorithm can be used to encrypt the number system encoding parameters, the number of storage blocks occupied by the telomere block, and the theoretical maximum number of erase / write cycles.
[0104] Optionally, the terminal determines the radix encoding parameters corresponding to the telomere region by receiving a radix encoding parameter setting instruction triggered by the user. The terminal stores the radix encoding parameters, the number of storage blocks occupied by each telomere block in the storage space, and the theoretical maximum number of erase / write cycles in the root storage block of the telomere region.
[0105] Step 308: Determine the random number corresponding to the end granule block, store the hash value corresponding to the random number and the offset value indicating whether the end granule block is used in the header storage block of the end granule block, and store the encoded information corresponding to the random number in the information bit storage block.
[0106] The random number is set manually. The random number must meet the following condition: (1 <= R <= Q) L-1), where R is the random number, Q is the base encoding parameter, and L represents the number of information bit storage blocks in an endgranular block. Setting boundary values is to prevent bit overflow after base conversion. For example, when L=2, Q=2, and the selected random number is 8, according to the process, 8 is first converted to binary to get 1000. Since L=2, only two bits can be stored, so only 00 is stored. Therefore, the value retrieved during verification is 00, which is converted to decimal to 0. The hash value of 0 is compared with the hash value stored in the header storage block. However, the hash value stored in the header storage block is calculated based on the originally selected random number 8, so it will not match, leading to an error. Therefore, we limit the boundary so that the number of bits in the random number after base conversion will not exceed L. Furthermore, when the number of bits after base conversion is insufficient, leading zeros are added. For example, when L=2, Q=2, and the selected random number is 1, it is converted to binary to 1, and if it is insufficient to two bits, leading zeros are added to make it 01. This zero-padding mechanism does not change the original value; both 1 and 01 will be 1 when converted to decimal.
[0107] Each information bit storage block in each end-granular block can store one sub-code. For example, when the random number R = 2, the base encoding parameter Q = 2, and the information bit storage block length L = 2, R is first converted to binary 10, then the first information bit storage block stores sub-code 1, and the second information bit storage block stores sub-code 0.
[0108] The initial value of the offset value for all end granules is 0, indicating that it is an active end granule. When an active end granule is consumed or used, it may become a jump end granule. At this time, its offset represents the offset to find the next active end granule or the next jump end granule. When the program runs for the first time, it searches for the first end-granular block. It finds that the offset of the first end-granular block is 0, indicating that it is an active end-granular block. The program then consumes the first end-granular block for validity verification and increments its offset by 1, making the first end-granular block's offset 1. At this point, the first end-granular block becomes a jump end-granular block. The program runs for the second time, again finding the first end-granular block with an offset of 1. It then moves the pointer to the next end-granular block, the second one, and consumes it. Finally, the program increments the offset of the first end-granular block again, making its offset 2. The program runs for the third time, again finding the first end-granular block with an offset of 2. It then moves the pointer to the next-next end-granular block, the third one, and consumes it. Finally, the program increments the offset of the first end-granular block again, making its offset 3. The subsequent processes are the same. Note that the maximum value of the end-granular block's offset is limited to P / 2. Because writing and erasing the same end-granule P times consecutively will damage it, to be on the safe side, the offset threshold needs to be set to P / 2, where P is the theoretical maximum number of write / erase cycles. So, when the program runs for the P / 2+1th time, it first finds the first end-granule, discovers its offset = P / 2, and then shifts the pointer forward by P / 2 end-granules, to the P / 2+1th end-granule. At this point, the offset of this end-granule is 0, so the program consumes it and increments the offset of the P / 2+1th end-granule by one. Note that this increment is not for the first end-granule. When the program runs for the P / 2+2th time, it again first finds the first end-granule, discovers its offset = P / 2, and then shifts the pointer forward by P / 2 end-granules, to the P / 2+1th end-granule. The offset of the P / 2+1th telomere block is found to be 1, which means that this telomere block is also a jump telomere block. The pointer is then shifted forward by one telomere block, namely the P / 2+2th telomere block, and the subsequent processes are the same. The telomere block jump is as follows: Figure 4 As shown.
[0109] Optionally, the terminal determines the boundary values of the random number based on the radix encoding parameters stored in the root storage block and the number of information bit storage blocks in the endgranular block. The terminal determines the random number corresponding to the endgranular block by receiving a random number selection command triggered by the user. The random number is within the boundary range. The terminal uses a strong hash algorithm to calculate the hash value of the random number and stores the hash value and an offset value indicating whether the endgranular block is used in the header storage block of the endgranular block. The initial offset values stored in the endgranular block all indicate that the endgranular block is not used. The terminal uses the radix encoding parameters stored in the root storage block to encode the random number, obtaining encoded information composed of multiple sub-encodes. The terminal stores each sub-encode in the encoded information sequentially in the respective information bit storage blocks of the endgranular block according to the order of arrangement.
[0110] In one embodiment, the hash value in the header storage block of the telomere block can also be determined based on information such as the device's physical address and the CPU's identifier. For example, consider a USB flash drive that distinguishes between the telomere area and the program area. If the device initially connected to the USB flash drive is device A, then the hash value of the header storage block to be stored in the telomere block will be determined based on the physical address and CPU identifier of device A. After the USB flash drive is connected to device B, since the physical address and CPU identifier of device A are different from those of device B, a difference in hash values will occur during hash value comparison. Consequently, the program to be run on the USB flash drive cannot be run on device B and can only be run on device A.
[0111] Step 310: Determine the number of times the information bit storage block can be erased and rewritten based on the base encoding parameters, the theoretical maximum number of erase / write cycles, and the encoded information stored in the information bit storage block.
[0112] The formula for determining the number of erase / write cycles is: r i ×P / Q, r i Let represent the sub-encoding stored in the i-th information bit storage block, P represent the theoretical maximum number of erase / write cycles, and Q represent the base encoding parameters. The theoretical remaining number of erase / write cycles corresponding to the information bit storage block is P - (r i ×P / Q).
[0113] Optionally, the terminal determines the theoretical maximum number of erasable / write cycles, the base encoding parameters, and the sub-encoded information stored in each information bit storage block, using formula r. i ×P / Q determines the number of erase / write cycles for each information bit storage block.
[0114] Step 312: Erase and rewrite the information bit storage block based on the number of erase / write cycles to construct a telomere region for detecting whether the runtime environment of the program to be run is a legitimate runtime environment.
[0115] Optionally, the terminal erases and writes each information bit storage block according to the number of erases and writes corresponding to each information bit storage block. After all information bit storage blocks are erased and written, the telomere region used to detect whether the running environment of the program to be run is a legal running environment is constructed.
[0116] In this embodiment, by obtaining the number of storage blocks occupied by the telomere region, the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region are determined, thereby determining the number of storage blocks occupied by each telomere block in the telomere region; by storing the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles in the root storage block of the telomere region, the security of the radix encoding parameters, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles can be ensured, preventing them from being obtained by third-party devices; by determining the random number corresponding to the telomere block, and storing the random number... The corresponding hash value and the offset value indicating whether the telomere block is used are stored in the header storage block. The encoded information corresponding to the random number is stored in the information bit storage block. The number of times the information bit storage block can be erased and written is determined based on the base encoding parameters, the theoretical maximum number of erasures and writes, and the encoded information stored in the information bit storage block. Then, the information bit storage block is erased and written based on the number of erasures and writes. This allows the construction of a telomere region for detecting whether the running environment of the program to be run is a legitimate running environment. This simplifies the process of verifying the legitimacy of the environment based on the constructed telomere region and reduces the amount of resources used for legitimacy verification.
[0117] In an exemplary embodiment, the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles are stored in the root storage block of the telomere region, including:
[0118] Symmetric encryption is performed on the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles to obtain the number of encrypted erase / write cycles, the number of encryptions, and the encryption encoding parameters.
[0119] The number of encryption erase / write cycles, the number of encryptions, and the encryption encoding parameters are stored in the root storage block of the telomere region.
[0120] Symmetric encryption is achieved through symmetric encryption algorithms such as AES.
[0121] Optionally, the terminal uses a symmetric encryption algorithm to symmetrically encrypt the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles, respectively, to obtain the encryption period after encrypting the theoretical maximum number of erase / write cycles, the encryption encoding parameters after encrypting the radix encoding parameters, and the encryption quantity after encrypting the number of storage blocks occupied by the telomere block in the storage space. The terminal then stores the encryption quantity, encryption encoding parameters, and encryption erase / write cycles in the header storage block of the telomere region.
[0122] In this embodiment, a symmetric encryption algorithm is used to encrypt the radix encoding parameters, the theoretical maximum number of erase / write cycles, and the number of storage blocks occupied by the telomere block in the storage space. The encrypted erase / write cycles, the number of encryptions, and the encryption encoding parameters are then stored in the root storage block of the telomere region. This ensures the security of the stored information, preventing third-party servers from decrypting the encryption encoding parameters, the number of encryptions, and the number of erase / write cycles, thus preventing them from obtaining the decrypted radix encoding parameters, the theoretical maximum number of erase / write cycles, and the number of storage blocks occupied by the telomere block in the storage space.
[0123] In one exemplary embodiment, obtaining the number of storage blocks occupied by the telomere region in the storage space includes:
[0124] Get the storage space corresponding to a file that is filled with data and organized into storage blocks.
[0125] Based on the number of storage blocks occupied by the program to be run, the storage space is divided into the program area and the telomere area of the storage space.
[0126] Use the program to be run to replace the data in the program area.
[0127] The number of storage blocks occupied by the telomere region in the storage space is determined based on the difference between the number of storage blocks occupied by the program area where the program to be run is located and the total number of storage blocks in the storage space.
[0128] Storage space refers to the storage space of the storage medium, such as the storage space in a USB flash drive. A file is a file stored within that storage space, such as a file created on a USB flash drive. The data filled into a file can be random data. The storage space corresponding to a file filled with data refers to the total storage space occupied by the data-filled file. Filling the storage space of the USB flash drive with data first prevents the data from being moved, thus ensuring that the program to be run, which is finally filled into the USB flash drive, can be stored in a specific location—that is, in the program area, rather than the telomere area.
[0129] The program area occupies the same number of storage blocks as the program to be executed. The telomere area occupies the same number of storage blocks as the total number of storage blocks in the memory space minus the number of storage blocks occupied by the program area. The division between the program area and the telomere area is as follows: Figure 5 As shown.
[0130] Replacement refers to first extracting the data written in the program area, and then writing the program to be run into the blank program area.
[0131] Optionally, the terminal obtains the storage space containing the file, which is filled with data and organized into storage blocks. Based on the number of storage blocks occupied by the program to be run, the terminal divides the storage space containing the file into a telomere region and a program region. The terminal first extracts the data written to the program region, and then writes the program to be run into the empty program region, thus replacing the data in the program region. The terminal calculates the number of storage blocks occupied by the telomere region by subtracting the number of storage blocks occupied by the program region from the total number of storage blocks occupied by the total number of storage blocks occupied by the storage space.
[0132] In this embodiment, by obtaining the storage space corresponding to a file filled with data in units of storage blocks, and then dividing the storage space based on the number of storage blocks occupied by the program to be run, the number of storage blocks occupied by the program area and the telomere area can be obtained respectively. By first extracting the data written in the program area, and then writing the program to be run into the blank program area, the storage location of the program to be run can be the program area, rather than the telomere area.
[0133] This application also provides an application scenario in which the above-described program execution method is applied. Specifically, the program execution method is applied in this scenario as follows: A file X is created on a USB flash drive, and data is written into X until the entire storage space of the USB flash drive is filled. Using storage blocks as the basic unit, X is divided into a program area and a telomere area. The terminal first extracts the data written in the program area, and then writes the program to be executed into the blank program area.
[0134] The specific steps for setting up the telomere region are as follows: Obtain the number of storage blocks S occupied by the telomere region in the storage space and the theoretical maximum number of erasable / write cycles P of the telomere region; select the number of runs T to represent the number of telomere blocks to be generated; set the telomere block length parameter to L+1 to represent how many storage blocks each telomere block needs to occupy, with each telomere block including one header storage block and L information bit storage blocks; set the radix encoding parameter Q to perform radix conversion of the telomere block key. Note that T, L, and S should satisfy the inequality T×(L+1)+1≤S, where 1 represents the number of storage blocks occupied by the root of the telomere region, i.e., the number of root storage blocks.
[0135] The terminal uses the first storage block of the telomere region as the root storage block of the telomere region, and stores parameters P, L, and Q into the root storage block. These parameters will be used to perform validation of the environment. The data storage structure is as follows: Figure 6 As shown. To prevent others from directly accessing the root and obtaining parameter information, encryption technology is used to protect parameters P, L, and Q before they are stored in the root storage block.
[0136] The terminal selects L+1 consecutive memory blocks, starting from the second memory block, as a telomere block. A random number R (1 ≤ R ≤ Q) is selected. L -1) As the key for this end-granular block, firstly, a strong hash algorithm is used to calculate the hash value of R, and then R is converted from decimal to Q-base, denoted as r1 r2…r L The first storage block in the telomere block is called the header storage block, which stores the hash value and offset value of R. For the i-th (1≤i≤L) information bit, the terminal repeatedly writes to and erases (r) the corresponding storage block. i ×P / Q) times, at this point, the theoretical number of erase cycles remaining for the storage block corresponding to this information bit is (Pr i ×P / Q). After traversing all information bits, the construction of the current telomere block is complete. After traversing all telomere blocks, the construction of the telomere region is complete.
[0137] When the program starts, it first checks whether the runtime environment is valid. If it is valid, execution continues; otherwise, it is interrupted. The specific steps for validity verification are as follows:
[0138] The following example illustrates how to divide a USB flash drive into a program area and a telomere area. The terminal controls the program to be run to read the encrypted data (P, L, and Q) from the root storage block of the telomere area, and then decrypts it to obtain the parameters P, L, and Q. The terminal defines data pointers H1 and H2, where H1 is used to locate the active telomere block, and H2 is used to record the jump telomere block pointing to the active telomere block. The terminal controls the program to be run to make H1 point to the first telomere block. The terminal controls the program to be run to read the offset from the header of the telomere block pointed to by data pointer H1. If offset = -1, it means all end-granular blocks have been used, the program has reached its maximum execution count, and the program to be run is interrupted. If offset > 0, it means the current end-granular block is a jump end-granular block. The program to be run is controlled to point the data pointer H2 to the current end-granular block, and the program to be run is controlled to offset the data pointer H1 by offset × (L+1) memory blocks. Then, the program to be run is controlled to extract the offset from the header memory block. If offset = 0, it means the current end-granular block is an active end-granular block. The terminal controls the program to be run to access the i-th (1≤i≤L) information bit memory block in the end-granular block in sequence. For each information bit, the erase is repeated until the block is corrupted and marked as a bad block. The number of erase / write operations is recorded as n.i Considering volatility, n i There may be some error compared to the theoretical remaining number of erases. Floating-point numbers are used for calculation here, and the result is rounded to the nearest integer, i.e., r. i =ROUND((Pn i ()×Q / P), note the r obtained at this time i It belongs to Q-ary encoding. After traversing all the information bit storage blocks, the program to be run will store all the r... i (1≤i≤L-1) concatenation yields r1 r2…r (L-1) Then convert it to decimal to get The terminal then controls the program to be run to calculate the hash value corresponding to R' using the strong hash algorithm used for hashing R, and compares it with the hash value stored in the header storage block of the telomere block. If they are not equal, it proves that the device to which the program is to be run is not the device to which the USB flash drive was initially connected, and the program's execution is interrupted. If you want to copy the program to be run to another USB flash drive, you need to copy the telomere area at the same time. However, since the storage block of the copied USB flash drive does not perform a repeated erase operation on the information bit storage block, the hash value calculated based on the copied USB flash drive does not match the hash value stored in the header storage block of the telomere block. That is, the program to be run can identify the current USB flash drive as a copied USB flash drive, thus preventing the program to be run from being copied and executed.
[0139] In the above embodiments, by obtaining the radix encoding parameters corresponding to the telomere region and obtaining the offset value from the header storage block of the telomere block in the telomere region, it can be determined whether the telomere block has been used. By accessing the information bit storage block in the telomere block when the telomere block is not used, the verification encoding information corresponding to the information bit storage block can be obtained. By using the radix encoding parameters corresponding to the telomere region to encode the verification encoding information, the verification number used to obtain the verification hash value can be obtained. Then, by comparing the verification hash value with the hash value stored in the header storage block, it can be verified whether the running environment of the program to be run is a legitimate running environment. If the verification hash value is the same as the hash value stored in the header storage block, the program to be run is run based on the verification result indicating that the running environment of the program to be run is a legitimate running environment. This simplifies the verification process of whether the running environment of the program to be run is a legitimate running environment, saves resources used in the verification process, and does not require interaction with a third-party server during the verification process. That is, the legality verification of the environment can be successfully performed even when there is no network connection or access to the verification server, making the application scenarios more extensive.
[0140] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0141] Based on the same inventive concept, this application also provides an apparatus for implementing the above-described method of program execution. The solution provided by this apparatus is similar to the implementation described in the above-described method; therefore, the specific limitations in one or more embodiments of the program execution apparatus provided below can be found in the limitations of the program execution method described above, and will not be repeated here.
[0142] In one exemplary embodiment, such as Figure 7 As shown, a device for running a program is provided, comprising:
[0143] The data acquisition module 702 is used to acquire the radix encoding parameters corresponding to the telomere region and extract the offset value from the head storage block of the telomere block in the telomere region. The telomere region is used to detect whether the runtime environment of the program to be run is a valid runtime environment. The program to be run is the program stored in the program area associated with the telomere region.
[0144] Access module 704 is used to access the information bit storage block in the end-granular block when the offset value characterization end-granular block is not used, and obtain the code information to be verified corresponding to the information bit storage block.
[0145] The encoding conversion module 706 is used to perform encoding conversion on the encoding information to be verified based on the base encoding parameters, to obtain the number to be verified, and to determine the hash value to be verified of the number to be verified.
[0146] The verification module 708 is used to obtain a verification result that the running environment of the program to be run is a valid running environment if the hash value to be verified is the same as the hash value stored in the header storage block.
[0147] The execution module 710 is used to run the program to be run based on the verification results.
[0148] In the above embodiments, by obtaining the radix encoding parameters corresponding to the telomere region and obtaining the offset value from the header storage block of the telomere block in the telomere region, it can be determined whether the telomere block has been used. When the telomere block is not used, the information bit storage block in the telomere block is accessed to obtain the verification encoding information corresponding to the information bit storage block. The verification encoding information is then encoded using the radix encoding parameters corresponding to the telomere region to obtain the verification number used to obtain the verification hash value. The verification hash value is then compared with the hash value stored in the header storage block to verify whether the runtime environment of the program to be run is a legitimate runtime environment. If the verification hash value is the same as the hash value stored in the header storage block, the program to be run is run based on the verification result indicating that the runtime environment of the program to be run is legitimate. This simplifies the verification process for whether the runtime environment of the program to be run is legitimate, saves resources used in the verification process, and eliminates the need for interaction with a third-party server during verification. This allows for successful environment legitimacy verification even when there is no internet connection or access to the verification server, making the application scenarios more extensive.
[0149] In one embodiment, the telomere block includes at least a first telomere block and a second telomere block. The offset value includes at least a first offset value and a second offset value. The access module includes:
[0150] The jump unit is used to determine the end-granule block to be jumped to based on the first offset value and the number of storage blocks occupied by the first end-granule block, when the first offset value indicates that the first end-granule block has been used, and to use the end-granule block to be jumped to as the second end-granule block.
[0151] The information access unit is used to access the information bit storage block of the second end block when the second offset value of the second end block indicates that the second end block is not used, and obtain the code information to be verified corresponding to the information bit storage block.
[0152] In one embodiment, the access module includes:
[0153] The first data acquisition unit is used to sequentially access each information bit storage block in the end-granule block to obtain the number of erase / write operations for each information bit storage block.
[0154] The encoding acquisition unit is used to determine the encoding information to be verified corresponding to the information bit storage block based on the number of erase / write operations corresponding to each information bit storage block, the theoretical maximum number of erase / write operations pre-stored in the root storage block of the telomere region, and the base encoding parameters.
[0155] In one embodiment, the data acquisition module includes:
[0156] The second data acquisition unit is used to acquire the number of storage blocks occupied by the telomere region in the storage space, and to determine the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region.
[0157] The quantity determination unit is used to determine the number of storage blocks occupied by the telomere region in the storage space based on the number of storage blocks occupied by the telomere region in the storage space and the number of times it needs to be run.
[0158] The first data storage unit is used to store the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase and write cycles to the root storage block of the telomere region.
[0159] The second data storage unit is used to determine the random number corresponding to the end granule block, store the hash value corresponding to the random number and the offset value indicating whether the end granule block is used in the header storage block of the end granule block, and store the encoded information corresponding to the random number in the information bit storage block.
[0160] The third data acquisition unit is used to determine the number of times the information bit storage block can be erased and rewritten based on the base encoding parameters, the theoretical maximum number of erase and rewrite cycles, and the encoded information stored in the information bit storage block.
[0161] The erase / write unit is used to erase and write the information bit storage block based on the number of erase / write cycles, so as to construct the telomere region for detecting whether the running environment of the program to be run is a legitimate running environment.
[0162] In one embodiment, the first data storage unit includes:
[0163] The encryption subunit is used to perform symmetric encryption processing on the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erasure and write cycles, respectively, to obtain the number of encryption erasure and write cycles, the number of encryptions, and the encryption encoding parameters.
[0164] The encrypted storage subunit is used to store the number of encryption erase / write cycles, the number of encryptions, and the encryption encoding parameters in the root storage block of the telomere region.
[0165] In one embodiment, the second data acquisition unit includes:
[0166] The storage space determination sub-unit is used to obtain the storage space corresponding to a file that is filled with data and is organized into storage blocks.
[0167] The sub-unit is used to divide the storage space based on the number of storage blocks occupied by the program to be run, resulting in the program area and telomere area of the storage space.
[0168] The data replacement subunit is used to replace the data in the program area with the program to be run.
[0169] The data determination subunit is used to determine the number of storage blocks occupied by the telomere region in the storage space based on the difference between the number of storage blocks occupied by the program area where the program to be run is located and the total number of storage blocks in the storage space.
[0170] Each module in the device that runs the above program can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0171] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface is used for exchanging information between the processor and external devices. When the computer program is executed by the processor, it implements a method for program execution. Those skilled in the art will understand that... Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0172] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0173] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0174] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0175] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0176] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include non-volatile memory. Non-volatile memory can include USB flash drives, flash memory, etc. The databases involved in the embodiments provided in this application can include at least one type of relational database and non-relational database. Non-relational databases can include blockchain-based distributed databases, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited thereto.
[0177] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0178] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for running a program, characterized in that, The method includes: Obtain the number of storage blocks occupied by the telomere region in the storage space, and determine the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region; Based on the number of storage blocks occupied by the telomere region in the storage space and the number of times to be run, the number of storage blocks occupied by the telomere block in the storage space is determined, and the base encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase and write cycles are stored in the root storage block of the telomere region. Determine the random number corresponding to the telomere block, store the hash value corresponding to the random number and the offset value representing whether the telomere block is used in the header storage block of the telomere block, and store the encoded information corresponding to the random number in the information bit storage block; The number of times the information bit storage block can be erased and written is determined based on the base encoding parameters, the theoretical maximum number of erase and write cycles, and the encoded information stored in the information bit storage block. The information bit storage block is erased and rewritten based on the number of erase / write cycles to construct a telomere region for detecting whether the running environment of the program to be run is a legitimate running environment; Obtain the radix encoding parameters corresponding to the telomere region, and extract the offset value from the head storage block of the telomere block in the telomere region; the telomere region is used to detect whether the running environment of the program to be run is a legal running environment; the program to be run is the program stored in the program area associated with the telomere region; When the offset value indicates that the end granule block is not used, the information bit storage block in the end granule block is accessed to obtain the code information to be verified corresponding to the information bit storage block; Based on the base encoding parameters, the encoding information to be verified is encoded and converted to obtain the number to be verified, and the hash value to be verified of the number to be verified is determined. If the hash value to be verified is the same as the hash value stored in the header storage block, the verification result is that the running environment of the program to be run is a legitimate running environment. Based on the verification results, run the program to be run; The step of storing the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles into the root storage block of the telomere region includes: performing symmetric encryption processing on the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles to obtain the encrypted erase / write cycles, the encrypted quantity, and the encrypted encoding parameters; and storing the encrypted erase / write cycles, the encrypted quantity, and the encrypted encoding parameters into the root storage block of the telomere region.
2. The method according to claim 1, characterized in that, The telomere block includes at least a first telomere block and a second telomere block; the offset value includes at least a first offset value and a second offset value; When the offset value indicates that the endgranulation block is not used, accessing the information bit storage block in the endgranulation block to obtain the unverified encoded information corresponding to the information bit storage block includes: If the first offset value indicates that the first end-granule block has been used, the end-granule block to be jumped to is determined based on the first offset value and the number of storage blocks occupied by the first end-granule block, and the end-granule block to be jumped to is used as the second end-granule block. When the second offset value of the second end block indicates that the second end block is not used, the information bit storage block of the second end block is accessed to obtain the code information to be verified corresponding to the information bit storage block.
3. The method according to claim 1, characterized in that, The step of accessing the information bit storage block in the telomere block to obtain the verification-to-be-verified encoded information corresponding to the information bit storage block includes: Each information bit storage block in the telomere block is accessed sequentially to obtain the number of erase / write cycles for each information bit storage block. Based on the number of erase / write cycles corresponding to each of the information bit storage blocks, the theoretical maximum number of erase / write cycles pre-stored in the root storage block of the telomere region, and the base encoding parameters, the encoding information to be verified corresponding to the information bit storage block is determined.
4. The method according to claim 1, characterized in that, The acquisition of the number of storage blocks occupied by the telomere region in the storage space includes: Retrieve the storage space corresponding to a file that is filled with data and organized into storage blocks; Based on the number of storage blocks occupied by the program to be run, the storage space is divided to obtain the program area and telomere area of the storage space; The program to be run is used to replace the data in the program area; The number of storage blocks occupied by the telomere region in the storage space is determined based on the difference between the number of storage blocks occupied by the program area where the program to be run is located and the total number of storage blocks in the storage space.
5. A device for running a program, characterized in that, The device includes: The data acquisition module is used to acquire the base encoding parameters corresponding to the telomere region and extract the offset value from the head storage block of the telomere block in the telomere region; the telomere region is used to detect whether the running environment of the program to be run is a legal running environment; the program to be run is the program stored in the program area associated with the telomere region; The access module is used to access the information bit storage block in the end granule block when the offset value indicates that the end granule block is not used, and obtain the unverified encoded information corresponding to the information bit storage block. The encoding conversion module is used to perform encoding conversion on the encoding information to be verified based on the base encoding parameters, to obtain the number to be verified, and to determine the hash value to be verified of the number to be verified; The verification module is used to obtain a verification result that the running environment of the program to be run is a legitimate running environment if the hash value to be verified is the same as the hash value stored in the header storage block. The execution module is used to run the program to be run based on the verification results; The data acquisition module further includes: a second data acquisition unit, used to acquire the number of storage blocks occupied by the telomere region in the storage space, and determine the theoretical maximum number of erase / write cycles and the number of cycles to be run for the telomere region; a quantity determination unit, used to determine the number of storage blocks occupied by the telomere block in the storage space based on the number of storage blocks occupied by the telomere region in the storage space and the number of cycles to be run; a first data storage unit, used to store the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erase / write cycles to the root storage block of the telomere region; and a second data storage unit, used for... A third data acquisition unit is used to determine the number of times the information bit storage block is erased and written based on the base encoding parameters, the theoretical maximum number of erasures and writes, and the encoding information stored in the information bit storage block. An erasure and write unit is used to erase and write the information bit storage block based on the number of erasures and writes to construct a telomere region for detecting whether the running environment of the program to be run is a legitimate running environment. The unit determines the random number corresponding to the telomere block, stores the hash value corresponding to the random number and the offset value indicating whether the telomere block is used in the header storage block of the telomere block, and stores the encoded information corresponding to the random number of erasures and writes in the information bit storage block. The first data storage unit includes: an encryption subunit, used to perform symmetric encryption processing on the radix encoding parameters corresponding to the telomere region, the number of storage blocks occupied by the telomere block in the storage space, and the theoretical maximum number of erasure and write operations, respectively, to obtain the number of encryption erasure and write operations, the number of encryption operations, and the encryption encoding parameters; and an encryption storage subunit, used to store the number of encryption erasure and write operations, the number of encryption operations, and the encryption encoding parameters in the root storage block of the telomere region.
6. The apparatus according to claim 5, characterized in that, The telomere block includes at least a first telomere block and a second telomere block; the offset value includes at least a first offset value and a second offset value; the access module includes: A jump unit is configured to determine the end-granule to be jumped to based on the first offset value and the number of storage blocks occupied by the first end-granule when the first offset value indicates that the first end-granule has been used, and to use the end-granule to be jumped to as the second end-granule. The information access unit is used to access the information bit storage block of the second end-bit block when the second offset value of the second end-bit block indicates that the second end-bit block is not used, and obtain the verification-to-be-verified encoded information corresponding to the information bit storage block.
7. The apparatus according to claim 5, characterized in that, The access module further includes: The first data acquisition unit is used to sequentially access each information bit storage block in the telomere block to obtain the number of erase / write cycles for each information bit storage block. The encoding acquisition unit is used to determine the encoding information to be verified corresponding to the information bit storage block based on the number of erase / write operations corresponding to each of the information bit storage blocks, the theoretical maximum number of erase / write operations pre-stored in the root storage block of the telomere region, and the base encoding parameters.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.