CN103532706B - Data encryption/decryption method, device and mobile terminal - Google Patents

Data encryption/decryption method, device and mobile terminal Download PDF

Info

Publication number
CN103532706B
CN103532706B CN201210228169.3A CN201210228169A CN103532706B CN 103532706 B CN103532706 B CN 103532706B CN 201210228169 A CN201210228169 A CN 201210228169A CN 103532706 B CN103532706 B CN 103532706B
Authority
CN
China
Prior art keywords
key
byte
boolean function
encryption
key stream
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
Application number
CN201210228169.3A
Other languages
Chinese (zh)
Other versions
CN103532706A (en
Inventor
曲博
罗小伟
林福辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Spreadtrum Communications Shanghai Co Ltd
Original Assignee
Spreadtrum Communications Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Spreadtrum Communications Shanghai Co Ltd filed Critical Spreadtrum Communications Shanghai Co Ltd
Priority to CN201210228169.3A priority Critical patent/CN103532706B/en
Publication of CN103532706A publication Critical patent/CN103532706A/en
Application granted granted Critical
Publication of CN103532706B publication Critical patent/CN103532706B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of data encryption/decryption method, device and mobile terminal, are related to encryption technology field.The method includes:Key stream source is generated according to encryption key/decruption key;Boolean function is based on according to the key stream source and xor operation generates key stream;The key stream and data to be encrypted/to be decrypted are carried out into xor operation and generates encrypting/decrypting data.The encipher-decipher method of disclosure employing, apparatus structure are simple, relatively low to software and hardware requirement, can also use in the poor low side devices of computing capability, and the size of data after encrypting will not increase too much.

Description

Data encryption/decryption method, device and mobile terminal
Technical field
The present invention relates to data encryption technology, more particularly to a kind of data encryption/decryption method, device and mobile terminal.
Background technology
In the last few years, widely using with the hand-hold multimedia terminals equipment such as mobile phone, MP4, consumer is increasingly liked Carry out on devices watching the activities such as video.The development of memory technology is limited to, in many multimedia terminal equipments, especially It is that memory space is all very restricted, and consumer can be stored in then wishing equipment more more on the equipment of low side Content of multimedia.Additionally, the computing capability of low side devices is often also extremely limited.On the other hand, with the fast development of PC, Video on PC is all intended to SD and high definition rank now, and general resolution all in more than 480p (640x480), can reach 720p (1280x720) even more high.Thus there is the drop between actual demand and the disposal ability of hardware device.
Typically there are two kinds of approach to solve this problem.A kind of is that resolution higher video is placed directly on equipment to broadcast Put, another is first to be put into again in equipment to play video compress.When mobile terminal device calculating and storage capacity it is limited When, first method is infeasible, is so done, and on one side mobile terminal device, storable content is extremely limited, another Side is limited to computing capability, and institute's storage content may not also be correctly playable.Second method, can be according to mobile terminal device Practical capacity to wanting storage content to carry out proper treatment so that can ensure that deposited content can be correctly playable.
In this context, some mobile terminal device manufacturers etc. will consider how to keep clear to a certain extent In the case of clear degree, video compress is obtained into less.When this be made it is relatively good after, corresponding manufacturer will be considered how to this The technology of sample is protected, and widespread practice is that video is encrypted so that the video after process can only be in dedicated play Play on device.
When high-resolution video is played on the equipment of low resolution, original video output has to pass through the post processings such as scaling Operation could show all videos content.In this case, video first can be compressed on PC by general user, press Just it is transferred on mobile device after being reduced to suitable resolution.When the compress technique of certain manufacturer is made fine, it is necessary to pressure Video file after contracting carries out suitably protecting so as to only can just play on special player, so it is also possible that pressure Contracting technology is protected.Due to the computing capability of present PC it is stronger, so compression and encrypted video are all without depositing on PC In too many difficulty, but some mobile devices are really not so.
In view of the limited computing capability of mobile device and storage capacity, must need to consider solution when to video-encryption Close complexity, the video otherwise encrypted will be unable to play in movement, or the video volume increase after encryption is a lot, also Lose the meaning of compression.
The content of the invention
The inventors found that in above-mentioned prior art and have problems, and therefore for the problem at least one Individual problem proposes a kind of new technical scheme.
It is an object of the present invention to provide a kind of technical scheme for data encrypting and deciphering.
According to the first aspect of the invention, there is provided a kind of data encryption/decryption method, including:According to encryption key/decryption Key production key stream source;Boolean function is based on according to the key stream source and xor operation generates key stream;By the key Stream carries out xor operation with data to be encrypted/to be decrypted and generates encrypting/decrypting data.
Alternatively, for encryption method, the method also includes:The encryption for obtaining encryption is encrypted to the encryption key Key;Or for decryption method, the method also includes:Decruption key to encrypting is decrypted the acquisition decruption key.
Alternatively, the method also includes:Obtain the encryption key/decruption key.
Alternatively, key stream source state is 48;It is described that Boolean function and xor operation are based on according to the key stream source Generating key stream includes:By 1,2,4,5 of the key stream source state through Boolean functionProcess, 7,11,13,14 Through Boolean functionProcess, 16,20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 through Boolean functionProcess, obtain the output of 51, the output of 51 is through boolean FunctionProcess obtains 1 output;The key stream source state remaining position is carried out into XOR, then with1 export into Row XOR obtains the value of feedback of 1;The key stream source state is moved to left into 1, the value of feedback of 1 is inserted into the key stream The 48th of source state;The position that output is moved to left by the key stream source state forms key stream.
Alternatively, the key stream and data to be encrypted/to be decrypted are carried out into xor operation and generates encrypting/decrypting data bag Include:1 byte key streams are formed per 8 key streams, carry out with corresponding byte in data to be encrypted/to be decrypted successively xor operation from And produce encrypting/decrypting data.
Alternatively, 1 byte key stream is formed per 8 key streams, is entered with corresponding byte in data to be encrypted/to be decrypted successively Row xor operation includes so as to produce encrypting/decrypting data:The A byte key streams that discarding is first produced;Judge B+8 whether less than institute State the size of the current byte of to be encrypted/data p to be decrypted;If it is, starting to continuously generate 16 byte keys from p [B+8] Stream, with the 1 byte key stream byte XOR corresponding with p for calling generation every time, exports encrypting/decrypting data;Otherwise, from p [8] Start to continuously generate 16 byte key streams, with the 1 byte key stream byte XOR corresponding with p for calling generation every time, export and add Close/ciphertext data;Wherein, A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C=A^B, p for it is to be encrypted/ The first address of data to be decrypted, the seed seed2 of 1 byte are the low byte of current file size.
Alternatively, generating key stream source according to encryption key/decruption key includes:Pressed by p [4], p [5], p [6], p [7] , into nybble IV, wherein p [4] is in high byte for sequential concatenation;Start continuously from the tmp_1 bytes of 16 byte encryption key key Take 6 byte informations and obtain current_key, wherein, low 4 place values of the tmp_1 for C;From the tmp_ of 16 byte encryption key key 2 bytes start continuously to take 4 byte informations acquisition serial, high 4 place values of the wherein tmp_2 for C;The serial of 32 is inserted into 48 First 32 of bit register state, by first 16 of current_key insert state latter 16;For i=0 ...., 31, Operation is following to be operated:
By the 1 of state, 2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16th, 20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 Position is through Boolean functionProcess, respectively obtain the out of 51, the out of 51 is again through Boolean functionProcess is obtained 1 out;State remaining position is carried out into XOR, then the i-th bit of the i-th bit with 1 out, IV, current_key carry out it is different Or obtain value of feedback feedback of 1;State is moved to left into 1, the feedback of 1 is inserted into the 48th of state.
According to the first aspect of the invention, there is provided a kind of data encrypting and deciphering device, including:Key stream source generation module, For generating key stream source according to encryption key/decruption key;Key stream generation module, for being based on according to the key stream source Boolean function and xor operation generate key stream;Data encrypting and deciphering module, for by the key stream and number to be encrypted/to be decrypted Encrypting/decrypting data is generated according to xor operation is carried out.
Alternatively, the device also includes:Key encryption/decryption module, is encrypted for being encrypted to the encryption key Encryption key;Or the decruption key to encrypting is decrypted the acquisition decruption key.
Alternatively, the device also includes:Key Acquisition Module, for obtaining the encryption key/decruption key.
Alternatively, key stream source state is 48;The key stream generation module includes:Boolean calculation unit, for inciting somebody to action 1,2,4,5 of the key stream source state are through Boolean functionProcess, 7,11,13,14 through Boolean functionPlace Reason, 16,20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43, 45 through Boolean functionProcess, obtain the output of 51, the output of 51 is through Boolean functionProcess obtains 1 Position output;Position XOR unit, for the key stream source state remaining position carried out XOR, then with1 it is defeated Go out to carry out the value of feedback that XOR obtains 1;Lt operating unit, for the key stream source state is moved to left 1, by 1 Value of feedback insert the 48th of the key stream source state;The position that output is moved to left by the key stream source state forms key Stream.
Alternatively, data encrypting and deciphering module will form 1 byte key streams per 8 key streams, successively with it is to be encrypted/to be decrypted In data, correspondence byte carries out xor operation so as to produce encrypting/decrypting data.
Alternatively, data encrypting and deciphering module, for abandoning the A byte key streams for first producing;Judge B+8 whether less than described The size of the current byte of to be encrypted/data p to be decrypted;If it is, start to continuously generate 16 byte key streams from p [B+8], With the 1 byte key stream byte XOR corresponding with p for calling generation every time, encrypting/decrypting data is exported;Otherwise, open from p [8] Beginning continuously generates 16 byte key streams, with 1 byte key stream byte XOR corresponding with p for calling generation every time, export encrypt/ Ciphertext data;Wherein, A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C=A^B, p for it is to be encrypted/treat The first address of ciphertext data, the seed seed2 of 1 byte are the low byte of current file size.
Alternatively, key stream source generation module, for p [4], p [5], p [6], p [7] are spliced into nybble in order IV, wherein p [4] are in high byte;Start continuously to take 6 byte informations from the tmp_1 bytes of 16 byte encryption key key and obtain Current_key, wherein, low 4 place values of the tmp_1 for C;Start continuously to take from the tmp_2 bytes of 16 byte encryption key key 4 byte informations obtain serial, high 4 place values of the wherein tmp_2 for C;The serial of 32 is inserted into 48 bit register state's First 32, by first 16 of current_key insert state latter 16;
For i=0 ...., 31, operation is following to be operated:
By the 1 of state, 2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16th, 20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 Position is through Boolean functionProcess, respectively obtain the out of 51, the out of 51 is again through Boolean functionProcess is obtained 1 out;State remaining position is carried out into XOR, then the i-th bit of the i-th bit with 1 out, IV, current_key carry out it is different Or obtain value of feedback feedback of 1;State is moved to left into 1, the feedback of 1 is inserted into the 48th of state.
According to another aspect of the invention, there is provided a kind of mobile terminal, including above-mentioned data encrypting and deciphering device.
An advantage of the invention that, the encipher-decipher method simple structure of employing is relatively low to software and hardware requirement, after encryption Size of data will not increase too much.
By referring to the drawings to the present invention exemplary embodiment detailed description, the present invention further feature and its Advantage will be made apparent from.
Description of the drawings
The Description of Drawings embodiments of the invention of a part for description are constituted, and is used for together with the description solving Release the principle of the present invention.
Referring to the drawings, according to detailed description below, the present invention can be more clearly understood from, wherein:
The flow chart that Fig. 1 illustrates one embodiment of the data encryption/decryption method of the present invention;
Fig. 2 illustrates the schematic diagram of the example of a generation key stream of the present invention;
The flow chart that Fig. 3 illustrates one embodiment of the data ciphering method of the present invention;
The flow chart that Fig. 4 illustrates one embodiment of the data decryption method of the present invention;
The flow chart that Fig. 5 illustrates an example for producing key stream source of the present invention;
Fig. 6 illustrates that Fig. 5 produces the diagram of key stream source example;
Fig. 7 illustrates the structure chart of one embodiment of the data encrypting and deciphering device of the present invention;
Fig. 8 illustrates the structure chart of another embodiment of the data encrypting and deciphering device of the present invention;
Fig. 9 illustrates the structure chart of another embodiment of the data encrypting and deciphering device of the present invention.
Specific embodiment
Describe the various exemplary embodiments of the present invention now with reference to accompanying drawing in detail.It should be noted that:Unless had in addition Body illustrates that the part and the positioned opposite of step, numerical expression and numerical value for otherwise illustrating in these embodiments does not limit this The scope of invention.
Simultaneously, it should be appreciated that for the ease of description, the size of the various pieces shown in accompanying drawing is not according to reality Proportionate relationship draw.
It is illustrative below to the description only actually of at least one exemplary embodiment, never as to the present invention And its application or any restriction for using.
For known to person of ordinary skill in the relevant, technology, method and apparatus may be not discussed in detail, but suitable In the case of, the technology, method and apparatus should be considered the part for authorizing description.
In all examples of shown here and discussion, any occurrence should be construed as merely exemplary, and not It is as restriction.Therefore, the other examples of exemplary embodiment can have different values.
It should be noted that:Similar label and letter represent similar terms in following accompanying drawing, therefore, once a certain Xiang Yi It is defined in individual accompanying drawing, then which need not be further discussed in subsequent accompanying drawing.
The flow chart that Fig. 1 illustrates one embodiment of the data encryption/decryption method of the present invention.
As shown in figure 1, step 102, generates key stream source according to encryption key/decruption key.Can be in several ways The key stream source or the key stream source according to decruption key generation decryption of encryption are generated according to encryption key.For example, may be used Using directly by encryption key/decruption key as key stream source, or according to information associated with the data by splicing or position Operation generates key stream source.
Step 104, is based on Boolean function according to key stream source and xor operation generates key stream.A generation is introduced after a while The specific example of key stream.
Key stream and data to be encrypted/to be decrypted are carried out xor operation and generate encrypting/decrypting data by step 106.For The key stream of generation, carries out step-by-step xor operation successively according to byte with the corresponding byte of to be encrypted/data to be decrypted, generates and adds Close/ciphertext data.
In above-described embodiment, the encipher-decipher method simple structure of employing is relatively low to software and hardware requirement, poor in computing capability Low side devices on can also use, and encrypt after size of data will not increase too much.Wherein, the encryption and decryption of data It is symmetry algorithm, easily realizes.
Encryption key can be generated at random, or be generated with reference to be-encrypted data.Encryption key can be through encryption transmission To data receiver, it is decrypted in encryption key of the data receiver in a predetermined manner to encrypting, as decruption key Encryption data is decrypted.Encryption/the decryption of encryption key can adopt various ways, or select as needed, here Specifically do not limited.In one embodiment, the encryption of encryption key adopts asymmetric encryption techniques, and enters encryption data Encryption uses symmetric cryptosystem, realizes the combination of symmetric and unsymmetric encryption technology, it is ensured that the safety of encrypted data Property.
Fig. 2 illustrates the schematic diagram of the example of a generation key stream of the present invention.As shown in Fig. 2 in this example embodiment, key Stream source state is 48, is based on Boolean function according to key stream source and xor operation generates key stream and includes:By key stream source The 1st, 2,4,5 of state are through Boolean functionProcess, the 7th, 11,13,14 through Boolean functionProcess, the 16th, 20th, 22,25 through Boolean functionProcess, the 27th, 28,30,32 through Boolean functionProcess, the 33rd, 42,43,45 Position is through Boolean functionProcess, the output of output 0,1,2,3,4,51 of 51 is obtained through Boolean functionPlace Reason obtains 1 output out;Key stream source state remaining position is carried out into XOR, then with1 output out carry out XOR Obtain value of feedback feedback of 1;Key stream source state is moved to left into 1, the value of feedback of 1 is inserted into key stream source state The 48th;The position that output is moved to left by key stream source state forms key stream.Wherein, Boolean function WithAs a example by explain Function budget cycle, the input of the function is 4, is output as 1,4 hytes of input is synthesized a number (being designated as a), then 0x2C79 is moved to right into a positions, last position is taken for input.Calculating process be similar to, will not be described here.
The flow chart that Fig. 3 illustrates one embodiment of the data ciphering method of the present invention.In the data encrypting and deciphering shown in Fig. 3 In method, two kinds of encryption methods are mainly used to the process of video-encryption, encryption method 1 and encryption method 2 has been designated as here.
As shown in figure 3, step 302, calls encryption method 1, random to generate 16 byte datas, this 16 byte data will be passed to Encryption method 2 is as its encryption key.
Step 304, calls encryption method 2 according to encryption key, generates encryption key stream.
Step 306, is encrypted to every frame by encryption key stream.
16 byte datas can be encrypted by step 308 using encryption method 1, generate 32 byte cryptograms.
Step 310,32 byte cryptograms are stored in video file, are used when giving over to decryption.
The flow chart that Fig. 4 illustrates one embodiment of data decryption method corresponding with the encryption method of Fig. 3, it is concrete to decrypt Process is as described below:
As shown in figure 4, step 402, first reads 32 byte cryptograms.
Step 404, calls the decrypting process of encryption method 1, obtains 16 byte decruption keys.
The decruption key is passed to encryption method 2 and is decrypted for producing key stream by step 406.
Step 408, calls the decrypting process of encryption method 2 to produce decruption key stream according to decruption key.
Step 410, treats ciphertext data by decruption key stream and is decrypted.
In one embodiment of the invention, encryption method 1 adopts asymmetric arithmetic, and encryption and decryption processes are different, and And such as can complete on PC on backstage in view of ciphering process, decrypting process is mainly completed on mobile terminal such as mobile phone, Therefore, when the algorithm is realized, using complex ciphering process, decrypting process is relatively simple.The encryption and decryption of encryption method 1 Key is encrypted protection.
According to another embodiment of the invention, be encrypted for the every frame in video using encryption method 2 or Decryption, encrypts identical with decrypting process.The input of encryption method 2, in addition to needing key key, in addition it is also necessary to two initialization Value V1 and V2, output be key stream, with plaintext XOR to be encrypted with realize encryption.The process needs the value for participating in be followed successively by The first address of 16 byte keys that the first address (p) of encryption and decryption frame, frame length (size), encryption method 1 are generated is treated currently (key), seed (seed2).Wherein the 4th parameter, is a byte information, is the low byte of current file size.Either Encryption or decrypt, be all the key stream that 16 bytes are produced by certain rule, then the key stream with this 16 byte with it is current 16 byte of certain of frame carries out XOR, that is, when encrypting, 16 byte key streams of generation and the 16 byte plaintext XORs chosen;Decryption When, find plus 16 overstocked bytes, XOR is carried out again with 16 byte key stream of identical.First address of the p for present frame, note p [a] For a bytes of present frame, " ^ " represents xor operation.With reference to Fig. 5 and Fig. 6 introduce it is a kind of produce encryption key and according to Encryption key generates implementing for key stream source.
As shown in figure 5, step 502, generation parameter A, B, C, IV, current_key and serial:
1) calculate:A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C=A^B;
P [4], p [5], p [6], p [7] are spliced into nybble (p [4] is in high byte), are denoted as V1;
3) low 4 place value (decimal scale 0~15) for remembering C is N, starts continuously to take 6 byte informations from the nth byte of key and is denoted as Current_key (for example, N=1, then from the 1st~6 byte for removing key;N=14, then take the word of the 14th, 15 and 1~4 of key Section);
4) remember again C high 4 place value be N, take 4 byte informations according to method same in previous step and be designated as V2;From 16 bytes The nth byte of encryption key key starts continuously to take 4 byte informations acquisition serial.Required key will be produced according to key, V1, V2 Stream source.
The serial of 32 is inserted first 32 of 48 bit register state, by before current_key 16 by step 504 Insert rear 16 (the referring to Fig. 6) of state in position.Initialization i=0.
Step 506, takes 1,2,4,5 of state through Boolean functionProcess, 7,51,13,14 through Boolean functionProcess, 16,20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33, 42nd, 43,45 through Boolean functionProcess, respectively obtain the out (referring to Fig. 6) of 51.
Step 508, the out of 51 is again through Boolean functionProcess obtains 1 out (referring to Fig. 6).
State remaining position is carried out XOR by step 510, then with Boolean function1 out carry out XOR and obtain 1 Value of feedback feedback (referring to Fig. 6).
Step 512, feedback is carried out with the i-th bit of the i-th bit of IV, current_key XOR again and obtains 1 anti- Feedback value feedback (refers to Fig. 6).
State is moved to left 1 by step 514, and the feedback of 1 is inserted the 48th (the referring to Fig. 6) of state.
Step 516, judges i>=32If it is, continuing step 518, otherwise continue step 520.
Step 518, i+=1 continue step 506.
Step 520, using the state for generating as key stream source.
In one embodiment, after process described in Fig. 5 terminates, A byte key streams are first produced, but these key streams is not used in Encryption, only gives up.Next judge whether B+28 is less than the size of present frame (current byte A), if it is, opening from p [B+8] Beginning continuously generates 16 byte key streams, with the 1 byte key stream byte XOR corresponding with p for calling generation every time, a kind of tool Body corresponded manner is:One offset information, the offset information are produced by xor operation by 4 bytes that p [4] to p [8] is constituted Indicate the position of correspondence byte;If it is not, then proceeding by same operation from p [8], i.e., start to continuously generate 16 from p [8] Byte key stream, with the 1 byte key stream byte XOR corresponding with p for calling generation every time, exports encrypting/decrypting data.
Fig. 7 illustrates the structure chart of one embodiment of the data encrypting and deciphering device of the present invention.As shown in figure 8, the data add Decryption device includes:Key stream source generation module 71, for generating key stream source according to encryption key/decruption key;Key stream Generation module 72, for being based on Boolean function and xor operation generation key stream according to key stream source;Data encrypting and deciphering module 73, Encrypting/decrypting data is generated for key stream and data to be encrypted/to be decrypted are carried out xor operation.
It may be noted that the data encrypting and deciphering device in above-described embodiment can be single data encryption device, or Single data decryption apparatus, it is also possible to both also served as data decryption apparatus as data encryption device.For brevity, not Various situations are individually described, it will be understood by those of skill in the art that above-described embodiment should not be limited to one kind therein Or two kinds of situations.
Fig. 8 illustrates the structure chart of another embodiment of the data encrypting and deciphering device of the present invention.In this embodiment, except Key stream source generation module 71, key stream generation module 72 and data encryption/decryption module 73, the device also include:Key obtains mould Block 84, for obtaining encryption key/decruption key.Key encryption/decryption module 85, is added for being encrypted to encryption key Close encryption key;Or the decruption key to encrypting is decrypted acquisition decruption key.
Fig. 9 illustrates the structure chart of another embodiment of the data encrypting and deciphering device of the present invention.In this embodiment, key Stream source state is 48;Key stream generation module 92 includes:Boolean calculation unit 921, for by the key stream source state 1,2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16,20,22,25 Jing Cross Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 through Boolean functionProcess, obtain the output of 51, the output of 51 is through Boolean functionProcess obtains 1 output;Position XOR Unit 922, for key stream source state remaining position carried out XOR, then with1 output carry out XOR and obtain 1 Value of feedback;The value of feedback of 1, for key stream source state is moved to left 1, is inserted key stream source by lt operating unit 923 The 48th of state;The position that output is moved to left by key stream source state forms key stream.
In one embodiment of the invention, data encrypting and deciphering module will form 1 byte key stream per 8 key streams, according to It is secondary to carry out xor operation so as to produce encrypting/decrypting data with corresponding byte in data to be encrypted/to be decrypted.
In one embodiment of the invention, data encrypting and deciphering module, for abandoning the A byte key streams for first producing;Sentence Whether disconnected B+8 is less than the size of the current byte A of to be encrypted/data p to be decrypted;If it is, starting to connect from p [B+8] It is continuous to produce 16 byte key streams, with the 1 byte key stream byte XOR corresponding with p for calling generation every time, output encryption/decryption Data;Otherwise, start to continuously generate 16 byte key streams from p [8], with calling every time, 1 byte key stream of generation is corresponding with p Byte XOR, exports encrypting/decrypting data;Wherein, A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C =A^B, p are the first address of to be encrypted/data to be decrypted, and the seed seed2 of 1 byte is the low byte of current file size.
In one embodiment of the invention, key stream source generation module, for by p [4], p [5], p [6], p [7] by suitable Sequence is spliced into nybble IV, and wherein p [4] is in high byte;Start continuously to take 6 from the tmp_1 bytes of 16 byte encryption key key Byte information obtains current_key, wherein, low 4 place values of the tmp_1 for C;From the tmp_2 words of 16 byte encryption key key Section starts continuously to take 4 byte informations acquisition serial, high 4 place values of the wherein tmp_2 for C;The serial of 32 is inserted into 48 First 32 of depositor state, by first 16 of current_key insert state latter 16;
For i=0 ...., 31, operation is following to be operated:
By the 1 of state, 2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16th, 20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 Position is through Boolean functionProcess, respectively obtain the out of 51, the out of 51 is again through Boolean functionProcess is obtained 1 out;
State remaining position is carried out into XOR, then the i-th bit of the i-th bit with 1 out, IV, current_key carry out it is different Or obtain value of feedback feedback of 1;
State is moved to left into 1, the feedback of 1 is inserted into the 48th of state.
It may be noted that the correspondence that the function of the modules in Fig. 7-9 may refer to embodiment of the method in Fig. 1-6 is retouched State, for brevity, here is not described in detail.
It will be understood by those of skill in the art that DEA and decipherment algorithm have correspondence, in given data In the case of encryption method, those skilled in the art can correspondingly obtain the decryption of the encryption data obtained by the encryption method Method, in the case of being symmetry algorithm particularly with AES and decipherment algorithm, directly can be decrypted from AES Algorithm.Therefore, in some circumstances, if having been disclosed for AES, can simplify or omit the description of decipherment algorithm.
Preferably, the encipher-decipher method of above-described embodiment, device are applied to the encryption and decryption process of video data.
The computing capability of mobile device is poor, storage capacity is weak, and system data bandwidth is limited.Traditional encryption and decryption side Method, relative to this programme, decrypting scheme needs excessive resource, decodes and broadcast on the mobile terminal that will cause to be limited in computing capability Put not smooth, or even cannot play.The disclosure gives a kind of safety, but requires extremely low encryption and decryption side to computing capability Case.For example, PC end is directly encrypted after the completion of video compress, and mobile device end then while decryption while play, if Cannot correctly decrypt, then can not play.
The disclosure provides a kind of light weight efficient video encrypting/deciphering method and apparatus so that pressed on backstage such as PC The video of contracting encryption, can be played back by smooth on the mobile device that computing capability is limited, have little influence on storage While with decoding performance, play a part of to protect video.
So far, data encryption/decryption method of the invention, device and mobile terminal is described in detail.In order to avoid The design of the masking present invention, does not describe some details known in the field.Those skilled in the art as described above, Completely it can be appreciated how implementing technical scheme disclosed herein.
The method of the present invention and system may be achieved in many ways.For example, can by software, hardware, firmware or Software, hardware, any combinations of firmware are realizing the method for the present invention and system.For said sequence the step of methods described Merely to illustrate, order described in detail above is not limited to the step of the method for the present invention, it is special unless otherwise Do not mentionlet alone bright.Additionally, in certain embodiments, also the present invention can be embodied as recording program in the recording medium, these programs Including for realizing the machine readable instructions of the method according to the invention.Thus, the present invention also covers storage for performing basis The recording medium of the program of the method for the present invention.
Although being described in detail to some specific embodiments of the present invention by example, the skill of this area Art personnel it should be understood that above example is merely to illustrate, rather than in order to limit the scope of the present invention.The skill of this area Art personnel are it should be understood that can modify to above example without departing from the scope and spirit of the present invention.This Bright scope is defined by the following claims.

Claims (13)

1. a kind of data encryption/decryption method, it is characterised in that include:
Key stream source is generated according to encryption key/decruption key, wherein, the key stream source state is 48;
Boolean function is based on according to the key stream source and xor operation generates key stream;
The key stream and data to be encrypted/to be decrypted are carried out into xor operation and generates encrypting/decrypting data;
Wherein, it is described to be included based on Boolean function and xor operation generation key stream according to the key stream source:
By 1,2,4,5 of the key stream source through Boolean functionProcess, 7,11,13,14 through Boolean functionPlace Reason, 16,20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43, 45 through Boolean functionProcess, obtain the output of 51, the output of 51 is through quadratic Boolean functionProcess Export to 1;Wherein, Boolean function Boolean FunctionProcessing procedure be:By 4 one numbers a of synthesis of input, 0x2C79 is moved to right into a positions, last position is taken for output;Cloth That functionProcessing procedure be:By 4 one numbers b of synthesis of input, 0x6671 is moved to right into b positions, last position is taken for output; Boolean functionProcessing procedure be:By 5 one numbers c of synthesis of input, 0x7907287B is moved to right into c positions, last position is taken For output;
The key stream source remaining position is carried out into XOR, then with quadratic Boolean function1 output carry out XOR and obtain 1 Value of feedback;
The key stream source is moved to left into 1, the value of feedback of 1 is inserted into last position in the key stream source;
The position that output is moved to left by the key stream source forms key stream.
2. method according to claim 1, it is characterised in that
For encryption method, also include:
The encryption key for obtaining encryption is encrypted to the encryption key;
Or
For decryption method, also include:
Decruption key to encrypting is decrypted the acquisition decruption key.
3. method according to claim 1, it is characterised in that also include:
Obtain the encryption key/decruption key.
4. method according to claim 1, it is characterised in that described by the key stream and data to be encrypted/to be decrypted Carrying out xor operation generation encrypting/decrypting data includes:
1 byte key stream is formed per 8 key streams, xor operation is carried out with corresponding byte in data to be encrypted/to be decrypted successively So as to produce encrypting/decrypting data.
5. method according to claim 4, it is characterised in that the 1 byte key streams, successively of being formed per 8 key streams Xor operation is carried out with corresponding byte in data to be encrypted/to be decrypted includes so as to produce encrypting/decrypting data:
The A byte key streams that discarding is first produced;
Judge whether B+8 is less than the size of the current byte of to be encrypted/data p to be decrypted;
If it is, start to continuously generate 16 byte key streams from p [B+8], with the 1 byte key stream and p that call generation every time Middle correspondence byte XOR, exports encrypting/decrypting data;
Otherwise, start to continuously generate 16 byte key streams from p [8], with calling every time, 1 byte key stream of generation is corresponding with p Byte XOR, exports encrypting/decrypting data;
Wherein, A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C=A^B, p are number to be encrypted/to be decrypted According to first address, the low byte of the seed seed2 of 1 byte for current file size.
6. method according to claim 5, it is characterised in that described that key stream is generated according to encryption key/decruption key Source includes:
Nybble IV is spliced in order by p [4], p [5], p [6], p [7], wherein p [4] is in high byte;
Start continuously to take 6 byte informations from the tmp_1 bytes of 16 byte encryption key key and obtain current_key, wherein, Low 4 place values of the tmp_1 for C;
Start continuously to take 4 byte informations from the tmp_2 bytes of 16 byte encryption key key and obtain serial, wherein tmp_2 is High 4 place value of C;
The serial of 32 is inserted into first 32 of 48 bit register state, state is inserted by first 16 of current_key Latter 16;
For i=0 ...., 31, operation is following to be operated:
By the 1 of state, 2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16, 20th, 22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 Jing Cross Boolean functionProcess, respectively obtain the out of 51, the out of 51 is again through Boolean functionProcess obtains 1 out;
State remaining position is carried out into XOR, then the i-th bit of the i-th bit with 1 out, IV, current_key carries out XOR and obtains To value of feedback feedback of 1;
State is moved to left into 1, the feedback of 1 is inserted into the 48th of state.
7. a kind of data encrypting and deciphering device, it is characterised in that include:
Key stream source generation module, for generating key stream source according to encryption key/decruption key, wherein, the key stream source For 48;
Key stream generation module, for being based on Boolean function and xor operation generation key stream according to the key stream source;
Data encrypting and deciphering module, generates encryption/solution for the key stream and data to be encrypted/to be decrypted are carried out xor operation Ciphertext data;
Wherein, the key stream generation module includes:
Boolean calculation unit, for 1,2,4,5 by the key stream source through Boolean functionProcess, 7,11,13,14 Jing Cross Boolean functionProcess, 16,20,22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionPlace Reason, 33,42,43,45 through Boolean functionProcess, obtain the output of 51, the output of 51 is through quadratic Boolean functionProcess obtains 1 output;Wherein, Boolean function Boolean functionProcessing procedure be:By 4 one numbers a of synthesis of input, 0x2C79 is moved to right into a positions, it is defeated to take last position Go out;Boolean functionProcessing procedure be:By 4 one numbers b of synthesis of input, 0x6671 is moved to right into b positions, last position is taken For output;Boolean functionProcessing procedure be:By 4 one numbers c of synthesis of input, 0x7907287B is moved to right into c positions, is taken Last position is output;
Position XOR unit, for the key stream source remaining position carried out XOR, then with quadratic Boolean function1 Output carries out the value of feedback that XOR obtains 1;
The value of feedback of 1, for the key stream source is moved to left 1, is inserted the key stream source by lt operating unit Last position;The position that output is moved to left by the key stream source forms key stream.
8. device according to claim 7, it is characterised in that also include:
Key encryption/decryption module, for the encryption key for obtaining encryption is encrypted to the encryption key;Or to encryption Decruption key is decrypted the acquisition decruption key.
9. device according to claim 7, it is characterised in that also include:
Key Acquisition Module, for obtaining the encryption key/decruption key.
10. device according to claim 7, it is characterised in that the data encrypting and deciphering module will be formed per 8 key streams 1 byte key stream, carries out xor operation so as to produce encryption/decryption number with corresponding byte in data to be encrypted/to be decrypted successively According to.
11. devices according to claim 10, it is characterised in that the data encrypting and deciphering module, first produce for abandoning A byte key streams;Judge whether B+8 is less than the size of the current byte of to be encrypted/data p to be decrypted;If it is, Start to continuously generate 16 byte key streams from p [B+8], with calling every time, the 1 byte key stream byte corresponding with p of generation is different Or, output encrypting/decrypting data;Otherwise, start to continuously generate 16 byte key streams from p [8], with 1 word for calling generation every time Section key stream byte XOR corresponding with p, exports encrypting/decrypting data;
Wherein, A=p [4] ^p [5] ^seed2, B=p [6] ^p [7] ^ (seed2<<4), C=A^B, p are number to be encrypted/to be decrypted According to first address, the low byte of the seed seed2 of 1 byte for current file size.
12. devices according to claim 11, it is characterised in that key stream source generation module, for by p [4], p [5], p [6], p [7] are spliced into nybble IV in order, and wherein p [4] is in high byte;From the of 16 byte encryption key key Tmp_1 bytes start continuously to take 6 byte informations acquisition current_key, wherein, low 4 place values of the tmp_1 for C;Add from 16 bytes The tmp_2 bytes of key key start continuously to take 4 byte informations acquisition serial, high 4 place values of the wherein tmp_2 for C;Will The serial of 32 inserts first 32 of 48 bit register state, inserts rear the 16 of state by first 16 of current_key Position;
For i=0 ...., 31, operation is following to be operated:
By the 1 of state, 2,4,5 through Boolean functionProcess, 7,11,13,14 through Boolean functionProcess, 16, 20th, 22,25 through Boolean functionProcess, 27,28,30,32 through Boolean functionProcess, 33,42,43,45 Jing Cross Boolean functionProcess, respectively obtain the out of 51, the out of 51 is again through Boolean functionProcess obtains 1 out;
State remaining position is carried out into XOR, then the i-th bit of the i-th bit with 1 out, IV, current_key carries out XOR and obtains To value of feedback feedback of 1;
State is moved to left into 1, the feedback of 1 is inserted into the 48th of state.
13. a kind of mobile terminals, it is characterised in that fill including the data encrypting and deciphering described in any one in claim 7 to 12 Put.
CN201210228169.3A 2012-07-03 2012-07-03 Data encryption/decryption method, device and mobile terminal Active CN103532706B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210228169.3A CN103532706B (en) 2012-07-03 2012-07-03 Data encryption/decryption method, device and mobile terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210228169.3A CN103532706B (en) 2012-07-03 2012-07-03 Data encryption/decryption method, device and mobile terminal

Publications (2)

Publication Number Publication Date
CN103532706A CN103532706A (en) 2014-01-22
CN103532706B true CN103532706B (en) 2017-03-29

Family

ID=49934414

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210228169.3A Active CN103532706B (en) 2012-07-03 2012-07-03 Data encryption/decryption method, device and mobile terminal

Country Status (1)

Country Link
CN (1) CN103532706B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104125055B (en) * 2014-06-25 2017-11-14 小米科技有限责任公司 Encryption and decryption method and electronic equipment
CN108023724B (en) * 2016-11-04 2020-10-20 北京紫光展锐通信技术有限公司 Data transmission method and device
CN110855423A (en) * 2019-09-23 2020-02-28 深圳市智讯互动体育科技有限公司 Method, device and storage medium for encrypting and decrypting ordered numerical value string

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1732259A1 (en) * 2002-02-01 2006-12-13 Cisco Technology, Inc. Method and system for securely storing and transmitting data by applying a one-time pad
CN101841415A (en) * 2009-12-29 2010-09-22 中国科学院软件研究所 Word-oriented key stream generating method and encrypting method
CN101923802A (en) * 2009-06-12 2010-12-22 中国科学院数据与通信保护研究教育中心 Sequential cipher realization method and device
CN102014266A (en) * 2010-12-01 2011-04-13 华中科技大学 Digital watermarking-based high-definition video encrypted transmitting method and system
CN102469345A (en) * 2010-11-19 2012-05-23 康佳集团股份有限公司 Method for encrypting and decrypting multimedia-media data

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1732259A1 (en) * 2002-02-01 2006-12-13 Cisco Technology, Inc. Method and system for securely storing and transmitting data by applying a one-time pad
CN101923802A (en) * 2009-06-12 2010-12-22 中国科学院数据与通信保护研究教育中心 Sequential cipher realization method and device
CN101841415A (en) * 2009-12-29 2010-09-22 中国科学院软件研究所 Word-oriented key stream generating method and encrypting method
CN102469345A (en) * 2010-11-19 2012-05-23 康佳集团股份有限公司 Method for encrypting and decrypting multimedia-media data
CN102014266A (en) * 2010-12-01 2011-04-13 华中科技大学 Digital watermarking-based high-definition video encrypted transmitting method and system

Also Published As

Publication number Publication date
CN103532706A (en) 2014-01-22

Similar Documents

Publication Publication Date Title
US8213607B2 (en) Method for securely extending key stream to encrypt high-entropy data
JP4976107B2 (en) Method for scrambling and descrambling a unit of data
CN1150760C (en) Mehtod for protecting audio-visual data across NRSS interface
CN100464584C (en) Video monitoring system and method for implementing signal encription
JP2010193449A (en) Method of securely providing control word from smart card to conditional access module
JP4710607B2 (en) Encryption device, encryption method and encryption program, decryption device, decryption method and decryption program, and recording medium
CN101882993A (en) Cryptographic system and cryptographic methods
CN1875568B (en) Transmitting apparatus, receiving apparatus, and data transmitting system
CN1633068B (en) A method of media stream transmission in point-to-point communication
CN101247520B (en) Video data enciphering/deciphering method
CN102637246A (en) Method and device for generating control words
CN106506518A (en) The encryption/decryption module of big data safe transmission
CN103532706B (en) Data encryption/decryption method, device and mobile terminal
EP2904731B1 (en) Method and device for digital data blocks encryption and decryption
CN105704526B (en) DRM method and system, TV gateway and the terminal of DTV
CN101390332B (en) Method and apparatus for synchronous stream cipher encryption with reserved codes
CN101800878B (en) System and method for encrypting and decrypting MPEG (Moving Picture Experts Group) video based on position files
CN106851339A (en) The treating method and apparatus of data encryption, the treating method and apparatus of data deciphering
CN103313097B (en) Method and system for encrypting and decrypting encoded file
CN101335875A (en) Information processing device and video and audio frequency information protection method
JP4287397B2 (en) Ciphertext generation apparatus, ciphertext decryption apparatus, ciphertext generation program, and ciphertext decryption program
CN101651549B (en) Multimedia broadcasting system, method and system for safely playing multimedia broadcasting contents
CN100353765C (en) Encrypting/decrypting method adapted for movie and television program content data
CN106559682A (en) A kind of method and device of DTV finger water-print protection
CN105306975B (en) The method and system of control word safe transmission without binding machine and card

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant