CN106209736B - Streaming media data playing method, terminal and streaming media server - Google Patents
Streaming media data playing method, terminal and streaming media server Download PDFInfo
- Publication number
- CN106209736B CN106209736B CN201510220928.5A CN201510220928A CN106209736B CN 106209736 B CN106209736 B CN 106209736B CN 201510220928 A CN201510220928 A CN 201510220928A CN 106209736 B CN106209736 B CN 106209736B
- Authority
- CN
- China
- Prior art keywords
- data packet
- seed
- byte
- ciphertext data
- streaming media
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a streaming media data playing method, a terminal and a streaming media server, and belongs to the technical field of networks. The method comprises the following steps: when a streaming media data acquisition request sent by a terminal is received, acquiring a random seed and at least two prime numbers encrypted by the streaming media data; determining a key stream of a plurality of plaintext data packets included in the streaming media data based on the random seed and the at least two prime numbers; encrypting the plaintext data packets respectively based on the key streams of the plaintext data packets to obtain ciphertext data packets; and sending the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets. According to the invention, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, and the key stream is not easy to attack, so that the security of the streaming media data is improved.
Description
Technical Field
The present invention relates to the field of network technologies, and in particular, to a streaming media data playing method, a terminal, and a streaming media server.
Background
With the rapid development of technology, more and more users use terminals to play streaming media data such as video streams, audio streams, and the like. Before playing the streaming media data, the terminal needs to acquire the streaming media data from the streaming media server. In order to ensure the security of the streaming media data, when the terminal acquires the streaming media data from the streaming media server, the streaming media server needs to encrypt the streaming media data.
At present, the method for encrypting streaming media data is basically implemented based on a symmetric encryption algorithm RC4, that is, when a streaming media server receives a streaming media data acquisition request sent by a terminal, a random sequence and an encryption key are acquired, the random sequence is composed of characters from 0 to 255, a key stream is generated through the random sequence and the encryption key, and the length of the key stream is equal to the length of the streaming media data. And performing XOR operation on the bytes at the same position to obtain encrypted streaming media data, sending the encrypted streaming media data to the terminal, enabling the terminal to decrypt the received streaming media data, and playing the decrypted streaming media data.
Since the key stream generated by the RC4 algorithm has a high probability of repeated bytes, it is vulnerable to attack, and the security of the streaming media data is reduced.
Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a streaming media data playing method, a terminal, and a streaming media server. The technical scheme is as follows:
in a first aspect, a method for playing streaming media data is provided, where the method includes:
when a streaming media data acquisition request sent by a terminal is received, acquiring a random seed and at least two prime numbers encrypted by the streaming media data;
determining a key stream of a plurality of plaintext data packets included in the streaming media data based on the random seed and the at least two prime numbers;
encrypting the plaintext data packets respectively based on the key streams of the plaintext data packets to obtain ciphertext data packets;
and sending the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
In a second aspect, a method for playing streaming media data is provided, where the method includes:
when a streaming media data acquisition instruction is received, sending a streaming media data acquisition request to a streaming media server, and enabling the streaming media server to return a ciphertext data packet of the streaming media data, wherein the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
when receiving a ciphertext data packet sent by the streaming media server, acquiring a corresponding key stream from a corresponding relation between a stored sequence number and the key stream based on the sequence number of the ciphertext data packet;
decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet;
and playing the streaming media data based on the plaintext data packet.
In a third aspect, a streaming media server is provided, where the streaming media server includes:
the acquisition module is used for acquiring a random seed and at least two prime numbers encrypted by the streaming media data when a streaming media data acquisition request sent by a terminal is received;
a determining module, configured to determine, based on the random seed and the at least two prime numbers, a key stream of a plurality of plaintext data packets included in the streaming media data;
the encryption module is used for respectively encrypting the plaintext data packets based on the key streams of the plaintext data packets to obtain ciphertext data packets;
and the sending module is used for sending the plurality of ciphertext data packets to the terminal so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
In a fourth aspect, a terminal is provided, which includes:
the sending module is used for sending a streaming media data obtaining request to a streaming media server when receiving a streaming media data obtaining instruction, so that the streaming media server returns a ciphertext data packet of the streaming media data, wherein the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
the acquisition module is used for acquiring a corresponding key stream from the corresponding relation between the stored serial number and the key stream based on the serial number of the ciphertext data packet when receiving the ciphertext data packet sent by the streaming media server;
the decryption module is used for decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet;
and the playing module is used for playing the streaming media data based on the plaintext data packet.
The technical scheme provided by the embodiment of the invention has the following beneficial effects: in this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is an architecture diagram of a streaming media data playing system according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for playing streaming media data according to an embodiment of the present invention;
fig. 3 is a flowchart of another streaming media data playing method provided in the embodiment of the present invention;
fig. 4 is a flowchart of another streaming media data playing method provided in the embodiment of the present invention;
fig. 5 is a schematic structural diagram of a streaming media server according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a terminal according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a streaming media server according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
Fig. 1 is an architecture diagram of a streaming media data playing system according to an embodiment of the present invention. Referring to fig. 1, the system includes a terminal and a streaming server, and the terminal and the streaming server may be connected through a network. The terminal is used for acquiring a plurality of ciphertext data packets included in the streaming media data from the streaming media server, decrypting the ciphertext data packets to obtain a plurality of plaintext data packets, and playing the streaming media data based on the plaintext data packets; the streaming media server is used for encrypting each plaintext data packet included in the streaming media data requested by the terminal to obtain a plurality of ciphertext data packets, and sending the obtained plurality of ciphertext data packets to the terminal.
Fig. 2 is a flowchart of a method for playing streaming media data according to an embodiment of the present invention. Referring to fig. 2, the method is applied to a streaming media server, and the method includes:
step 201: when a streaming media data acquisition request sent by a terminal is received, acquiring a random seed and at least two prime numbers of the encrypted streaming media data.
Step 202: and determining a key stream of a plurality of plaintext data packets included in the streaming media data based on the random seed and the at least two prime numbers.
Step 203: and encrypting the plurality of plaintext data packets respectively based on the key stream of the plurality of plaintext data packets to obtain a plurality of ciphertext data packets.
Step 204: and sending the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
Optionally, determining, based on the random seed and the at least two prime numbers, a key stream of a plurality of plaintext data packets included in the streaming media data, includes:
determining seeds of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers and a second prime number of the at least two prime numbers;
determining a seed of each byte in the plurality of plaintext data packets respectively based on the seeds of the plurality of plaintext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers;
and respectively determining key streams of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets.
Optionally, determining a seed of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers, includes:
for a first plaintext data packet of the plurality of plaintext data packets, determining a seed of the first plaintext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
for each plaintext data packet after the first plaintext data packet, determining the seed of the plaintext data packet based on the seed of the previous plaintext data packet, the first prime number and the second prime number, wherein the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
Optionally, determining a seed of each byte in the plurality of plaintext data packets based on the seed of the plurality of plaintext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively, includes:
for each plaintext data packet in the plurality of plaintext data packets, determining an internal seed of the plaintext data packet based on the seed of the plaintext data packet;
determining a seed for each byte within the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers.
Optionally, determining a seed of each byte in the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, includes:
for a first byte in the plaintext data packet, determining a seed of the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the plaintext data packet, determining a seed for the byte based on a seed for a last byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, determining the key stream of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets respectively includes:
for each plaintext data packet in the plurality of plaintext data packets, acquiring the lowest-order byte of the seed of each byte in the plaintext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the plaintext data packet, forming the plurality of lowest-order bytes into the key stream of the plaintext data packet.
All the above optional technical solutions can be combined arbitrarily to form an optional embodiment of the present invention, which is not described in detail herein.
Fig. 3 is a flowchart of a method for playing streaming media data according to an embodiment of the present invention. Referring to fig. 3, the method is applied to a terminal, and the method includes:
step 301: when a streaming media data acquisition instruction is received, a streaming media data acquisition request is sent to a streaming media server, so that the streaming media server returns a ciphertext data packet of the streaming media data, and the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server.
Step 302: and when receiving a ciphertext data packet sent by the streaming media server, acquiring a corresponding key stream from the corresponding relation between the stored sequence number and the key stream based on the sequence number of the ciphertext data packet.
Step 303: and decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet.
Step 304: and playing the streaming media data based on the plaintext data packet.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
Optionally, before acquiring a corresponding key stream from the correspondence between the stored sequence number and the key stream based on the sequence number of the ciphertext data packet, the method further includes:
when a first ciphertext data packet sent by the streaming media server is received, determining a key stream of a plurality of ciphertext data packets based on a random seed and at least two prime numbers encrypted by the streaming media data, wherein the plurality of ciphertext data packets comprise the first ciphertext data packet and a plurality of ciphertext data packets with continuous designated values behind the first ciphertext data packet;
and storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams.
Optionally, determining key streams of a plurality of ciphertext data packets based on the random seed and at least two prime numbers of the stream media data encryption includes:
determining seeds of the plurality of ciphertext data packets respectively based on the random seed encrypted by the streaming media data, a first prime number of the at least two prime numbers and a second prime number of the at least two prime numbers;
determining a seed of each byte in the plurality of ciphertext data packets respectively based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers;
and respectively determining key streams of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets.
Optionally, determining the seeds of the plurality of ciphertext data packets based on the encrypted random seed of the streaming media data, the first prime number of the at least two prime numbers, and the second prime number of the at least two prime numbers, respectively, includes:
for a first ciphertext data packet of the plurality of ciphertext data packets, determining a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
and for each ciphertext data packet after the first ciphertext data packet, determining the seed of the ciphertext data packet based on the seed of the last ciphertext data packet, the first prime number and the second prime number, wherein the last ciphertext data packet is a ciphertext data packet before the ciphertext data packet and adjacent to the ciphertext data packet.
Optionally, determining a seed of each byte in the plurality of ciphertext data packets based on the seed of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively, includes:
for each ciphertext data packet in the plurality of ciphertext data packets, determining an internal seed of the ciphertext data packet based on the seed of the ciphertext data packet;
and determining the seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers and the fourth prime number of the at least two prime numbers.
Optionally, determining a seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, includes:
for a first byte in the ciphertext data packet, determining a seed of the first byte based on an internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the ciphertext data packet, determining a seed for a last byte based on the seed for the byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, respectively determining key streams of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets, includes:
obtaining the lowest-order byte of the seed of each byte in the ciphertext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the ciphertext data packet, forming the plurality of lowest-order bytes into a key stream of the ciphertext data packet.
Optionally, the method further comprises:
when a next ciphertext data packet sent by the streaming media server is received, determining a key stream of an adjacent ciphertext data packet behind the last ciphertext data packet based on the seed of the last ciphertext data packet in the ciphertext data packets and the at least two prime numbers;
and updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
All the above optional technical solutions can be combined arbitrarily to form an optional embodiment of the present invention, which is not described in detail herein.
Fig. 4 is a flowchart of a method for playing streaming media data according to an embodiment of the present invention. Referring to fig. 4, the method includes:
step 401: and when the terminal receives the streaming media data acquisition instruction, sending a streaming media data acquisition request to the streaming media server.
Therefore, when the terminal receives a streaming media data obtaining instruction, the terminal may send a streaming media data obtaining request to the streaming media server, where the streaming media data obtaining request may carry a streaming media data identifier.
The streaming media data acquisition instruction is used for generating a streaming media data acquisition request and acquiring corresponding streaming media data from a streaming media server. The stream media data obtaining instruction may be triggered by a user, that is, the user may trigger the stream media data obtaining instruction through a specified operation, where the specified operation may be a click operation, a sliding operation, a voice operation, and the like, and this is not particularly limited in this embodiment of the present invention.
In addition, the identifier of the streaming media data may be a name of the streaming media data, a play address of the streaming media data, a number of the streaming media data, and the like, which is not specifically limited in this embodiment of the present invention.
Step 402: when the streaming media server receives a streaming media data acquisition request sent by a terminal, acquiring the encrypted random seed and at least two prime numbers of the streaming media data.
When the streaming media server receives a streaming media data acquisition request sent by a terminal, corresponding streaming media data can be acquired from a corresponding relationship between the stored streaming media data identifier and the streaming media data according to the streaming media data identifier carried by the streaming media data acquisition request. Then, the streaming media server may send the obtained streaming media data to the terminal, and in order to improve the security of the streaming media data, before the streaming media server sends the streaming media data to the terminal, the streaming media server may encrypt the streaming media data, so that the streaming media server may obtain the encrypted random seed and the at least two prime numbers of the streaming media data.
The operation of the streaming media server obtaining the encrypted random seed and the at least two prime numbers of the streaming media data may be: randomly selecting a text from a preset text library, carrying out characteristic value operation on the selected text to obtain a characteristic value of the text, dividing the characteristic value into two parts according to byte average to obtain a first sub-characteristic value and a second sub-characteristic value, wherein the first sub-characteristic value comprises the byte of the first half part of the characteristic value, the second sub-characteristic value comprises the byte of the second half part of the characteristic value, and the second sub-characteristic value is determined as a random seed for encrypting the streaming media data. The first sub-feature value is divided into four parts according to byte average, a first numerical value, a second numerical value, a third numerical value and a fourth numerical value are sequentially obtained, a first prime number and a second prime number are obtained from a first preset prime number array on the basis of the first numerical value and the second numerical value, and a third prime number and a fourth prime number are obtained from a second preset prime number array on the basis of the third numerical value and the fourth numerical value. For example, the feature value operation is performed on the selected text to obtain that the feature value of the text is 16 bytes, at this time, the first 8 bytes of the feature value may be determined as a first sub-feature value, the last 8 bytes of the feature value may be determined as a second sub-feature value, and the random seed of the streaming media data is determined as the last 8 bytes of the feature value, that is, the random seed of the streaming media data is 64 bits, and the first 8 bytes of the feature value are divided equally to obtain 4 2-byte values, that is, the first value, the second value, the third value, and the fourth value.
Based on the first numerical value and the second numerical value, the specific operation of obtaining the first prime number and the second prime number from the first preset prime number array may be: and obtaining the prime number positioned at the first numerical position from the first preset prime number array, determining the prime number as the first prime number, obtaining the prime number positioned at the second numerical position from the first preset prime number array, and determining the prime number as the second prime number. Similarly, based on the third numerical value and the fourth numerical value, the specific operation of obtaining the third prime number and the fourth prime number from the second preset prime number array may be: and obtaining the prime number positioned on the third numerical value position from the second preset prime number array, determining the prime number as the third prime number, obtaining the prime number positioned on the fourth numerical value position from the second preset prime number array, and determining the prime number as the fourth prime number.
For example, the streaming media server randomly selects a text as "pump and pump, magnolia when the user organizes" from a preset text library, performs feature value operation on the text to obtain a feature value of the text as 89759644, divides the feature value according to byte average to obtain a first sub-feature value of 8975 and a second sub-feature value of 9644, and determines that the random seed for encrypting the streaming media data is 9644. Dividing the first sub-feature value 8975 into four parts according to byte average, sequentially obtaining a first value of 8, a second value of 9, a third value of 7 and a fourth value of 5, obtaining a prime number 4200000131 at the 8 th position from a first preset prime number array based on the first value 8 and the second value 9, and obtaining a prime number 4200000149 at the 9 th position from the first preset prime number array, thereby determining that the first prime number is 4200000131 and the second prime number is 4200000149. Based on the third value of 7 and the fourth value of 5, a prime number located at the 7 th position is obtained as 65579 from the second preset prime number array, and a prime number located at the 5 th position is obtained as 65557 from the second preset prime number array, and therefore, the third prime number is determined as 65579, and the fourth prime number is determined as 65557.
It should be noted that the characteristic value operation may be a DM5(Message Digest 5) operation, an SHA (Secure Hash Algorithm 1) operation, a Hash operation, and the like, which is not specifically limited in this embodiment of the present invention. In addition, the predetermined text library, the first predetermined prime number array and the second predetermined prime number array may be stored in advance, the first predetermined prime number array may be 65536 prime numbers which are close to each other in a 42 hundred million upward direction, and the second predetermined prime number array may be 65536 prime numbers which are close to each other in a 65536 upward direction. In addition, in order to make the repetition period in the generation of the key stream larger and avoid the attack, the modulo of the prime numbers in the first preset prime number array and the second preset prime number array to 4 may be equal to 1, that is, the prime numbers in the first preset prime number array and the second preset prime number array both need to satisfy the condition that the modulo of 4 is equal to 1. Optionally, in the embodiment of the present invention, it may only be required to ensure that the prime numbers in the first preset prime number array satisfy the condition that modulo 4 is equal to 1, which is not specifically limited in the embodiment of the present invention.
In addition, because the streaming media server has many ways to obtain the random seed and the at least two prime numbers for encrypting the streaming media data, that is, the streaming media server can obtain the random seed and the at least two prime numbers by the above ways, in practical applications, the random seed and the at least two prime numbers can also be obtained by other ways, for example, two prime numbers can be randomly selected from a first preset prime number group as the first prime number and the second prime number, two prime numbers can be randomly selected from a second preset prime number group as the third prime number and the fourth prime number, and one value can be randomly selected as the random seed. The embodiments of the present invention do not list them.
It should be noted that, in the embodiment of the present invention, each time the streaming media server receives a streaming media data acquisition request sent by one terminal, the streaming media server may acquire the random seed and the at least two prime numbers once, that is, for different terminals, the random seed and the at least two prime numbers encrypted by the streaming media data may be different, and for different streaming media data, the random seed and the at least two prime numbers may also be different, which is not specifically limited in this embodiment of the present invention.
Step 403: the streaming media server determines a seed of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers and a second prime number of the at least two prime numbers.
Because the streaming media server obtains the streaming media data as unencrypted data based on the streaming media data identifier, that is, the obtained streaming media data is plaintext data, when the streaming media server obtains the random seed and the at least two prime numbers of the encrypted streaming media data, the streaming media server may determine the seeds of the plurality of plaintext data packets included in the streaming media data. The specific operation of the streaming media server determining the seeds of the plurality of plaintext data packets included in the streaming media data based on the random seed, the first prime number of the at least two prime numbers, and the second prime number of the at least two prime numbers may be: for a first plaintext data packet of the plurality of plaintext data packets, determining a seed of the first plaintext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers; for each plaintext data packet after the first plaintext data packet, determining the seed of the plaintext data packet based on the seed, the first prime number and the second prime number of the previous plaintext data packet, wherein the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
In the embodiment of the present invention, for any plaintext data packet included in the streaming media data, the seed of the plaintext data packet may be calculated by the following formula (1);
F(n)=(F(n-1)*A+B)mod 264(1)
in the above formula (1), n is a sequence number of a plaintext data packet included in the streaming media data packet, where the sequence number may be located in a header of the plaintext data packet, F (n) is a seed of the plaintext data packet with the sequence number n, F (n-1) is a seed of a previous plaintext data packet of the plaintext data packet with the sequence number n, that is, F (n-1) is a seed of the plaintext data packet with the sequence number n-1, a is a first prime number of the at least two prime numbers, B is a second prime number of the at least two prime numbers, mod is a modulo operation, and 264And performing modulus operation regardless of whether the calculation result overflows or not. Therefore, for a first plaintext data packet included in the streaming media data, F (n-1) is F (0), that is, a random seed of the streaming media data, and therefore, for a first plaintext data packet in the plurality of plaintext data packets, a seed of the first plaintext data packet may be determined based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers, and for each plaintext data packet subsequent to the first plaintext data packet, a seed of the plaintext data packet needs to be determined based on a seed of a previous plaintext data packet, the first prime number, and the second prime number. For example, for a second plaintext data packet, a seed for the second plaintext data packet needs to be determined based on the seed of the first plaintext data packet, the first prime number, and the second prime number.
It should be noted that, in the embodiment of the present invention, the sequence number of the plaintext data packet is a sequence number obtained by numbering a plurality of plaintext data packets included in the streaming media data in sequence, for example, the sequence number of the first plaintext data packet is 1, and the sequence number of the second plaintext data packet is 2, and similarly, the sequence number of each byte in each plaintext data packet is also obtained by numbering a plurality of bytes in the plaintext data packet in sequence. In addition, in the embodiment of the present invention, the seed of each plaintext data packet may be determined according to the above formula (1), and may also be determined in other manners, for example, the above formula (1) is slightly modified, which is not specifically limited in the embodiment of the present invention.
Step 404: the streaming media server determines a seed of each byte in the plurality of plaintext data packets respectively based on the seeds of the plurality of plaintext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers.
In order to increase the security of the streaming media data, after the streaming media server determines the seed of each plaintext data packet included in the streaming media data, the seed of each byte in each plaintext data packet may also be determined, and the specific operation of the streaming media server, based on the seeds of the plurality of plaintext data packets, the third prime number of the at least two prime numbers, and the fourth prime number of the at least two prime numbers, to respectively determine the seed of each byte in the plurality of plaintext data packets may be: for each plaintext data packet in the plurality of plaintext data packets, determining an internal seed of the plaintext data packet based on the seed of the plaintext data packet; determining a seed for each byte within the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers.
The operation of the streaming media server determining the internal seed of the plaintext data packet based on the seed of the plaintext data packet may be: based on the seed of the plaintext data packet, the internal seed of the plaintext data packet may be determined according to the following formula (2);
f(0)=F(n)mod 232(2)
wherein, in the above formula (2), f (0) is the internal seed of the plaintext data packet, when the sequence number of the plaintext data packet is n, F (n) is the seed of the plaintext data packet, and 232And performing modulus operation regardless of whether the calculation result overflows or not.
The streaming media server determines a seed of each byte in the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers, and the method comprises the following steps: for a first byte in the plaintext data packet, determining a seed of the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers; for each byte after the first byte, determining the seed of the byte based on the seed of the last byte, the third prime number and the fourth prime number, the last byte being the byte before and adjacent to the byte.
In the embodiment of the present invention, for any byte in the plaintext data packet, the seed of the byte can be calculated by the following formula (3);
f(m)=(f(m-1)*C+D)mod 232(3)
wherein, in the above formula (3), m is the sequence number of the byte in the plaintext data packet, f (m) is the seed of the byte with sequence number m in the plaintext data packet, f (m-1) is the seed of the previous byte with sequence number m in the plaintext data packet, C is the third prime number, D is the fourth prime number, and pair 232And performing modulus operation regardless of whether the calculation result overflows or not. Therefore, for the first byte in the plaintext data packet, f (m-1) is f (0), that is, the internal seed of the plaintext data packet, and therefore, for the first byte in the plaintext data packet, the seed of the first byte may be determined based on the internal seed of the plaintext data packet, the third prime number of the at least two prime numbers, and the fourth prime number of the at least two prime numbers, and for each byte after the first byte, the seed of the byte needs to be determined based on the seed of the last byte, the third prime number, and the fourth prime number, where the last byte is the byte before the byte and adjacent to the byteA byte. For example, for the second byte, the seed of the second byte needs to be determined based on the seed of the first byte, the third prime number, and the fourth prime number.
It should be noted that, in the embodiment of the present invention, not only the internal seed of each plaintext data packet may be determined according to the above formula (2), but also the seed of each byte in the plaintext data packet may be determined according to the above formula (3), and may also be determined in other manners, for example, the above formulas (2) and (3) are slightly modified, which is not specifically limited in the embodiment of the present invention.
Step 405: and the streaming media server respectively determines the key stream of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets.
After the streaming media server determines the seed of each byte in the plurality of plaintext data packets, the streaming media server may determine the key stream of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets, respectively. For the convenience of encryption and reduction of encryption complexity, the operation of the streaming media server, based on the seed of each byte in the plurality of plaintext data packets, respectively determining the key stream of the plurality of plaintext data packets may be: for each plaintext data packet in the plurality of plaintext data packets, acquiring the lowest-order byte of the seed of each byte in the plaintext data packet to obtain a plurality of lowest-order bytes; and according to the sequence of each byte in the plaintext data packet, forming the plurality of lowest-order bytes into the key stream of the plaintext data packet.
For example, the second plaintext data packet includes three bytes, the lowest byte of the first byte of the three bytes is 01101011, the lowest byte of the second byte is 10101100, and the lowest byte of the third byte is 10111011, and at this time, the key stream constituting the second plaintext data packet may be 011010111010110010111011 according to the order of the three bytes.
In the embodiment of the present invention, the streaming media server obtains the lowest bit byte of the seed of each byte in the plaintext data packet, and obtains a plurality of lowest bit bytes, which can be obtained according to the following formula (4);
k(m)=f(m)&0xFF (4)
in the above formula (4), k (m) is the lowest byte obtained from the seed of the byte with sequence number m in the plaintext data packet, & is and operation, 0xFF is 255, and is converted into the binary number 11111111.
Step 406: and the streaming media server encrypts the plurality of plaintext data packets respectively based on the key stream of the plurality of plaintext data packets to obtain a plurality of ciphertext data packets, and sends the plurality of ciphertext data packets to the terminal.
Specifically, for each plaintext data packet in the plurality of plaintext data packets, an exclusive or operation may be performed on each byte in the plaintext data packet and each byte in the key stream of the plaintext data packet, where the byte is located at the same position, so as to obtain a ciphertext data packet corresponding to the plaintext data packet, and then the ciphertext data packet is sent to the terminal.
For example, for the second plaintext data packet, the first byte in the plaintext data packet is 10110100, the second byte is 10101110, the third byte is 11101100, the first byte in the key stream of the second plaintext data packet is 01101011, the second byte is 10101100, and the third byte is 10111011. Therefore, the first byte 10110100 of the plaintext data packet is xored with the first byte 01101011 in the key stream of the second plaintext data packet to obtain the first byte 11011111 of the ciphertext data packet, the second byte 10101110 of the plaintext data packet is xored with the second byte 10101100 in the key stream of the second plaintext data packet to obtain the second byte 00000010 of the ciphertext data packet, and the third byte 11101100 of the plaintext data packet is xored with the third byte 10111011 in the key stream of the second plaintext data packet to obtain the third byte 01010111 of the ciphertext data packet. The ciphertext data packet corresponding to the plaintext data packet is obtained as 110111110000001001010111.
It should be noted that, each time the streaming media server determines the key stream of a plaintext data packet, the streaming media server encrypts the plaintext data packet, and then sends the ciphertext data packet to the terminal. Of course, the streaming media server may also encrypt all plaintext data packets when acquiring the key stream of all plaintext data packets included in the streaming media data, and then send the encrypted ciphertext data packets to the terminal one by one. Preferably, in order to enable the terminal to play the streaming media data faster, the streaming media server may encrypt a plaintext data packet each time a key stream of the plaintext data packet is determined, and then send the ciphertext data packet to the terminal.
The plaintext data packets included in the streaming media data are encrypted through the steps of the steps 401 and 406, and the encrypted ciphertext data packets are sent to the terminal, and the terminal can decrypt the ciphertext data packets according to the following steps, so as to play the streaming media data.
Step 407: when the terminal receives a ciphertext data packet sent by the streaming media server, the corresponding key stream is obtained from the corresponding relation between the stored sequence number and the key stream based on the sequence number of the ciphertext data packet.
In this embodiment of the present invention, the streaming media server may send the random seed and the at least two prime numbers encrypted by the streaming media data to the terminal when sending the first ciphertext data packet to the terminal, and may also send the random seed and the at least two prime numbers encrypted by the streaming media data to the terminal when establishing a connection between the terminal and the streaming media server. Therefore, when the terminal receives a first ciphertext data packet sent by the streaming media server, the terminal may determine a key stream of a plurality of ciphertext data packets based on the random seed and the at least two prime numbers for encrypting the streaming media data, where the plurality of ciphertext data packets include the first ciphertext data packet and a specified number of ciphertext data packets that are consecutive after the first ciphertext data packet; and storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams. When the terminal receives the next ciphertext data packet sent by the streaming media server, the terminal may obtain the corresponding key stream from the correspondence between the stored sequence number and the key stream based on the sequence number of the next ciphertext data packet.
For example, the terminal may determine that the key stream of the plurality of ciphertext data packets is 101110111000110, 110111110000001001010111, 101110110110111001110011 … … based on the random seed and the at least two prime numbers for encrypting the streaming media data, and thus may store the sequence numbers of the plurality of ciphertext data packets and the key stream of the plurality of ciphertext data packets in the correspondence between the sequence numbers and the key stream as shown in table 1 below.
TABLE 1
Serial number | Keystream |
1 | 101110111000110 |
2 | 110111110000001001010111 |
3 | 101110110110111001110011 |
…… | …… |
The designated value is set in advance, for example, the designated value is 1999, and thus the number of the plurality of ciphertext data packets is 2000, which is not particularly limited in the embodiment of the present invention.
Since the terminal receives the ciphertext data packet of the streaming media data, that is, the encrypted data for encrypting the streaming media data, when the terminal receives the ciphertext data packet sent by the streaming media server, it needs to determine the key stream of the ciphertext data packet, so as to decrypt the ciphertext data packet based on the key stream. And the terminal determines the key stream of a plurality of ciphertext data packets based on the random seed and at least two prime numbers encrypted by the streaming media data, and the method comprises the following steps: the terminal respectively determines the seeds of the plurality of ciphertext data packets based on the random seed encrypted by the streaming media data, the first prime number of the at least two prime numbers and the second prime number of the at least two prime numbers; determining a seed of each byte in the plurality of ciphertext data packets respectively based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers; and respectively determining key streams of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets.
When the terminal determines the seeds of the plurality of ciphertext data packets respectively based on the random seed encrypted by the streaming media data, the first prime number of the at least two prime numbers and the second prime number of the at least two prime numbers, the method is the same as the method for determining the plaintext data packet seeds by the streaming media server, and specifically comprises the following steps: for a first ciphertext data packet of the plurality of ciphertext data packets, determining a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers; and for each ciphertext data packet after the first ciphertext data packet, determining the seed of the ciphertext data packet based on the seed, the first prime number and the second prime number of the last ciphertext data packet, wherein the last ciphertext data packet is a ciphertext data packet before the ciphertext data packet and adjacent to the ciphertext data packet.
In the embodiment of the present invention, for any ciphertext data packet included in the streaming media data, the seed of the ciphertext data packet may be calculated by the above formula (1); in this case, in the above formula (1), n is the number of the ciphertext data packet included in the streaming media data packet, F (n) is the seed of the ciphertext data packet with the number n, and F (n-1) is the seed of the previous ciphertext data packet of the ciphertext data packet with the number n. Therefore, for a first ciphertext data packet included in the streaming media data, F (n-1) is F (0), that is, a random seed of the streaming media data, and therefore, for the first ciphertext data packet in the plurality of ciphertext data packets, the seed of the first ciphertext data packet may be determined based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers, and for each ciphertext data packet subsequent to the first ciphertext data packet, the seed of the ciphertext data packet needs to be determined based on the seed of the last ciphertext data packet, the first prime number, and the second prime number. For example, for the second ciphertext data packet, the seed of the second ciphertext data packet needs to be determined based on the seed of the first ciphertext data packet, the first prime number, and the second prime number.
The terminal determines the seed of each byte in the plurality of ciphertext data packets respectively based on the seeds of the plurality of ciphertext data packets, the third prime number of the at least two prime numbers and the fourth prime number of the at least two prime numbers, and the method comprises the following steps: for each ciphertext data packet in the plurality of ciphertext data packets, determining an internal seed of the ciphertext data packet based on the seed of the ciphertext data packet; and determining the seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers and the fourth prime number of the at least two prime numbers.
The operation of the terminal determining the internal seed of the ciphertext data packet based on the seed of the ciphertext data packet may be the same as the method of the streaming media server determining the internal seed of the plaintext data packet, specifically: based on the seed of the ciphertext data packet, the internal seed of the ciphertext data packet may be determined according to the above formula (2), except that in this case, f (0) in the above formula (2) is the internal seed of the ciphertext data packet, and when the sequence number of the ciphertext data packet is n, f (n) is the seed of the ciphertext data packet.
Furthermore, the method for the terminal to determine the seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers, and the fourth prime number of the at least two prime numbers is the same as the method for the streaming media server to determine the seed of each byte in the plaintext data packet, and specifically includes: for a first byte in the ciphertext data packet, determining a seed of the first byte based on the internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers; for each byte after the first byte, determining the seed of the byte based on the seed of the last byte, the third prime number and the fourth prime number, the last byte being the byte before and adjacent to the byte.
In the embodiment of the present invention, for any byte in the ciphertext data packet, the seed of the byte may be calculated by the above formula (3); in this case, m in the above formula (3) is the sequence number of the byte in the ciphertext data packet, f (m) is the seed of the byte with sequence number m in the ciphertext data packet, f (m-1) is the seed of the previous byte of the byte with sequence number m in the ciphertext data packet, C is the third prime number, and D is the fourth prime number. Therefore, for the first byte in the ciphertext data packet, f (m-1) is f (0), that is, the internal seed of the ciphertext data packet, and therefore, for the first byte in the ciphertext data packet, the seed of the first byte may be determined based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers, and the fourth prime number of the at least two prime numbers, and for each byte after the first byte, the seed of the byte needs to be determined based on the seed of the last byte, the third prime number, and the fourth prime number, where the last byte is a byte before and adjacent to the byte. For example, for the second byte, the seed of the second byte needs to be determined based on the seed of the first byte, the third prime number, and the fourth prime number.
The terminal determines the key stream of the plurality of ciphertext data packets respectively based on the seed of each byte in the plurality of ciphertext data packets, and the method includes: obtaining the lowest-order byte of the seed of each byte in the ciphertext data packet to obtain a plurality of lowest-order bytes; and according to the sequence of each byte in the ciphertext data packet, forming the plurality of lowest-order bytes into a key stream of the ciphertext data packet.
In the embodiment of the present invention, the terminal obtains the lowest bit byte of the seed of each byte in the ciphertext data packet, and obtains a plurality of lowest bit bytes, which can be obtained according to the above formula (4); in this case, the lowest byte is obtained from the seed of the byte with the sequence number m in the ciphertext data packet as k (m) in the above formula (4).
Further, the method further comprises: when the terminal receives the next ciphertext data packet sent by the streaming media server, determining the key stream of the adjacent ciphertext data packet behind the last ciphertext data packet based on the seed of the last ciphertext data packet in the ciphertext data packets and the at least two prime numbers; and updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
For example, when the terminal receives a first ciphertext data packet sent by the streaming media server, the terminal may calculate the keystream of the first 2000 ciphertext data packets in the streaming media data, when the terminal receives a second ciphertext data packet sent by the streaming media server, the terminal may calculate the keystream of the 2001 ciphertext data packet, and when the terminal receives a third ciphertext data packet sent by the streaming media server, the terminal may calculate the keystream of the 2002 ciphertext data packet.
Based on the sequence number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet, the operation of updating the correspondence between the sequence number and the key stream by the terminal may be: and the terminal stores the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet in the corresponding relation between the serial number and the key stream. Or, in the corresponding relationship between the sequence number and the key stream, the sequence number of the first ciphertext data packet and the corresponding key stream are deleted, and the sequence number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet are stored in the corresponding relationship between the sequence number and the key stream.
For example, when the terminal receives the second ciphertext data packet sent by the streaming media server, the terminal may calculate the keystream of the 2001 th ciphertext data packet, and store the sequence number of the 2001 th ciphertext data packet and the keystream in the correspondence between the sequence number and the keystream. Or, the sequence number of the first ciphertext data packet and the key stream in the corresponding relation between the sequence number and the key stream are deleted, and the sequence number of the 2001 th ciphertext data packet and the key stream are stored in the corresponding relation between the sequence number and the key stream.
It should be noted that, in the embodiment of the present invention, the header of the ciphertext data packet sent by the streaming media server to the terminal may carry the sequence number of the ciphertext data packet, and the sequence number of the ciphertext data packet is not encrypted. Therefore, when the streaming media server transmits the ciphertext data packet through a User Datagram Protocol (UDP) and the sent ciphertext data packet is lost or out of order, as long as the sequence number of the ciphertext data packet is obtained from the packet header of the ciphertext data packet, the corresponding key stream can be obtained from the corresponding relationship between the sequence number and the key stream, so as to decrypt the ciphertext data packet, thereby improving the reliability of decryption of the ciphertext data packet. In addition, when the embodiment of the invention is used for encryption, only the seeds of the plaintext data packet, the internal seeds of the plaintext data packet and the seeds of each byte in the plaintext data packet need to be calculated, so that the calculation complexity is reduced, the performance of encrypting the plaintext data packet is better, and the efficiency of encrypting the plaintext data packet is further improved; similarly, when the embodiment of the invention decrypts, only the seed of the ciphertext data packet, the internal seed of the ciphertext data packet and the seed of each byte in the ciphertext data packet need to be calculated, so that the calculation complexity is reduced, the performance of encrypting the ciphertext data packet is better, and the efficiency of decrypting the ciphertext data packet is further improved.
It should be noted that, when the terminal receives the first ciphertext data packet, the terminal may determine the key streams of the plurality of ciphertext data packets based on the random seed and the at least two prime numbers for encrypting the streaming media data, then decrypt the first ciphertext data packet based on the key stream of the first ciphertext data packet to obtain the first plaintext data packet, and play the streaming media data based on the first plaintext data packet. Certainly, when the terminal receives the first ciphertext data packet, the terminal may determine the key stream of the first ciphertext data packet based on the random seed and the at least two prime numbers for encrypting the streaming media data, decrypt the first ciphertext data packet based on the key stream of the first ciphertext data packet to obtain the first plaintext data packet, play the streaming media data based on the first plaintext data packet, and calculate the key stream of consecutive ciphertext data packets with specified values after the first ciphertext data packet in the process of playing the streaming media data. The embodiment of the present invention is not particularly limited to this.
Step 408: and the terminal decrypts the ciphertext data packet based on the acquired key stream to obtain a corresponding plaintext data packet, and plays the streaming media data based on the plaintext data packet.
Specifically, the terminal may perform an exclusive-or operation on each byte in the obtained key stream and each byte in the ciphertext data packet, where the bytes are located at the same position, so as to obtain a plaintext data packet corresponding to the ciphertext data packet, and play the streaming media data based on the plaintext data packet.
It should be noted that, in the embodiment of the present invention, when the streaming media server transmits the ciphertext data packet through a TCP (transmission control Protocol), because the TCP is a connection-oriented, reliable transport layer communication Protocol based on a byte stream, that is, the TCP is streaming data instead of transmission of one data packet by one data packet, when the streaming media server encrypts the data packet by using the method provided in the embodiment of the present invention, the streaming media data needs to be divided to obtain a plurality of plaintext data packets. And how to divide the data into blocks, which is not limited in the embodiments of the present invention.
In addition, the encryption and decryption method provided by the embodiment of the invention can be applied to not only a scene of playing streaming media data, but also other scenes, for example, when a user logs in a certain application, the login account password can be encrypted in order to ensure the security of the login account and the password. The embodiment of the present invention is not particularly limited to this.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved. In addition, each plaintext data packet included in the streaming media data corresponds to a key stream, and the key stream does not depend on the plaintext data packet, so that in the process of sending the ciphertext data packet included in the streaming media data to the terminal, if the data packet is lost or out of order, the received ciphertext data packet can be decrypted, and the decryption reliability is improved.
Fig. 5 is a schematic structural diagram of a streaming media server according to an embodiment of the present invention. Referring to fig. 5, the streaming server includes:
an obtaining module 501, configured to obtain a random seed and at least two prime numbers for encrypting streaming media data when a streaming media data obtaining request sent by a terminal is received;
a determining module 502, configured to determine, based on the random seed and the at least two prime numbers, a key stream of a plurality of plaintext data packets included in the streaming media data;
an encrypting module 503, configured to encrypt the plaintext data packets based on the key streams of the plaintext data packets, respectively, to obtain ciphertext data packets;
the sending module 504 is configured to send the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
Optionally, the determining module 502 comprises:
a first determining unit, configured to determine seeds of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
a second determining unit, configured to determine a seed of each byte in the plurality of plaintext data packets based on the seeds of the plurality of plaintext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively;
and a third determining unit, configured to determine key streams of the plurality of plaintext data packets, respectively, based on a seed of each byte in the plurality of plaintext data packets.
Optionally, the first determination unit includes:
a first determining subunit, configured to determine, for a first plaintext data packet in the plurality of plaintext data packets, a seed of the first plaintext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
and the second determining subunit is used for determining the seed of the plaintext data packet based on the seed of the previous plaintext data packet, the first prime number and the second prime number for each plaintext data packet after the first plaintext data packet, wherein the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
Optionally, the second determination unit includes:
a third determining subunit, configured to determine, for each plaintext data packet in the plurality of plaintext data packets, an internal seed of the plaintext data packet based on the seed of the plaintext data packet;
a fourth determining subunit, configured to determine a seed of each byte in the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers.
Alternatively,
a fourth determining subunit, specifically configured to:
for a first byte in the plaintext data packet, determining a seed of the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the plaintext data packet, determining a seed for the byte based on a seed for a last byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, the third determining unit includes:
the acquiring subunit is used for acquiring the lowest-order byte of the seed of each byte in the plaintext data packets to obtain a plurality of lowest-order bytes for each plaintext data packet in the plurality of plaintext data packets;
and the forming subunit is used for forming the plurality of lowest-order bytes into the key stream of the plaintext data packet according to the sequence of each byte in the plaintext data packet.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
Fig. 6 is a schematic structural diagram of a terminal according to an embodiment of the present invention. Referring to fig. 6, the terminal includes:
a sending module 601, configured to send a streaming media data obtaining request to a streaming media server when receiving a streaming media data obtaining instruction, so that the streaming media server returns a ciphertext data packet of the streaming media data, where the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
an obtaining module 602, configured to, when a ciphertext data packet sent by the streaming media server is received, obtain, based on a sequence number of the ciphertext data packet, a corresponding key stream from a correspondence between a stored sequence number and a key stream;
a decryption module 603, configured to decrypt the ciphertext data packet based on the obtained key stream, so as to obtain the plaintext data packet;
the playing module 604 is configured to play the streaming media data based on the plaintext data packet.
Optionally, the terminal further includes:
a first determining module, configured to determine, when a first ciphertext data packet sent by the streaming media server is received, a key stream of a plurality of ciphertext data packets based on a random seed and at least two prime numbers encrypted by the streaming media data, where the plurality of ciphertext data packets include the first ciphertext data packet and a specified number of ciphertext data packets consecutive to the first ciphertext data packet;
and the storage module is used for storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams.
Optionally, the first determining module includes:
a first determining unit, configured to determine seeds of the multiple ciphertext data packets based on the random seed for encrypting the streaming media data, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers, respectively;
a second determining unit, configured to determine a seed of each byte in the plurality of ciphertext data packets, based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively;
and the third determining unit is used for respectively determining the key stream of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets.
Optionally, the first determination unit includes:
a first determining subunit, configured to determine, for a first ciphertext data packet of the plurality of ciphertext data packets, a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
and the second determining subunit is configured to determine, for each ciphertext data packet subsequent to the first ciphertext data packet, a seed of the ciphertext data packet based on the seed of a last ciphertext data packet, the first prime number, and the second prime number, where the last ciphertext data packet is a ciphertext data packet that is previous to the ciphertext data packet and adjacent to the ciphertext data packet.
Optionally, the second determination unit includes:
a third determining subunit, configured to determine, for each ciphertext data packet of the plurality of ciphertext data packets, an internal seed of the ciphertext data packet based on the seed of the ciphertext data packet;
and the fourth determining subunit is used for determining the seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers and the fourth prime number of the at least two prime numbers.
Alternatively,
a fourth determining subunit, specifically configured to:
for a first byte in the ciphertext data packet, determining a seed of the first byte based on an internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the ciphertext data packet, determining a seed for a last byte based on the seed for the byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, the third determining unit includes:
the obtaining subunit is used for obtaining the lowest-order byte of the seed of each byte in the ciphertext data packet to obtain a plurality of lowest-order bytes;
and the composition subunit is used for composing the plurality of lowest-order bytes into the key stream of the ciphertext data packet according to the sequence of each byte in the ciphertext data packet.
Optionally, the terminal further includes:
a second determining module, configured to determine, when a next ciphertext data packet sent by the streaming media server is received, a key stream of an adjacent ciphertext data packet after a last ciphertext data packet based on a seed of the last ciphertext data packet in the ciphertext data packets and the at least two prime numbers;
and the updating module is used for updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
It should be noted that: in the streaming media data playing apparatus provided in the foregoing embodiment, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above. In addition, the streaming media data playing apparatus and the streaming media data playing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
Referring to fig. 7, a schematic structural diagram of a streaming media server according to an embodiment of the present invention is shown. The streaming media server 700 includes a Central Processing Unit (CPU)701, a system memory 704 including a Random Access Memory (RAM)702 and a Read Only Memory (ROM)703, and a system bus 705 connecting the system memory 704 and the central processing unit 701. The streaming media server 700 also includes a basic input/output system (I/O system) 706 to facilitate information transfer between devices within the computer, and a mass storage device 707 for storing an operating system 713, application programs 710, and other program modules 715.
The basic input/output system 706 comprises a display 708 for displaying information and an input device 709, such as a mouse, keyboard, etc., for a user to input information. Wherein the display 708 and input device 709 are connected to the central processing unit 701 through an input output controller 710 coupled to the system bus 705. The basic input/output system 706 may also include an input/output controller 710 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input-output controller 710 may also provide output to a display screen, a printer, or other type of output device.
The mass storage device 707 is connected to the central processing unit 701 through a mass storage controller (not shown) connected to the system bus 705. The mass storage device 707 and its associated computer-readable media provide non-volatile storage for the streaming media server 700. That is, the mass storage device 707 may include a computer-readable medium (not shown), such as a hard disk or CD-ROM drive.
Without loss of generality, the computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM, EEPROM, flash memory or other solid state memory technology, CD-ROM, DVD, or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the foregoing. The system memory 704 and mass storage device 707 described above may be collectively referred to as memory.
The streaming media server 700 may also operate as a remote computer connected to a network through a network such as the internet according to various embodiments of the present invention. That is, the streaming media server 700 may be connected to the network 712 through the network interface unit 711 connected to the system bus 705, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 711.
The memory further includes one or more programs, the one or more programs are stored in the memory, and the one or more programs include instructions for performing the streaming media data playing method provided by the embodiment of the present invention, including:
when a streaming media data acquisition request sent by a terminal is received, acquiring a random seed and at least two prime numbers encrypted by the streaming media data;
determining a key stream of a plurality of plaintext data packets included in the streaming media data based on the random seed and the at least two prime numbers;
encrypting the plurality of plaintext data packets respectively based on the key stream of the plurality of plaintext data packets to obtain a plurality of ciphertext data packets;
and sending the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
Optionally, determining, based on the random seed and the at least two prime numbers, a key stream of a plurality of plaintext data packets included in the streaming media data, includes:
determining seeds of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers and a second prime number of the at least two prime numbers;
determining a seed of each byte in the plurality of plaintext data packets respectively based on the seeds of the plurality of plaintext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers;
and respectively determining key streams of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets.
Optionally, determining a seed of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers, includes:
for a first plaintext data packet of the plurality of plaintext data packets, determining a seed of the first plaintext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
for each plaintext data packet after the first plaintext data packet, determining the seed of the plaintext data packet based on the seed of the previous plaintext data packet, the first prime number and the second prime number, wherein the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
Optionally, determining a seed of each byte in the plurality of plaintext data packets based on the seed of the plurality of plaintext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively, includes:
for each plaintext data packet in the plurality of plaintext data packets, determining an internal seed of the plaintext data packet based on the seed of the plaintext data packet;
determining a seed for each byte within the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers.
Optionally, determining a seed of each byte in the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, includes:
for a first byte in the plaintext data packet, determining a seed of the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the plaintext data packet, determining a seed for the byte based on a seed for a last byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, determining the key stream of the plurality of plaintext data packets based on the seed of each byte in the plurality of plaintext data packets respectively includes:
for each plaintext data packet in the plurality of plaintext data packets, acquiring the lowest-order byte of the seed of each byte in the plaintext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the plaintext data packet, forming the plurality of lowest-order bytes into the key stream of the plaintext data packet.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
Referring to fig. 8, which illustrates a block diagram of a terminal according to an embodiment of the present invention, the terminal 800 may include a communication unit 810, a memory 820 including one or more computer-readable storage media, an input unit 830, a display unit 840, a sensor 850, an audio circuit 860, a WIFI (Wireless Fidelity) module 870, a processor 880 including one or more processing cores, and a power supply 890. Those skilled in the art will appreciate that the terminal structure shown in fig. 8 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the communication unit 810 may be used for receiving and transmitting information or signals during a call, and the communication unit 810 may be an RF (Radio Frequency) circuit, a router, a modem, or other network communication devices. Specifically, when the communication unit 810 is an RF circuit, downlink information of a base station is received and then delivered to the one or more processors 880 for processing; in addition, data relating to uplink is transmitted to the base station. Generally, the RF circuit as a communication unit includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the communication unit 810 can also communicate with a network and other devices through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (general packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (long term Evolution), email, SMS (Short Messaging Service), and the like. The memory 820 may be used to store software programs and modules, and the processor 880 executes various functional applications and data processing by operating the software programs and modules stored in the memory 820. The memory 820 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal 800, and the like. Further, the memory 820 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 820 may also include a memory controller to provide the processor 880 and the input unit 830 access to the memory 820.
The input unit 830 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. Preferably, the input unit 830 may include a touch-sensitive surface 831 as well as other input devices 832. The touch-sensitive surface 831, also referred to as a touch display screen or a touch pad, may collect touch operations by a user on or near the touch-sensitive surface 831 (e.g., operations by a user on or near the touch-sensitive surface 831 using a finger, a stylus, or any other suitable object or attachment) and drive the corresponding connection device according to a predefined program. Alternatively, the touch-sensitive surface 831 can include two portions, a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts it to touch point coordinates, and sends the touch point coordinates to the processor 880, and can receive and execute commands from the processor 880. In addition, the touch-sensitive surface 831 can be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. The input unit 830 may include other input devices 832 in addition to the touch-sensitive surface 831. Preferably, other input devices 832 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 840 may be used to display information input by or provided to a user and various graphical user interfaces of the terminal 800, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 840 may include a Display panel 841, and the Display panel 841 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like, as an option. Further, touch-sensitive surface 831 can overlay display panel 841 and, upon detecting a touch operation on or near touch-sensitive surface 831, communicate to processor 880 to determine the type of touch event, whereupon processor 880 can provide a corresponding visual output on display panel 841 in accordance with the type of touch event. Although in FIG. 8, touch-sensitive surface 831 and display panel 841 are implemented as two separate components to implement input and output functions, in some embodiments, touch-sensitive surface 831 may be integrated with display panel 841 to implement input and output functions.
The terminal 800 can also include at least one sensor 850, such as light sensors, motion sensors, and other sensors. The light sensor may include an ambient light sensor that adjusts the brightness of the display panel 841 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 841 and/or backlight when the terminal 800 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the terminal 800, further description is omitted here.
To implement wireless communication, a wireless communication unit 870 may be configured on the terminal, and the wireless communication unit 870 may be a WIFI module. WIFI belongs to a short-distance wireless transmission technology, and the terminal 800 may help a user send and receive e-mails, browse webpages, access streaming media, and the like through the wireless communication unit 870, and provide the user with wireless broadband internet access. Although the wireless communication unit 870 is shown in the drawing, it is understood that it does not belong to the essential constitution of the terminal 800 and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 880 is a control center of the terminal 800, connects various parts of the entire handset using various interfaces and lines, and performs various functions of the terminal 800 and processes data by operating or executing software programs and/or modules stored in the memory 820 and calling data stored in the memory 820, thereby integrally monitoring the handset. Optionally, processor 880 may include one or more processing cores; preferably, the processor 880 may integrate an application processor, which mainly handles operating systems, user interfaces, applications, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 880.
Although not shown, the terminal 800 may further include a camera, a bluetooth module, etc., which will not be described herein.
In this embodiment, the terminal further includes one or more programs, where the one or more programs are stored in the memory and configured to be executed by one or more processors, and the one or more programs include instructions for performing the streaming media data playing method provided by the embodiment of the present invention, and the method includes:
when a streaming media data acquisition instruction is received, sending a streaming media data acquisition request to a streaming media server, and enabling the streaming media server to return a ciphertext data packet of the streaming media data, wherein the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
when receiving a ciphertext data packet sent by the streaming media server, acquiring a corresponding key stream from a corresponding relation between a stored sequence number and the key stream based on the sequence number of the ciphertext data packet;
decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet;
and playing the streaming media data based on the plaintext data packet.
Optionally, before acquiring a corresponding key stream from the correspondence between the stored sequence number and the key stream based on the sequence number of the ciphertext data packet, the method further includes:
when a first ciphertext data packet sent by the streaming media server is received, determining a key stream of a plurality of ciphertext data packets based on a random seed and at least two prime numbers encrypted by the streaming media data, wherein the plurality of ciphertext data packets comprise the first ciphertext data packet and a plurality of ciphertext data packets with continuous designated values behind the first ciphertext data packet;
and storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams.
Optionally, determining key streams of a plurality of ciphertext data packets based on the random seed and at least two prime numbers of the stream media data encryption includes:
determining seeds of the plurality of ciphertext data packets respectively based on the random seed encrypted by the streaming media data, a first prime number of the at least two prime numbers and a second prime number of the at least two prime numbers;
determining a seed of each byte in the plurality of ciphertext data packets respectively based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers and a fourth prime number of the at least two prime numbers;
and respectively determining key streams of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets.
Optionally, determining the seeds of the plurality of ciphertext data packets based on the encrypted random seed of the streaming media data, the first prime number of the at least two prime numbers, and the second prime number of the at least two prime numbers, respectively, includes:
for a first ciphertext data packet of the plurality of ciphertext data packets, determining a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least two prime numbers, and a second prime number of the at least two prime numbers;
and for each ciphertext data packet after the first ciphertext data packet, determining the seed of the ciphertext data packet based on the seed of the last ciphertext data packet, the first prime number and the second prime number, wherein the last ciphertext data packet is a ciphertext data packet before the ciphertext data packet and adjacent to the ciphertext data packet.
Optionally, determining a seed of each byte in the plurality of ciphertext data packets based on the seed of the plurality of ciphertext data packets, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, respectively, includes:
for each ciphertext data packet in the plurality of ciphertext data packets, determining an internal seed of the ciphertext data packet based on the seed of the ciphertext data packet;
and determining the seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, the third prime number of the at least two prime numbers and the fourth prime number of the at least two prime numbers.
Optionally, determining a seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers, includes:
for a first byte in the ciphertext data packet, determining a seed of the first byte based on an internal seed of the ciphertext data packet, a third prime number of the at least two prime numbers, and a fourth prime number of the at least two prime numbers;
for each byte subsequent to the first byte in the ciphertext data packet, determining a seed for a last byte based on the seed for the byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
Optionally, respectively determining key streams of the plurality of ciphertext data packets based on the seed of each byte in the plurality of ciphertext data packets, includes:
obtaining the lowest-order byte of the seed of each byte in the ciphertext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the ciphertext data packet, forming the plurality of lowest-order bytes into a key stream of the ciphertext data packet.
Optionally, the method further comprises:
when a next ciphertext data packet sent by the streaming media server is received, determining a key stream of an adjacent ciphertext data packet behind the last ciphertext data packet based on the seed of the last ciphertext data packet in the ciphertext data packets and the at least two prime numbers;
and updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
In this embodiment of the present invention, the streaming media server determines, based on the random seed and the at least two prime numbers, key streams of a plurality of plaintext data packets included in the streaming media data, and encrypts the plurality of plaintext data packets based on the key streams of the plurality of plaintext data packets, respectively. Because the randomness of the random seed of the streaming media data is high, and the repeatability of generating the random sequence through the prime number is low, when the key stream of a plurality of plaintext data packets included in the streaming media data is determined through the random seed and at least two prime numbers, the probability of repeated bytes appearing in the key stream is low, the key stream is not easy to attack, and the safety of the streaming media data is improved.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (22)
1. A method for playing streaming media data, the method comprising:
when a streaming media data acquisition request sent by a terminal is received, acquiring a random seed and at least four prime numbers of the encrypted streaming media data;
determining seeds of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least four prime numbers and a second prime number of the at least four prime numbers;
determining a seed of each byte in the plurality of plaintext data packets based on the seeds of the plurality of plaintext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers, respectively;
determining key streams of the plurality of plaintext data packets respectively based on the seed of each byte in the plurality of plaintext data packets;
encrypting the plaintext data packets respectively based on the key streams of the plaintext data packets to obtain ciphertext data packets;
and sending the plurality of ciphertext data packets to the terminal, so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
2. The method of claim 1, wherein the determining the seed for the plurality of plaintext data packets that the streaming media data comprises based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers comprises:
for a first plaintext data packet of the plurality of plaintext data packets, determining a seed of the first plaintext data packet based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers;
for each plaintext data packet after the first plaintext data packet, determining the seed of the plaintext data packet based on the seed of the previous plaintext data packet, the first prime number and the second prime number, where the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
3. The method of claim 1, wherein the separately determining the seed for each byte within the plurality of plaintext data packets based on the seed for the plurality of plaintext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers comprises:
for each plaintext data packet in the plurality of plaintext data packets, determining an internal seed of the plaintext data packet based on a seed of the plaintext data packet;
determining a seed for each byte within the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers.
4. The method of claim 3, wherein determining the seed for each byte within the plaintext data packet based on the internal seed for the plaintext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers comprises:
for a first byte within the plaintext data packet, determining a seed for the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers;
for each byte subsequent to the first byte within the plaintext data packet, determining a seed for the byte based on a seed for a last byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
5. The method of claim 1, wherein said separately determining the keystream for the plurality of plaintext data packets based on a seed for each byte within the plurality of plaintext data packets comprises:
for each plaintext data packet in the plurality of plaintext data packets, acquiring the lowest-order byte of the seed of each byte in the plaintext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the plaintext data packet, forming the plurality of lowest-order bytes into the key stream of the plaintext data packet.
6. A method for playing streaming media data, the method comprising:
when a streaming media data acquisition instruction is received, sending a streaming media data acquisition request to a streaming media server, and enabling the streaming media server to return a ciphertext data packet of the streaming media data, wherein the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
when a first ciphertext data packet sent by the streaming media server is received, determining seeds of a plurality of ciphertext data packets respectively based on a random seed encrypted by the streaming media data, a first prime number in at least four prime numbers and a second prime number in the at least four prime numbers, wherein the plurality of ciphertext data packets comprise the first ciphertext data packet and a plurality of ciphertext data packets with continuous designated values behind the first ciphertext data packet;
determining a seed of each byte in the plurality of ciphertext data packets based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers, respectively;
determining key streams of the plurality of ciphertext data packets respectively based on the seed of each byte in the plurality of ciphertext data packets;
storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams;
based on the serial number of the ciphertext data packet sent by the streaming media server, acquiring a corresponding key stream from the corresponding relation between the stored serial number and the key stream;
decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet;
and playing the streaming media data based on the plaintext data packet.
7. The method of claim 6, wherein the determining the seed of the plurality of ciphertext data packets based on the random seed for the encryption of the streaming media data, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers, respectively, comprises:
for a first ciphertext data packet of the plurality of ciphertext data packets, determining a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers;
and for each ciphertext data packet after the first ciphertext data packet, determining the seed of the ciphertext data packet based on the seed of the last ciphertext data packet, the first prime number and the second prime number, wherein the last ciphertext data packet is a ciphertext data packet before the ciphertext data packet and adjacent to the ciphertext data packet.
8. The method of claim 6, wherein the separately determining the seed for each byte within the plurality of ciphertext data packets based on the seed for the plurality of ciphertext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers comprises:
for each ciphertext data packet of the plurality of ciphertext data packets, determining an internal seed for the ciphertext data packet based on the seed for the ciphertext data packet;
determining a seed for each byte within the ciphertext data packet based on the internal seed of the ciphertext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers.
9. The method of claim 8, wherein determining the seed for each byte within the ciphertext data packet based on the internal seed of the ciphertext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers comprises:
for a first byte within the ciphertext data packet, determining a seed for the first byte based on an internal seed of the ciphertext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers;
for each byte subsequent to the first byte within the ciphertext data packet, determining a seed for a last byte based on the seed for the byte, the third prime, and the fourth prime, the last byte being a byte preceding and adjacent to the byte.
10. The method of claim 6, wherein the separately determining the keystream for the plurality of ciphertext data packets based on a seed for each byte within the plurality of ciphertext data packets comprises:
obtaining the lowest-order byte of the seed of each byte in the ciphertext data packet to obtain a plurality of lowest-order bytes;
and according to the sequence of each byte in the ciphertext data packet, forming the plurality of lowest-order bytes into a key stream of the ciphertext data packet.
11. The method of claim 6, wherein the method further comprises:
when a next ciphertext data packet sent by the streaming media server is received, determining a key stream of an adjacent ciphertext data packet behind the last ciphertext data packet based on the seed of the last ciphertext data packet in the plurality of ciphertext data packets and the at least four prime numbers;
and updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
12. A streaming media server, characterized in that the streaming media server comprises:
the acquisition module is used for acquiring a random seed and at least four prime numbers encrypted by the streaming media data when a streaming media data acquisition request sent by a terminal is received;
a determining module, including a first determining unit, a second determining unit, and a third determining unit, where the first determining unit is configured to determine seeds of a plurality of plaintext data packets included in the streaming media data based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers; the second determining unit is configured to determine a seed of each byte in the plurality of plaintext data packets based on the seeds of the plurality of plaintext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers, respectively; the third determining unit is configured to determine key streams of the plurality of plaintext data packets respectively based on a seed of each byte in the plurality of plaintext data packets;
the encryption module is used for respectively encrypting the plaintext data packets based on the key streams of the plaintext data packets to obtain ciphertext data packets;
and the sending module is used for sending the plurality of ciphertext data packets to the terminal so that the terminal plays the streaming media data based on the plurality of ciphertext data packets.
13. The streaming media server according to claim 12, wherein the first determining unit comprises:
a first determining subunit, configured to determine, for a first plaintext data packet in the plurality of plaintext data packets, a seed of the first plaintext data packet based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers;
a second determining subunit, configured to determine, for each plaintext data packet after the first plaintext data packet, a seed of a previous plaintext data packet based on the seed of the previous plaintext data packet, the first prime number, and the second prime number, where the previous plaintext data packet is a plaintext data packet before the plaintext data packet and adjacent to the plaintext data packet.
14. The streaming media server of claim 12, wherein the second determining unit comprises:
a third determining subunit, configured to determine, for each plaintext data packet in the plurality of plaintext data packets, an internal seed of the plaintext data packet based on the seed of the plaintext data packet;
a fourth determining subunit, configured to determine a seed of each byte in the plaintext data packet based on the internal seed of the plaintext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers.
15. The streaming media server of claim 14,
the fourth determining subunit is specifically configured to:
for a first byte within the plaintext data packet, determining a seed for the first byte based on an internal seed of the plaintext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers;
for each byte subsequent to the first byte within the plaintext data packet, determining a seed for the byte based on a seed for a last byte, the third prime number, and the fourth prime number, the last byte being a byte preceding and adjacent to the byte.
16. The streaming media server according to claim 12, wherein the third determining unit comprises:
the acquiring subunit is configured to acquire, for each plaintext data packet in the plurality of plaintext data packets, a lowest-order byte of a seed of each byte in the plaintext data packet to obtain a plurality of lowest-order bytes;
and the forming subunit is used for forming the plurality of lowest-order bytes into the key stream of the plaintext data packet according to the sequence of each byte in the plaintext data packet.
17. A terminal, characterized in that the terminal comprises:
the sending module is used for sending a streaming media data obtaining request to a streaming media server when receiving a streaming media data obtaining instruction, so that the streaming media server returns a ciphertext data packet of the streaming media data, wherein the ciphertext data packet is obtained by encrypting a plaintext data packet of the streaming media data by the streaming media server;
the first determining unit is configured to determine seeds of a plurality of ciphertext data packets respectively based on a random seed for encrypting the streaming media data, a first prime number of at least four prime numbers, and a second prime number of the at least four prime numbers when a first ciphertext data packet sent by the streaming media server is received, where the plurality of ciphertext data packets include a specified number of ciphertext data packets that are consecutive after the first ciphertext data packet and the first ciphertext data packet; the second determining unit is configured to determine a seed of each byte in the plurality of ciphertext data packets based on the seeds of the plurality of ciphertext data packets, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers, respectively; the third determining unit is configured to determine key streams of the plurality of ciphertext data packets respectively based on a seed of each byte in the plurality of ciphertext data packets;
the storage module is used for storing the serial numbers of the plurality of ciphertext data packets and the key streams of the plurality of ciphertext data packets in the corresponding relation between the serial numbers and the key streams;
the acquisition module is used for acquiring a corresponding key stream from the corresponding relation between the stored serial number and the key stream based on the serial number of the ciphertext data packet sent by the streaming media server;
the decryption module is used for decrypting the ciphertext data packet based on the acquired key stream to obtain the plaintext data packet;
and the playing module is used for playing the streaming media data based on the plaintext data packet.
18. The terminal of claim 17, wherein the first determining unit comprises:
a first determining subunit, configured to determine, for a first ciphertext data packet of the plurality of ciphertext data packets, a seed of the first ciphertext data packet based on the random seed, a first prime number of the at least four prime numbers, and a second prime number of the at least four prime numbers;
and a second determining subunit, configured to determine, for each ciphertext data packet subsequent to the first ciphertext data packet, a seed of a last ciphertext data packet based on the seed of the last ciphertext data packet, the first prime number, and the second prime number, where the last ciphertext data packet is a ciphertext data packet that is previous to the ciphertext data packet and adjacent to the ciphertext data packet.
19. The terminal of claim 17, wherein the second determining unit comprises:
a third determining subunit, configured to determine, for each ciphertext data packet of the plurality of ciphertext data packets, an internal seed of the ciphertext data packet based on the seed of the ciphertext data packet;
a fourth determining subunit, configured to determine a seed of each byte in the ciphertext data packet based on the internal seed of the ciphertext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers.
20. The terminal of claim 19,
the fourth determining subunit is specifically configured to:
for a first byte within the ciphertext data packet, determining a seed for the first byte based on an internal seed of the ciphertext data packet, a third prime number of the at least four prime numbers, and a fourth prime number of the at least four prime numbers;
for each byte subsequent to the first byte within the ciphertext data packet, determining a seed for a last byte based on the seed for the byte, the third prime, and the fourth prime, the last byte being a byte preceding and adjacent to the byte.
21. The terminal of claim 17, wherein the third determining unit comprises:
the obtaining subunit is configured to obtain a lowest-order byte of a seed of each byte in the ciphertext data packet, and obtain a plurality of lowest-order bytes;
and the composition subunit is used for composing the plurality of lowest-order bytes into the key stream of the ciphertext data packet according to the sequence of each byte in the ciphertext data packet.
22. The terminal of claim 17, wherein the terminal further comprises:
a second determining module, configured to determine, when a next ciphertext data packet sent by the streaming media server is received, a key stream of an adjacent ciphertext data packet after a last ciphertext data packet in the plurality of ciphertext data packets based on a seed of the last ciphertext data packet and the at least four prime numbers;
and the updating module is used for updating the corresponding relation between the serial number and the key stream based on the serial number of the ciphertext data packet adjacent to the last ciphertext data packet and the key stream of the ciphertext data packet adjacent to the last ciphertext data packet.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510220928.5A CN106209736B (en) | 2015-05-04 | 2015-05-04 | Streaming media data playing method, terminal and streaming media server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510220928.5A CN106209736B (en) | 2015-05-04 | 2015-05-04 | Streaming media data playing method, terminal and streaming media server |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106209736A CN106209736A (en) | 2016-12-07 |
CN106209736B true CN106209736B (en) | 2020-01-17 |
Family
ID=57458639
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510220928.5A Active CN106209736B (en) | 2015-05-04 | 2015-05-04 | Streaming media data playing method, terminal and streaming media server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106209736B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1714531A (en) * | 2002-11-20 | 2005-12-28 | 斯蒂芬·L.·博伦 | Method of generating a stream cipher using multiple keys |
CN104618091A (en) * | 2015-02-16 | 2015-05-13 | 哈尔滨理工大学 | Dual-chaotic system dynamic key and RSA jointed streaming media secret communication method |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9043588B2 (en) * | 2012-05-08 | 2015-05-26 | Alcatel Lucent | Method and apparatus for accelerating connections in a cloud network |
-
2015
- 2015-05-04 CN CN201510220928.5A patent/CN106209736B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1714531A (en) * | 2002-11-20 | 2005-12-28 | 斯蒂芬·L.·博伦 | Method of generating a stream cipher using multiple keys |
CN104618091A (en) * | 2015-02-16 | 2015-05-13 | 哈尔滨理工大学 | Dual-chaotic system dynamic key and RSA jointed streaming media secret communication method |
Also Published As
Publication number | Publication date |
---|---|
CN106209736A (en) | 2016-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111600710B (en) | Key storage method, device, terminal, server and readable medium | |
CN106850220B (en) | Data encryption method, data decryption method and device | |
CN110417543B (en) | Data encryption method, device and storage medium | |
CN106712932B (en) | Key management method, apparatus and system | |
WO2018176781A1 (en) | Information sending method, information receiving method, apparatus, and system | |
CN108011879B (en) | File encryption and decryption method, device, equipment and storage medium | |
CN104821937A (en) | Token acquisition method, device and system | |
CN111064713B (en) | Node control method and related device in distributed system | |
CN107154935B (en) | Service request method and device | |
US10454905B2 (en) | Method and apparatus for encrypting and decrypting picture, and device | |
CN106845177A (en) | Cipher management method and system | |
CN114553612B (en) | Data encryption and decryption method and device, storage medium and electronic equipment | |
CN107404720B (en) | Method for resetting wireless setting information and related equipment | |
CN114629649B (en) | Data processing method and device based on cloud computing and storage medium | |
CN117318937A (en) | Encryption method, decryption method, encryption and decryption system, equipment and medium | |
WO2017185312A1 (en) | Encryption and decryption methods and devices | |
CN104639394A (en) | Statistical method, device and system for number of users of client | |
CN115589286B (en) | Data encryption and decryption method and device, electronic equipment and storage medium | |
CN108880787B (en) | Information key processing method and related equipment | |
CN106209736B (en) | Streaming media data playing method, terminal and streaming media server | |
CN105306505A (en) | Data updating methods, terminal and server | |
CN111090894B (en) | Method and device for reconstructing data of lock card | |
CN114389825B (en) | Data communication method based on block chain and related device | |
CN116073985A (en) | Data processing method and related device | |
CN117118647A (en) | Data encryption method, device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |