CN112202548A - Stream encryption key stream generation method, device, circuit and encryption method - Google Patents

Stream encryption key stream generation method, device, circuit and encryption method Download PDF

Info

Publication number
CN112202548A
CN112202548A CN202011418785.6A CN202011418785A CN112202548A CN 112202548 A CN112202548 A CN 112202548A CN 202011418785 A CN202011418785 A CN 202011418785A CN 112202548 A CN112202548 A CN 112202548A
Authority
CN
China
Prior art keywords
sequence
key
integer
stream
standard
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
Application number
CN202011418785.6A
Other languages
Chinese (zh)
Inventor
吴良顺
蔡恒进
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuo Erzhi Lian Wuhan Research Institute Co Ltd
Original Assignee
Zhuo Erzhi Lian Wuhan Research Institute Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Zhuo Erzhi Lian Wuhan Research Institute Co Ltd filed Critical Zhuo Erzhi Lian Wuhan Research Institute Co Ltd
Priority to CN202011418785.6A priority Critical patent/CN112202548A/en
Publication of CN112202548A publication Critical patent/CN112202548A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/065Encryption by serially and continuously modifying data stream elements, e.g. stream cipher systems, RC4, SEAL or A5/3
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/08Key distribution or management, e.g. generation, sharing or updating, of cryptographic keys or passwords
    • H04L9/0861Generation of secret information including derivation or calculation of cryptographic keys or passwords
    • H04L9/0869Generation of secret information including derivation or calculation of cryptographic keys or passwords involving random numbers or seeds

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Storage Device Security (AREA)

Abstract

The application relates to a stream encryption key stream generation method, a stream encryption key stream generation device, a stream encryption key stream generation circuit and an encryption method. The method comprises the following steps: determining the serial number of the current element, selecting a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selecting a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence; converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the pseudo-random integer sequence is traversed; and (4) paralleling each round of key subsequences according to the sequence of the element sequence numbers to obtain the key stream, so that the generation speed of the key stream can be increased.

Description

Stream encryption key stream generation method, device, circuit and encryption method
Technical Field
The present invention relates to the field of encryption technologies, and in particular, to a method, an apparatus, a circuit, and an encryption method for generating a stream encryption key stream.
Background
With the development of encryption technology, stream encryption has emerged. Stream encryption is one of symmetric encryption algorithms, and the same pseudorandom encryption data stream is used as a key on an encryption side and a decryption side, so that plaintext data and the key are correspondingly encrypted to generate ciphertext data during encryption, and the ciphertext data and the key are correspondingly decrypted to obtain the plaintext data during decryption, thereby completing data security transmission.
However, the inventors have found that at least the following problems exist in the conventional techniques: the conventional technology has the problem of slow key stream generation speed.
Disclosure of Invention
In view of the above, it is necessary to provide a stream encryption key stream generation method, apparatus, circuit and encryption method capable of increasing the key stream generation speed, in order to solve the problem of slow key stream generation speed in the conventional technology.
A stream encryption keystream generation method, comprising:
determining a current element serial number, selecting a first element corresponding to the current element serial number from the first pseudorandom integer sequence, and selecting a second element corresponding to the current element serial number from the second pseudorandom integer sequence;
converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form;
performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain the key stream.
In one embodiment, the step of truncating the first intermediate sequence from the first normal form and the step of truncating the second intermediate sequence from the second normal form comprises:
and intercepting the first intermediate sequence from the first standard formula according to the number of preset values in the first standard formula, and intercepting the second intermediate sequence from the second standard formula according to the number of preset values in the second standard formula.
In one embodiment, the predetermined value is 1; the length of the first standard formula and the length of the second standard formula are both
Figure 27288DEST_PATH_IMAGE001
The number of 1 s in the first standard formula is
Figure 153376DEST_PATH_IMAGE002
The number of 1 s in the first standard formula is
Figure 460598DEST_PATH_IMAGE003
The steps of intercepting the first intermediate sequence from the first standard form according to the number of preset values in the first standard form, and intercepting the second intermediate sequence from the second standard form according to the number of preset values in the second standard form include:
the first standard formula
Figure 395056DEST_PATH_IMAGE002
Is located to
Figure 794945DEST_PATH_IMAGE004
The sequence between the bits is identified as the first intermediate sequence, and the second standard is identified as the second intermediate sequence
Figure 1804DEST_PATH_IMAGE003
Is located to
Figure 676499DEST_PATH_IMAGE005
The sequence between the bits is identified as the second intermediate sequence.
In one embodiment, before the step of determining the current element sequence number, the method further includes:
acquiring a first pseudorandom integer sequence and a second pseudorandom integer sequence; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the length of a plaintext.
In one embodiment, the step of obtaining the first pseudo-random integer sequence and the second pseudo-random integer sequence comprises:
obtaining a key pair; the key pair comprises a first key and a second key;
a first pseudorandom integer sequence is generated from the first key and a second pseudorandom integer sequence is generated from the second key.
In one embodiment, the first key comprises a first integer, a second integer, and a third integer; the second key comprises a fourth integer, a fifth integer and a sixth integer;
the steps of generating a first pseudo-random sequence of integers from a first key and a second pseudo-random sequence of integers from a second key include:
processing the first key using the following formula to generate a first pseudorandom integer sequence:
Figure 465464DEST_PATH_IMAGE006
wherein the content of the first and second substances,
Figure 347838DEST_PATH_IMAGE007
is a first integer;
Figure 730409DEST_PATH_IMAGE008
is a second integer;
Figure 458062DEST_PATH_IMAGE009
is a third integer;
Figure 367112DEST_PATH_IMAGE010
is the element number;
Figure 108803DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 290255DEST_PATH_IMAGE010
An element;
Figure 634649DEST_PATH_IMAGE012
is the first in the first pseudorandom integer sequence
Figure 70309DEST_PATH_IMAGE013
An element;
Figure 509467DEST_PATH_IMAGE014
is the total number of elements;
processing the second key using the following formula to generate a second pseudorandom integer sequence:
Figure 663368DEST_PATH_IMAGE015
wherein the content of the first and second substances,
Figure 732824DEST_PATH_IMAGE016
is a fourth integer;
Figure 350887DEST_PATH_IMAGE017
is a fifth integer;
Figure 496698DEST_PATH_IMAGE018
is a sixth integer;
Figure 324845DEST_PATH_IMAGE010
is the element number;
Figure 214304DEST_PATH_IMAGE019
is the first in the second pseudorandom integer sequence
Figure 545928DEST_PATH_IMAGE010
An element;
Figure 924957DEST_PATH_IMAGE020
is the first in the second pseudorandom integer sequence
Figure 505980DEST_PATH_IMAGE021
An element;
Figure 933550DEST_PATH_IMAGE022
is the total number of elements.
An encryption method comprising the steps of:
acquiring plaintext data;
generating a key stream by adopting the stream encryption key stream generation method;
and carrying out exclusive OR operation on the key stream and the plaintext data according to the bit to obtain ciphertext data.
A stream encryption keystream generation apparatus, comprising:
the element selection module is used for determining the serial number of the current element, selecting a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selecting a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence;
the intermediate sequence intercepting module is used for converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting the first intermediate sequence from the first standard form and intercepting the second intermediate sequence from the second standard form;
the key subsequence obtaining module is used for performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining a key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and the key stream acquisition module is used for paralleling each key subsequence according to the sequence of the element sequence numbers to obtain the key stream.
An encryption apparatus comprising:
the plaintext acquisition module is used for acquiring plaintext data;
stream encryption key stream generation means for generating a key stream by the above-described stream encryption key stream generation method;
and the ciphertext acquisition module is used for carrying out XOR operation on the key stream and the plaintext data according to bits to obtain ciphertext data.
A stream cipher key generation circuit, comprising:
the first encoder is used for converting the first element into a Fibonacci binary standard form to obtain a first standard form;
the second encoder is used for converting the second element into a Fibonacci binary standard form to obtain a second standard form;
the key stream generating device determines the serial number of the current element, selects a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selects a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence; intercepting a first intermediate sequence from the first standard formula and intercepting a second intermediate sequence from the second standard formula; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed; and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain the key stream.
In one embodiment, the method further comprises the following steps:
a storage device for storing the first 32-bit Fibonacci number; each fibonacci number is used to instruct the first encoder to convert the first element to a fibonacci binary standard form and the second encoder to convert the second element to a fibonacci binary standard form.
In one embodiment, the first encoder, the second encoder and the keystream generation apparatus are all FPGA devices.
An encryption device includes the stream encryption key generation circuit as described above.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned method.
The stream encryption key stream generation method, the stream encryption key stream generation device, the stream encryption key stream generation circuit and the stream encryption key stream generation method determine a current element serial number, select a first element corresponding to the current element serial number from a first pseudorandom integer sequence, and select a second element corresponding to the current element serial number from a second pseudorandom integer sequence; converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed; and (4) paralleling each round of key subsequences according to the sequence of the element sequence numbers to obtain the key stream, so that the generation speed of the key stream can be increased.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments or the conventional technologies of the present application, the drawings used in the descriptions of the embodiments or the conventional technologies will be briefly introduced below, it is obvious that the drawings in the following descriptions are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a first flowchart of a method for generating an encryption key stream according to an embodiment;
FIG. 2 is a flow diagram illustrating the steps in one embodiment for obtaining a pseudorandom integer sequence;
FIG. 3 is a diagram illustrating a second process of a method for generating an encryption key stream according to an embodiment;
FIG. 4 is a flow diagram illustrating an encryption method in one embodiment;
FIG. 5 is a flow diagram illustrating a decryption method in one embodiment;
FIG. 6 is a block diagram showing the structure of a stream cipher key generation circuit in one embodiment;
FIG. 7 is an RTL circuit of a stream cipher key generation circuit in one embodiment;
FIG. 8 is a state transition diagram of the stream cipher key generation circuit of FIG. 7;
FIG. 9 is a block diagram showing the construction of a stream cipher key stream generating apparatus according to an embodiment;
fig. 10 is a block diagram showing the configuration of an encryption device according to an embodiment.
Detailed Description
To facilitate an understanding of the present application, the present application will now be described more fully with reference to the accompanying drawings. Embodiments of the present application are set forth in the accompanying drawings. This application may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
It is understood that "plurality" can be more than two, such as two, three, or five, etc. The terms "first," "second," and the like as used herein may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, a first resistance may be referred to as a second resistance, and similarly, a second resistance may be referred to as a first resistance, without departing from the scope of the present application. The first resistance and the second resistance are both resistances, but they are not the same resistance.
It is to be understood that "connection" in the following embodiments is to be understood as "electrical connection", "communication connection", and the like if the connected circuits, modules, units, and the like have communication of electrical signals or data with each other.
As used herein, the singular forms "a", "an" and "the" may include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises/comprising," "includes" or "including," etc., specify the presence of stated features, integers, steps, operations, components, parts, or combinations thereof, but do not preclude the presence or addition of one or more other features, integers, steps, operations, components, parts, or combinations thereof. Also, as used in this specification, the term "and/or" includes any and all combinations of the associated listed items.
At present, in stream encryption, an RC4 encryption algorithm is generally used to generate a key stream, and plaintext data is encrypted by using the key stream, so as to obtain ciphertext data. The RC4 encryption algorithm is an encryption method for generating a key stream by using a state vector and a temporary vector, wherein the temporary vector can be generated according to an initial key input by a user, and the position of each element in the state vector is replaced by the temporary vector, so that the key stream with strong randomness can be obtained. However, the inventors have found that when a key stream is generated by an RC4 random stream generator, the key stream generation speed is slow.
In one embodiment, as shown in fig. 1, there is provided a stream encryption key stream generation method, including the steps of:
step 110, determining the serial number of the current element, selecting a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selecting a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence.
Wherein the first pseudo-random sequence of integers may include one or more integers, each integer constituting a respective element of the first pseudo-random sequence of integers; the second pseudo-random sequence of integers may include one or more integers, each of which constitutes a respective element of the second pseudo-random sequence of integers. It should be understood that the first pseudo-random integer sequence and the second pseudo-random integer sequence are two separate integer sequences, and there is no necessary relationship between the two.
Further, the number of elements in the first pseudo-random integer sequence, i.e., the number of integers included in the first pseudo-random integer sequence, may be the same as or different from the number of elements in the second pseudo-random integer sequence, i.e., the number of integers included in the second pseudo-random integer sequence. If the number of elements of the first pseudorandom integer sequence is different from the number of elements of the second pseudorandom integer sequence, the first pseudorandom integer sequence and/or the second pseudorandom integer sequence may be adjusted such that the number of elements in the two sequences is the same. For example, a pseudo-random integer sequence with a large number of elements may be truncated, or a pseudo-random integer sequence with a small number of elements may be data-padded.
Specifically, after determining the current element sequence number, the corresponding elements in the first pseudo-random integer sequence and the second pseudo-random integer sequence may be determined by the element sequence number. Taking the first pseudo-random integer sequence as an example, when
Figure 260626DEST_PATH_IMAGE023
Then, the first pseudorandom integer sequence contains 3 elements,
Figure 997507DEST_PATH_IMAGE024
is the number of 3, and the number of the carbon atoms is 3,
Figure 550979DEST_PATH_IMAGE025
is a mixture of a water-soluble polymer and a water-soluble polymer, and is 5,
Figure 31508DEST_PATH_IMAGE026
if the current element number is 2, the element in the first pseudorandom integer sequence corresponding to the current element number is 5. Similarly, the second pseudorandom integer sequence may also determine the element in the sequence corresponding to the current element sequence number through the above-described process.
Further, the embodiment of selecting the first element and the second element from the first pseudorandom integer sequence and the second pseudorandom integer sequence may be implemented by any method in the prior art, for example, the pseudorandom integer sequence may be stored in an array manner, a corresponding storage address may be determined by a current element sequence number, and the corresponding first element and the corresponding second element may be obtained after accessing the storage address.
And step 120, converting the first element and the second element into fibonacci binary standard forms to obtain a first standard form and a second standard form respectively, intercepting the first intermediate sequence from the first standard form, and intercepting the second intermediate sequence from the second standard form.
Specifically, a natural number is represented as one orAnd summing a plurality of mutually-different Fibonacci numbers, and mapping all Fibonacci numbers in position to generate a bit string consisting of 0 s and 1 s, wherein the bit string is a Fibonacci binary representation of the natural number. If Fibonacci is expressed in binary, there is no adjacent 1, and there is no addition
Figure 478670DEST_PATH_IMAGE027
(i.e., the first fibonacci number), then the expression is a fibonacci scale standard expression.
For example, the natural number 20 may be expressed as 20 = 2+5+13 =
Figure 606026DEST_PATH_IMAGE028
Then its fibonacci binary expression (in the example of an 8-bit length) is 01010100. Fibonacci scale expression of natural number 20
Figure 958378DEST_PATH_IMAGE029
And there is no adjacent 1, 01010100 is a fibonacci scale standard of 20.
The first intermediate sequence is part or all of the first standard, that is, the first intermediate sequence may be a continuous bit string between the start bit and the end bit in the first standard, for example, 1010 may be an intermediate sequence of 01010100. Similarly, the second intermediate sequence is part or all of the second standard, that is, the second intermediate sequence may be a continuous bit string between the start bit and the end bit in the second standard. It is to be understood that the length of the first intermediate sequence and the length of the second intermediate sequence may be equal or different, and the lengths of the two intermediate sequences are not necessarily related.
Specifically, after determining the first element and the second element, the first element may be converted into a fibonacci scale standard form to obtain a first standard form, and the second element may be converted into a fibonacci scale standard form to obtain a second standard form. It should be noted that there may be one or more fibonacci scale standard forms for the same natural number, and the first standard form and the second standard form may be any one of them.
After obtaining the first standard, the first intermediate sequence may be truncated from the first standard, and after obtaining the second standard, the second intermediate sequence may be truncated from the second standard. Further, the probability of the occurrence of the preset value (e.g., 0 or 1) in the first intermediate sequence may be constant, and the probability of the occurrence of the preset value in the second intermediate sequence may be constant.
And step 130, performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed.
Wherein the key subsequence may be a component of the key stream; the key stream may be a random stream.
Specifically, the present application may determine the intersection of the first intermediate sequence and the second intermediate sequence according to the position of the first intermediate sequence in the first standard formula and the position of the second intermediate sequence in the second standard formula, for example, if the first intermediate sequence is from 1 st to 3 rd bits (the lowest bit is 1 st bit) in the first standard formula and the second intermediate sequence is from 2 nd to 5 th bits in the second standard formula, the intersection may be from 2 nd to 3 rd bits of the first intermediate sequence (i.e., from 2 nd to 3 rd bits in the first standard formula) and from 1 st to 2 nd bits of the second intermediate sequence (i.e., from 2 nd to 3 rd bits in the second standard formula).
In addition, the method can also determine intersection bits according to the length of the first intermediate sequence and the length of the second intermediate sequence, and the highest bits are aligned or the lowest bits are aligned by taking the intermediate sequence with shorter length as a standard, so that the intersection bits of the first intermediate sequence and the second intermediate sequence can be determined. In the above example, the intersection bits may be the 1-3 bits of the first intermediate sequence (i.e. the 1-3 bits in the first normal form) and the 1-3 bits of the second intermediate sequence (i.e. the 2-4 bits of the second normal form), or the intersection bits may be the 1-3 bits of the first intermediate sequence (i.e. the 1-3 bits in the first normal form) and the 2-4 bits of the second intermediate sequence (i.e. the 3-5 bits of the second normal form).
After determining the intersection bits, performing an OR (OR) operation on the intersection bits in a bit-by-bit manner, and performing OR on a value corresponding to the intersection bit in the first intermediate sequence and a value corresponding to the intersection bit in the second intermediate sequence for each intersection bit until all the intersection bits are processed and the key subsequence of the current round is obtained.
When the key subsequence of the current round is obtained, the sequence number of the current element is incremented, and the step size of the increment can be determined according to the storage formats of the first pseudo-random integer sequence and the second pseudo-random integer sequence, for example, the step size of the increment can be 1. After the current element sequence number is incremented, step 110, step 120 and step 130 are performed, and the key subsequence of the next round is obtained. And repeatedly executing the steps until all elements in the first pseudorandom integer sequence and all elements in the second pseudorandom integer sequence are traversed to obtain the key subsequence corresponding to each element sequence number.
And 140, paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain a key stream.
Specifically, after traversing the first pseudorandom integer sequence and the second pseudorandom integer sequence, the key subsequences may be arranged in parallel according to the order of the element sequence numbers, and the key subsequences are sequentially arranged to obtain a string of key streams. Wherein the keystream may be used to encrypt plaintext data. For example, if the key subsequence corresponding to the element number 1 is 123 and the key subsequence corresponding to the element number 2 is 456, the key stream obtained after the parallelization is 123456.
In the stream encryption key stream generation method, the stream encryption key stream generation device, the stream encryption key stream generation circuit and the stream encryption key stream generation method, a current element serial number is determined, a first element corresponding to the current element serial number is selected from a first pseudorandom integer sequence, and a second element corresponding to the current element serial number is selected from a second pseudorandom integer sequence; converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed; and (4) paralleling each round of key subsequences according to the sequence of the element sequence numbers to obtain the key stream, so that the generation speed of the key stream can be increased.
In one embodiment, the step of truncating the first intermediate sequence from the first normal form and the step of truncating the second intermediate sequence from the second normal form comprises:
and intercepting the first intermediate sequence from the first standard formula according to the number of preset values in the first standard formula, and intercepting the second intermediate sequence from the second standard formula according to the number of preset values in the second standard formula.
The preset value may be 0 or 1, and the number of the preset values may be the number of the preset values appearing in the standard formula.
Specifically, the first standard form and the second standard form are bit strings composed of 0 and 1, the number of preset numerical values in the first standard form can be obtained, and the first intermediate sequence is intercepted from the first standard form according to the number of the preset numerical values in the first standard form. Similarly, the number of the preset values in the second standard formula may be obtained, and the second intermediate sequence may be extracted from the second standard formula according to the number of the preset values in the second standard formula. It should be noted that the number of the preset numerical values in the first standard formula and the number of the preset numerical values in the second standard formula may be equal or different.
The obtaining of the number of the preset values in the standard formula may be implemented by any method in the prior art, for example, the number of the preset values may be obtained by traversing the standard formula, or the number of the preset values in the standard formula may be counted by using an edge trigger device or a level trigger device.
In one embodiment, the predetermined value is 1; the length of the first standard formula and the length of the second standard formula are bothLThe number of 1 s in the first standard formula is
Figure 931014DEST_PATH_IMAGE002
The number of 1 s in the first standard formula is
Figure 498261DEST_PATH_IMAGE003
The steps of intercepting the first intermediate sequence from the first standard form according to the number of preset values in the first standard form, and intercepting the second intermediate sequence from the second standard form according to the number of preset values in the second standard form include:
the first standard formula
Figure 311365DEST_PATH_IMAGE002
Is located to
Figure 105009DEST_PATH_IMAGE030
The sequence between the bits is identified as the first intermediate sequence, and the second standard is identified as the second intermediate sequence
Figure 5969DEST_PATH_IMAGE003
Is located to
Figure 286777DEST_PATH_IMAGE031
The sequence between the bits is identified as the second intermediate sequence.
Specifically, the preset value may be 1. The first standard formula is
Figure 614991DEST_PATH_IMAGE032
A bit Fibonacci scale, the second standard being
Figure 82881DEST_PATH_IMAGE032
A bit fibonacci scale. For a length of
Figure 521953DEST_PATH_IMAGE032
1 is the number of
Figure 470317DEST_PATH_IMAGE033
Of the Fibonacci scale standard 0, 1 sequence
Figure 297328DEST_PATH_IMAGE034
When it comes to
Figure 659039DEST_PATH_IMAGE035
The probability of a bit appearing at 1 is constant.
When the number of 1 s in the first standard formula
Figure 26435DEST_PATH_IMAGE002
Then, the first standard formula can be used
Figure 94885DEST_PATH_IMAGE036
The sequence therebetween is identified as the first intermediate sequence (excluding the second
Figure 499322DEST_PATH_IMAGE002
Bit and
Figure 738542DEST_PATH_IMAGE030
a bit). When the number of 1 s in the second standard formula is
Figure 519416DEST_PATH_IMAGE003
Then, the second standard formula
Figure 707952DEST_PATH_IMAGE037
The sequence therebetween is confirmed as a second intermediate sequence (excluding the first
Figure 673503DEST_PATH_IMAGE003
Bit and
Figure 275386DEST_PATH_IMAGE031
a bit).
In the method for generating the stream encryption key stream, the first intermediate sequence is intercepted from the first standard formula according to the number of the preset numerical values in the first standard formula, and the second intermediate sequence is intercepted from the second standard formula according to the number of the preset numerical values in the second standard formula, so that the probability of the preset numerical values at each position in the first intermediate sequence and the second intermediate sequence can be determined, the key stream can be used for stream encryption, and the generation speed of the key stream is increased. Experiments prove that the generation speed of the key generated by adopting the stream encryption key generation method can be improved by 4 times compared with that of RC 4.
In one embodiment, before the step of determining the current element sequence number, the method further includes:
acquiring a first pseudorandom integer sequence and a second pseudorandom integer sequence; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the length of a plaintext.
Specifically, prior to step 110, a first pseudo-random integer sequence and a second pseudo-random integer sequence may be obtained. The number of elements included in the first pseudo-random integer sequence and the number of elements included in the second pseudo-random integer sequence may be equal, and the number of elements in the first pseudo-random integer sequence and the number of elements in the second pseudo-random integer sequence may be determined according to the length of the plaintext data.
For example, the first pseudorandom integer sequence may be
Figure 735317DEST_PATH_IMAGE038
The second pseudo-random sequence of integers may be
Figure 840676DEST_PATH_IMAGE039
Number of elements therein
Figure 977128DEST_PATH_IMAGE040
Can be based on the length of plaintext data
Figure 472832DEST_PATH_IMAGE041
And (4) determining.
In the stream encryption key stream generation method, before the step of determining the current element sequence number, a first pseudorandom integer sequence and a second pseudorandom integer sequence are obtained; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the plaintext length, so that the key stream can be generated through the first pseudorandom integer sequence and the second pseudorandom integer sequence, the processing steps of the first pseudorandom integer sequence and the second pseudorandom integer sequence are reduced, and the generation speed of the key stream can be further improved.
In one embodiment, as shown in fig. 2, the step of obtaining the first pseudo-random integer sequence and the second pseudo-random integer sequence includes:
step 210, obtaining a key pair; the key pair comprises a first key and a second key;
step 220 generates a first pseudorandom integer sequence based on the first key and a second pseudorandom integer sequence based on the second key.
In particular, the first key and the second key of the key pair may be the same or different, the step of generating the first pseudo-random sequence of integers from the first key and the step of generating the second pseudo-random sequence of integers from the second key may be the same. For example, the key and the previous element may be modulo to obtain the current element in the pseudorandom integer sequence, and it should be understood that the method for generating the pseudorandom integer sequence according to the key in the present application may also be implemented by other embodiments in the prior art, and is not limited to the manner listed in the above example.
In one embodiment, the first key comprises a first integer, a second integer, and a third integer; the second key comprises a fourth integer, a fifth integer and a sixth integer;
the steps of generating a first pseudo-random sequence of integers from a first key and a second pseudo-random sequence of integers from a second key include:
processing the first key using the following formula to generate a first pseudorandom integer sequence:
Figure 861088DEST_PATH_IMAGE006
wherein the content of the first and second substances,
Figure 957306DEST_PATH_IMAGE007
is a first integer;
Figure 140026DEST_PATH_IMAGE008
is a second integer;
Figure 388604DEST_PATH_IMAGE009
is a third integer;
Figure 439606DEST_PATH_IMAGE010
is the element number;
Figure 519557DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 748545DEST_PATH_IMAGE010
An element;
Figure 546736DEST_PATH_IMAGE012
is the first in the first pseudorandom integer sequence
Figure 401429DEST_PATH_IMAGE013
An element;
Figure 7991DEST_PATH_IMAGE014
is the total number of elements;
processing the second key using the following formula to generate a second pseudorandom integer sequence:
Figure 798092DEST_PATH_IMAGE015
wherein the content of the first and second substances,
Figure 942634DEST_PATH_IMAGE016
is a fourth integer;
Figure 210805DEST_PATH_IMAGE017
is a fifth integer;
Figure 140715DEST_PATH_IMAGE018
is a sixth integer;
Figure 23089DEST_PATH_IMAGE010
is the element number;
Figure 530294DEST_PATH_IMAGE019
is the first in the second pseudorandom integer sequence
Figure 477521DEST_PATH_IMAGE010
An element;
Figure 386571DEST_PATH_IMAGE020
is the first in the second pseudorandom integer sequence
Figure 377530DEST_PATH_IMAGE021
An element;
Figure 309714DEST_PATH_IMAGE022
is the total number of elements.
In particular, the key pair may be
Figure 919687DEST_PATH_IMAGE042
Wherein
Figure 807877DEST_PATH_IMAGE043
Is a first key to be used for the first time,
Figure 845103DEST_PATH_IMAGE044
is the second key. Each key consists of three integers, namely:
Figure 467845DEST_PATH_IMAGE045
wherein the content of the first and second substances,
Figure 802881DEST_PATH_IMAGE007
is a first integer;
Figure 686523DEST_PATH_IMAGE008
is a second integer;
Figure 770017DEST_PATH_IMAGE009
is a third integer;
Figure 394902DEST_PATH_IMAGE016
is a fourth integer;
Figure 346678DEST_PATH_IMAGE017
is a fifth integer;
Figure 225772DEST_PATH_IMAGE046
is a sixth integer. Further, the first initial value can be obtained
Figure 526172DEST_PATH_IMAGE047
And a second initial value
Figure 982561DEST_PATH_IMAGE048
Figure 347815DEST_PATH_IMAGE047
And
Figure 206049DEST_PATH_IMAGE048
are integers greater than zero.
Figure 146192DEST_PATH_IMAGE009
And
Figure 761981DEST_PATH_IMAGE018
may be two prime numbers of the same order of magnitude,
Figure 55559DEST_PATH_IMAGE007
<
Figure 892934DEST_PATH_IMAGE009
Figure 613766DEST_PATH_IMAGE008
<
Figure 920113DEST_PATH_IMAGE009
Figure 938754DEST_PATH_IMAGE016
<
Figure 506001DEST_PATH_IMAGE018
Figure 538679DEST_PATH_IMAGE017
<
Figure 191377DEST_PATH_IMAGE018
then, each element in the first pseudorandom integer sequence may be generated by the following formula:
Figure 951392DEST_PATH_IMAGE049
wherein the content of the first and second substances,
Figure 310829DEST_PATH_IMAGE010
is the element number;
Figure 639042DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 434829DEST_PATH_IMAGE010
An element;
Figure 14846DEST_PATH_IMAGE012
is the first in the first pseudorandom integer sequence
Figure 291106DEST_PATH_IMAGE013
An element;
Figure 914855DEST_PATH_IMAGE022
is the total number of elements, namely the length of the plaintext;modis a modulo operation.
Meanwhile, each element in the second pseudorandom integer sequence may be generated by the following formula:
Figure 214249DEST_PATH_IMAGE050
wherein the content of the first and second substances,
Figure 191432DEST_PATH_IMAGE019
is the first in the second pseudorandom integer sequence
Figure 724131DEST_PATH_IMAGE010
An element;
Figure 394147DEST_PATH_IMAGE020
is the first in the second pseudorandom integer sequence
Figure 180837DEST_PATH_IMAGE021
An element;modis a modulo operation.
For example when all the parameters are as shown below,
Figure 86345DEST_PATH_IMAGE051
Figure 602777DEST_PATH_IMAGE052
Figure 319060DEST_PATH_IMAGE053
Figure 655364DEST_PATH_IMAGE054
Figure 364563DEST_PATH_IMAGE055
the first pseudo-random integer sequences can be generated according to the above formula
Figure 407605DEST_PATH_IMAGE038
And a second pseudo-random integer sequence
Figure 419423DEST_PATH_IMAGE039
And is denoted as FibonacciSystem of standard type
Figure 102078DEST_PATH_IMAGE056
And
Figure 162437DEST_PATH_IMAGE057
. Wherein
Figure 122303DEST_PATH_IMAGE056
Is the first in the first pseudorandom integer sequenceiFibonacci scale standard form of element with length ofL
Figure 226394DEST_PATH_IMAGE057
Is the first in the second pseudorandom integer sequenceiFibonacci scale standard form of element with length ofL. In each standard form
Figure 678235DEST_PATH_IMAGE058
To pair
Figure 604603DEST_PATH_IMAGE059
And
Figure 543609DEST_PATH_IMAGE060
performing logical OR operation according to bit to obtain a key subsequence
Figure 162809DEST_PATH_IMAGE061
HA sub-sequence of keys
Figure 836367DEST_PATH_IMAGE061
Paralleling to obtain the key stream
Figure 222218DEST_PATH_IMAGE062
For convenience of explanation of the solution of the present application, the following description is made by using a specific example, and as shown in fig. 3, there is provided a stream encryption key stream generation method, including:
step 310, a key pair, a first initial value and a second initial value are obtained.
In particular, a key pair
Figure 422255DEST_PATH_IMAGE063
Wherein
Figure 87723DEST_PATH_IMAGE064
Figure 842052DEST_PATH_IMAGE065
. First initial value
Figure 500436DEST_PATH_IMAGE066
And a second initial value
Figure 227083DEST_PATH_IMAGE067
Are all integers greater than zero and satisfy (1)
Figure 922507DEST_PATH_IMAGE068
And
Figure 554345DEST_PATH_IMAGE069
two prime numbers which may be of the same order of magnitude; (2)
Figure 626206DEST_PATH_IMAGE070
Figure 410623DEST_PATH_IMAGE071
;(3)
Figure 463898DEST_PATH_IMAGE072
Figure 458399DEST_PATH_IMAGE073
step 320, a first pseudorandom integer sequence and a second pseudorandom integer sequence are obtained.
Wherein the first pseudorandom integer sequence is obtainable by the following formula:
Figure 209317DEST_PATH_IMAGE074
the second pseudorandom integer sequence may be obtained by the following equation:
Figure 972874DEST_PATH_IMAGE075
specifically, the total number of elementsHCan be based on the length of plaintext dataDegree PAnd (4) determining.
Step 330, all elements in the first pseudo-random integer sequence and all elements in the second pseudo-random integer sequence are adopted to have the length of
Figure 134734DEST_PATH_IMAGE001
Expressed in fibonacci scale standard form.
Wherein the content of the first and second substances,
Figure 554214DEST_PATH_IMAGE076
and 340, intercepting the first intermediate sequence from the first standard formula according to the number of 1 in the first standard formula, and intercepting the second intermediate sequence from the second standard formula according to the number of 1 in the second standard formula.
In particular, for a length of
Figure 967878DEST_PATH_IMAGE032
1 is the number of
Figure 710575DEST_PATH_IMAGE033
Of the Fibonacci scale standard 0, 1 sequence
Figure 918702DEST_PATH_IMAGE077
When it comes to
Figure 763161DEST_PATH_IMAGE035
The probability of a bit appearing at 1 is constant. Intermediate part for first and second standard forms
Figure 901888DEST_PATH_IMAGE078
The intersection bit of the key is bitwise OR to obtain the key of the current roundSequence of
Figure 640037DEST_PATH_IMAGE079
And 350, incrementing the current element sequence number to obtain the element sequence number for acquiring the next round of key subsequence until traversing the first pseudorandom integer sequence and the second pseudorandom integer sequence.
And step 360, paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain a key stream.
Figure 691169DEST_PATH_IMAGE080
The stream encryption key stream generation method is provided. Generated keystream sequenceCThe assumption of Golomb randomness is satisfied and can be used for stream encryption.
In one embodiment, as shown in fig. 4, there is provided an encryption method comprising the steps of:
step 410, obtaining plaintext data;
step 420, generating a key stream by using the stream encryption key stream generation method in any of the above embodiments;
and 430, performing exclusive or operation on the key stream and the plaintext data according to bits to obtain ciphertext data.
Specifically, after the plaintext data is obtained, a key stream may be generated by using the stream encryption key stream generation method in any of the embodiments, and then, an exclusive or (XOR) operation may be performed on the plaintext data and the key stream according to bits to obtain ciphertext data.
In one embodiment, as shown in fig. 5, there is provided a decryption method comprising the steps of:
step 510, obtaining ciphertext data;
step 520, acquiring a key stream; the key stream may be generated by using the stream encryption key stream generation method in any of the embodiments described above;
and step 530, carrying out exclusive OR operation on the key stream and the ciphertext data according to the bit to obtain plaintext data.
It should be understood that although the various steps in the flowcharts of fig. 1-5 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps of fig. 1-5 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
In one embodiment, as shown in fig. 6, there is provided a stream cipher key generation circuit including:
the first encoder is used for converting the first element into a Fibonacci binary standard form to obtain a first standard form;
the second encoder is used for converting the second element into a Fibonacci binary standard form to obtain a second standard form;
the key stream generating device determines the serial number of the current element, selects a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selects a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence; intercepting a first intermediate sequence from the first standard formula and intercepting a second intermediate sequence from the second standard formula; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed; and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain the key stream.
Specifically, the stream encryption key generation circuit may include a first encoder, a second encoder, and a key stream generation device, an output end of the key stream generation device is connected to an input end of the first encoder and an input end of the second encoder, respectively, and an input end of the key stream generation device is connected to an output end of the first encoder and an output end of the second encoder, respectively.
The keystream generation apparatus may select a first element corresponding to a current element number from a first pseudorandom integer sequence and a second element corresponding to the current element number from a second pseudorandom integer sequence, and may transmit the first element to a first encoder and the second element to a second encoder. Further, the first element and the second element may each be 16 binary numbers. The first encoder converts the first element into a Fibonacci binary standard form to obtain a first standard form, and the second encoder converts the second element into a Fibonacci binary standard form to obtain a second standard form.
Or, the keystream generation device may respectively obtain/generate a first pseudorandom integer sequence and a second pseudorandom integer sequence, transmit the obtained first pseudorandom integer sequence to the first encoder, and transmit the obtained second pseudorandom integer sequence to the second encoder. And the second encoder performs Fibonacci standard type coding on the generated second pseudorandom integer sequence to obtain a second standard type.
The first standard formula is input into the key stream generating device sequentially through the output end of the first encoder and the input end of the key stream generating device, and the second standard formula is input into the key stream generating device sequentially through the output end of the second encoder and the input end of the key stream generating device.
The key stream generation device intercepts a first intermediate sequence from the first standard formula, intercepts a second intermediate sequence from the second standard formula, and performs bitwise OR operation on intersection bits of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence corresponding to the current element sequence number. And increasing the sequence number of the current element, transmitting a next first element and a next second element to the first encoder and the second encoder respectively, and acquiring a next round of key subsequence until traversing the first pseudorandom integer sequence and the second pseudorandom integer sequence.
And after traversing the first pseudorandom integer sequence and the second pseudorandom integer sequence, the key stream generation device parallels the key subsequences of each round according to the sequence of the element sequence numbers to obtain the key stream.
In one embodiment, further comprising:
a storage device for storing the first 32-bit Fibonacci number; each fibonacci number is used to instruct the first encoder to convert the first element to a fibonacci binary standard form and the second encoder to convert the second element to a fibonacci binary standard form.
Specifically, referring to fig. 7, fig. 7 shows an RTL (Register Transfer Level) circuit of the stream cipher key generation circuit. The Memory device may be a RAM (Random Access Memory) device in which the first 32-bit fibonacci number is stored, i.e. in which the first 32-bit fibonacci number is stored
Figure 272192DEST_PATH_IMAGE081
. The storage device may be connected to the first encoder and the second encoder, respectively.
When the Fibonacci binary coding is performed, the Fibonacci number in the storage device can be read, so that repeated calculation can be avoided, and the key stream generation speed can be further increased.
In one embodiment, the first encoder, the second encoder and the key stream generating device are all FPGA (Field Programmable Gate Array) devices.
For the purpose of illustrating the aspects of the present application, a specific example will be described below. A stream encryption key stream generation circuit, whose RTL stage circuit can be shown in FIG. 7, and state transition diagram can be shown in FIG. 8.
The resource occupation comparison of the stream encryption key stream generation circuit and the RC4 random code stream generator can be shown in table 1, and as can be seen from table 1, the stream encryption key stream generation circuit occupies 3 times of logic gates and register resources, but occupies 1/3 IO pins, compared with the RC4 random code stream generator. Both of them have more emphasis on hardware resource layout and have no obvious advantages and disadvantages.
Table 1 comparison of FPGA resource occupation between stream encryption key stream generation circuit and RC4 random code stream generator
Figure 762079DEST_PATH_IMAGE082
In contrast to the time consumption, when the crystal oscillator is 50MHz (megahertz), for 8 bits of plaintext data, the generation time of the random code stream generated by the present application is 4630ps (picosecond) for 231 clock cycles, and the generation time of the RC4 random code stream is 15694ps (783 clock cycles). That is, the generation speed of the random code stream of the stream encryption key stream generation circuit of the present application is about 3 times faster than the generation speed of the random code stream generator of RC 4.
By integrating the comparison results of resource consumption and time occupation, it can be considered that although the register and logic gate resources occupy a little more, the speed of generating the random code stream of the stream encryption key stream generating circuit is obviously faster, and fewer pins are occupied, so that the random code stream generating method is superior to the random code stream generating method of RC4 in the overall view.
In one embodiment, there is provided an encryption device comprising the stream cipher key generation circuit of any of the above embodiments.
Further, the encryption device may further include a receiving circuit that receives the plaintext data and an encryption circuit that exclusive-ors the keystream and the plaintext data.
In one embodiment, as shown in fig. 9, there is provided a stream encryption key stream generation apparatus including:
and the element selection module is used for determining the serial number of the current element, selecting a first element corresponding to the serial number of the current element from the first pseudorandom integer sequence, and selecting a second element corresponding to the serial number of the current element from the second pseudorandom integer sequence.
And the intermediate sequence intercepting module is used for converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting the first intermediate sequence from the first standard form, and intercepting the second intermediate sequence from the second standard form.
The key subsequence obtaining module is used for performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining a key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and the key stream acquisition module is used for paralleling each key subsequence according to the sequence of the element sequence numbers to obtain the key stream.
In one embodiment, the intermediate sequence clipping module is configured to clip the first intermediate sequence from the first standard form according to the number of preset values in the first standard form, and clip the second intermediate sequence from the second standard form according to the number of preset values in the second standard form.
In one embodiment, the predetermined value is 1; the length of the first standard formula and the length of the second standard formula are bothLThe number of 1 s in the first standard formula is
Figure 495680DEST_PATH_IMAGE002
The number of 1 s in the first standard formula is
Figure 311189DEST_PATH_IMAGE003
(ii) a A middle sequence intercepting module for intercepting the second sequence in the first standard form
Figure 910667DEST_PATH_IMAGE083
Is located to
Figure 345190DEST_PATH_IMAGE004
The sequence between the bits is identified as the first intermediate sequence, and the second standard is identified as the second intermediate sequence
Figure 792352DEST_PATH_IMAGE003
Is located to
Figure 903396DEST_PATH_IMAGE031
The sequence between the bits is identified as the second intermediate sequence.
In one embodiment, the stream encryption key stream generation apparatus further includes: the pseudo-random code acquisition module is used for acquiring a first pseudo-random integer sequence and a second pseudo-random integer sequence; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the length of a plaintext.
In one embodiment, the pseudo random code obtaining module is further configured to obtain a key pair; the key pair comprises a first key and a second key; a first pseudorandom integer sequence is generated from the first key and a second pseudorandom integer sequence is generated from the second key.
In one embodiment, the first key comprises a first integer, a second integer, and a third integer; the second key comprises a fourth integer, a fifth integer and a sixth integer; the pseudo-random code acquisition module is further configured to process the first secret key using the following formula to generate a first pseudo-random integer sequence:
Figure 334378DEST_PATH_IMAGE006
wherein the content of the first and second substances,
Figure 103751DEST_PATH_IMAGE007
is a first integer;
Figure 807351DEST_PATH_IMAGE008
is a second integer;
Figure 699083DEST_PATH_IMAGE009
is a third integer;
Figure 227148DEST_PATH_IMAGE010
is the element number;
Figure 49479DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 736813DEST_PATH_IMAGE010
An element;
Figure 674813DEST_PATH_IMAGE012
is the first in the first pseudorandom integer sequence
Figure 814807DEST_PATH_IMAGE013
An element;
Figure 378512DEST_PATH_IMAGE014
is the total number of elements;
processing the second key using the following formula to generate a second pseudorandom integer sequence:
Figure 592456DEST_PATH_IMAGE015
wherein the content of the first and second substances,
Figure 91570DEST_PATH_IMAGE016
is a fourth integer;
Figure 577915DEST_PATH_IMAGE017
is a fifth integer;
Figure 820678DEST_PATH_IMAGE018
is a sixth integer;
Figure 154707DEST_PATH_IMAGE010
is the element number;
Figure 949357DEST_PATH_IMAGE019
is the first in the second pseudorandom integer sequence
Figure 798364DEST_PATH_IMAGE010
An element;
Figure 454605DEST_PATH_IMAGE020
is the first in the second pseudorandom integer sequence
Figure 971037DEST_PATH_IMAGE021
An element;
Figure 733325DEST_PATH_IMAGE022
is the total number of elements.
For specific limitations of the stream encryption key stream generation apparatus, reference may be made to the above limitations of the stream encryption key stream generation method, which will not be described herein again. The respective modules in the stream encryption key stream generation apparatus described above may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules. It should be noted that, in the embodiment of the present application, the division of the module is schematic, and is only one logic function division, and there may be another division manner in actual implementation.
In one embodiment, as shown in fig. 10, there is provided an encryption apparatus including:
the plaintext acquisition module is used for acquiring plaintext data;
a stream encryption key stream generation device, configured to generate a key stream by using the stream encryption key stream generation method in any of the embodiments;
and the ciphertext acquisition module is used for carrying out exclusive OR operation on the key stream and the plaintext data according to bits to obtain ciphertext data.
Specifically, the stream encryption key stream generation apparatus may be as described in any of the above embodiments.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
determining a current element serial number, selecting a first element corresponding to the current element serial number from the first pseudorandom integer sequence, and selecting a second element corresponding to the current element serial number from the second pseudorandom integer sequence;
converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form;
performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain the key stream.
In one embodiment, the computer program when executed by the processor further performs the steps of: and intercepting the first intermediate sequence from the first standard formula according to the number of preset values in the first standard formula, and intercepting the second intermediate sequence from the second standard formula according to the number of preset values in the second standard formula.
In one embodiment, the predetermined value is 1; the length of the first standard formula and the length of the second standard formula are bothLThe number of 1 s in the first standard formula is
Figure 944995DEST_PATH_IMAGE002
The number of 1 s in the first standard formula is
Figure 529560DEST_PATH_IMAGE003
(ii) a The computer program when executed by the processor further realizes the steps of: the first standard formula
Figure 25132DEST_PATH_IMAGE002
Is located to
Figure 771371DEST_PATH_IMAGE004
The sequence between the bits is identified as the first intermediate sequence, and the second standard is identified as the second intermediate sequence
Figure 735916DEST_PATH_IMAGE003
Is located to
Figure 779964DEST_PATH_IMAGE031
The sequence between the bits is identified as the second intermediate sequence.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring a first pseudorandom integer sequence and a second pseudorandom integer sequence; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the length of a plaintext.
In one embodiment, the computer program when executed by the processor further performs the steps of: obtaining a key pair; the key pair comprises a first key and a second key; a first pseudorandom integer sequence is generated from the first key and a second pseudorandom integer sequence is generated from the second key.
In one embodiment, the first key comprises a first integer, a second integer, and a third integer; the second key comprises a fourth integer, a fifth integer and a sixth integer; the computer program when executed by the processor further realizes the steps of: processing the first key using the following formula to generate a first pseudorandom integer sequence:
Figure 270989DEST_PATH_IMAGE006
wherein the content of the first and second substances,
Figure 329075DEST_PATH_IMAGE007
is a first integer;
Figure 374391DEST_PATH_IMAGE008
is a second integer;
Figure 222130DEST_PATH_IMAGE009
is a third integer;
Figure 443027DEST_PATH_IMAGE010
is the element number;
Figure 531069DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 453894DEST_PATH_IMAGE010
An element;
Figure 856057DEST_PATH_IMAGE012
is the first in the first pseudorandom integer sequence
Figure 56094DEST_PATH_IMAGE013
An element;
Figure 439671DEST_PATH_IMAGE014
is the total number of elements;
processing the second key using the following formula to generate a second pseudorandom integer sequence:
Figure 725159DEST_PATH_IMAGE015
wherein the content of the first and second substances,
Figure 931012DEST_PATH_IMAGE016
is a fourth integer;
Figure 110189DEST_PATH_IMAGE084
is a fifth integer;
Figure 805613DEST_PATH_IMAGE018
is a sixth integer;
Figure 188184DEST_PATH_IMAGE010
is the element number;
Figure 260045DEST_PATH_IMAGE019
is the first in the second pseudorandom integer sequence
Figure 90467DEST_PATH_IMAGE010
An element;
Figure 97737DEST_PATH_IMAGE020
is the first in the second pseudorandom integer sequence
Figure 92238DEST_PATH_IMAGE085
An element;
Figure 826844DEST_PATH_IMAGE014
is the total number of elements.
In one embodiment, another computer-readable storage medium is provided, having a computer program stored thereon, the computer program, when executed by a processor, implementing the steps of:
acquiring plaintext data;
generating a key stream by adopting a stream encryption key stream generation method in any embodiment;
and carrying out exclusive OR operation on the key stream and the plaintext data according to the bit to obtain ciphertext data.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile memory can include RAM or external cache memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
In the description herein, references to the description of "some embodiments," "other embodiments," "desired embodiments," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, a schematic description of the above terminology may not necessarily refer to the same embodiment or example.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (14)

1. A stream encryption key stream generation method, comprising:
determining a current element serial number, selecting a first element corresponding to the current element serial number from a first pseudorandom integer sequence, and selecting a second element corresponding to the current element serial number from a second pseudorandom integer sequence;
converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form;
performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain a key stream.
2. The stream cipher key stream generating method of claim 1, wherein the step of cutting out a first intermediate sequence from the first standard and a second intermediate sequence from the second standard comprises:
and intercepting a first intermediate sequence from the first standard formula according to the number of preset values in the first standard formula, and intercepting a second intermediate sequence from the second standard formula according to the number of preset values in the second standard formula.
3. The stream cipher key stream generation method of claim 2, wherein the preset value is 1; the length of the first standard formula and the length of the second standard formula are bothLThe number of 1 s in the first standard formula is
Figure 149413DEST_PATH_IMAGE001
The number of 1 s in the first standard formula is
Figure 961380DEST_PATH_IMAGE002
The step of truncating a first intermediate sequence from the first normal form according to the number of the preset values in the first normal form, and truncating a second intermediate sequence from the second normal form according to the number of the preset values in the second normal form comprises:
combining the first standard formula with the second standard formula
Figure 24014DEST_PATH_IMAGE001
Is located to
Figure 836112DEST_PATH_IMAGE003
The sequence between the bits is identified as the first intermediate sequence, and the second standard is identified as the second intermediate sequence
Figure 399817DEST_PATH_IMAGE002
Is located to
Figure 676078DEST_PATH_IMAGE004
The sequence between bits is confirmed asThe second intermediate sequence.
4. The stream cipher key stream generating method of claim 1, wherein the step of determining the current element sequence number is preceded by:
acquiring the first pseudorandom integer sequence and the second pseudorandom integer sequence; the number of elements of the first pseudorandom integer sequence is equal to the number of elements of the second pseudorandom integer sequence, and the number of elements of the first pseudorandom integer sequence is determined according to the length of a plaintext.
5. The stream cipher keystream generation method of claim 4, wherein obtaining the first sequence of pseudorandom integers and the second sequence of pseudorandom integers comprises:
obtaining a key pair; the key pair comprises a first key and a second key;
generating the first pseudorandom integer sequence according to the first key and generating the second pseudorandom integer sequence according to the second key.
6. The stream cipher key stream generation method of claim 5, wherein the first key includes a first integer, a second integer, and a third integer; the second key comprises a fourth integer, a fifth integer, and a sixth integer;
the steps of generating the first pseudorandom integer sequence based on the first key and generating the second pseudorandom integer sequence based on the second key include:
processing the first key using the following formula to generate the first pseudorandom integer sequence:
Figure 701758DEST_PATH_IMAGE005
wherein the content of the first and second substances,
Figure 63469DEST_PATH_IMAGE006
is a stand forThe first integer;
Figure 821079DEST_PATH_IMAGE007
is the second integer;
Figure 483004DEST_PATH_IMAGE008
is the third integer;
Figure 74391DEST_PATH_IMAGE009
is the element number;
Figure 188978DEST_PATH_IMAGE010
is the first in the first pseudorandom integer sequence
Figure 297748DEST_PATH_IMAGE009
An element;
Figure 283022DEST_PATH_IMAGE011
is the first in the first pseudorandom integer sequence
Figure 999305DEST_PATH_IMAGE012
An element;
Figure 601188DEST_PATH_IMAGE013
is the total number of elements;
processing the second key using the following formula to generate the second pseudorandom integer sequence:
Figure 107124DEST_PATH_IMAGE014
wherein the content of the first and second substances,
Figure 87850DEST_PATH_IMAGE015
is the fourth integer;
Figure 21039DEST_PATH_IMAGE016
is the fifth integer;
Figure 703693DEST_PATH_IMAGE017
is the sixth integer;
Figure 826370DEST_PATH_IMAGE009
is the element number;
Figure 661602DEST_PATH_IMAGE018
is the second in the second pseudorandom integer sequence
Figure 31273DEST_PATH_IMAGE009
An element;
Figure 76589DEST_PATH_IMAGE019
is the second in the second pseudorandom integer sequence
Figure 675061DEST_PATH_IMAGE020
An element;
Figure 879646DEST_PATH_IMAGE013
is the total number of elements.
7. An encryption method, comprising the steps of:
acquiring plaintext data;
generating a keystream using the stream encryption keystream generation method of any of claims 1-6;
and carrying out exclusive OR operation on the key stream and the plaintext data according to the bit to obtain ciphertext data.
8. A stream encryption key stream generation apparatus, comprising:
the element selection module is used for determining the serial number of the current element, selecting a first element corresponding to the serial number of the current element from a first pseudorandom integer sequence, and selecting a second element corresponding to the serial number of the current element from a second pseudorandom integer sequence;
the intermediate sequence intercepting module is used for converting the first element and the second element into Fibonacci binary standard forms to respectively obtain a first standard form and a second standard form, intercepting a first intermediate sequence from the first standard form, and intercepting a second intermediate sequence from the second standard form;
a key subsequence obtaining module, configured to perform bitwise or operation on intersection bits of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increment the current element sequence number to obtain an element sequence number used for obtaining a key subsequence of the next round, until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed;
and the key stream acquisition module is used for paralleling the key subsequences according to the sequence of the element sequence numbers to obtain the key stream.
9. An encryption apparatus, comprising:
the plaintext acquisition module is used for acquiring plaintext data;
stream encryption keystream generation means for generating a keystream using the stream encryption keystream generation method of any one of claims 1 through 6;
and the ciphertext acquisition module is used for carrying out exclusive OR operation on the key stream and the plaintext data according to bits to obtain ciphertext data.
10. A stream cipher key generation circuit, comprising:
the first encoder is used for converting the first element into a Fibonacci binary standard form to obtain a first standard form;
the second encoder is used for converting the second element into a Fibonacci binary standard form to obtain a second standard form;
the key stream generating device determines a current element serial number, selects a first element corresponding to the current element serial number from a first pseudorandom integer sequence, and selects a second element corresponding to the current element serial number from a second pseudorandom integer sequence; intercepting a first intermediate sequence from the first standard formula and intercepting a second intermediate sequence from the second standard formula; performing bitwise OR operation on intersection positions of the first intermediate sequence and the second intermediate sequence to obtain a key subsequence of the current round, increasing the current element sequence number to obtain an element sequence number used for obtaining the key subsequence of the next round until the first pseudorandom integer sequence and the second pseudorandom integer sequence are traversed; and paralleling the key subsequences of each round according to the sequence of the element sequence numbers to obtain a key stream.
11. The stream cipher key generation circuit of claim 10, further comprising:
a storage device for storing the first 32-bit Fibonacci number; each of the fibonacci numbers is to instruct the first encoder to convert the first element to a fibonacci binary standard form and the second encoder to convert the second element to a fibonacci binary standard form.
12. The stream cipher key generation circuit of claim 10, wherein the first encoder, the second encoder, and the keystream generation device are all FPGA devices.
13. An encryption device comprising the stream cipher key generation circuit according to any one of claims 10 to 12.
14. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202011418785.6A 2020-12-07 2020-12-07 Stream encryption key stream generation method, device, circuit and encryption method Pending CN112202548A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011418785.6A CN112202548A (en) 2020-12-07 2020-12-07 Stream encryption key stream generation method, device, circuit and encryption method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011418785.6A CN112202548A (en) 2020-12-07 2020-12-07 Stream encryption key stream generation method, device, circuit and encryption method

Publications (1)

Publication Number Publication Date
CN112202548A true CN112202548A (en) 2021-01-08

Family

ID=74034499

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011418785.6A Pending CN112202548A (en) 2020-12-07 2020-12-07 Stream encryption key stream generation method, device, circuit and encryption method

Country Status (1)

Country Link
CN (1) CN112202548A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116527233A (en) * 2023-03-13 2023-08-01 安徽合工质能双碳科技有限公司 Energy monitoring data management system based on cloud computing

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201936335U (en) * 2011-01-20 2011-08-17 广东商学院 RFID (radio frequency identification) electronic tag chip with encryption function
CN102752107A (en) * 2011-04-19 2012-10-24 中国科学院微电子研究所 Device and method for realizing RC4 encryption/decryption
EP3316125A1 (en) * 2016-10-26 2018-05-02 Nxp B.V. Method of generating an elliptic curve cryptographic key pair
CN111431716A (en) * 2020-03-30 2020-07-17 卓尔智联(武汉)研究院有限公司 Data transmission method and device, computer equipment and storage medium
CN111464296A (en) * 2020-03-30 2020-07-28 卓尔智联(武汉)研究院有限公司 Sequence cipher generation method, data encryption method and data decryption method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201936335U (en) * 2011-01-20 2011-08-17 广东商学院 RFID (radio frequency identification) electronic tag chip with encryption function
CN102752107A (en) * 2011-04-19 2012-10-24 中国科学院微电子研究所 Device and method for realizing RC4 encryption/decryption
EP3316125A1 (en) * 2016-10-26 2018-05-02 Nxp B.V. Method of generating an elliptic curve cryptographic key pair
CN111431716A (en) * 2020-03-30 2020-07-17 卓尔智联(武汉)研究院有限公司 Data transmission method and device, computer equipment and storage medium
CN111464296A (en) * 2020-03-30 2020-07-28 卓尔智联(武汉)研究院有限公司 Sequence cipher generation method, data encryption method and data decryption method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116527233A (en) * 2023-03-13 2023-08-01 安徽合工质能双碳科技有限公司 Energy monitoring data management system based on cloud computing
CN116527233B (en) * 2023-03-13 2023-09-19 安徽合工质能双碳科技有限公司 Energy monitoring data management system based on cloud computing

Similar Documents

Publication Publication Date Title
Beaulieu et al. The SIMON and SPECK lightweight block ciphers
Li et al. Chaotic encryption scheme for real-time digital video
TWI739090B (en) Puf-based true random number generator
US5835600A (en) Block encryption algorithm with data-dependent rotations
KR101246490B1 (en) A closed galois field cryptographic system
US8320557B2 (en) Cryptographic system including a mixed radix number generator with chosen statistical artifacts
EP1583278B1 (en) Stream Cipher Design with Revolving Buffers
JPH04250490A (en) Encrypting system based on chaos theory
US20090296928A1 (en) Pseudorandom number generating system, encryption system, and decryption system
WO2006033013A2 (en) Substitution boxes
US8229108B2 (en) Pseudo-random number generation based on periodic sampling of one or more linear feedback shift registers
JP2005215688A (en) Hardware encryption/decryption apparatus using s-box operation, and method for the same
WO2004032098A1 (en) Pseudo-random number generation method and pseudo-random number generator
Cheung et al. Tradeoffs in parallel and serial implementations of the international data encryption algorithm IDEA
WO2000001111A1 (en) Secure data encoder and decoder
Paar et al. Stream ciphers
Ghazi et al. Robust and efficient dynamic stream cipher cryptosystem
CN112202548A (en) Stream encryption key stream generation method, device, circuit and encryption method
WO2004086673A1 (en) Device, method, and program for random number generation, encryption, and decryption, and recording medium
Maximov Some words on cryptanalysis of stream ciphers
Younes et al. CeTrivium: A Stream Cipher Based on Cellular Automata for Securing Real-TimeMultimedia Transmission.
Abumuala et al. A new method for generating cryptographically strong sequences of pseudo random bits for stream cipher
Singh et al. Analysis of 64-bit RC5 Encryption Algorithm for Pipelined Architecture
Hendricks et al. Polysizemic Encryption: Towards a Variable-Length Output Symmetric-Key Cryptosystem
Sonawane et al. Synthesis and simulation of FPGA based hardware design of RC4 stream cipher

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: 20210108

RJ01 Rejection of invention patent application after publication