Method and apparatus for video stream encryption and decryption

By encrypting the video data frame header and inserting a custom frame flag code and a random number before the frame header, and utilizing SM4's CBC mode, the problem of high computational complexity in existing technologies is solved, achieving fast decryption and efficient encryption.

CN116668743BActive Publication Date: 2026-05-19CHINA RAILWAY ERYUAN ENGINEERING GROUP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA RAILWAY ERYUAN ENGINEERING GROUP CO LTD
Filing Date
2023-05-17
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing video data encryption methods encrypt the entire packet data, resulting in high computational complexity and thus imposing a huge computational burden on decryption.

Method used

Encryption is applied only to the frame headers of the video data, and a custom frame flag code and a random number are inserted before the frame header. Encryption is performed using SM4's CBC mode to reduce computational load.

Benefits of technology

By encrypting the frame header and quickly retrieving and decrypting it, the computational burden is reduced and the encryption and decryption efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116668743B_ABST
    Figure CN116668743B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of video monitoring, and particularly relates to a video stream encryption and decryption method and device. The method comprises the following steps: obtaining video stream data to be encrypted, wherein the video stream comprises a plurality of messages, and the messages comprise a standard frame header and frame data; the standard frame header is encrypted to obtain an encrypted frame header, and a custom frame flag code is inserted in the message, wherein the custom frame flag code and the encrypted frame header constitute encrypted information, and the encrypted information in each message is not repeated. The encryption method of the present application only changes the frame header of the video data, encrypts the frame header, does not increase the number of frames, can quickly search the special frame header, decrypts, is simple to operate, and reduces the calculation pressure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of video surveillance technology, and to a method and apparatus for encrypting and decrypting video streams. Background Technology

[0002] With the rapid development of wireless sensing technology and the increasing prevalence of networks, video transmission is being used more and more widely. Ensuring that video data is not stolen or tampered with in such networks, and guaranteeing the security of video transmission, has become an urgent problem to be solved. Security monitoring video data often uses H.264 and H.265 encoding, and the security of video stream data transmitted over the public network has always been a key concern. In traditional encryption approaches, to achieve a completely undecoding effect, multiple parts of the packet structure are encrypted. While this ensures "not completely recoverable," it does not guarantee "completely unrecoverable." Current technologies tend to encrypt the entire packet data, resulting in high computational complexity for encryption / decryption. When there are many encrypted video channels, this places a significant computational burden on the central decryption end. Summary of the Invention

[0003] To address the problem that existing encryption methods encrypt the entire packet data, resulting in high computational complexity for encryption or decryption and placing significant pressure on decryption, this paper proposes a method and apparatus for video stream encryption and decryption. This method encrypts only the frame headers of the video data without increasing the number of frames, thus enabling rapid retrieval of the specific frame headers for decryption. This reduces computational load and improves encryption and decryption efficiency.

[0004] To achieve the above objectives, the following technical solutions are provided:

[0005] A video stream encryption method includes the following steps:

[0006] Obtain the video stream data to be encrypted, wherein the video stream includes several messages, and the messages include a standard frame header and intra-frame data;

[0007] The standard frame header is encrypted to obtain an encrypted frame header, and a custom frame flag code is inserted into the message. The custom frame flag code and the encrypted frame header constitute encrypted information, and the encrypted information in each message is unique.

[0008] As a specific implementation, a custom frame flag code is inserted by shifting the offset in the message, with the position of the encrypted frame header as a reference.

[0009] As a specific embodiment, a custom frame flag code is inserted before or after the encrypted frame header.

[0010] As a specific embodiment, the method also includes randomly inserting a password into the intra-frame data.

[0011] As a specific embodiment, the encryption method further includes adding a random number to the encrypted information, the random number being inserted between a custom frame flag code and the encrypted frame header.

[0012] Based on the same concept, a video stream decryption method is also proposed, including the following steps:

[0013] Obtain an encrypted video stream, wherein the encrypted video stream is encrypted using any of the aforementioned video stream encryption methods;

[0014] The custom frame flag code is deleted from the encrypted video stream, and the encrypted frame header is decrypted to obtain the standard frame header.

[0015] As a specific embodiment, it further includes: if the encrypted information contains a random number, then deleting the random number from the encrypted information.

[0016] As a specific embodiment, it further includes: if there is a randomly inserted password in the intra-frame data, then the randomly inserted password in the intra-frame data is deleted.

[0017] Based on the same concept, a device for encrypting video streams is also proposed, including a video acquisition module and an encryption control module. The output of the video acquisition module is connected to the input of the encryption control module. The video acquisition module is used to output video stream data to be encrypted to the encryption control module. The encryption control module is used to execute the aforementioned video stream encryption method to encrypt the video stream based on the received video stream data to be encrypted.

[0018] Based on the same concept, a video stream decryption device is also proposed, including a receiving terminal and a decryption control module. The output of the receiving terminal is connected to the input of the decryption control module. The receiving terminal is used to acquire the encrypted video stream and output the encrypted video stream to the decryption control module. The decryption control module is used to execute the aforementioned video stream decryption method according to the received encrypted video stream to decrypt the video stream.

[0019] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0020] The encryption method of the present invention only changes the frame header of the video data and encrypts the frame header without increasing the number of frames. It can quickly retrieve the special frame header and decrypt it. The operation is simple and reduces the computational burden. Attached Figure Description

[0021] Figure 1 This is a flowchart of a video stream encryption method according to Embodiment 1 of the present invention;

[0022] Figure 2 This is a diagram illustrating the data structure before and after encryption of the video stream in Embodiment 1 of the present invention. Detailed Implementation

[0023] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0024] In the description of this invention, it should be understood that the terms "longitudinal", "lateral", "up", "down", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.

[0025] In the description of this invention, unless otherwise specified and limited, it should be noted that the terms "installation", "connection" and "linking" should be interpreted broadly. For example, they can refer to mechanical or electrical connections, or internal connections between two components. They can be direct connections or indirect connections through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms according to the specific circumstances.

[0026] Example 1

[0027] A video stream encryption method, flowchart as follows Figure 1 As shown, it includes the following steps:

[0028] Obtain the video stream data to be encrypted, wherein the video stream includes several messages, and the messages include standard frame headers and intra-frame data;

[0029] The standard frame header is encrypted to obtain an encrypted frame header, and a custom frame flag code is inserted before the encrypted frame header. The encrypted information consisting of the custom frame flag code and the encrypted frame header is unique.

[0030] Furthermore, after inserting a custom frame flag code, fake encryption codes are randomly inserted into the frame data. Randomly inserting fake encryption codes into the frame data increases the workload for attackers, making cracking more difficult and thus improving security.

[0031] Furthermore, the custom frame flag code is in plaintext. This results in a simple structure that is easy to use.

[0032] Furthermore, the existing standard frame header is encrypted using SM4's CBC mode. SM4's CBC mode is simple to operate and easy to use. CBC mode encryption can repeatedly encrypt a limited number of frame header data types, resulting in different random numbers for each encrypted data point.

[0033] Furthermore, a random number is inserted between the custom frame flag code and the encrypted frame header. Inserting a random number enhances encryption reliability and is simple to use.

[0034] The present invention also provides a method for decrypting video streams, comprising the following steps:

[0035] Receive encrypted video stream data, search for and delete custom frame flag codes;

[0036] Decrypt the encrypted frame header and restore the standard frame header.

[0037] This decryption method corresponds to the encryption method, is simple to operate, and is easy to use.

[0038] Furthermore, when decrypting and restoring the standard frame header, the inserted random number and the fake encryption codes randomly inserted into the frame data are directly discarded.

[0039] When the decryption and recovery process reveals a fake frame header, the frame header is discarded directly for ease of operation.

[0040] The present invention also provides an apparatus for encrypting video streams, including a video acquisition module and an encryption control module. The output terminal of the video acquisition module is connected to the input terminal of the encryption control module. The control module executes the encryption method described in the present invention to encrypt the video stream.

[0041] The device uses an encryption control module to encrypt the captured video, and has a simple structure that is easy to use.

[0042] The present invention also provides an apparatus for decrypting video streams, including a receiving terminal and a decoding control module. The input end of the decoding control module is connected to the output end of the receiving terminal. The decoding control module receives encrypted video stream data from the receiving terminal and executes the decryption method described in the present invention to decrypt the video stream.

[0043] The device decrypts encrypted videos through a decoding control module, making it simple to operate and easy to use.

[0044] Furthermore, it also includes a wireless transmission module, through which the decryption control module connects to the receiving terminal. The encrypted video stream data is obtained wirelessly using the wireless transmission module. The wireless transmission module can be, but is limited to, communication modules such as Zigbee or Wi-Fi.

[0045] This invention encrypts all frame header identifiers. Although the data inside is not encrypted, the missing frame identifier information prevents others from knowing the location of the I-frame and thus from decoding the encrypted video. It is also simple to operate and reduces computational burden.

[0046] Example 2

[0047] Example 2, based on the principle of Example 1, provides a specific method for encrypting video streams. It encrypts all frame header identifiers of H.265. Although the intra-frame data is not encrypted, the missing frame identifier information makes it impossible to determine the location of the I-frame, thus preventing decoding. The encryption method of this scheme includes the following steps:

[0048] Obtain the video stream data to be encrypted, and insert a custom frame flag code into the standard frame header of the video stream (such as a H.265 stream). Preferably, the custom frame flag code is plaintext. The specific custom frame flag can be arbitrarily specified. For example, the H.264 encoded frame flag can be used: 00 00 00 01, followed by the frame type.

[0049] The insertion point can be placed before the actual standard frame header, or it can be inserted randomly, such as at a random offset position in the standard frame header. This offset can then be encrypted for later use in finding the true frame flag position. More preferably, after inserting a custom frame flag code, a fake encryption code can be randomly inserted into the data content to increase the workload for the attacker. When decryption and recovery reveal a fake frame header, the header can be discarded directly for easier processing.

[0050] The original frame flags of the video stream are encrypted to obtain encrypted frame headers, ensuring they are not duplicated and eliminating frame type information. During decryption, the custom frame flag code is searched for, and then the original frame flags are decrypted to restore the frame flags.

[0051] The types of frame flags are limited. To prevent ciphertext repetition, the preferred method is to use SM4's CBC mode (Cipher Block Chaining mode, where the plaintext block is first XORed with the previous ciphertext block before encryption) to encrypt the existing frame flags. A random number is inserted between the custom frame flag code and the encrypted pseudo-frame header. An 8-bit initialization vector is defined from a 32-bit random number. This 32-bit random number is sent to the receiver along with the message. The 8-bit initialization vector can be customized from these 32 bits, offering flexibility. This random number is the initial random number required for CBC encryption, ensuring that the encryption result is different for the same data segment (frame flag) each time because the initial random number is different.

[0052] The method of this invention is to encrypt the frame flag. The encryption computation is very small. After encryption, if the entire data stream is disordered, the thief will be completely unable to carry out the decoding work.

[0053] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0054] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A video stream encryption method, characterized in that, Includes the following steps: Obtain the video stream data to be encrypted, wherein the video stream includes several messages, and the messages include a standard frame header and intra-frame data; The standard frame header is encrypted to obtain an encrypted frame header, and a custom frame flag code is inserted into the message. The custom frame flag code and the encrypted frame header constitute encrypted information, and the encrypted information in each message is unique. Using the position of the encrypted frame header as a reference, a custom frame flag code is inserted by shifting the offset within the message; The offset is then encrypted again to retrieve the location of the actual custom frame identifier code.

2. The video stream encryption method as described in claim 1, characterized in that, Insert a custom frame flag code before or after the encrypted frame header.

3. The video stream encryption method as described in claim 1, characterized in that, It also includes randomly inserting passwords into the intraframe data.

4. A video stream encryption method as described in any one of claims 1-3, characterized in that, The encryption method also includes adding a random number to the encrypted information, the random number being inserted between a custom frame flag code and the encrypted frame header.

5. A video stream decryption method, characterized in that, Includes the following steps: Obtain an encrypted video stream, wherein the encrypted video stream is encrypted using a video stream encryption method according to any one of claims 1-3; The custom frame flag code is deleted from the encrypted video stream, and the encrypted frame header is decrypted to obtain the standard frame header.

6. The video stream decryption method as described in claim 5, characterized in that, Also includes: If the encrypted information contains a random number, then the random number in the encrypted information is also deleted.

7. The video stream decryption method as described in claim 6, characterized in that, Also includes: If the intraframe data contains randomly inserted passwords, the randomly inserted passwords in the intraframe data are also deleted.

8. A device for encrypting video streams, characterized in that, The device includes a video acquisition module and an encryption control module. The output of the video acquisition module is connected to the input of the encryption control module. The video acquisition module is used to output video stream data to be encrypted to the encryption control module. The encryption control module is used to perform video stream encryption according to any one of claims 1-4 based on the received video stream data to be encrypted.

9. A video stream decryption device, characterized in that, The device includes a receiving terminal and a decryption control module. The output of the receiving terminal is connected to the input of the decryption control module. The receiving terminal is used to acquire an encrypted video stream and output the encrypted video stream to the decryption control module. The decryption control module is used to perform a video stream decryption method as described in any one of claims 5-7 based on the received encrypted video stream.