A kind of data encryption method of compact disc
Technical field
The present invention relates to a kind of data ciphering method, specifically a kind of encryption method of data of optical disk.
Background technology
Sometimes, we do not think that the data of optical disk of oneself making is at will copied by other people, perhaps are used in other unauthorized occasion and use.Such as own elaborate Karaoke CD, only want to play at the DVD disc player of oneself authorizing.At this moment, the encrypted work for CD just extremely is necessary.
At first, simply introduce physical method and logical method that data of optical disk is deposited.On the physical store method, whole CD only has a spiral path, and this track rotates to outer ring (non-concentric circles organizational form) from the inner ring of CD successively.Data are stored on this track in 0 or 1 mode.
On the logical storage mode, the data storage standard is ISO9660.Storage data in orbit are by continuous each logic sector that is divided into, and next logic sector of normal condition comprises 2048 bytes, and the size of data in the ISO9660 permission sector is not 2048 certainly, in most of situation, is 2048 byte numbers.Logic sector is numbered as 0,1,2 successively ... whole storage space is divided into two parts, and is divided into system realm from 16 logic sectors that are numbered 0-15, and system realm generally keeps to system's usefulness, as making boot cd-rom etc.Default situations, its data general complete be 0. to begin to finish to CD from being numbered 16 sector, be divided into user data area.
The several continuous sector that begins from numbering 16 sector begins to deposit the different Volume Descriptor of all kinds (Volume Descriptor) successively, finishes Volume Descriptor with one or several at last and represents that Volume Descriptor finishes.Finish the data that Volume Descriptor has following 2048 bytes.Front 7 bytes are 10 systems: 255,67,68,48,48,49 and 1.2041 remaining bytes are 0 entirely, about the meaning of Volume Descriptor type and the representative of each territory, and can be referring to the ISO9660 standard.
The sector of numbering 16 is first Volume Descriptor, and type is Primary Volume Descriptor (Primary VolumeDescriptor).This is the Volume Descriptor once that we are concerned about the most.2048 bytes of Primary Volume Descriptor comprise following information:
Byte location |
The title of Primary Volume Descriptor recording domain |
1 |
The type of Volume Descriptor |
[0008]
2~6 |
Standard volume identifier (CD001) |
7 |
Volume Descriptor version number |
8 |
Do not use (00) |
9~40 |
System identifier |
41~72 |
Volume identifier |
73~80 |
Do not use (00) |
81~88 |
The volume space size |
89~120 |
Do not use (00) |
121~124 |
Volume series size |
125~128 |
Volume serial number |
129~132 |
Logical block size |
133~140 |
The routing table size |
141~144L |
Tabular value position, type path, L-type: least significant byte formerly |
145~148L |
Type routing table selected value position |
149~152M |
Tabular value position, type path, most significant byte formerly |
153~156M |
Type routing table selected value position |
157~190 |
The catalogue record of root directory |
191~318 |
The volume set identifier |
319~446 |
Publisher's sign symbol |
447~574 |
Data preparator's identifier |
575~702 |
Application software identifier (such as CD-I) |
703~739 |
The rights file identifier |
740~776 |
The digest identifier |
777~813 |
The bibliography file identifier |
814~830 |
Volume creation date and time |
[0009]
831~847 |
Volume is revised date and time |
848~864 |
Be rolled onto the phase date and time |
865~881 |
Volume date of expiration and time |
882 |
File structure version number |
883 |
(reservation) |
884~1395 |
Application program is used |
1396~2048 |
(reservation) |
And in the above in these recording domains, our real concern be the catalogue record of the root directory that represents of the runic from skew 157-190.This segment data has recorded the catalogue record of the root directory of CD.
CD adopts the implicit expression hierarchical directory structure, catalogue is used as file treats, and whole catalogue is included in 1 or a few file.The file that comprises catalogue is called catalogue file.Catalogue file and common user file are similar, but the directory file structure that CD adopts has been made concrete regulation.Catalogue file is comprised of the catalogue record of a series of variable-lengths.The form of each catalogue record is as shown in the table.Can see that a catalogue record includes many recording domains.Record file identifier in these territories, with the file size of byte calculating, first logical block number (LBN) (LBN) in the file territory, and open and use needed other information of this file.The below is the form of catalogue record:
Byte location |
The title of recording domain |
1 |
Catalogue record length (LEN_DR) |
2 |
Extended attribute record (XAR) length |
3~10 |
The file domain addresses |
11~18 |
Data length |
19~25 |
Date and time |
26 |
File mark |
27 |
The file unit size |
28 |
The transpostion interval size |
[0013]
29~32 |
Volume serial number |
33 |
File identifier length (LEN_FI) |
34-(33+LEN_FI) |
File identifier |
34+LEN_FI |
Region filling |
(34+LEN_FI+1)-LEN_DR |
System uses (reservation) |
The below is the catalogue record (each numeric field data is with hexadecimal representation) of the root directory that extracts from CD of reality:
=====================
22 catalogue record lengths
00 extended attribute record (XAR) length
1C 00 00 00 00 00 00 1C file domain addresses
00 08 00 00 00 00 08 00 catalogue file length
6D 0A 0A 0A 10 14 F0 date and times
02 file mark
00 file unit size
00 transpostion interval size
01 00 00 01 volume serial numbers
01 file identifier length
00 region filling
From top introduction, we can sum up a CD and how to be read:
1. at first read and be numbered 16 logic sector, therefrom read Primary Volume Descriptor information.
2. from Primary Volume Descriptor, obtain the catalogue record of root directory.
3. by the catalogue record of root directory, obtain the file domain addresses of first logic sector at root directory file place.The sector at this place, address, we want the sector of encryption just.
4. by the root directory file, the data of can recurrence reading whole CD.
By top analysis as can be known, if the sector at root directory file place is encrypted, will cause the whole Zhang Guangpan can not be by correct reading.And our encryption method just is being based on and is encrypting this sector data.
Summary of the invention
The technical problem to be solved in the present invention provides a kind of encryption method of data of optical disk, can effectively prevent other people reading, copying data of optical disk.
For solving the problems of the technologies described above, the present invention by the following technical solutions:
A kind of data encryption method of compact disc, this CD comprises the CD lamellar body, the data tunnel of eccentric pattern on lamellar body, the logic sector of a plurality of storage data is divided in the data tunnel successively, logic sector outwards is numbered with 0 natural number that begins in CD successively, comprise in the logic sector that one stores the host sectors of root directory file, described encrypting step is:
A. according to the encryption rule of setting the root directory file is encrypted processing, and specifies logic sector to make encryption identification at CD;
B. write fashionablely in data, the root directory file after host sectors encrypted is stored to and is numbered non-16 blank logic sector.
Wherein, described encryption identification generation method is: the cdrom encryption secret key data process MD5 algorithm with 32 bytes, generate 16 byte summary infos, and summary info is identical with the identification data whether CD is encrypted.
Described cdrom encryption secret key length storage address adopts C language definition to be:
#define ENCRYPTION_REALLEN_ADDR 0xB00000;
The storage physical address of cryptographic keys adopts C language definition to be:
#defineENCRYPTION_KEY_ADDR 0xC00000;
The length of its memory address of the identification data whether CD is encrypted and identification data adopts C language definition to be:
#define ENCRYPTION_ID_ADDR 0xD00000
#define ENCRYPTION_ID_LEN 16。
Described encryption rule uses 4 kinds of algorithms, and type is followed successively by 0,1,2,3, and wherein, each encryption type algorithm is specially:
0---by the byte negate, with 2048 bytes of be-encrypted data, each byte negate;
1---by the byte XOR, use 8 bit value as the XOR value, 2048 bytes of be-encrypted data, each byte is XOR with it;
2---the des cryptographic algorithm, use 64 bit keys, the 2048 bytes employing ecb mode of be-encrypted data is encrypted;
3---the rc4 cryptographic algorithm, use 64 bit keys, 2048 bytes of be-encrypted data are encrypted.
Described encryption type address adopts C language definition to be:
#define ENCRYPTION_TYPE_ADDR 0xE00000(14M)。
After the root directory fileinfo was encrypted, the actual storage address adopted C language definition to be:
#define ENCRYPTION_DATA_ADDR 0xA00000。
In order further to improve its Cipher Strength, in the logic sector storage random digit that is numbered 16.
By the CD after this method encryption, other can't read in without the disc accessing of decryption mechanisms, data in the copy, even with whole CD complete copy out, can't or not have at Computer optical disc drive to play back in the disc accessing of decryption mechanisms yet, have reliable security performance.
Embodiment
For the ease of those skilled in the art's understanding, below in conjunction with specific embodiment and accompanying drawing structural principle of the present invention is described in further detail:
The CD encryption method that the embodiment of the invention discloses is write at data of optical disk and fashionable data to be encrypted processing, can guarantee can't to read in without the disc accessing of decryption mechanisms the data of CD after this encryptions, prevents the data of optical disk leakage.
The related CD CD of the method comprises the CD lamellar body, the data tunnel of eccentric pattern on lamellar body, the logic sector of a plurality of storage data is divided in the data tunnel successively, logic sector outwards is numbered with 0 natural number that begins in CD successively, comprise in the logic sector that one stores the host sectors of root directory file, described encrypting step is: a. is encrypted processing according to the encryption rule of setting with the root directory file, and specifies logic sector to make encryption identification at CD; B. write fashionablely in data, the root directory file after host sectors encrypted is stored to and is numbered non-16 blank logic sector.
Wherein, described encryption identification generation method is: with the cdrom encryption secret key data process MD5 algorithm (Message-Digest Algorithm 5 md5-challenges) of 32 bytes, generate 16 byte summary infos, summary info is identical with the identification data whether CD is encrypted.When reading CD, take out the cdrom encryption secret key of 32 bytes, produce summary info by the MD5 algorithm, compare with identification data again, if identical, then CD is CD-enciphering, adopts corresponding decrypted program to read data of optical disk, otherwise be the unencryption CD, then according to conventional disc reading mode reading out data.
Simultaneously, described cdrom encryption secret key length storage address adopts C language definition to be:
#define ENCRYPTION_REALLEN_ADDR 0xB00000;
The storage physical address of cryptographic keys adopts C language definition to be:
#define ENCRYPTION_KEY_ADDR 0xC00000;
The length of its memory address of the identification data whether CD is encrypted and identification data adopts C language definition to be:
#define ENCRYPTION_ID_ADDR 0xD00000(13M)
#define ENCRYPTION_ID_LEN 16。
And encryption rule can use 4 kinds of algorithms, and type is followed successively by 0,1,2,3, and wherein, each encryption type algorithm is specially:
0---by the byte negate, with 2048 bytes of be-encrypted data, each byte negate;
1---by the byte XOR, use 8 bit value as the XOR value, 2048 bytes of be-encrypted data, each byte is XOR with it;
2---des (Data Encryption Standard) cryptographic algorithm, use 64 bit keys, the 2048 bytes employing ecb mode of be-encrypted data is encrypted;
3---the rc4 cryptographic algorithm, use 64 bit keys, 2048 bytes of be-encrypted data are encrypted.The encryption type address adopts C language definition to be:
#define ENCRYPTION_TYPE_ADDR 0xE00000(14M)。
After the root directory fileinfo was encrypted, the actual storage address adopted C language definition to be:
#define ENCRYPTION_DATA_ADDR 0xA00000。
In order to improve Cipher Strength, in the logic sector storage random digit that is numbered 16.
When reading data of optical disk, namely the decrypted program idiographic flow is:
A. read encryption identification, whether to determine institute's CD of being read as CD-enciphering, if not CD-enciphering, then action is read in end, if CD-enciphering then enters next step;
B. read encryption type, according to corresponding algorithm deciphering, generate summary info;
C. read the data after the encryption;
E. data decryption;
F. reduce the catalogue file of root directory, finish to read action.
Be the preferred version that the present invention realizes for embodiment more than; and indefiniteness is exhaustive, and the present invention can also have other variations under same idea, need to prove; under the prerequisite that does not break away from inventive concept of the present invention, any apparent replacement is all within protection domain of the present invention.