CN113259719A - SM 4-based video encryption method and system - Google Patents

SM 4-based video encryption method and system Download PDF

Info

Publication number
CN113259719A
CN113259719A CN202110521070.1A CN202110521070A CN113259719A CN 113259719 A CN113259719 A CN 113259719A CN 202110521070 A CN202110521070 A CN 202110521070A CN 113259719 A CN113259719 A CN 113259719A
Authority
CN
China
Prior art keywords
ciphertext
key
round
encryption
odd
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
CN202110521070.1A
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.)
Chongqing Research Institute Of Changchun University Of Technology
Changchun University of Science and Technology
Original Assignee
Chongqing Research Institute Of Changchun University Of Technology
Changchun University of Science and Technology
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 Chongqing Research Institute Of Changchun University Of Technology, Changchun University of Science and Technology filed Critical Chongqing Research Institute Of Changchun University Of Technology
Priority to CN202110521070.1A priority Critical patent/CN113259719A/en
Publication of CN113259719A publication Critical patent/CN113259719A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/234Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs
    • H04N21/2347Processing of video elementary streams, e.g. splicing of video streams or manipulating encoded video stream scene graphs involving video stream encryption
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
    • H04L63/0428Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
    • H04L63/0435Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload wherein the sending and receiving network entities apply symmetric encryption, i.e. same key used for encryption and decryption
    • 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/0618Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
    • H04L9/0631Substitution permutation network [SPN], i.e. cipher composed of a number of stages or rounds each involving linear and nonlinear transformations, e.g. AES algorithms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/25Management operations performed by the server for facilitating the content distribution or administrating data related to end-users or client devices, e.g. end-user or client device authentication, learning user preferences for recommending movies
    • H04N21/266Channel or content management, e.g. generation and management of keys and entitlement messages in a conditional access system, merging a VOD unicast channel into a multicast channel
    • H04N21/26613Channel or content management, e.g. generation and management of keys and entitlement messages in a conditional access system, merging a VOD unicast channel into a multicast channel for generating or managing keys in general
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/44Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs
    • H04N21/4408Processing of video elementary streams, e.g. splicing a video clip retrieved from local storage with an incoming video stream or rendering scenes according to encoded video stream scene graphs involving video stream encryption, e.g. re-encrypting a decrypted video stream for redistribution in a home network

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Multimedia (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)

Abstract

The invention relates to a video encryption method and a system based on SM4, wherein the method comprises the following steps: converting video information to be encrypted into binary data streams and dividing the binary data streams into 2N 128-bit arrays; dividing each array into an odd array consisting of odd arrays and an even array consisting of even arrays; dividing every two adjacent bytes in each array in the odd array into a group, and carrying out bitwise XOR operation on each group to obtain an odd array ciphertext; randomly generating a master key, and carrying out XOR operation on each subelement in the master key and system parameters corresponding to each subelement to obtain an encryption key; acquiring a round key according to the encryption key, and encrypting each sequence in the dual queue according to the round key based on an SM4 algorithm to obtain a corresponding output ciphertext; when each array in the even array is encrypted, connecting output ciphertexts corresponding to each array to obtain an even array cipher text; and connecting the even-numbered columns of the ciphertext with the odd-numbered columns of the ciphertext to obtain a final output ciphertext. The invention improves the encryption efficiency and the security.

Description

SM 4-based video encryption method and system
Technical Field
The invention relates to the technical field of video encryption, in particular to a video encryption method and system based on SM 4.
Background
In the current selective video encryption algorithm, data such as key frames and format header information of a video stream are encrypted, so that not only the format of the data is changed, but also the encrypted data stream is poor in safety, operability and compatibility.
Disclosure of Invention
The invention aims to provide a video encryption method and system based on SM4, which improve encryption efficiency and security.
In order to achieve the purpose, the invention provides the following scheme:
a video encryption method based on SM4, comprising:
converting video information to be encrypted into a binary data stream;
dividing the binary data stream into 2N 128-bit arrays;
sequencing each array, and forming odd arrays into odd arrays and even arrays into even arrays;
dividing every two adjacent bytes in each array in the odd array into a group, and carrying out bitwise XOR operation on each group to obtain an odd array ciphertext;
a master key is randomly generated, denoted MK ═ M (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits;
carrying out XOR operation on each subelement in the master key and the system parameter corresponding to each subelement to obtain an encryption key; the encryption key is expressed as
Figure BDA0003063999410000011
Wherein, KiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters;
obtaining a round key from the encryption key, the round key being denoted rki,i=0,1,2,…31;
Based on the SM4 algorithm, encrypting the nth sequence in the even queue according to a round key to obtain an nth output ciphertext;
judging whether each array in the even queue is encrypted or not;
if not, updating the iteration number, returning to the step of randomly generating a master key, wherein the master key is represented as MK (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits ";
if so, connecting the output ciphertexts corresponding to each array in the even-pair array to obtain an even-array cipher text;
and connecting the even column ciphertext with the odd column ciphertext to obtain the ciphertext of the video information to be encrypted.
Optionally, the obtaining a round key according to the encryption key specifically includes:
according to the formula
Figure BDA0003063999410000021
Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
Optionally, the encrypting, based on the SM4 algorithm, the nth sequence of numbers in the even queue according to a round key to obtain an nth output ciphertext specifically includes:
performing 32 rounds of round function operation on the nth number of the arrays to obtain an nth initial ciphertext;
the nth initial ciphertext is inverted to obtain the nth output ciphertext,
optionally, the performing 32 rounds of round function operations on the nth number of columns to obtain the nth initial ciphertext specifically includes:
sequentially inputting the ith round of input data into a round function to obtain 32 rounds of output data, wherein the round function operation is represented as:
Figure BDA0003063999410000022
will be (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
The invention discloses a video encryption system based on SM4, which comprises:
the binary line-changing module is used for converting the video information to be encrypted into a binary data stream;
a number column dividing module, configured to divide the binary data stream into 2N 128-bit number columns;
the odd-even queue obtaining module is used for sequencing all the rows, forming odd rows into odd queues and forming even rows into even queues;
the odd-column ciphertext obtaining module is used for dividing every two adjacent bytes in each column in the odd queue into one group, and performing bitwise XOR operation on each group to obtain an odd-column ciphertext;
a master key obtaining module for randomly generating a master key, wherein the master key is expressed as MK ═ or (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits;
the encryption key obtaining module is used for carrying out XOR operation on each subelement in the master key and the system parameters corresponding to each subelement to obtain an encryption key; the encryption key is expressed as
Figure BDA0003063999410000031
Wherein, KiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters;
a round key obtaining module for obtaining a round key according to the encryption key, the round key being expressed as rki,i=0,1,2,…31;
The round key encryption module is used for encrypting the nth sequence in the even queue according to the round key based on the SM4 algorithm to obtain the nth output ciphertext;
the judging module is used for judging whether all the arrays in the even queue are encrypted or not;
a return module, configured to update the iteration times if all even columns in the even queue are not encrypted, and return to the master key obtaining module;
an even column ciphertext obtaining module, configured to connect output ciphertexts corresponding to each even column in the even pair of columns to obtain an even column ciphertext if each even column in the even queue is encrypted;
and the ciphertext obtaining module is used for connecting the even column ciphertext with the odd column ciphertext to obtain the ciphertext of the video information to be encrypted.
Optionally, the round key obtaining module specifically includes:
according to the formula
Figure BDA0003063999410000032
Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
Optionally, the round key encryption module specifically includes:
the round function operation unit is used for carrying out 32 rounds of round function operations on the nth number of rows to obtain an nth initial ciphertext;
and the ciphertext output unit is used for performing reverse order on the nth initial ciphertext to obtain the nth output ciphertext.
Optionally, the round function operation unit specifically includes:
a round function operation subunit, configured to sequentially input the ith round of input data into a round function to obtain 32 rounds of output data, where the round function operation is expressed as:
Figure BDA0003063999410000033
Figure BDA0003063999410000034
an initial cipher text output subunit for outputting (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
According to the specific embodiment provided by the invention, the invention discloses the following technical effects:
the invention is based on SM4 encryption algorithm, adopts different encryption modes to encrypt odd column data and even column data, not only ensures encryption efficiency, but also improves the security of video data in the transmission process to a great extent.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
Fig. 1 is a schematic flow chart of a video encryption method based on SM4 according to the present invention;
fig. 2 is a schematic data flow diagram of a video encryption method based on SM4 according to the present invention;
fig. 3 is a schematic structural diagram of a video encryption system based on SM4 according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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 invention.
The invention aims to provide a video encryption method and system based on SM4, which improve encryption efficiency and security.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Fig. 1 is a schematic flow diagram of a video encryption method based on SM4 of the present invention, fig. 2 is a schematic data flow diagram of a video encryption method based on SM4 of the present invention, and as shown in fig. 1-2, a video encryption method based on SM4 includes:
step 101: the video information to be encrypted is converted into a binary data stream.
Step 102: the binary data stream is divided into 2N 128bit sequences.
Step 103: and sequencing the rows, wherein odd rows form an odd queue, and even rows form an even queue.
Step 104: dividing every two adjacent bytes in each array in the odd array into one group, and carrying out bitwise XOR operation on each group to obtain the odd array ciphertext.
Wherein, step 104 specifically includes:
dividing every two adjacent bytes in each array in the odd array into a group, carrying out bitwise XOR operation on each group to obtain the calculation results of the bitwise XOR operation corresponding to each odd array, and sequentially connecting the calculation results to obtain the ciphertext of the odd array.
Step 105: a master key is randomly generated, denoted MK ═ M (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Representing 32bit data.
Step 106: carrying out XOR operation on each subelement in the master key and the system parameter corresponding to each subelement to obtain an encryption key; the encryption key is expressed as
Figure BDA0003063999410000053
Wherein, KiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters.
Step 107: obtaining a round key from the encryption key, the round key being denoted rki,i=0,1,2,…31。
The obtaining of the round key according to the encryption key specifically includes:
according to the formula
Figure BDA0003063999410000051
Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
Step 108: and based on the SM4 algorithm, encrypting the nth sequence in the even queue according to the round key to obtain the nth output ciphertext.
The encrypting, based on the SM4 algorithm, the nth sequence of numbers in the even queue according to the round key to obtain the nth output ciphertext specifically includes:
performing 32 rounds of round function operation on the nth number of the arrays to obtain an nth initial ciphertext;
carrying out reverse order on the nth initial ciphertext to obtain nth output ciphertext;
the performing 32 rounds of round function operations on the nth number sequence to obtain the nth initial ciphertext specifically includes:
sequentially inputting the number of the ith roundObtaining 32 rounds of output data according to an input round function, wherein the round function operation is represented as:
Figure BDA0003063999410000052
will be (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
Step 109: and judging whether all the number arrays in the even queue are encrypted or not.
If all even columns in the even queue are not encrypted, step 110 is executed.
Step 110: and updating the iteration number and returning to the step 105.
If all even columns in the even queue are encrypted, step 111 is executed.
Step 111: connecting the output ciphertexts corresponding to the even columns to obtain even column ciphertexts;
step 112: and connecting the even column ciphertext with the odd column ciphertext to obtain the ciphertext of the video information to be encrypted.
Therefore, the invention effectively combines the strong security of the SM4 algorithm with the strong practicability of the selective video encryption algorithm, and improves the ciphertext feedback mode in the encryption technology in the SM4 algorithm, so that the video encryption algorithm has higher security and confidentiality and better meets the requirement of video safe real-time transmission.
The following describes a video encryption method based on SM4 according to the present invention with specific embodiments.
Because the encrypted plaintext is 128bit, the SM4 algorithm process can know that the Length of the encrypted plaintext is 128bit, and the Length of the working key K is 128bit, the SM 4-based video encryption method process comprises the following steps:
(1) dividing a binary data stream of video information to be encrypted into 2N 128-bit sequences, wherein the 2N 128-bit sequences are expressed as: a is1,a2,a3…a2N-1,a2N
Odd column bytes are selected in each 128-bit data stream to form an odd queue, and even column bytes are selected to form an even queue.
(2) Simple bitwise XOR operation is carried out on the data stream of the odd-numbered columns to obtain a ciphertext z1,z2…zn
(3) Then, a master key is randomly generated, and the encrypted master key is set as follows: MK ═ e (MK)0,MK1,MK2,MK3) In which MKi∈Z32,i=0,1,2,3;
Let Kj∈Z32,j=0,1,…,35,KjAs the working key, the round key is rki∈Z32,i=0,1,2,…31。FKiFor the corresponding system parameter, i is 0,1,2, … 31, i.e. FK (FK)0,FK1,FK2,FK3) For the encryption key KiPerforming the operation may result in:
Figure BDA0003063999410000061
namely, it is
Figure BDA0003063999410000062
Figure BDA0003063999410000063
Figure BDA0003063999410000064
And obtaining a round key and a working key during each round of encryption according to a formula II.
Wherein the formula CKiDenotes a fixed parameter, CKiThe obtained formula is: CK (CK)i=(cki,0,cki,1,cki,2,cki,3)∈(Z8)4I.e. CKiRepresents 4 8-bit data, cki,jRepresents a fixed parameter CKiWhere i is 0,1, …, 31; j is 0,1,2,3, cki,jThe generation method comprises the following steps: cki,j=(4i+j)×7(mod 256). In the formula II, the linear transformation L in the synthesis and replacement T is changed into L 'in the following formula to obtain T', the T is formed by compounding nonlinear transformation and linear transformation, and the input of the linear transformation is assumed to be B epsilon Z32And then:
Figure BDA0003063999410000071
the nonlinear transformation in T is embodied in a round robin operation by 4 parallel S-boxes, where each S-box is a permutation of a fixed 8-bit input and 8-bit output, denoted Sbox (). Let the input be A (a)0,a1,a2,a3)∈(Z8)4The output is B (B)0,b1,b2,b3)∈(Z8)4Then, then
B(b0,b1,b2,b3)=(Sbox(a0),Sbox(a1),Sbox(a2),Sbox(a3))。
The linear transformation in T is embodied in a round function as a shift operation and an exclusive or operation in an S-box. The input to the linear transformation is the output of the non-linear transformation. Let input be B e Z32The output is C ∈ Z32Then, then
Figure BDA0003063999410000072
And B is an output result of the encrypted data after the nonlinear transformation process.
Rk obtained by the above procedureiThe 1 st 128-bit data a of the dual queue by the SM4 algorithm1Encryption is carried out, and the encryption process comprises 32 rounds of round functions and a transformation operation in an inverted order. If a1=(a′0,a′1,a′2,a′3)∈Z32Let the round key be denoted rki∈Z32I is 0,1,2, …, 31. When the first round of encryption is carried out, the round key rk obtained for the first time in the previous step is used0Substituting into wheel function F to obtain a'4That is to say
Figure BDA0003063999410000073
Then a'4And the last three terms just entered, namely a'1,a′2,a′3As an input term for the next round of the function. Then the second round key rk is obtained1And is carried into the next round of the round of functions. The 32 rounds are recycled to finally obtain (a'32,a′33,a′34,a′35)∈(Z32)4Then, the ciphertext is subjected to inverse transform R, and the output ciphertext is assumed to be represented as (c'0,c′1,c′2,c′3)∈(Z32)4And performing reverse order transformation on the last round of data to obtain a ciphertext and outputting:
(c′0,c′1,c′2,c′3)=R(a′32,a′33,a′34,a′35)=(a′35,a′34,a′33,a′32) ④
let c1=(c′0,c′1,c′2,c′3) And indicates the encrypted ciphertext finally output. The 1 st 128-bit data a of the even queue1The encryption is complete.
(4) Encrypting by using the same flow in the step (3) to the 2 nd 128bit data a of the dual queue2Encrypting, the encryption process is the same as the data a of the dual queue in the step (3)1The encryption process is the same, and a ciphertext c is obtained after the encryption is finished2(ii) a And so on, the nth 128bit data a of the dual queuenEncrypted to obtain a ciphertext cnWhere N is a maximum of 2N. The final ciphertext data Q:
Q=c1+c2+…+cn+z1+z2+…+zn
the video information is encrypted by using the SM 4-based video encryption method, and related data information can be selectively encrypted according to the importance degree of video stream data. For example, the video stream data may be encrypted frame by frame, or only all format header information may be encrypted, or some important key information in the data may be selectively encrypted, etc.
Fig. 3 is a schematic structural diagram of a SM 4-based video encryption system according to the present invention, and as shown in fig. 3, a SM 4-based video encryption system according to the present invention includes:
a binary line-feed module 201, configured to convert video information to be encrypted into a binary data stream;
a number sequence dividing module 202, configured to divide the binary data stream into 2N 128-bit number sequences;
an odd-even queue obtaining module 203, configured to sort the rows, form odd rows into odd queues, and form even rows into even queues;
an odd-column ciphertext obtaining module 204, configured to divide every two adjacent bytes in each column in the odd queue into one group, and perform bitwise xor operation on each group to obtain an odd-column ciphertext;
a master key obtaining module 205 for randomly generating a master key, which is denoted as MK ═ MK (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits;
an encryption key obtaining module 206, configured to perform xor operation on each sub-element in the master key and the system parameter corresponding to each sub-element to obtain an encryption key; the encryption key is expressed as
Figure BDA0003063999410000081
Wherein, KiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters;
a round key obtaining module 207 configured to obtain a round key from the encryption key, where the round key is denoted by rki,i=0,1,2,…31;
The round key encryption module 208 is configured to encrypt an nth sequence in the even queue according to a round key based on the SM4 algorithm to obtain an nth output ciphertext;
a judging module 209, configured to judge whether each array in the even queue is encrypted;
a returning module 210, configured to update the iteration count if each even column in the even queue is not encrypted, and return to the master key obtaining module 205;
an even column ciphertext obtaining module 211, configured to connect output ciphertexts corresponding to each even column in the even pair of columns to obtain an even column ciphertext if each even column in the even queue is encrypted;
and a ciphertext obtaining module 212 of the video information to be encrypted, configured to connect the even-column ciphertext with the odd-column ciphertext to obtain a ciphertext of the video information to be encrypted.
The round key obtaining module 207 specifically includes:
according to the formula
Figure BDA0003063999410000091
Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
The round key encryption module 208 specifically includes:
the round function operation unit is used for carrying out 32 rounds of round function operations on the nth number of rows to obtain an nth initial ciphertext;
the ciphertext output unit is used for performing reverse order on the nth initial ciphertext to obtain the nth output ciphertext;
the round function operation unit specifically includes:
a round function operation subunit, configured to sequentially input the ith round of input data into a round function to obtain 32 rounds of output data, where the round function operation is expressed as:
Figure BDA0003063999410000092
Figure BDA0003063999410000093
an initial cipher text output subunit for outputting (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description.
The principles and embodiments of the present invention have been described herein using specific examples, which are provided only to help understand the method and the core concept of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed. In view of the above, the present disclosure should not be construed as limiting the invention.

Claims (8)

1. A video encryption method based on SM4, comprising:
converting video information to be encrypted into a binary data stream;
dividing the binary data stream into 2N 128-bit arrays;
sequencing each array, and forming odd arrays into odd arrays and even arrays into even arrays;
dividing every two adjacent bytes in each array in the odd array into a group, and carrying out bitwise XOR operation on each group to obtain an odd array ciphertext;
a master key is randomly generated, denoted MK ═ M (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits;
carrying out XOR operation on each subelement in the master key and the system parameter corresponding to each subelement to obtain an encryption key; the encryption key is represented by Ki=MKi⊕FKiWhich isIn, KiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters;
obtaining a round key from the encryption key, the round key being denoted rki,i=0,1,2,…31;
Based on the SM4 algorithm, encrypting the nth sequence in the even queue according to a round key to obtain an nth output ciphertext;
judging whether each array in the even queue is encrypted or not;
if not, updating the iteration number, returning to the step of randomly generating a master key, wherein the master key is represented as MK (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits ";
if so, connecting the output ciphertexts corresponding to each array in the even-pair array to obtain an even-array cipher text;
and connecting the even column ciphertext with the odd column ciphertext to obtain the ciphertext of the video information to be encrypted.
2. The SM 4-based video encryption method according to claim 1, wherein the obtaining a round key from the encryption key specifically comprises:
according to the formula rki=Ki+4=Ki⊕T′(Ki+1⊕Ki+2⊕Ki+3⊕CKi) Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
3. The SM 4-based video encryption method according to claim 1, wherein the encrypting an nth sequence of numbers in the even queue according to a round key based on the SM4 algorithm to obtain an nth output ciphertext specifically comprises:
performing 32 rounds of round function operation on the nth number of the arrays to obtain an nth initial ciphertext;
and performing reverse order on the nth initial ciphertext to obtain the nth output ciphertext.
4. The SM 4-based video encryption method according to claim 3, wherein the performing 32 rounds of round function operations on the nth number sequence to obtain the nth initial ciphertext specifically comprises:
sequentially inputting the ith round of input data into a round function to obtain 32 rounds of output data, wherein the round function operation is represented as: a'i+4=F(a′i⊕a′i+1⊕a′i+2⊕a′i+3⊕rki),i=0,1,2,…31;
Will be (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
5. A SM 4-based video encryption system, comprising:
the binary line-changing module is used for converting the video information to be encrypted into a binary data stream;
a number column dividing module, configured to divide the binary data stream into 2N 128-bit number columns;
the odd-even queue obtaining module is used for sequencing all the rows, forming odd rows into odd queues and forming even rows into even queues;
the odd-column ciphertext obtaining module is used for dividing every two adjacent bytes in each column in the odd queue into one group, and performing bitwise XOR operation on each group to obtain an odd-column ciphertext;
a master key obtaining module for randomly generating a master key, wherein the master key is expressed as MK ═ or (MK)0,MK1,MK2,MK3) MK denotes the master key, MKiRepresenting a sub-element, MK, in said master keyi∈Z32,i=0,1,2,3,Z32Data representing 32 bits;
the encryption key obtaining module is used for carrying out XOR operation on each subelement in the master key and the system parameters corresponding to each subelement to obtain an encryption key; the encryption keyIs represented by Ki=MKi⊕FKiWherein, K isiRepresenting an encryption key, FKiRepresents MKiCorresponding system parameters;
a round key obtaining module for obtaining a round key according to the encryption key, the round key being expressed as rki,i=0,1,2,…31;
The round key encryption module is used for encrypting the nth sequence in the even queue according to the round key based on the SM4 algorithm to obtain the nth output ciphertext;
the judging module is used for judging whether all the arrays in the even queue are encrypted or not;
a return module, configured to update the iteration times if all even columns in the even queue are not encrypted, and return to the master key obtaining module;
an even column ciphertext obtaining module, configured to connect output ciphertexts corresponding to each even column in the even pair of columns to obtain an even column ciphertext if each even column in the even queue is encrypted;
and the ciphertext obtaining module is used for connecting the even column ciphertext with the odd column ciphertext to obtain the ciphertext of the video information to be encrypted.
6. The SM 4-based video encryption system according to claim 5, wherein the round key obtaining module specifically comprises:
according to the formula rki=Ki+4=Ki⊕T′(Ki+1⊕Ki+2⊕Ki+3⊕CKi) Calculating the ith round key, i ═ 0,1,2, … 31, where CKiRepresenting a fixed parameter and T' a synthetic permutation in the round function.
7. The SM 4-based video encryption system according to claim 5, wherein the round key encryption module specifically comprises:
the round function operation unit is used for carrying out 32 rounds of round function operations on the nth number of rows to obtain an nth initial ciphertext;
and the ciphertext output unit is used for performing reverse order on the nth initial ciphertext to obtain the nth output ciphertext.
8. The SM 4-based video encryption system according to claim 7, wherein the round function operation unit specifically includes:
a round function operation subunit, configured to sequentially input the ith round of input data into a round function to obtain 32 rounds of output data, where the round function operation is expressed as: a'i+4=F(a′i⊕a′i+1⊕a′i+2⊕a′i+3⊕rki),i=0,1,2,…31;
An initial cipher text output subunit for outputting (a'32,a′33,a′34,a′35) As the nth initial ciphertext.
CN202110521070.1A 2021-05-13 2021-05-13 SM 4-based video encryption method and system Pending CN113259719A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110521070.1A CN113259719A (en) 2021-05-13 2021-05-13 SM 4-based video encryption method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110521070.1A CN113259719A (en) 2021-05-13 2021-05-13 SM 4-based video encryption method and system

Publications (1)

Publication Number Publication Date
CN113259719A true CN113259719A (en) 2021-08-13

Family

ID=77181627

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110521070.1A Pending CN113259719A (en) 2021-05-13 2021-05-13 SM 4-based video encryption method and system

Country Status (1)

Country Link
CN (1) CN113259719A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117411618A (en) * 2023-12-07 2024-01-16 杭州城市大脑有限公司 Key generation method, device and encryption method applied to international event

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100064139A1 (en) * 2008-09-10 2010-03-11 Dolby Laboratories Licensing Corporation System and method of extending marking information in content distribution
CN103607272A (en) * 2013-11-26 2014-02-26 曙光信息产业股份有限公司 Video encryption method
CN105490802A (en) * 2015-11-27 2016-04-13 桂林电子科技大学 Improved SM4 parallel encryption and decryption communication method based on GPU (Graphics Processing Unit)
CN108882030A (en) * 2018-06-12 2018-11-23 成都三零凯天通信实业有限公司 A kind of monitor video classification encryption and decryption method and system based on time-domain information
CN110311771A (en) * 2018-03-20 2019-10-08 北京松果电子有限公司 SM4 encipher-decipher method and circuit
CN110427762A (en) * 2019-07-23 2019-11-08 湖南匡安网络技术有限公司 A kind of encryption and decryption approaches for realizing the transmission of electric power monitoring system Video security
CN112118097A (en) * 2020-09-07 2020-12-22 昆明理工大学 Symmetric key encryption algorithm

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100064139A1 (en) * 2008-09-10 2010-03-11 Dolby Laboratories Licensing Corporation System and method of extending marking information in content distribution
CN103607272A (en) * 2013-11-26 2014-02-26 曙光信息产业股份有限公司 Video encryption method
CN105490802A (en) * 2015-11-27 2016-04-13 桂林电子科技大学 Improved SM4 parallel encryption and decryption communication method based on GPU (Graphics Processing Unit)
CN110311771A (en) * 2018-03-20 2019-10-08 北京松果电子有限公司 SM4 encipher-decipher method and circuit
CN108882030A (en) * 2018-06-12 2018-11-23 成都三零凯天通信实业有限公司 A kind of monitor video classification encryption and decryption method and system based on time-domain information
CN110427762A (en) * 2019-07-23 2019-11-08 湖南匡安网络技术有限公司 A kind of encryption and decryption approaches for realizing the transmission of electric power monitoring system Video security
CN112118097A (en) * 2020-09-07 2020-12-22 昆明理工大学 Symmetric key encryption algorithm

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
袁志民: "《基于SM4的选择性视频加密算法》", 《通信技术》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117411618A (en) * 2023-12-07 2024-01-16 杭州城市大脑有限公司 Key generation method, device and encryption method applied to international event
CN117411618B (en) * 2023-12-07 2024-02-20 杭州城市大脑有限公司 Key generation method, device and encryption method applied to international event

Similar Documents

Publication Publication Date Title
US5745577A (en) Symmetric cryptographic system for data encryption
Sajisha et al. An encryption based on DNA cryptography and steganography
JPH0863097A (en) Method and system for symmetric encoding for encoding of data
JP5141558B2 (en) Common key block encryption apparatus, method thereof, program thereof, and recording medium
US8000471B2 (en) Robust cipher design
CN110880967B (en) Method for parallel encryption and decryption of multiple messages by adopting packet symmetric key algorithm
Wu et al. Dynamic and implicit latin square doubly stochastic s-boxes with reversibility
Gehlot et al. Implementation of Modified Twofish Algorithm using 128 and 192-bit keys on VHDL
CN113259719A (en) SM 4-based video encryption method and system
CN113746622A (en) Lightweight grouped text encryption method based on double two-dimensional chaotic system
Luykx et al. Optimal forgeries against polynomial-based MACs and GCM
Mersaid et al. The encryption algorithm AES-RFWKIDEA32-1 based on network RFWKIDEA32-1
Hussain et al. Efficient video encryption using lightweight cryptography algorithm
Pal et al. Design of strong cryptographic schemes based on Latin squares
Patel et al. Hybrid security algorithms for data transmission using AES-DES
CN107493164B (en) DES encryption method and system based on chaotic system
Salameh A new symmetric-key block ciphering algorithm
CN115459950A (en) Iterative encryption method and device
Andonov et al. Application of machine learning in DES cryptanalysis
Al-Hamami et al. A proposed modified data encryption standard algorithm by using fusing data technique
Luo et al. The Pseudorandomness of Many-Round Lai-Massey Scheme.
WO2012060685A1 (en) A method for linear transformation in substitution-permutation network symmetric-key block cipher
Mirsaid et al. The encryption algorithm AES-RFWKPES32-4
Al-Sabaawi Cryptanalysis of Stream Cipher: Method Implementation
JP2001016197A (en) Self-synchronized stream enciphering system and mac generating method using the same

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20210813