Data encryption and decryption method and device, chip, electronic equipment and storage medium
By determining the encryption level using the macroblock encoding information of the video frame and selecting the target video frame for encryption processing, the power consumption and delay increase caused by the encryption of video frame data in the prior art is solved, and a video frame encryption effect with high security and low power consumption is achieved.
Patent Information
- Application Number
- CN202311391574.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-24
- Publication Date
- 2025-04-25
AI Technical Summary
When encrypting video frame data, the prior art usually adopts a full encryption scheme, which leads to an increase in power consumption and an increase in delay of electronic devices, and some video frame data are easily decrypted and restored after encryption, affecting encryption security.
The encryption level of each video frame is determined by the macroblock encoding information of the video frame, and the target video frame with an encryption level higher than the preset threshold is selected for encryption processing, and the encryption is carried out in combination with the Advanced Encryption Standard (AES) algorithm.
It realizes a more accurate evaluation of the encryption value of video frames, and selects some video frames with high encryption levels for encryption, taking into account the security and low power consumption of video frame encryption.
Smart Images

Figure CN119893214A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of data encryption technology, and more specifically, to a data encryption and decryption method and device, a chip, an electronic device, and a storage medium. Background Art
[0002] With the continuous development of Internet technology, more and more audio and video applications are widely used in various fields, such as video conferencing, live webcasting, online education, etc. However, the data involved in these video applications often needs to be transmitted on the network, and data transmission on the network is easy to be eavesdropped and intercepted, which poses a great threat to the security of video data. Therefore, audio and video stream encryption technology came into being, which can encrypt and protect video and audio data, and effectively protect the security of audio and video data during transmission on the network.
[0003] Therefore, how to encrypt video frame data effectively and quickly is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a data encryption and decryption method and device, a chip, an electronic device, and a storage medium. The following introduces various aspects involved in the embodiments of the present application.
[0005] In a first aspect, a data encryption method is provided, which is applied to a first electronic device, and the method includes: obtaining a data frame to be encrypted, the data frame to be encrypted includes multiple video frames; determining an encryption level of each video frame in the multiple video frames based on macroblock coding information of the multiple video frames; determining a target video frame based on the encryption level of each video frame, the encryption level of the target video frame being greater than a preset encryption level threshold; and encrypting the target video frame.
[0006] In a second aspect, a data decryption method is provided, which is applied to a second electronic device, and the method includes: receiving an encrypted data packet from a peer device of the second electronic device, wherein the encrypted data packet is a data packet encrypted according to the data encryption method described in the first aspect; determining an encrypted data frame in the encrypted data packet; and decrypting the encrypted data frame.
[0007] According to a third aspect, a data encryption device is provided, which is applied to a first electronic device, and comprises: an acquisition module, used to obtain data frames to be encrypted, wherein the data frames to be encrypted comprise multiple video frames; an encryption module, used to perform the following operations: determining an encryption level of each video frame in the multiple video frames according to macroblock coding information of the multiple video frames; determining a target video frame according to the encryption level of each video frame; and encrypting the target video frame, wherein the encryption level of the target video frame is greater than a preset encryption level threshold.
[0008] In a fourth aspect, a data decryption device is provided, which is applied to a second electronic device, and the device includes: a receiving module, which is used to receive an encrypted data packet from a peer device of the second electronic device, and the encrypted data packet is a data packet encrypted according to the data encryption method described in the first aspect; a decryption module, which is used to determine an encrypted data frame in the encrypted data packet and decrypt the encrypted data frame.
[0009] In a fifth aspect, a chip is provided, comprising: a processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes the method described in the first aspect or the second aspect.
[0010] In a sixth aspect, an electronic device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to control the electronic device to execute the method described in the first aspect or the second aspect.
[0011] In a seventh aspect, a computer-readable storage medium is provided, on which executable code is stored. When the executable code is executed, the method as described in the first aspect or the second aspect can be implemented.
[0012] The embodiment of the present application provides a data encryption method, including: obtaining a data frame to be encrypted, the data frame to be encrypted includes multiple video frames; determining the encryption level of each video frame in the multiple video frames according to the macroblock coding information of the multiple video frames; determining the target video frame according to the encryption level of each video frame, the encryption level of the target video frame is greater than the preset encryption level threshold; encrypting the target video frame. This scheme determines the encryption level of the video frame through the macroblock coding information of the video frame, and can more accurately evaluate the encryption value of the video frame, and then selects some video frames with relatively high encryption levels from the multiple video frames for encryption processing, thereby helping to balance the security and low power consumption of video frame encryption. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a flowchart of a data encryption method provided in one embodiment of the present application.
[0014] Figure 2 It is a structural diagram of a data encryption system provided in one embodiment of the present application.
[0015] Figure 3 It is a flowchart of a data encryption method provided by another embodiment of the present application.
[0016] Figure 4 It is a schematic diagram of the format of a coding frame provided in an embodiment of the present application.
[0017] Figure 5 for Figure 4 FIG. 4 is a schematic diagram of the format of the extended identification byte shown in FIG.
[0018] Figure 6 It is a flowchart of a data decryption method provided in one embodiment of the present application.
[0019] Figure 7 It is a structural diagram of a data encryption device provided in one embodiment of the present application.
[0020] Figure 8 It is a structural diagram of a data decryption device provided in one embodiment of the present application.
[0021] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0023] It should be noted that the electronic device in the embodiment of the present application can be a device with a data transmission function. The electronic device can be, for example: a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, or a wireless terminal in smart home, a smart large screen, etc. This application does not make specific restrictions on this.
[0024] With the continuous development of Internet technology, more and more audio and video applications are widely used in various fields, such as video conferencing, live webcasting, online education, etc. However, the data involved in these video applications often needs to be transmitted on the network, and data transmission on the network is easy to be eavesdropped and intercepted, which poses a great threat to the security of video data. Therefore, audio and video stream encryption technology came into being, which can encrypt and protect video and audio data, and effectively protect the security of audio and video data during transmission on the network.
[0025] At present, the mainstream method of encrypting video frame data is to fully encrypt all video frames, which will cause an increase in power consumption and delay of electronic devices. In related technologies, encryption schemes for partial video frame data have also been proposed, but they are easily decrypted and restored, affecting the security of encryption.
[0026] Therefore, how to encrypt video frame data effectively and quickly is a technical problem that needs to be solved urgently.
[0027] In response to the above problems, an embodiment of the present application provides a data encryption method, including: obtaining a data frame to be encrypted, the data frame to be encrypted includes multiple video frames; determining the encryption level of each video frame in the multiple video frames according to the macroblock coding information of the multiple video frames; determining a target video frame according to the encryption level of each video frame, the encryption level of the target video frame being greater than a preset encryption level threshold; encrypting the target video frame. This solution determines the encryption level of the video frame through the macroblock coding information of the video frame, and can more accurately evaluate the encryption value of the video frame, and then selects some video frames with relatively high encryption levels from the multiple video frames for encryption processing, thereby helping to balance the security and low power consumption of video frame encryption.
[0028] Combined with the following Figure 1 The data encryption method in the embodiment of the present application is described in detail. Figure 1 As shown, the data encryption method 100 can be used for a first electronic device. It should be understood that the first electronic device can be any type of electronic device mentioned above. The data encryption method 100 can include steps: S110 to S140.
[0029] In step S110, a data frame to be encrypted is obtained, wherein the data frame to be encrypted may include multiple video frames.
[0030] The data frame to be encrypted may be audio and video frame data. In some embodiments, the data frame to be encrypted may be acquired by camera acquisition. The audio and video frame data may include audio frame data (which may be referred to as audio frame for short) and video frame data (which may be referred to as video frame for short).
[0031] In some embodiments, the plurality of video frames may refer to a continuous sequence of video frames.
[0032] In step S120, the encryption level of each video frame in the plurality of video frames is determined according to the macroblock coding information of the plurality of video frames.
[0033] In some embodiments, the macroblock encoding information includes one or more of the following parameters: the number of intra-frame macroblocks, the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks, and the intra-frame macroblock quantization parameter.
[0034] In some embodiments, the macroblock encoding information may include the number of macroblocks within a frame, the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, and a quantization parameter of the macroblocks within a frame. Determining the encryption level of each video frame in a plurality of video frames based on the macroblock encoding information of the plurality of video frames may include: determining the encryption level of each video frame based on the number of macroblocks within a frame, the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, and the quantization parameter of the macroblocks within a frame in each video frame, as well as a mapping relationship between the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, the quantization parameter of the macroblocks within a frame and the encryption level.
[0035] The embodiment of the present application provides a mapping relationship between the number of macroblocks within a frame, the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, and the quantization parameter of the macroblocks within a frame and the encryption level, that is, the encryption level D of each video frame score for:
[0036]
[0037] Wherein, δ is a normalization coefficient, X is the number of macroblocks in a frame (i.e., the total number of macroblocks in a frame), Y is the number of reference macroblocks in a frame, Z is the number of referenced macroblocks in a frame, and Q is the quantization parameter of the macroblocks in a frame, 0≤Q≤51. The quantization parameter Q of the macroblocks in a frame may refer to the degree of encoding compression of the video frame. When Q is 0, it indicates that the quantization is the finest (i.e., no compression is performed on the original video frame); when Q is 51, it indicates that the quantization is the coarsest (i.e., the original video frame is compressed to the maximum extent). In some embodiments, the encryption level D of each video frame may be set to the value of the encryption level D of the video frame. score Normalized to [0, 100], at this time, the normalization coefficient δ is 50.
[0038] As an example, if the normalization coefficient δ is 50 and the intra-frame macroblock quantization parameter Q is a fixed value of 51, when the number of intra-frame reference macroblocks Y is equal to the number of intra-frame macroblocks X, and the number of intra-frame referenced macroblocks Z is 0, the encryption level of the video frame is 0 (the lowest encryption level); when the number of intra-frame reference macroblocks Y is 0, and the number of intra-frame referenced macroblocks Z is equal to the number of intra-frame macroblocks X, the encryption level of the video frame is 100 (the highest encryption level). According to the above content, it can be seen that under a certain coding compression rate, the more referenced macroblocks in a frame, the stronger the correlation between the video frame and other frames, so the encryption value of such a video frame is relatively high.
[0039] In some embodiments, the intra-frame reference macroblock may include a forward reference macroblock (Predicted MacroBlock) and a bidirectional reference macroblock (Bidirectional Macro Block) in the frame, and therefore, the number of intra-frame reference macroblocks includes the number of forward reference macroblocks and the number of bidirectional reference macroblocks in the frame. The referenced macroblocks in the frame may include one or more of the following macroblocks: a forward reference macroblock, a bidirectional reference macroblock, and an intra-coded macroblock (Intra-coded Macro Block) in the frame. In other words, the forward reference macroblock, the bidirectional reference macroblock, and the intra-coded macroblock in the frame may all become referenced macroblocks. Among them, the intra-coded macroblock may also be called a key macroblock, the intra-coded macroblock may be referred to as an I macroblock, the forward reference macroblock may be referred to as a P macroblock, and the bidirectional reference macroblock may be referred to as a B macroblock.
[0040] In step S130, a target video frame is determined according to the encryption level of each video frame, and the encryption level of the target video frame is greater than a preset encryption level threshold.
[0041] The preset encryption level threshold can be set according to the demand, for example, the preset encryption level threshold can be set to 25. That is to say, the present application mainly selects some video frames with relatively high encryption value from multiple video frames, so as to effectively resist the cracking recovery capability. Since only some video frames are encrypted, the power consumption of electronic devices can be reduced and the data transmission delay can be reduced.
[0042] In some embodiments, in order to ensure low power consumption and low latency of electronic devices, the number of target video frames selected in the embodiments of the present application can also be adjusted according to the current amount of encrypted video frames, that is, the preset encryption level threshold is updated according to the current amount of encrypted video frames; the target video frame is determined according to the encryption level of each video frame and the updated preset encryption level threshold; wherein the encryption level of the target video frame is greater than the updated preset encryption level threshold.
[0043] In some embodiments, if the current encrypted video frame amount is greater than the target encrypted video frame amount, the preset encryption level threshold is increased; or, if the current encrypted video frame amount is less than the target encrypted video frame amount, the preset encryption level threshold is lowered. The target encrypted video frame amount may refer to the percentage of the target encrypted video frame amount to the total video frame amount. For example, the target encrypted video frame amount may be set to 50. When the target encrypted video frame amount is 50, it means that half of the video frames need to be selected from multiple video frames for encryption. The encrypted video frame amount may refer to the percentage of the current encrypted video frame amount to the total video frame amount. The target encrypted video frame amount may be set as required, and this application does not impose any specific restrictions on this.
[0044] In some embodiments, a video frame may include a key frame and a non-key frame, wherein the key frame is an intra-coded frame, and the non-key frame includes a predicted frame and a bidirectional frame. The intra-coded frame may be referred to as an I frame, the predicted frame may be referred to as a P frame, and the bidirectional frame may be referred to as a B frame. Generally, an I frame is an independent frame and does not rely on information from other frames. An I frame contains complete image information and can be decoded independently, and an I frame is usually a reference frame, so the key frame in the video frame needs to be encrypted, and the encryption level of the I frame may be set to the highest. Then, the encryption level of the video frames in the non-key frames is evaluated, and a target non-key video frame with a relatively high encryption value is selected from the non-key frames. The encryption level of the target non-key frame is greater than a preset encryption level threshold, and the target video frame includes a key frame and a target non-key frame.
[0045] In some embodiments, the encryption level of each video frame may also be determined based on the number of times a macroblock in each video frame is referenced. The number of times a macroblock in a video frame is referenced may refer to the average number of times all macroblocks in the video frame are referenced. The more times a macroblock in a frame is referenced, the stronger the correlation of the video frame is, and the higher the encryption value of the video frame is.
[0046] In some embodiments, the encryption level of each video frame can be determined based on the number of times a macroblock in each video frame is referenced, and the mapping relationship between the number of times a macroblock in a frame is referenced and the encryption level of the video frame. In some embodiments, the encryption level can be normalized so that the range of the encryption level is [0, 100]. The normalization coefficient can be set according to the requirements, and this application does not impose specific restrictions on this.
[0047] In step S140, the target video frame is encrypted.
[0048] According to the above description, it can be seen that this scheme determines the encryption level of the video frame through the macroblock encoding information of the video frame, which can more accurately evaluate the encryption value of the video frame, and then select some video frames with relatively high encryption levels from multiple video frames for encryption processing, thereby helping to balance the security and low power consumption of video frame encryption.
[0049] In some embodiments, encrypting the target video frame may include: encrypting the target video frame using an advanced encryption standard (AES) algorithm.
[0050] In some embodiments, before the target video frame is encrypted using the Advanced Encryption Standard algorithm, an extended identification field may be inserted before the encrypted data of the target video frame, and the extended identification field includes an encryption flag, so that the video frame to be encrypted can be easily identified. The extended indication field may occupy one byte.
[0051] In some embodiments, a random initialization vector may be inserted between the extension identification field and the encrypted data. The encryption reliability may be improved by inserting the random initialization vector. The random initialization vector may occupy 16 bytes.
[0052] In some embodiments, the advanced encryption standard algorithm includes an output feedback mode, a counter mode, a cipher feedback mode, an electronic code book mode, and a cipher block chaining mode. Then, the encryption mode flag bit can be configured in the extended identification field, and the encryption mode flag bit is used to mark any one of the following encryption modes: output feedback mode (OFB), counter mode (CTR), cipher feed back mode (CFB), electronic code book mode (ECB), and cipher block chaining mode (CBC). It can be understood that the encryption flag bit can occupy 1 bit, and the encryption mode flag bit can use 3 bits (which can represent 8 modes) to represent the above five encryption modes. The other remaining bits in the extended representation field can be used as a backup.
[0053] In some embodiments, encrypting a target video frame may include: encrypting the target video frame and parameter sets of multiple video frames; wherein the parameter sets of multiple video frames include video parameter sets (VPS), sequence parameter sets (SPS) and picture parameter sets (PPS) of multiple video frames.
[0054] In some embodiments, after obtaining the data frame to be encrypted, multiple video frames may be encoded to obtain macroblock encoding information of the multiple video frames.
[0055] In some embodiments, the data frame to be encrypted includes multiple audio frames, and the multiple audio frames can also be encoded to obtain multiple perception information of the multiple audio frames, and the multiple perception information is used to indicate the encryption level of each audio frame in the multiple audio frames; then, according to the multiple perception information, a target audio frame is determined, and the encryption level of the target audio frame is greater than a preset encryption level threshold. In some embodiments, in the process of encoding the audio data frame using the encoding module, the encoding module can determine a more important audio frame.
[0056] In some embodiments, the target audio frame can be determined based on multiple perception information and the mapping relationship between the perception information and the encryption level. The present application can normalize the encryption level so that the encryption level of the audio frame is [0, 100]. The normalization parameter can be set according to the requirements.
[0057] In some embodiments, after the encrypted data frame is encrypted, the encrypted multiple audio frames and multiple video frames can be packaged to obtain an encrypted data packet, and the encrypted data packet is sent to the peer device of the first electronic device through the socket. In some embodiments, the encrypted multiple audio frames and multiple video frames can be sent to the peer device (second electronic device) of the first electronic device through the socket using the real-time transport protocol (RTP).
[0058] In order to deepen the understanding of the data encryption method described above, Figure 2 The data encryption method is described with examples in more detail. Figure 2 An encryption system is provided for an embodiment of the present application, such as Figure 2 As shown, the encryption system includes a sending end 210 (such as a first electronic device) and a receiving end 220 (such as a second electronic device). The sending end 210 and the receiving end 220 can be any type of electronic devices mentioned above.
[0059] The sending end 210 includes a collection module 211 , a coding module 212 , an encryption module 213 and a sending module 214 , and the receiving end 220 includes a receiving module 221 , a decryption module 222 , a decoding module 223 and a playing module 224 .
[0060] The acquisition module 211 may be used to acquire data frames to be encrypted, where the data frames to be encrypted include video frames and audio frames. The acquisition module 211 may include a camera and a microphone.
[0061] The encoding module 212 can be used to encode the video frames and audio frames to be encrypted. For video frames: the encoding module 212 can output encoding details, which include macroblock encoding information within the video frame, and the macroblock encoding information includes the number of macroblocks X within the frame, the number of reference macroblocks Y within the frame, the number of referenced macroblocks Z within the frame, and the quantization parameter Q of the macroblocks within the frame. The encoding details also include audio frame perception information. For audio frames: the encoding module 212 can output the perception information of the audio frame, and the perception information can be used to indicate the importance of the audio frame. The perception information can correspond to the corresponding encryption level one by one. Among them, the encoding module 212 can include a video encoding module and an audio encoding module. The encoding module 212 can be an encoder.
[0062] The encryption module 213 can be used to calculate the encryption value score of the video frame (i.e., the video frame encryption level) based on the macroblock encoding information fed back by the encoding module 212; and calculate the encryption value score of the audio frame (i.e., the audio frame encryption level) based on the perception information fed back by the encoding module 212.
[0063] Furthermore, the encryption module 213 is also used to decide the target audio and video frames to be extracted based on the encryption value points of the audio and video frames and the current amount of encrypted data. After determining the target audio frame, the encryption module 213 is used to encrypt the target audio and video frame using an encryption algorithm. For example, the AES encryption algorithm can be used to encrypt the target audio and video frame.
[0064] In some embodiments, an extended identification field can be inserted before the encrypted data of the encryption frame. The extended identification field includes an encryption flag (Encrypt Flag), and the encrypted data frame can be identified by the encryption flag; the extended identification field includes a non-encrypt flag (Non-encrypt flag), and the non-encrypted data frame can be identified by the non-encryption flag.
[0065] The sending module 214 can be used to write the partially encrypted audio and video data frames into the Socket, and use the real-time transport protocol RTP to send the encrypted audio and video data frames to the receiving end 220. Before the partially encrypted audio and video data frames are written into the Socket, the sending module 214 is also used to perform RTP encapsulation and packaging on the encrypted audio and video data frames to obtain encrypted data packets.
[0066] The receiving module 221 can be used to read the encrypted RTP data packet from the network Socket and separate the encrypted audio and video frame data.
[0067] The decryption module 222 may be used to parse the flag bits inserted into the audio and video frame data, thereby distinguishing between encrypted audio and video frames and non-encrypted audio and video frames.
[0068] The decoding module 223 is used to decrypt the encrypted audio and video frame data using a corresponding decryption algorithm.
[0069] The playback module 224 may be used to decode audio and video frames, respectively, and to render video images and play audio sounds.
[0070] In order to deepen the understanding of the data encryption method described above, Figure 3 The data encryption method is described with examples in more detail. Figure 3 Another embodiment of the present invention provides a data encryption method, which can be applied to Figure 2 In the encryption system, the data encryption method may include the following steps: S301~S307.
[0071] In step S301, a data frame to be encrypted is collected by a collection module, and the data frame to be decrypted includes a video frame and an audio frame.
[0072] In step S302, the encoding module is used to encode the video frame and audio frame to be encrypted, and the encoding detailed information and encoding data are output. For the video frame: the encoding detailed information includes the macroblock encoding information in the video frame, and the macroblock encoding information includes the number of macroblocks X in the frame, the number of reference macroblocks Y in the frame, the number of referenced macroblocks Z in the frame, and the macroblock quantization parameter Q in the frame. For the audio frame: the encoding detailed information includes the perceptual information of the audio frame, and the perceptual information can be used to indicate the importance of the audio frame, and the perceptual information can correspond to the corresponding audio frame encryption level.
[0073] In step S303, the encryption value of the audio and video frame is calculated according to the encoding detailed information.
[0074] For video frames: Based on the macroblock coding information and the mapping relationship between the macroblock coding information and the video frame encryption level, the encryption value score of the video frame (i.e., the video frame encryption level) is calculated, as follows:
[0075] The encoding module outputs the number of coded macroblocks of non-key frames (i.e. forward reference P frames or bidirectional reference B frames) as X, the number of reference macroblocks (P macroblocks or B macroblocks) within the frame as Y, the number of referenced macroblocks within the frame as Z, and the average quantization parameter of macroblocks within the frame as Q. Encryption level points:
[0076]
[0077] Among them, D score ∈[0, 100], 50 is the normalization coefficient, X is the number of macroblocks in the frame (i.e. the total number of macroblocks in the frame), Y is the number of reference macroblocks in the frame, Z is the number of referenced macroblocks in the frame, Q is the quantization parameter of the macroblocks in the frame, 0≤Q≤51.
[0078] Represents the reference macroblock coefficients The larger the value, the more reference macroblocks (P macroblocks and B macroblocks) the current frame contains, the lower the possibility of obtaining a complete image through independent decoding, and the lower the encryption level of the video frame. Key frames (I frames) generally only contain I macroblocks, no P macroblocks or B macroblocks, so the reference macroblock coefficient is 0.
[0079] Indicates the referenced macroblock coefficients The larger the value, the more important the frame is for reference, contains more important video image information, and has a higher encryption level. It should be understood that the reference macroblock P macroblock or B macroblock may also be referenced, and the I macroblock may not be referenced. For a key frame (I frame), not all macroblocks in the I frame are used as references.
[0080] Represents the quantization coefficient. The larger the value, the larger the video frame quantization parameter, the higher the compression rate, and the smaller the amount of encrypted data after encoding.
[0081] From the above video frame encryption value formula, it can be seen that: if the macroblocks of the non-key frame are all I macroblocks, and each macroblock is used as a reference macroblock, Q takes the maximum value of 51, then the encryption level score of the non-key frame is 100.
[0082] It should be understood that, generally, key frames (I frames) are determined to be encrypted and do not need to be encrypted level calculated. Non-key frames (B frames and P frames) can be encrypted level calculated according to the above rules so that target non-key frames with high encryption value ratio can be selected in subsequent steps.
[0083] For audio frames: the audio frame encryption value score (ie, the audio frame encryption level) may be determined based on the perception information fed back by the encoding module and the mapping relationship between the perception information and the audio frame encryption level.
[0084] In step S304, according to the encryption level of the audio and video frames, audio and video frame data with an encryption level score greater than a preset encryption level threshold (Threshold) is selected from the data frames to be encrypted. The Threshold can be set to 25.
[0085] In step S305, a flag is inserted into the audio and video frame data. The flag type may include an encryption flag and a non-encryption flag. According to the flag type in the audio and video data, the audio and video frames that need to be encrypted and the audio and video frames that do not need to be encrypted can be separated.
[0086] In step S306, the audio and video frames to be encrypted are encrypted using an encryption algorithm, and the current amount of encrypted data can be output.
[0087] In step S307, during the data encryption process, the preset encryption level threshold is dynamically adjusted according to the current encrypted audio frame amount and the target encrypted audio frame amount; or, according to the current encrypted video frame amount and the target encrypted video frame amount, the preset encryption level threshold is dynamically adjusted. The following mainly takes the video frame as an example for explanation.
[0088] The target encrypted video frame volume may refer to the percentage value of the target encrypted video volume to the total video volume, and the current encrypted video frame volume may refer to the percentage value of the current encrypted video volume to the total video volume. The target encrypted video frame volume can be determined based on the power consumption index requirements and encryption strength requirements, and the application does not impose specific restrictions on this. The target encrypted video frame volume can be set to 50 (that is, the target encryption volume is half of the total video volume). If the current encrypted video frame volume is less than the target encrypted video frame volume, the Threshold score is gradually lowered; if the current encrypted video frame volume is greater than the target encrypted video frame volume, the Threshold score can be gradually increased to ensure that high-value audio and video frames are encrypted as much as possible while encrypting a certain amount of data.
[0089] It is understandable that, generally speaking, for 720P and above videos, the audio frame data volume in the audio and video transmission stream accounts for only 2%-3%, which has little impact on encryption power consumption, so in specific implementation, full encryption can be used for audio data. That is, the encryption level score of all audio frames can be set to 100.
[0090] The above mainly introduces the data encryption method in detail. The following takes the use of AES to encrypt audio and video frames as an example. Figure 4-Figure 5 The data stream format of the encrypted data frame is explained in detail with examples.
[0091] Figure 4 A schematic diagram of the data stream format of the coded frame provided in the embodiment of the present application, such as Figure 4 As shown, the coded frame 400 may include non-encrypted data 410 and encrypted data 420. The non-encrypted data 410 may refer to an audio and video header (NALU header, etc.). When the encrypted data 420 is encrypted using the AES algorithm, the encrypted data 420 is divided into a plurality of ciphertext groups (i.e., data groups of the encrypted data 420), each of which may be 128 bits (16 bytes).
[0092] In some embodiments, in order to better distinguish whether the coded frame 400 needs to be encrypted, an extended identification byte 430 can be inserted before the encrypted data in the coded frame 400. The extended identification byte 430 includes an encryption flag bit or a non-encryption flag bit. Through the flag bit in the extended identification byte, it can be determined whether the coded frame 400 is a data frame that needs to be encrypted. The extended identification byte 430 is located at the head of the encrypted data 420 and occupies one byte.
[0093] In some embodiments, in order to improve encryption reliability, a randomly generated random initialization vector 440 may be inserted between the extended identification byte 430 and the encrypted data 420. The random initialization vector 440 may be a 16-byte initialization vector, which may be used to calculate the first ciphertext block of the encrypted frame.
[0094] It can be understood that when the receiving end receives the audio and video data for decryption, it can determine whether the frame is an encrypted frame based on the extended identification byte 430. If it is an encrypted frame, the symmetric key, random initialization vector 440 and encrypted data 420 sent by the service signaling channel can be used as input to decrypt the encoded data.
[0095] For audio frames, if full data encryption is adopted in a specific implementation, it is no longer necessary to insert the extended identification byte 430 before the encrypted data, and it is sufficient to insert the random initialization vector 440 before the encrypted data 420 of each audio frame.
[0096] It should be understood that the coded frame 400 with the extended identification byte 430 and the random initialization vector 440 inserted therein will not affect normal encapsulation and packaging, nor will it violate standard protocol requirements, and can be transmitted according to standard protocols such as RTP.
[0097] In some embodiments, the AES encryption algorithm has five encryption modes: output feedback mode OFB, counter mode CTR, cipher feedback mode CFB, codebook mode ECB, and cipher block chain mode CBC. In order to further improve the security of data, a different encryption mode can be used for each data frame, that is, the audio and video data stream can be encrypted using a mixed encryption mode. Therefore, it is necessary to identify the encryption mode of each encrypted data frame for decryption. For example, the encryption mode flag bit can be inserted in the extended identification byte 430.
[0098] Figure 5 A schematic diagram of the format of the extended identification byte 430, see Figure 5 The extended identification byte 430 may include an encryption flag bit 431 , an encryption mode flag bit 432 , and other reserved flag bits 433 .
[0099] It should be understood that the encryption flag bit 431 may occupy 1 bit to identify whether the coded frame 400 is an encrypted frame. The encryption mode flag bit 432 may occupy 3 bits and may have eight identification modes 0-7. The encryption mode flag bit 432 may identify the encryption mode of the coded frame 400, which may be one of the five encryption modes mentioned above. Other reserved flag bits 433 may be used as spare flag bits.
[0100] The present application also provides a data decryption method. Figure 6 The data decryption method in the embodiment of the present application is described in detail. It should be understood that the data decryption algorithm corresponds to the data encryption algorithm described above. Therefore, the parts that are not described in detail can refer to the previous data encryption method embodiment.
[0101] like Figure 6 As shown, the data decryption method 600 can be used for the second electronic device. It should be understood that the second electronic device is the opposite end device of the first electronic device, and the second electronic device can be any type of electronic device mentioned above. The data decryption method 600 can include steps: S610-S630.
[0102] In step S610, an encrypted data packet is received from a peer device of the second electronic device.
[0103] The encrypted data packet is a data packet obtained by encrypting the data to be encrypted in the first electronic device according to any of the data encryption methods mentioned above.
[0104] In some embodiments, the encrypted data packet may be received from a peer device of the second electronic device via a socket.
[0105] In step S620, an encrypted data frame in the encrypted data packet is determined.
[0106] In some embodiments, the data frame in the encrypted data packet includes an extended identification field, the extended identification field includes an encryption flag bit, and determining the encrypted data frame in the encrypted data packet includes: determining the encrypted data frame in the encrypted data packet according to the encryption flag bit.
[0107] In step S630, the encrypted data frame is decrypted.
[0108] In some embodiments, the extended identification field also includes an encryption mode flag, and the encrypted data frame is decrypted, including: determining the encryption mode of the encrypted data frame according to the encryption flag; and decrypting the encrypted data frame using a symmetric decryption algorithm according to the encryption mode of the encrypted data frame. The encryption mode of the encrypted data frame includes any one of the following modes: output feedback mode, counter mode, cipher feedback mode, code book mode, and cipher packet chain mode.
[0109] In some embodiments, the data frame in the encrypted data packet also includes a random initialization vector, and the encrypted data frame is decrypted, including: decrypting the encrypted data frame using a symmetric decryption algorithm according to the encryption mode and random initialization vector of the encrypted data frame.
[0110] In some embodiments, the encrypted data packet includes multiple video frames, the multiple video frames include encrypted video frames, and the encrypted data frames are decrypted, including: decrypting the encrypted video frames and parameter sets of the multiple video frames; wherein the parameter sets of the multiple video frames include video parameter sets, sequence parameter sets and image parameter sets of the multiple video frames.
[0111] In some embodiments, the encrypted data packet includes audio and video data frames, and after decrypting the encrypted data frames, it also includes: respectively decoding the audio frames and video frames in the audio and video data frames; rendering the video images in the audio and video data frames, and playing the audio sounds in the audio and video data frames.
[0112] Combination of the above Figures 1 to 6 The method embodiment of the present application is described in detail. Figures 7 to 9 The device embodiment of the present application is described in detail. It should be understood that the description of the method embodiment corresponds to the description of the device embodiment, so the parts not described in detail can refer to the previous method embodiment.
[0113] Figure 7 The data encryption device 700 is a schematic diagram of a data encryption device according to an embodiment of the present application. The data encryption device 700 may be applied to a first electronic device, and may include a collection module 710 and an encryption module 720 .
[0114] The acquisition module 710 is used to acquire data frames to be encrypted, where the data frames to be encrypted include multiple video frames.
[0115] The encryption module 720 is used to perform the following operations: determine the encryption level of each video frame in the multiple video frames according to the macroblock encoding information of the multiple video frames; determine the target video frame according to the encryption level of each video frame; encrypt the target video frame, wherein the encryption level of the target video frame is greater than a preset encryption level threshold.
[0116] Optionally, the macroblock encoding information includes the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks and the intra-frame macroblock quantization parameter, and the encryption module 720 is used to determine the encryption level of each video frame according to the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks and the intra-frame macroblock quantization parameter in each video frame, and the mapping relationship between the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks and the intra-frame macroblock quantization parameter and the encryption level. .
[0117] Optionally, the encryption level D of each video frame score for: Wherein, δ is a normalization coefficient, X is the number of macroblocks in a frame, Y is the number of reference macroblocks in the frame, Z is the number of referenced macroblocks in the frame, Q is a quantization parameter of the macroblocks in the frame, and 0≤Q≤51.
[0118] Optionally, the number of intra-frame reference macroblocks includes the number of intra-frame forward reference macroblocks and the number of intra-frame bidirectional reference macroblocks, the normalization coefficient is 50, and the encryption level range of each video frame is [0, 100].
[0119] Optionally, the encryption module 720 is used to: update the preset encryption level threshold according to the current amount of encrypted video frames; determine the target video frame according to the encryption level of each video frame and the updated preset encryption level threshold; wherein the encryption level of the target video frame is greater than the updated preset encryption level threshold.
[0120] Optionally, updating the preset encryption level threshold according to the current encrypted video frame amount includes: if the current encrypted video frame amount is greater than the target encrypted video frame amount, raising the preset encryption level threshold; or if the current encrypted video frame amount is less than the target encrypted video frame amount, lowering the preset encryption level threshold.
[0121] Optionally, the multiple video frames include key frames and non-key frames, and the encryption module 720 is used to: determine the target non-key frame according to the encryption level of the non-key frame, the encryption level of the target non-key frame is greater than the preset encryption level threshold, and the target video frame includes the key frame and the target non-key frame.
[0122] Optionally, the key frame is an intra-coded frame, and the non-key frame includes a forward reference frame and a bidirectional reference frame.
[0123] Optionally, the encryption module 720 is used to determine the encryption level of each video frame according to the number of times a macroblock in each video frame is referenced.
[0124] Optionally, the encryption module 720 is used to: encrypt the target video frame using an Advanced Encryption Standard algorithm.
[0125] Optionally, the encryption module 720 is further configured to: insert an extension identification field before the encrypted data of the target video frame, before encrypting the target video frame using the Advanced Encryption Standard algorithm, wherein the extension identification field includes an encryption flag.
[0126] Optionally, the encryption module 720 is further configured to: insert a random initialization vector between the extended identification field and the encrypted data.
[0127] Optionally, the advanced encryption standard algorithm includes an output feedback mode, a counter mode, a cipher feedback mode, a code book mode and a cipher packet chain mode, and the encryption module 720 is further used to: configure an encryption mode flag in the extended identification field, and the encryption mode flag is used to mark any one of the following encryption modes: the output feedback mode, the counter mode, the cipher feedback mode, the code book mode and the cipher packet chain mode.
[0128] Optionally, the encryption module 720 is used to: encrypt the target video frame and the parameter sets of the multiple video frames; wherein the parameter sets of the multiple video frames include video parameter sets, sequence parameter sets and image parameter sets of the multiple video frames.
[0129] Optionally, the device further includes: an encoding module 730, which is used to encode the multiple video frames after obtaining the data frame to be encrypted, so as to obtain macroblock encoding information of the multiple video frames.
[0130] Optionally, the data frame to be encrypted includes multiple audio frames, and the encoding module 730 is also used to: encode the multiple audio frames to obtain multiple perception information of the multiple audio frames, and the multiple perception information is used to indicate the encryption level of each audio frame in the multiple audio frames; the encryption module 720 is also used to: determine the target audio frame based on the multiple perception information, and the encryption level of the target audio frame is greater than the preset encryption level threshold.
[0131] Optionally, the device further includes: a sending module 740, which is used to send the encrypted multiple audio frames and the multiple video frames to the opposite end device of the first electronic device through a socket after encrypting the data frame to be encrypted.
[0132] It should be understood that the acquisition module 710 and Figure 2 The acquisition module 211 is the same as that in Figure 2 The encoding module 212 is the same as that in Figure 2 The encryption module 213 is the same as that in FIG. Figure 2 The sending module 214 is the same as that in FIG. 2 and will not be described in detail here.
[0133] Figure 8 The data decryption device 800 is a schematic diagram of a data decryption device according to an embodiment of the present application. The data decryption device 800 may be applied to a second electronic device, and may include a receiving module 810 and a decryption module 820 .
[0134] The receiving module 810 is used to receive an encrypted data packet from a peer device of the second electronic device, where the encrypted data packet is a data packet obtained by encrypting the data to be encrypted in the first electronic device according to any of the data encryption methods described above.
[0135] The decryption module 820 is used to determine the encrypted data frame in the encrypted data packet and decrypt the encrypted data frame.
[0136] Optionally, the data frame in the encrypted data packet includes an extended identification field, the extended identification field includes an encryption flag bit, and the decryption module 820 is used to determine the encrypted data frame in the encrypted data packet according to the encryption flag bit.
[0137] Optionally, the extended identification field also includes an encryption mode flag, and the decryption module 820 is used to: determine the encryption mode of the encrypted data frame according to the encryption flag; and decrypt the encrypted data frame using a symmetric decryption algorithm according to the encryption mode of the encrypted data frame.
[0138] Optionally, the data frame in the encrypted data packet further includes a random initialization vector, and the decryption module 820 is used to: decrypt the encrypted data frame using a symmetric decryption algorithm according to the encryption mode of the encrypted data frame and the random initialization vector.
[0139] Optionally, the encryption mode of the encrypted data frame includes any one of the following modes: output feedback mode, counter mode, cipher feedback mode, code book mode, and cipher packet chaining mode.
[0140] Optionally, the encrypted data packet includes multiple video frames, the multiple video frames include encrypted video frames, and the decryption module 820 is used to: decrypt the encrypted video frames and parameter sets of the multiple video frames; wherein the parameter sets of the multiple video frames include video parameter sets, sequence parameter sets and image parameter sets of the multiple video frames.
[0141] Optionally, the receiving module 810 is used to: receive the encrypted data packet from a peer device of the second electronic device via a socket.
[0142] Optionally, the encrypted data packet includes audio and video data frames, and the device 800 also includes: a decoding and rendering module 830, which is used to decode the audio frames and video frames in the audio and video data frames respectively after decrypting the encrypted data frames; render the video pictures in the audio and video data frames, and play the audio sounds in the audio and video data frames.
[0143] Combine the following Fig. 9The electronic device 900 in the embodiment of the present application is introduced. The electronic device 900 can be used to implement the method described in the above method embodiment. Fig. 9 The dashed boxes indicate optional items.
[0144] It should be understood that the electronic device 900 can be applied to any type of electronic device mentioned above.
[0145] The electronic device 900 may include one or more processors 910. The processor 910 may support the electronic device 900 to implement the method described in the foregoing method embodiment.
[0146] The processor 910 may be a general-purpose processor or a special-purpose processor. For example, the processor may be a central processing unit (CPU). Alternatively, the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0147] The electronic device 900 may further include one or more memories 920. The memory 920 stores a program, which can be executed by the processor 910 to control the electronic device 900 to execute the method described in the above method embodiment. The memory 920 may be independent of the processor 910 or integrated in the processor 910.
[0148] The electronic device 900 may further include a transceiver 930. The processor 910 may communicate with other devices through the transceiver 930. For example, the processor 910 may perform data transmission and reception with other devices through the transceiver 930.
[0149] The present application also provides a chip in an embodiment, including a processor, which can be used to call and run a computer program from a memory, so that a device equipped with the chip performs the method described in the above method embodiment. It is understood that the processor can be any type of processor mentioned above. It is understood that the memory can be independent of the chip or integrated in the chip.
[0150] The embodiment of the present application also provides a machine-readable storage medium for storing a program, and the program enables a computer to execute the method in each embodiment of the present application.
[0151] The embodiment of the present application also provides a computer program product. The computer program product includes a program. The program enables a computer to execute the method in each embodiment of the present application.
[0152] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a machine-readable storage medium, or transmitted from one machine-readable storage medium to another machine-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The machine-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).
[0153] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments of the present disclosure can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present disclosure.
[0154] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0155] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0156] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0157] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A data encryption method, characterized in that: Applied to a first electronic device, the method includes: Acquire a data frame to be encrypted, wherein the data frame to be encrypted includes a plurality of video frames; Determining an encryption level of each video frame in the plurality of video frames according to macroblock coding information of the plurality of video frames; Determining a target video frame according to the encryption level of each video frame, wherein the encryption level of the target video frame is greater than a preset encryption level threshold; The target video frame is encrypted.
2. The method according to claim 1, characterized in that The macroblock encoding information includes one or more of the following parameters: the number of macroblocks within a frame, the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, and a quantization parameter of macroblocks within a frame.
3. The method according to claim 2, characterized in that The macroblock encoding information includes the number of macroblocks within a frame, the number of reference macroblocks within a frame, the number of referenced macroblocks within a frame, and a macroblock quantization parameter within a frame. The determining, according to the macroblock encoding information of the multiple video frames, the encryption level of each video frame in the multiple video frames includes: The encryption level of each video frame is determined based on the number of intra-frame macroblocks, the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks and the intra-frame macroblock quantization parameters in each video frame, as well as the mapping relationship between the number of intra-frame macroblocks, the number of intra-frame reference macroblocks, the number of intra-frame referenced macroblocks and the intra-frame macroblock quantization parameters and the encryption level.
4. The method according to claim 3, characterized in that: The encryption level D of each video frame score for: Wherein, δ is a normalization coefficient, X is the number of macroblocks in a frame, Y is the number of reference macroblocks in the frame, Z is the number of referenced macroblocks in the frame, Q is a quantization parameter of the macroblocks in the frame, and 0≤Q≤51.
5. The method according to claim 4, characterized in that The number of intra-frame reference macroblocks includes the number of intra-frame forward reference macroblocks and the number of intra-frame bidirectional reference macroblocks, the normalization coefficient is 50, and the encryption level range of each video frame is [0, 100].
6. The method according to claim 1, characterized in that Determining the target video frame according to the encryption level of each video frame includes: Updating the preset encryption level threshold according to the current encrypted video frame amount; Determining the target video frame according to the encryption level of each video frame and the updated preset encryption level threshold; The encryption level of the target video frame is greater than the updated preset encryption level threshold.
7. The method according to claim 6, characterized in that The updating of the preset encryption level threshold according to the current encrypted video frame amount includes: If the current encrypted video frame amount is greater than the target encrypted video frame amount, increasing the preset encryption level threshold; or If the current encrypted video frame amount is less than the target encrypted video frame amount, the preset encryption level threshold is reduced.
8. The method according to claim 1, characterized in that The multiple video frames include key frames and non-key frames, and determining the target video frame according to the encryption level of each video frame includes: According to the encryption level of the non-key frame, a target non-key frame is determined, the encryption level of the target non-key frame is greater than the preset encryption level threshold, and the target video frame includes the key frame and the target non-key frame.
9. The method according to claim 8, characterized in that The key frame is an intra-coded frame, and the non-key frame includes a forward reference frame and a bidirectional reference frame.
10. The method according to claim 1, characterized in that The step of determining the encryption level of each video frame in the plurality of video frames according to the macroblock coding information of the plurality of video frames comprises: The encryption level of each video frame is determined according to the number of times the macroblock in each video frame is referenced.
11. The method according to claim 1, characterized in that: The encrypting process of the target video frame includes: The target video frame is encrypted using an Advanced Encryption Standard algorithm.
12. The method according to claim 11, characterized in that Before the target video frame is encrypted using the advanced encryption standard algorithm, the method further includes: An extended identification field is inserted before the encrypted data of the target video frame, and the extended identification field includes an encryption flag bit.
13. The method according to claim 12, characterized in that The method further comprises: A random initialization vector is inserted between the extended identification field and the encrypted data.
14. The method according to claim 12, characterized in that The advanced encryption standard algorithm includes an output feedback mode, a counter mode, a cipher feedback mode, a codebook mode and a cipher packet chaining mode, and the method further includes: An encryption mode flag is configured in the extended identification field, and the encryption mode flag is used to mark any one of the following encryption modes: the output feedback mode, the counter mode, the cipher feedback mode, the code book mode and the cipher packet chain mode.
15. The method according to claim 1, characterized in that The encrypting process of the target video frame includes: Encrypting the target video frame and the parameter sets of the multiple video frames; The parameter sets of the multiple video frames include video parameter sets, sequence parameter sets and image parameter sets of the multiple video frames.
16. The method according to claim 1, characterized in that After obtaining the data frame to be encrypted, the method further includes: The multiple video frames are encoded to obtain macroblock encoding information of the multiple video frames.
17. The method according to claim 1, characterized in that The data frame to be encrypted includes a plurality of audio frames, and the method further includes: Performing encoding processing on the multiple audio frames to obtain multiple perception information of the multiple audio frames, where the multiple perception information is used to indicate an encryption level of each audio frame in the multiple audio frames; A target audio frame is determined according to the plurality of perception information, wherein an encryption level of the target audio frame is greater than the preset encryption level threshold.
18. The method according to claim 17, characterized in that After encrypting the data frame to be encrypted, the method further includes: Packing the encrypted audio frames and video frames to obtain encrypted data packets; The encrypted data packet is sent to a peer device of the first electronic device via a socket.
19. A data decryption method, characterized in that: Applied to a second electronic device, the method includes: receiving an encrypted data packet from a peer device of the second electronic device, wherein the encrypted data packet is a data packet encrypted by the data encryption method according to any one of claims 1 to 18; Determining an encrypted data frame in the encrypted data packet; The encrypted data frame is decrypted.
20. The method according to claim 19, characterized in that The data frame in the encrypted data packet includes an extended identification field, the extended identification field includes an encryption flag bit, and the determining of the encrypted data frame in the encrypted data packet includes: According to the encryption flag bit, an encrypted data frame in the encrypted data packet is determined.
21. The method according to claim 20, characterized in that The extended identification field also includes an encryption mode flag bit, and the decryption processing of the encrypted data frame includes: Determining the encryption mode of the encrypted data frame according to the encryption flag bit; According to the encryption mode of the encrypted data frame, the encrypted data frame is decrypted using a symmetric decryption algorithm.
22. The method according to claim 21, characterized in that The data frame in the encrypted data packet also includes a random initialization vector, and the decryption processing of the encrypted data frame includes: The encrypted data frame is decrypted using a symmetric decryption algorithm according to the encryption mode of the encrypted data frame and the random initialization vector.
23. The method according to claim 21, characterized in that The encryption mode of the encrypted data frame includes any one of the following modes: output feedback mode, counter mode, cipher feedback mode, code book mode, and cipher packet chain mode.
24. The method according to claim 19, characterized in that The encrypted data packet includes a plurality of video frames, wherein the plurality of video frames include an encrypted video frame, and the decrypting process on the encrypted data frame includes: Decrypting the encrypted video frame and the parameter sets of the multiple video frames; The parameter sets of the multiple video frames include video parameter sets, sequence parameter sets and image parameter sets of the multiple video frames.
25. The method according to claim 19, characterized in that The receiving an encrypted data packet from a peer device of the second electronic device includes: The encrypted data packet is received from a peer device of the second electronic device through a socket.
26. The method according to claim 19, characterized in that The encrypted data packet includes an audio and video data frame. After decrypting the encrypted data frame, the method further includes: Decoding the audio frame and the video frame in the audio and video data frame respectively; Render the video images in the audio and video data frame, and play the audio sounds in the audio and video data frame.
27. A data encryption device, characterized in that: The device is applied to a first electronic device, and includes: An acquisition module, used for acquiring a data frame to be encrypted, wherein the data frame to be encrypted includes a plurality of video frames; Cryptographic module that performs the following operations: Determining an encryption level of each video frame in the plurality of video frames according to macroblock coding information of the plurality of video frames; Determining a target video frame according to the encryption level of each video frame; The target video frame is encrypted, wherein the encryption level of the target video frame is greater than a preset encryption level threshold.
28. A data decryption device, characterized in that: Applied to a second electronic device, the device comprises: a receiving module, configured to receive an encrypted data packet from a peer device of the second electronic device, wherein the encrypted data packet is a data packet encrypted by the data encryption method according to any one of claims 1 to 18; The decryption module is used to determine the encrypted data frame in the encrypted data packet and decrypt the encrypted data frame.
29. A chip, characterized in that: include: A processor, configured to call and run a computer program from a memory, so that a device equipped with the chip executes a method as claimed in any one of claims 1 to 18 or a method as claimed in any one of claims 19 to 26.
30. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to control the electronic device to execute the method as described in any one of claims 1-18 or the method as described in any one of claims 19-26.
31. A computer-readable storage medium having executable code stored thereon, characterized in that: The code is used to implement the method according to any one of claims 1 to 18 or the method according to any one of claims 19 to 26.
Citation Information
Cited By
Data encryption method for video communication
CN121509711A
A data encryption method for video communication
CN121509711B