CN110851113A - Method and device for detecting randomness of byte sequence, storage medium and electronic equipment - Google Patents
Method and device for detecting randomness of byte sequence, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN110851113A CN110851113A CN202010045110.5A CN202010045110A CN110851113A CN 110851113 A CN110851113 A CN 110851113A CN 202010045110 A CN202010045110 A CN 202010045110A CN 110851113 A CN110851113 A CN 110851113A
- Authority
- CN
- China
- Prior art keywords
- sequence
- byte
- detected
- total number
- randomness
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F7/00—Methods or arrangements for processing data by operating upon the order or content of the data handled
- G06F7/58—Random or pseudo-random number generators
- G06F7/588—Random number generators, i.e. based on natural stochastic processes
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application provides a method and a device for detecting randomness of a byte sequence, a storage medium and electronic equipment. Firstly, the total number of runs is determined according to a sequence to be detected and a preset feature table, a byte sequence is not required to be converted into a bity sequence, the conversion workload is saved, and the conversion time is saved; then obtaining a first numerical value, calculating according to the number of bytes of the sequence to be detected, the first numerical value and the total number of runs to obtain a minimum significant level value of the sequence to be detected, wherein the sequence to be detected is a random sequence, and finally determining a detection result according to the minimum significant level value and a significant level threshold value, wherein the detection result indicates that the sequence to be detected passes randomness detection or does not pass randomness detection; the workload of converting the byte sequence into the bity sequence is saved, the conversion time is reduced, the detection efficiency is improved, and the load of a CPU is reduced.
Description
Technical Field
The present application relates to the field of randomness detection, and in particular, to a method and an apparatus for detecting randomness of a byte sequence, a storage medium, and an electronic device.
Background
Binary random sequences play a significant role in cryptographic application technology. Thus, it is necessary to detect randomness of a binary sequence generated by a random number generator or the like. The probability statistics method is adopted to analyze and detect the randomness of the binary sequence generated by the random number generator and the like, and whether the binary sequence to be detected can be statistically difficultly distinguished from the true random number is judged.
In the specification of randomness test promulgated in 2009, 15 statistical test methods for randomness test have also been proposed. The run total number detection (Runs Test) and the single bit detection (frequency (monobit) Test) are the detection items. In the existing process of detecting the total number of runs, when a sequence to be detected is a byte sequence, the byte sequence needs to be converted into a bity sequence, and the byte number of the sequence to be detected is very large, so that the conversion workload is large, long time is needed, the load of a CPU is increased, and the detection efficiency is reduced.
Disclosure of Invention
The present application aims to provide a method and an apparatus for detecting randomness of a byte sequence, a storage medium, and an electronic device, so as to solve the above problems.
In order to achieve the above purpose, the embodiments of the present application employ the following technical solutions:
in a first aspect, an embodiment of the present application provides a method for detecting randomness of a byte sequence, where the method includes:
determining the total number of runs according to a sequence to be detected and a preset feature table, wherein the feature table comprises the number of runs in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence;
acquiring a first numerical value, wherein the first numerical value is the total number of the bitol 1 in the sequence to be detected;
calculating to obtain the minimum significant level value of the sequence to be detected, which is a random sequence, according to the number of bytes of the sequence to be detected, the first numerical value and the total run number;
and determining a detection result according to the minimum significance level value and the significance level threshold value, wherein the detection result indicates that the sequence to be detected passes or fails randomness detection.
In a second aspect, an embodiment of the present application provides an apparatus for detecting randomness of a byte sequence, where the apparatus includes:
the processing unit is used for determining the total number of runs according to the sequence to be detected and a preset feature table, wherein the feature table comprises the number of the runs in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence; the method is also used for obtaining a first numerical value, wherein the first numerical value is the total number of the bitol 1 in the sequence to be detected; the sequence detection module is further used for calculating the minimum significant level value of the sequence to be detected, which is a random sequence, according to the number of bytes of the sequence to be detected, the first numerical value and the total run number;
and the detection unit is used for determining a detection result according to the minimum significance level value and the significance level threshold value, wherein the detection result indicates that the sequence to be detected passes or fails randomness detection.
In a third aspect, the present application provides a storage medium, on which a computer program is stored, and when executed by a processor, the computer program implements the method according to the first aspect.
In a fourth aspect, an embodiment of the present application provides an electronic device, including: a processor and memory for storing one or more programs; the one or more programs, when executed by the processor, implement the method as described in the first aspect.
Compared with the prior art, the method, the device, the storage medium and the electronic equipment for detecting the randomness of the byte sequence have the advantages that: firstly, the total number of runs is determined according to a sequence to be detected and a preset feature table, a byte sequence is not required to be converted into a bity sequence, the conversion workload is saved, and the conversion time is saved; then obtaining a first numerical value, calculating according to the number of bytes of the sequence to be detected, the first numerical value and the total number of runs to obtain a minimum significant level value of the sequence to be detected, wherein the sequence to be detected is a random sequence, and finally determining a detection result according to the minimum significant level value and a significant level threshold value, wherein the detection result indicates that the sequence to be detected passes randomness detection or does not pass randomness detection; the workload of converting the byte sequence into the bity sequence is saved, the conversion time is reduced, the detection efficiency is improved, and the load of a CPU is reduced.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and it will be apparent to those skilled in the art that other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a method for detecting randomness of a byte sequence according to an embodiment of the present application;
fig. 3 is a schematic view of substeps of S101 according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram illustrating the substeps of S102 according to an embodiment of the present disclosure;
fig. 5 is a schematic unit diagram of a device for detecting randomness of a byte sequence according to an embodiment of the present application.
In the figure: 10-a processor; 11-a memory; 12-a bus; 13-a communication interface; 201-a processing unit; 202-detection unit.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
In the description of the present application, it should be noted that the terms "upper", "lower", "inner", "outer", and the like indicate orientations or positional relationships based on orientations or positional relationships shown in the drawings or orientations or positional relationships conventionally found in use of products of the application, and are used only for convenience in describing the present application and for simplification of description, but do not indicate or imply that the referred devices or elements must have a specific orientation, be constructed in a specific orientation, and be operated, and thus should not be construed as limiting the present application.
In the description of the present application, it is also to be noted that, unless otherwise explicitly specified or limited, the terms "disposed" and "connected" are to be interpreted broadly, e.g., as being either fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
The embodiment of the application provides an electronic device which can be a computer device. Please refer to fig. 1, a schematic structural diagram of an electronic device. The electronic device comprises a processor 10, a memory 11, a bus 12. The processor 10 and the memory 11 are connected by a bus 12, and the processor 10 is configured to execute an executable module, such as a computer program, stored in the memory 11.
The processor 10 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the method for detecting the randomness of the byte sequence may be performed by hardware integrated logic circuits or instructions in the form of software in the processor 10. The Processor 10 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete gate or transistor logic device, or discrete hardware components.
The Memory 11 may comprise a high-speed Random Access Memory (RAM) and may further comprise a non-volatile Memory (non-volatile Memory), such as at least one disk Memory.
The bus 12 may be an ISA (Industry Standard architecture) bus, a PCI (peripheral component interconnect) bus, an EISA (extended Industry Standard architecture) bus, or the like. Only one bi-directional arrow is shown in fig. 1, but this does not indicate only one bus 12 or one type of bus 12.
The memory 11 is used for storing programs, such as programs corresponding to the detection device for detecting the randomness of the byte sequence. The device for detecting the randomness of the byte sequence comprises at least one software functional module which can be stored in the memory 11 in the form of software or firmware (firmware) or solidified in an Operating System (OS) of the electronic device. The processor 10 executes the program after receiving the execution instruction to realize the detection method of the randomness of the byte sequence.
Possibly, the electronic device provided by the embodiment of the present application further includes a communication interface 13. The communication interface 13 is connected to the processor 10 via a bus. The electronic device can receive the sequence to be detected transmitted by the external device through the communication interface 13.
It should be understood that the structure shown in fig. 1 is merely a structural schematic diagram of a portion of an electronic device, which may also include more or fewer components than shown in fig. 1, or have a different configuration than shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
The method for detecting randomness of a byte sequence provided in the embodiments of the present invention can be applied to, but is not limited to, the electronic device shown in fig. 1, and please refer to fig. 2:
s101, determining the total number of runs according to the sequence to be detected and a preset feature table.
The characteristic table comprises the number of the strokes in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence.
Specifically, taking byte M as an example, byte M is "00110101", the number of runs in byte M is 5, the number of bits 1 in byte M is 4, and the number of bits 0 in byte M is 4. The characteristic table has 256 elements, and each element corresponds to the number of run or the number of must 1 or the number of must 0 in one byte. Of course, the feature table may have 512 or 768 elements, each byte corresponds to 3 elements, and the number of the run, the number of the bitlets 1, and the number of the bitlets 0 in the byte are respectively represented.
The sequence to be detected often contains nearly a million bytes, and if one of them is converted into a petit sequence, it takes a lot of time, increasing the load of the CPU.
S102, acquiring a first numerical value.
Wherein the first value is the total number of the bitol 1 in the sequence to be detected.
S103, calculating according to the number of bytes of the sequence to be detected, the first numerical value and the total number of runs to obtain the minimum significant horizontal value of the random sequence of the sequence to be detected.
In particular, the resulting minimum significance level value is associated with the total number of runs. Whether the sequence to be detected passes the total number of runs in the random sequence detection can be judged according to the minimum significant level value.
And S104, determining a detection result according to the minimum significance level value and the significance level threshold value, wherein the detection result indicates that the sequence to be detected passes or fails randomness detection.
Specifically, when the minimum significance level value is greater than or equal to the significance level threshold value, the sequence to be detected is characterized by being detected through randomness, specifically, through total run number detection in randomness detection. And when the minimum significance level value is smaller than the significance level threshold value, indicating that the sequence to be detected does not pass randomness detection, specifically, does not pass total run number detection in randomness detection.
To sum up, in the method for detecting randomness of a byte sequence provided in the embodiment of the present application: firstly, the total number of runs is determined according to a sequence to be detected and a preset feature table, a byte sequence is not required to be converted into a bity sequence, the conversion workload is saved, and the conversion time is saved; then obtaining a first numerical value, calculating according to the number of bytes of the sequence to be detected, the first numerical value and the total number of runs to obtain a minimum significant level value of the sequence to be detected, wherein the sequence to be detected is a random sequence, and finally determining a detection result according to the minimum significant level value and a significant level threshold value, wherein the detection result indicates that the sequence to be detected passes randomness detection or does not pass randomness detection; the workload of converting the byte sequence into the bity sequence is saved, the conversion time is reduced, the detection efficiency is improved, and the load of a CPU is reduced.
On the basis of fig. 2, for the content in S101, when the feature table contains the run number in each byte, the embodiment of the present application also proposes a possible formula to determine the total number of runs:
wherein k is more than or equal to 0 and less than or equal to N-1, N represents the total number of bytes of the sequence to be detected, V(0)Is equal to 0, V(k+1)Characterizing the number of runs, byte E, contained in total from the first byte to the (k + 1) th byte of the sequence to be detectedkBelongs to the sequence to be detected, Table (E)k) Byte E of the characterization feature TablekNumber of strokes in, BkCharacterization byte EkAnd byte Ek+1When k is N-1, Vk+1Is namely VNAnd characterizing the total number of runs.
For B abovekThe embodiment of the present application further provides a possible formula:
wherein k is more than or equal to 0 and less than or equal to N-1, and when k is N-1, Ek+1Is namely EN,ENIs 0 bytes.
On the basis of fig. 2, for the content in S101, when the feature table includes the number of bits 1 in each byte, the embodiment of the present application further provides a possible implementation manner, please refer to fig. 3, where S101 includes:
s101-1, performing adjacent differentiation processing on each byte to obtain a corresponding differentiated byte.
Specifically, when two adjacent bits in the original byte are changed, a bitt 1 is added to the differential byte.
S101-2, determining the total number of runs according to the differentiated bytes, the feature table and each byte.
Specifically, by looking up the feature table, the total number of bits 1 included in the differential byte can be known, so that the number of strokes in the original byte corresponding to the differential byte can be known.
On the basis of fig. 3, a possible implementation manner is provided in the embodiment of the present application according to how to obtain the differential bytes and the total number of runs, please refer to the following.
The differential bytes are obtained according to the following equation:
the total number of runs is obtained according to the following equation:
wherein i is more than or equal to 0 and less than or equal to N-1, N represents the total number of bytes of the sequence to be detected, V(0)Is equal to 0, V(i +1)Characterizing the number of runs, byte E, contained in total from the first byte to the (i + 1) th byte of the sequence to be detectediBelongs to the sequence to be detected, Table (A)i) Byte A of the characterization feature listiNumber of bits 1 in, AiCharacterization and byte EiCorresponding differential byte, BiCharacterization byte EiAnd byte Ei+1When i takes the value of N-1, Vi+1Is namely VNAnd characterizing the total number of runs.
Wherein, BiThe calculation formula of (A) is similar to the above Bk。
On the basis of fig. 2, for the content in S101, when the feature table includes the number of runs in each byte, the embodiment of the present application also provides a possible implementation manner, please refer to the following:
determining a first class of trip numbers according to the sequence to be detected and the feature table, wherein the first class of trip numbers are trip numbers in each byte in the sequence to be detected;
determining a second type of trip number according to the last bit of the last byte and the first bit of the next byte in any adjacent bytes, wherein the second type of trip number is the trip number between each byte in the sequence to be detected;
and obtaining the total number of the runs according to the first class of run numbers and the second class of run numbers.
Specifically, the first type of run number, the second type of run number and the total run number are obtained according to the following equations;
wherein V represents the total number of runs, V1Characterizing the number of journeys of the first kind, V2Representing the number of second class run, N representing the total number of bytes of the sequence to be detected, byte EiBelongs to a sequence to be detected, i is more than or equal to 0 and less than or equal to N-1, Table (E)i) Characterization byte EiNumber of internal journeys, epsilon8i+8Characterization byte EiLast position of (e)8i+9Characterization byte Ei+1First bit of (a).
Possibly, respectively obtaining epsilon according to the following equations8i+8And ε8i+9:
Wherein the AND characterizes AND operation.
On the basis of fig. 2, for the content in S102, the embodiment of the present application further provides a possible implementation manner, when the feature table contains the number of a class number in each byte, the first numerical value can be obtained by querying the feature table, and the byte sequence does not need to be converted into a bity sequence, so that the conversion time is saved.
For example, when the feature table includes the number of the bitlets 1 in each byte, the total number of the bitlets 1 in the sequence to be detected, that is, the first numerical value, can be obtained by accumulating the number of the bitlets 1 in each byte.
When the feature table contains the number of the bitt 0 in each byte, the total number of the bitt 0 in the sequence to be detected can be obtained by accumulating the number of the bitt 0 in each byte, and the total length of the bitt 0 in the sequence to be detected is subtracted from the total number of the bitt 0 to obtain a first numerical value.
On the basis of fig. 2, for the content in S102, the embodiment of the present application further provides a possible implementation manner, please refer to fig. 4, where S102 includes:
s102-1, calling a first numerical value stored in advance, wherein the first numerical value is an intermediate value when the sequence to be detected is subjected to single-bit detection.
Specifically, single-bit detection is the basis of randomness detection, and during randomness detection, single-bit detection is often performed first, and then a first numerical value, that is, an intermediate value during single-bit detection of a sequence to be detected, is obtained. The first value is reserved for standby, namely, the step of repeatedly acquiring the first value in other detection is avoided, and time is saved.
On the basis of fig. 2, regarding how to obtain the minimum significant level value, the embodiment of the present application further provides a possible implementation manner, and the calculation formula of the minimum significant level value is:
wherein P represents the minimum significance level value, V(N)Representing the total number of runs, Z representing a first value, N =8N, N representing the total number of bytes of the sequence to be detected, and erfc being a residual function.
Taking the total run length detection of N-byte samples as an example, the method is based on the national secret standardThe pair of bytes, the traditional implementation and the computation of the present invention is as follows, for example, table 1. Table 1 shows the results under different conditionsThe total number of operations in each operation is as follows. In analyzing the computational load of the algorithm, the following abbreviated notation is employed: XOR represents an XOR operation; SHIFT represents a left/right SHIFT operation; ADD denotes an addition operation; AND represents an AND operation; LOAD denotes data loading; STORE represents data storage; TABLE denotes a TABLE lookup operation.
TABLE 1
Meanwhile, if the byte sequence is converted into the bitlet sequence, 8N of storage space is occupied. In the scheme provided by the embodiment of the application, only the space for storing the feature table needs to be additionally occupied, so that the space is relatively saved.
Referring to fig. 5, fig. 5 is a block diagram illustrating an apparatus for detecting byte sequence randomness according to an embodiment of the present application, where the apparatus for detecting byte sequence randomness is optionally applied to the electronic device described above.
The detection device for the randomness of the byte sequence comprises: a processing unit 201 and a detection unit 202.
The processing unit 201 is configured to determine the total number of runs according to the sequence to be detected and a preset feature table, where the feature table includes the number of runs in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence; the method is also used for obtaining a first numerical value, wherein the first numerical value is the total number of the bitt 1 in the sequence to be detected; and the method is also used for calculating the minimum significant level value of the sequence to be detected, which is a random sequence, according to the number of bytes, the first numerical value and the total number of runs of the sequence to be detected. Specifically, the processing unit 201 may execute the above S101 to S103.
A detecting unit 202, configured to determine a detection result according to the minimum significance level value and the significance level threshold, where the detection result indicates that the sequence to be detected passes or fails the randomness detection. Specifically, the detection unit 202 may perform S104 described above.
It should be noted that the apparatus for detecting randomness of a byte sequence provided in this embodiment may execute the method flows shown in the above method flow embodiments to achieve the corresponding technical effects. For the sake of brevity, the corresponding contents in the above embodiments may be referred to where not mentioned in this embodiment.
The embodiment of the invention also provides a storage medium, wherein the storage medium stores a computer instruction and a program, and the computer instruction and the program execute the method for detecting the randomness of the byte sequence of the embodiment when being read and run. The storage medium may include memory, flash memory, registers, or a combination thereof, etc.
The following provides an electronic device, which may be a computer device, a mobile phone or others, and the electronic device may implement the above-mentioned method for detecting the randomness of the byte sequence, as shown in fig. 1. Specifically, the electronic device includes: processor 10, memory 11, bus 12. The processor 10 may be a CPU. The memory 11 is used for storing one or more programs, and when the one or more programs are executed by the processor 10, the method for detecting the randomness of the byte sequence of the above-mentioned embodiment is performed.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned.
Claims (10)
1. A method for detecting randomness of a byte sequence, the method comprising:
determining the total number of runs according to a sequence to be detected and a preset feature table, wherein the feature table comprises the number of runs in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence;
acquiring a first numerical value, wherein the first numerical value is the total number of the bitol 1 in the sequence to be detected;
calculating to obtain the minimum significant level value of the sequence to be detected, which is a random sequence, according to the number of bytes of the sequence to be detected, the first numerical value and the total run number;
and determining a detection result according to the minimum significance level value and the significance level threshold value, wherein the detection result indicates that the sequence to be detected passes or fails randomness detection.
2. The method according to claim 1, wherein when the signature table contains run numbers in each byte, the total number of runs is determined according to the following equation:
wherein k is more than or equal to 0 and less than or equal to N-1, N represents the total number of bytes of the sequence to be detected, V(0)Is equal to 0, V(k+1)Characterizing the total number of strokes from the first byte to the (k + 1) th byte in the sequence to be detected, a byte EkBelongs to the sequence to be detected, Table (E)k) Characterizing byte E of said profile entrykNumber of strokes in, BkCharacterization byte EkAnd byte Ek+1When k is N-1, Vk+1Is namely VNAnd characterizing the total number of runs.
4. The method for detecting the randomness of byte sequences according to claim 1, wherein when the feature table contains the number of bits 1 in each byte, the step of determining the total number of runs according to the sequence to be detected and the predetermined feature table comprises:
performing adjacent differentiation processing on each byte to obtain corresponding differentiated bytes;
and determining the total number of runs according to the differential bytes, the feature table and the bytes.
5. The method according to claim 4, wherein the differential bytes are obtained according to the following formula:
obtaining the total number of runs according to the following formula:
wherein i is more than or equal to 0 and less than or equal to N-1, N represents the total number of bytes of the sequence to be detected, V(0)Is equal to 0, V(i +1)Characterizing the total number of strokes from the first byte to the (i + 1) th byte in the sequence to be detected, and a byte EiBelongs to the sequence to be detected, Table(Ai) Characterizing byte A of said profile entryiNumber of bits 1 in, AiCharacterization and byte EiCorresponding differential byte, BiCharacterization byte EiAnd byte Ei+1When i takes the value of N-1, Vi+1Is namely VNAnd characterizing the total number of runs.
6. The method for detecting the randomness of a byte sequence according to claim 1, wherein said step of obtaining a first value in said sequence to be detected comprises:
and calling the first numerical value which is stored in advance, wherein the first numerical value is an intermediate value when the sequence to be detected is subjected to single-bit detection.
7. The method of detecting randomness of a sequence of bytes as recited in claim 1 wherein the calculation of said minimum significance level value is as follows:
wherein P characterizes the minimum significance level value, V(N)And representing the total number of the runs, Z representing the first numerical value, N =8N, N representing the total number of bytes of the sequence to be detected, and erfc being a residual function.
8. An apparatus for detecting randomness of a byte sequence, the apparatus comprising:
the processing unit is used for determining the total number of runs according to the sequence to be detected and a preset feature table, wherein the feature table comprises the number of the runs in each byte and/or the number of a class of numbers in each byte, and the sequence to be detected is a byte sequence; the method is also used for obtaining a first numerical value, wherein the first numerical value is the total number of the bitol 1 in the sequence to be detected; the sequence detection module is further used for calculating the minimum significant level value of the sequence to be detected, which is a random sequence, according to the number of bytes of the sequence to be detected, the first numerical value and the total run number;
and the detection unit is used for determining a detection result according to the minimum significance level value and the significance level threshold value, wherein the detection result indicates that the sequence to be detected passes or fails randomness detection.
9. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
10. An electronic device, comprising: a processor and memory for storing one or more programs; the one or more programs, when executed by the processor, implement the method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010045110.5A CN110851113A (en) | 2020-01-16 | 2020-01-16 | Method and device for detecting randomness of byte sequence, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010045110.5A CN110851113A (en) | 2020-01-16 | 2020-01-16 | Method and device for detecting randomness of byte sequence, storage medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110851113A true CN110851113A (en) | 2020-02-28 |
Family
ID=69610834
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010045110.5A Pending CN110851113A (en) | 2020-01-16 | 2020-01-16 | Method and device for detecting randomness of byte sequence, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110851113A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112861121A (en) * | 2020-12-23 | 2021-05-28 | 工业信息安全(四川)创新中心有限公司 | Method and device for realizing maximum 1 and 0 run detection merging optimization in block |
CN113810332A (en) * | 2020-06-11 | 2021-12-17 | 北京威努特技术有限公司 | Encrypted data message judgment method and device and computer equipment |
CN116821925A (en) * | 2023-05-10 | 2023-09-29 | 成都海泰方圆科技有限公司 | Random number checking method and device, electronic equipment and storage medium |
CN117785449A (en) * | 2023-12-18 | 2024-03-29 | 北京海泰方圆科技股份有限公司 | Sequence randomness detection method and device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1461530A (en) * | 2001-04-19 | 2003-12-10 | 皇家菲利浦电子有限公司 | Method and device for encoding information words, method and device for decoding information words, storage medium and signal |
CN1722276A (en) * | 2004-04-02 | 2006-01-18 | 日立环球储存科技荷兰有限公司 | Techniques for detecting and correcting errors using multiple interleave erasure pointers |
CN110308892A (en) * | 2019-07-01 | 2019-10-08 | 湖南国科微电子股份有限公司 | A kind of distance of swimming test method based on look-up table |
CN110502208A (en) * | 2019-08-16 | 2019-11-26 | 兆讯恒达微电子技术(北京)有限公司 | A kind of how random power supply management method of randomizer |
-
2020
- 2020-01-16 CN CN202010045110.5A patent/CN110851113A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1461530A (en) * | 2001-04-19 | 2003-12-10 | 皇家菲利浦电子有限公司 | Method and device for encoding information words, method and device for decoding information words, storage medium and signal |
CN1722276A (en) * | 2004-04-02 | 2006-01-18 | 日立环球储存科技荷兰有限公司 | Techniques for detecting and correcting errors using multiple interleave erasure pointers |
CN110308892A (en) * | 2019-07-01 | 2019-10-08 | 湖南国科微电子股份有限公司 | A kind of distance of swimming test method based on look-up table |
CN110502208A (en) * | 2019-08-16 | 2019-11-26 | 兆讯恒达微电子技术(北京)有限公司 | A kind of how random power supply management method of randomizer |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113810332A (en) * | 2020-06-11 | 2021-12-17 | 北京威努特技术有限公司 | Encrypted data message judgment method and device and computer equipment |
CN113810332B (en) * | 2020-06-11 | 2023-10-31 | 北京威努特技术有限公司 | Encrypted data message judging method and device and computer equipment |
CN112861121A (en) * | 2020-12-23 | 2021-05-28 | 工业信息安全(四川)创新中心有限公司 | Method and device for realizing maximum 1 and 0 run detection merging optimization in block |
CN116821925A (en) * | 2023-05-10 | 2023-09-29 | 成都海泰方圆科技有限公司 | Random number checking method and device, electronic equipment and storage medium |
CN116821925B (en) * | 2023-05-10 | 2024-03-15 | 成都海泰方圆科技有限公司 | Random number checking method and device, electronic equipment and storage medium |
CN117785449A (en) * | 2023-12-18 | 2024-03-29 | 北京海泰方圆科技股份有限公司 | Sequence randomness detection method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110851113A (en) | Method and device for detecting randomness of byte sequence, storage medium and electronic equipment | |
CN109347787B (en) | Identity information identification method and device | |
CN110008080B (en) | Business index anomaly detection method and device based on time sequence and electronic equipment | |
CN109145080B (en) | Text fingerprint obtaining method and device | |
CN110289997B (en) | Log message checking method, device and system | |
CN115269304A (en) | Log anomaly detection model training method, device and equipment | |
CN113132416B (en) | Data packet detection method and device | |
CN106033574B (en) | Method and device for identifying cheating behaviors | |
WO2020173136A1 (en) | Method and apparatus for monitoring application system, device, and storage medium | |
CN109145651B (en) | Data processing method and device | |
CN110766160A (en) | Data verification method and device, storage medium and electronic equipment | |
CN113094742A (en) | Data desensitization method, data desensitization device, electronic device and storage medium | |
US10931714B2 (en) | Domain name recognition method and domain name recognition device | |
CN110798230A (en) | Run length detection method and device and electronic equipment | |
JP2013182468A (en) | Parameter value setting error detection system, parameter value setting error detection method and parameter value setting error detection program | |
CN112085588A (en) | Method and device for determining safety of rule model and data processing method | |
CN112085589B (en) | Method and device for determining safety of rule model and server | |
CN106295671B (en) | Application list clustering method and device and computing equipment | |
CN110719107A (en) | Poker card detection method and related device | |
CN109739858B (en) | ANSI C12.19-based data classification storage method and device and electronic equipment | |
CN108540137B (en) | Cyclic redundancy check code generation method and device | |
CN110704690B (en) | Data processing method, device and storage medium | |
CN118037472B (en) | Financial data processing method and related device | |
CN113806371B (en) | Data type determining method, device, computer equipment and storage medium | |
CN111352825A (en) | Data interface test method and device and server |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200228 |
|
RJ01 | Rejection of invention patent application after publication |