Embodiment
Refer to shown in Fig. 1 to Fig. 4, a kind of network terminal control method for playing back verified based on AES and material of the present invention, comprises the steps:
Step 1, ad content the html file (or htm file), txt text and the playlist xml file that use play by the network terminal carry out aes algorithm encryption by platform end, the material that the ad content of network terminal broadcasting is quoted is uploaded by platform end, and adds cryptographic check code at each material end;
Wherein, described ad content the html file, txt text and the playlist xml file that use play by the network terminal carries out aes algorithm encryption by platform end, specifically comprises the steps:
Step 10, the html file, txt text and the playlist xml file that use at platform end acquisition ad content; These three files are operated to step 18 by step 11 one by one:
The length of step 11, calculation document, obtains the file length value of the HEX form of 4 bytes, and inadequate 4 bytes of length of file length value, mend 0 above; More than 4 bytes, remove the high byte exceeded, retain the value of low 4 bytes;
The School Affairs of step 12, calculation document, obtains the checksum value of the HEX form of 4 bytes, and checksum value is obtained by accumulation calculating all bytes of whole file, and inadequate 4 bytes of checksum value length, mend 0 above; More than 4 bytes, remove the high byte exceeded, retain the value of low 4 bytes;
The alignment check value of step 13, acquisition file, obtain the alignment check value of the HEX form of 2 bytes, alignment check value is by the first byte of checksum value and low 42 bytes formed of the second byte in high 4 and the step 12 of the first byte of step 11 file length value and the second byte;
Step 14, the threshold value A (this threshold value A is 4 byte values that platform end and the network terminal are arranged) of 4 bytes file length value in step 11 and platform end preset carry out XOR (XOR) computing, again operation result is changed into ASCII value B, this B is the character string of 8 bytes;
Step 15, this threshold value C of threshold value C(of 4 bytes checksum value in step 12 and platform end preset are 4 byte values that platform end and the network terminal are arranged) carry out XOR (XOR) computing, again operation result is changed into ASCII value D, this D is the character string of 8 bytes;
Step 16, the alignment check value in step 13 is changed into ASCII value E, this E is the character string of 4 bytes;
Step 17, the character string B obtaining in step 14, step 15, step 16, D, E, form the character string F of 20 bytes with BED order;
Step 18, the character string F in step 17 is appended to the end of this file, and encrypts this file with aes algorithm.
The material that the ad content of network terminal broadcasting is quoted is uploaded by platform end, and adds cryptographic check code at each material end, specifically comprise the steps:
Step 21, the story types uploaded according to platform end, find out and need material, i.e. picture file and video file; This picture file and video file are all operated to step 29 by step 22:
The length of step 22, calculation document; Obtain the file length value of the HEX form of 4 bytes, inadequate 4 bytes of length of file length value, mend 0 above; More than 4 bytes, remove the high byte exceeded, retain the value of low 4 bytes;
The CRC32 verification of step 23, calculation document; Obtain the check value of the HEX form of 2 bytes, this test value gets 1K byte and last 1K byte before this file to do CRC32 verification;
Step 24, acquisition alignment check value, obtain the alignment check value of the HEX form of 2 bytes; This alignment check value is by the first byte of CRC32 check value and low 42 bytes formed of the second byte in high 4 and the step 23 of the first byte of step 22 file length value and the second byte;
Step 25, the threshold value A of the file length value in step 22 and described 4 bytes is carried out XOR, then operation result is changed into ASCII value H, this H is the character string of 8 bytes;
Step 26, the threshold value C of the check value in step 23 and described 4 bytes is carried out XOR, then operation result is changed into ASCII value I, this I is the character string of 8 bytes;
Step 27, the alignment check value in step 24 is changed into ASCII value J, this J is the character string of 4 bytes;
Step 28, the character string H obtaining in step 25, step 26, step 27, I, J, form the character string K of 20 bytes with HJI order;
Step 29, the character string K in step 28 done aes algorithm encryption, be then appended to the end of this file.
Step 2, platform end are by issuing download command to the network terminal, and the path at ftp server place needed for informing network terminal downloads,
Step 3, the network terminal obtain after described path resolves, and start FTP thread download html file, txt text and the playlist xml file after aes algorithm encryption and carry out end add the process of cryptographic check code after each material, (this playlist xml file is the strategy file that the network terminal controls media play, this file have recorded the material path and other property values of the time span of material broadcasting and the strategy of task switch etc. of quoting in network terminal playing process, the network terminal is in download material process with when calling playlist xml file broadcasting media task, all needing first to decipher playlist xml file and verification identifying code) network terminal is when broadcasting advertisement content, to the html file after encryption, txt text and playlist xml file are decrypted, and each material quoted in ad content is verified,
Step 4, when deciphering html file, txt text and playlist xml file, any file decryption is wrong or checking material is wrong, then the network terminal plays this wrong file or wrong material by forbidding; And reporting platform end, corresponding wrong file or material are downloaded in request again.
Wherein, the described network terminal, when broadcasting advertisement content, is decrypted html file, txt text and playlist xml file after encryption, specifically comprises the steps:
Step 31, the network terminal obtain each file downloaded, and judge whether each file type downloaded is html file, txt text or playlist xml file; Then each file downloaded is operated to step 38 according to step 32 one by one, no, then do not operate;
Step 32, the file downloaded with aes algorithm deciphering;
Step 33, extract this end of file 20 byte, and resolve into three parts, Part I is 8 bytes above in 20 bytes, and this character string is changed into the value L of the HEX form of 4 bytes; Part II is middle 4 bytes in 20 bytes, and the character string of middle 4 bytes is changed into the value M of the HEX form of 2 bytes; Part III is last 8 bytes in 20 bytes, and the character string of these last 8 bytes is changed into the value N of the HEX form of 4 bytes;
Step 34, the L obtained in step 33 and the threshold value A of described 4 bytes are carried out XOR, obtain result O; The threshold value C of the N obtained in step 33 and described 4 bytes is carried out XOR, obtains result P;
First byte and the second byte high 4 and extract the low 4 of the first byte and the second byte in P, the Q value of composition 2 bytes in O in step 35, extraction step 34;
Step 36, compare M value and whether Q value is equal, if equal, then continue step 37; If unequal, then forbid broadcasting advertisement content, and report the alignment of platform end file verification to make mistakes, request re-issues this file;
Step 37, remove end of file 20 bytes after, calculate length R and the School Affairs S of this file;
In step 38, determining step 37, whether R equals O, and whether S equals P; The two is all equal, then continue material checking, if one of them does not wait or the two is all unequal, then forbid broadcasting advertisement content, and report the bad checksum of platform end file, request re-issues this file.
The network terminal generally hardware resource is all relatively nervous, especially processes relatively large material file, as video file and picture file.Therefore, calculate the check value of picture and video, just do not adopt the cumulative sum algorithm of byte in full, but directly obtain this file header 1K byte and last 1K byte, then make CRC32 algorithm calculation check value.So just can shorten the CPU processing time to a great extent, improve running efficiency of system.The file relative path in the present invention, verify each material quoted in ad content, specifically comprise the steps: step 41, providing according to play list file obtains material in this locality, i.e. picture file or video file;
The character string of step 42,20 bytes in extraction document end, and being first decrypted with aes algorithm, then resolves into three parts, and Part I is 8 bytes above in 20 bytes, and this character string is changed into the value T of the HEX form of 4 bytes; Part II is middle 4 bytes in 20 bytes, and the character string of middle 4 bytes is changed into the value U of the HEX form of 2 bytes; Part III is last 8 bytes in 20 bytes, and the character string of last 8 bytes is changed into the value V of the HEX form of 4 bytes;
Step 43, the T obtained in step 42 and the threshold value A of described 4 bytes are carried out XOR, obtain result W; The threshold value C of the V obtained in step 42 and described 4 bytes is carried out XOR, obtains result X;
First byte and the second byte high 4 and extract the low 4 of the first byte and the second byte in X, the Y value of composition 2 bytes in W in step 44, extraction step 43;
Step 45, compare U value and whether Y value is equal, if equal, then continue step 46; If unequal, then forbid broadcasting advertisement content, and report the alignment of platform end picture file or video file verification to make mistakes, request re-issues this file;
Step 46, remove end of file 20 bytes after, calculate length Z and the CRC32 check value AB of this file, this check value AB does CRC32 computing obtain for getting file header 1K byte and end 1K byte;
In step 47, determining step 46, whether Z equals W, and whether AB equals X; The two is all equal, then, and and broadcasting advertisement content; If one of them does not wait or the two is all unequal, then forbid broadcasting advertisement content, and report platform end picture file or video file bad checksum, request re-issues this file.
Here it is worth mentioning that:
1, platform end encrypted authentication html(or htm) file, txt text, playlist xml file,
Platform end is according to the file uploaded, determine whether html(or htm) file, txt text, playlist xml file, when being these files, the file structure that final operation obtains is respectively as table 1:html(or htm) file structure, table 2:txt text structure, table 3 playlist xml file structure:
Table 1
Html file |
8 byte file length |
4 byte-aligned test values |
8 byte file School Affairs |
Table 2
Txt text |
8 byte file length |
4 byte-aligned test values |
8 byte file School Affairs |
Table 3
Playlist xml file |
8 byte file length |
4 byte-aligned test values |
8 byte file School Affairs |
Wherein: namely 8 byte file length are the ascii strings of 8 bytes, are character string B;
4 byte-aligned test values are also ascii strings, are character string E;
8 byte file School Affairs are also ascii strings, are character string D.
2, platform end encrypted authentication picture file, video file
Platform end, according to the file uploaded, determines whether picture file, video file, when being these files, finally operates the file structure that obtains respectively as table 4: picture file structure, table 5: video file structure.
Table 4
Picture file |
8 byte file length |
4 byte-aligned test values |
8 byte CRC32 check values |
Table 5
Video file |
8 byte file length |
4 byte-aligned test values |
8 byte CRC32 check values |
Wherein: namely 8 byte file length are the ascii strings of 8 bytes, are character string H;
The alignment test value of 4 bytes is also ascii string, is character string J;
8 byte CRC32 check values are also ascii strings, are character string I.
In a word, consider based on total system, especially for the embedded system that hardware resources is relatively nervous, propose a kind of novel encryption and verification algorithm.The data of media bearer are divided into two kinds of mode process by this algorithm, and one will carry out AES encryption in full, and another kind extracts certain position in data to make AES encryption.The effective combination of the two, in the fail safe of data content and the operational efficiency of system, finds a metastable balance point, is also well positioned to meet the Information Security of current device business proposition and the requirement of uniqueness.And it reduces in product the cost using encryption largely, improve product competitiveness in the market, and shorten the processing time of the network terminal to a great extent, also can ensure integrality and the uniqueness of material file.
The foregoing is only preferred embodiment of the present invention, all equalizations done according to the present patent application the scope of the claims change and modify, and all should belong to covering scope of the present invention.