CN103886087B - The calculation process and file verification method of MD5 - Google Patents

The calculation process and file verification method of MD5 Download PDF

Info

Publication number
CN103886087B
CN103886087B CN201410123911.3A CN201410123911A CN103886087B CN 103886087 B CN103886087 B CN 103886087B CN 201410123911 A CN201410123911 A CN 201410123911A CN 103886087 B CN103886087 B CN 103886087B
Authority
CN
China
Prior art keywords
end sequence
file
sequence type
64byte
calculate
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
CN201410123911.3A
Other languages
Chinese (zh)
Other versions
CN103886087A (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.)
China Resources Network Shenzhen Co Ltd
Original Assignee
Shanghai Feixun Data Communication Technology 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 Shanghai Feixun Data Communication Technology Co Ltd filed Critical Shanghai Feixun Data Communication Technology Co Ltd
Priority to CN201410123911.3A priority Critical patent/CN103886087B/en
Publication of CN103886087A publication Critical patent/CN103886087A/en
Application granted granted Critical
Publication of CN103886087B publication Critical patent/CN103886087B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention proposes a kind of calculation process of MD5 comprising first expands raw data file, forms calculation document;Obtain the end sequence type that MD5 is used;Judge whether end sequence type and current computing platform are identical, if identical, directly calculate N number of 64Byte original data packets MD5 verification and, if differed, then first by N number of 64Byte original numbers grouping by 32 bit bytes carry out syllable sequence reversing, then calculate MD5 verification and.The canonical algorithm of prior art MD5 generally will first do big end sequence platform syllable sequence reversing processing, then calculate when carrying out operation to 64 byte groups.Compared with prior art, the calculation process of MD5 of the present invention can avoid not having to carry out or carrying out less syllable sequence reversing processing on veneer, be taken so as to reduce verification.

Description

The calculation process and file verification method of MD5
Technical field
The present invention relates to the calculation process of a kind of method of calibration of file more particularly to a kind of MD5 and based on the calculating of MD5 The method of calibration of flow.
Background technology
Computer CPU to data store and read there are two types of hold sequence:Big end sequence and small end sequence.Big end sequence is initially in motor sieve It is used in the chip of drawing, it is widely used in some embedded chips at present.Small end sequence, initially uses in intel chips, It is widely used at present.
MD5(Message-Digest Algorithm5, Message Digest Algorithm 5)Canonical algorithm assumes that number of files It is identical with small end sequence platform with the mode of filling data storage according to storage, it is flat to big end sequence when carrying out operation to 64 byte groups Platform generally first will do syllable sequence reversing processing by 32 bit bytes, then calculate again.
Several pieces to more than ten pieces pluggable veneers are generally included in frame-type switch equipment, every piece of veneer there are independent CPU cores Piece.In these veneers, software starts and escalation process half is related to verifying the complete of file using MD5 methods of calibration Property.General checking process is:1)The md5 values of raw data file are first calculated according to the canonical algorithm of MD5 on PC, and and former Beginning data file synthesizes an APMB package, the specific Format Reference the following table 1 of the APMB package.
MD5 values
Raw data file
Table 1
2)When being handled on veneer, the MD5 values of raw data file in APMB package are also calculated according to the canonical algorithm of MD5; Then it is compared with the MD5 values in APMB package, unanimously then thinks that file is complete;Otherwise it is assumed that file is imperfect, damage It is bad.
Due to the cpu chip that the frame-type switch equipment of existing not small number uses, data are stored and are read using big Sequence is held, thus, it is unified to verified data to carry out syllable sequence reversing processing according to little-endian according to the canonical algorithm of MD5, so Verification is calculated afterwards and this will cause checking time to increase.
Invention content
The technical issues of present invention need to solve is to provide a kind of calculation process reducing the time-consuming MD5 of verification.
In order to solve the above technical problems, the present invention devises a kind of calculation process of MD5 comprising following steps:
Step 1:First expand raw data file, forms calculation document, the calculation document includes N number of 64Byte original numbers According to grouping, 1 initial data rest block and 1 expanding data block;
Step 2:Obtain the end sequence type that MD5 is used;
Step 3:Judge whether end sequence type and current computing platform are identical, if identical, directly calculate N number of 64Byte The MD5 of original data packet is verified and is carried out word by 32 bit bytes if it is not the same, being then first grouped N number of 64Byte original numbers Save sequence reverse, then calculate MD5 verification and;
Step 4:Judge whether current computing platform is small end sequence computing platform, if so, merging 1 initial data residue Block and 1 expanding data block, are grouped, and continue to calculate according to 64Byte, obtain final MD5 verification and, if not, merging 1 initial data rest block and 1 expanding data block, and be grouped according to 64Byte, then to each of obtaining grouping by 32 Bit byte carries out syllable sequence reversing, then calculates MD5 verifications and obtains final MD5 values.
Particularly, the end sequence type is big end sequence type or small end sequence type.
Particularly, the current computing platform is big end sequence computing platform or small end sequence computing platform.
The present invention also provides a kind of file verification methods, are the file verification methods of the calculation process based on above-mentioned MD5, Include the following steps:
Step 1:The calculation process of MD5 according to claim 1 obtains the MD5 values of raw data file on PC;
Step 2:Composite document packet, the file packet include MD5 values, hold sequence type and raw data file;
Step 3:It is handled on veneer, the original in file packet is obtained further according to the calculation process of MD5 described in claim 1 The MD5 values of beginning data file, wherein the end sequence type that acquisition MD5 is used is the end sequence type in file packet;
Step 4:The MD5 values of raw data file obtained above are compared with the MD5 values in the file packet, such as Fruit is consistent, then it is assumed that raw data file is complete, otherwise, then it is assumed that file is imperfect.
The canonical algorithm of prior art MD5 generally will first do word when carrying out operation to 64 byte groups to big end sequence platform Sequence reversing processing is saved, is then calculated, compared with prior art, the calculation process of MD5 of the present invention can avoid not having on veneer Syllable sequence reversing processing is carried out or carried out less, is taken so as to reduce verification.
Description of the drawings
Fig. 1 is the calculation process block diagram of MD5 of the embodiment of the present invention;
Fig. 2 is the step demonstration graph in the calculation process of MD5 of the embodiment of the present invention;
Fig. 3 is the structure chart of calculation document of the embodiment of the present invention;
Fig. 4 is the structure chart of file packet of the present invention.
Specific implementation mode
In order to make relevant technical staff in the field more fully understand technical scheme of the present invention, below in conjunction with of the invention real The technical solution in embodiment of the present invention is clearly and completely described in the attached drawing for applying mode, it is clear that described reality The mode of applying is only some embodiments of the invention, rather than whole embodiments.
As shown in Figure 1, for the calculation process of MD5 of the present invention, including:
Step 1:First expand raw data file, forms calculation document, the calculation document includes N number of 64Byte original numbers According to grouping, 1 initial data rest block and 1 expanding data block.
Step 2:The end sequence type that MD5 is used is obtained, end sequence type is big end sequence type or small end sequence type.Work as original number The format for storing and reading according to file is big end sequence, that is, it is big end sequence type to hold sequence type;When raw data file stores and reads The format taken is small end sequence, that is, it is small end sequence type to hold sequence type.
Step 3:Judge whether end sequence type and current computing platform are identical, if identical, directly calculate N number of 64Byte The MD5 of original data packet is verified and is carried out word by 32 bit bytes if it is not the same, being then first grouped N number of 64Byte original numbers Save sequence reverse, then calculate MD5 verification and.Current computing platform is big end sequence platform or small end sequence platform.It is run in PC machine When MD5 algorithms, PC machine is generally small end sequence computing platform.When being run on veneer, CPU classes used by veneer are depended on Type uses big end sequence as CPU stores data and reads, then computing platform is big end sequence computing platform.As CPU stores data Small end sequence is used with reading, then computing platform is small end sequence computing platform.
Step 4:Judge whether current computing platform is small end sequence computing platform, if so, merging 1 initial data residue Block and 1 expanding data block, are grouped, and continue to calculate according to 64Byte, obtain final MD5 verification and, if not, merging 1 initial data rest block and 1 expanding data block, and be grouped according to 64Byte, then to each of obtaining grouping by 32 Bit byte carries out syllable sequence reversing, then calculates MD5 verifications and obtains final MD5 values.
Based on the calculation process of MD5 of the present invention, can to avoid without carrying out or carrying out less syllable sequence reversing processing, so as to It is taken with reducing verification.The calculation process of MD5 is used to verify the file of frame-type switch by the embodiment of the present invention, but is not limited to school Test the file of frame-type switch.In the present embodiment, the veneer in frame-type switch uses big end sequence CPU.
The present embodiment, the software of veneer starts the verification for being related to file integrality with escalation process, using the verification sides MD5 Method obtains the MD5 values of raw data file according to the calculation process of MD5 of the present invention on PC, specifically implements means first It is:As shown in Fig. 2, first expanding raw data file, calculation document is formed, the calculation document includes N number of 64Byte original numbers According to grouping, 1 initial data rest block and 1 expanding data block, as shown in Figure 3.The end sequence type of MD5 uses is obtained again, this In embodiment, since the veneer in frame-type switch uses big end sequence CPU, therefore it is big end sequence type to hold sequence type, and is currently counted Calculation platform is PC machine, as small end sequence computing platform.Thus, end sequence type is differed with current computing platform, then to calculating text N number of 64Byte original data packets in part are first handled, and are carried out syllable sequence reversing by 32 bit bytes, are then calculated the schools MD5 Test and.Certainly, if the CPU that uses of veneer is small end sequence type, that is, hold sequence type identical with current computing platform, it is literary to calculating N number of 64Byte original data packets in part directly calculate MD5 verifications and need not carry out falling by 32 bit bytes progress syllable sequence Turn processing." 1 initial data rest block and 1 expanding data block " uncalculated in calculation document is further handled, Since current computing platform is small end sequence computing platform, " 1 initial data rest block and 1 expansion in joint account file Data block " is grouped according to 64Byte, and continues to calculate, obtain final MD5 verification and.Final MD5 verifications and as MD5 Value, calculating terminate.
After obtaining MD5 values in PC machine, the MD5 values, raw data file and end sequence type are synthesized into a file packet, This document, which is wrapped, to be passed on veneer, then carries out verifying its integrality.As shown in figure 4, the file packet includes MD5 values, sequence class is held Type and raw data file.In the present embodiment, end sequence type is big end sequence type.
It is whether complete to verify it when APMB package, which is transferred on veneer, to be started or upgrade, it needs to handle on veneer, count The MD5 values of the raw data file in APMB package are calculated, the MD5 values for calculating the raw data file in APMB package are again based on this hair The calculation process of bright MD5 expands the raw data file in APMB package to obtain calculation document first, and calculation document includes N number of 64Byte original data packets, 1 initial data rest block and 1 expanding data block.Then the end in APMB package is got Sequence type, as, the end sequence type that MD5 is used, in the present embodiment, end sequence type are big end sequence type, and calculating at this time Platform is handled on veneer, as big end sequence computing platform, then it is big end sequence to hold sequence type and current computing platform all, to N A 64Byte original data packets directly calculate MD5 verification and, need not carry out by 32 bit bytes carry out syllable sequence reversing processing, It thus avoids and carries out syllable sequence reversing processing, successfully reduce verification and take." 1 original for uncalculated in calculation document Data redundancy block and 1 expanding data block " is further handled, can not since current computing platform is big end sequence computing platform Avoid carry out syllable sequence reversing processing, according to canonical algorithm, i.e., in joint account file in " 1 initial data rest block and 1 A expanding data block " merges 1 initial data rest block and 1 expanding data block, and is grouped according to 64Byte, then right Each of obtain grouping and carry out syllable sequence reversing by 32 bit bytes, then calculate MD5 verifications and, obtain final MD5 values.
After the MD5 values of obtained raw data file, its value is compared with the MD5 values in the file packet, if Unanimously, then it is assumed that raw data file is complete, otherwise, then it is assumed that file is imperfect.
The calculation process of MD5 of the present invention can avoid not having to carry out on veneer or carry out syllable sequence reversing processing less, from And verification can be reduced and taken.
Only express one embodiment of the present invention above, the description thereof is more specific and detailed, but can not therefore and It is interpreted as the limitation to the scope of the claims of the present invention.It should be pointed out that for those of ordinary skill in the art, not taking off Under the premise of present inventive concept, various modifications and improvements can be made, these are all within the scope of protection of the present invention.Cause This, the protection domain of patent of the present invention should be determined by the appended claims.

Claims (4)

1. a kind of calculation process of MD5, which is characterized in that include the following steps:
Step 1:First expand raw data file, form calculation document, the calculation document includes N number of 64Byte initial data point Group, 1 initial data rest block and 1 expanding data block, N are natural number;
Step 2:Obtain the end sequence type that MD5 is used;
Step 3:Judge whether end sequence type and current computing platform are identical, if identical, it is original directly to calculate N number of 64Byte The MD5 of packet is verified and is carried out syllable sequence by 32 bit bytes if it is not the same, being then first grouped N number of 64Byte original numbers Reverse, then calculate MD5 verification and;
Step 4:When the end sequence type is small end sequence type, judge whether current computing platform is small end sequence computing platform, If so, merging 1 initial data rest block and 1 expanding data block, it is grouped, and continue to calculate, obtains according to 64Byte It verifies to final MD5 and if not, merging 1 initial data rest block and 1 expanding data block, and is carried out according to 64Byte Grouping, then to obtain each be grouped by 32 bit bytes carry out syllable sequence reversing, then calculate MD5 verification and, obtain final MD5 Value;
When the end sequence type is big end sequence type, judge whether current computing platform is big end sequence computing platform, if so, Merge 1 initial data rest block and 1 expanding data block, be grouped according to 64Byte, and continue to calculate, is obtained final MD5 verify and, if not, merging 1 initial data rest block and 1 expanding data block, and be grouped according to 64Byte, then Carry out syllable sequence reversing by 32 bit bytes to each of obtaining grouping, then calculate MD5 verifications and, obtain final MD5 values.
2. the calculation process of MD5 according to claim 1, which is characterized in that the end sequence type be big end sequence type or Small end sequence type.
3. the calculation process of MD5 according to claim 2, which is characterized in that the current computing platform is big end sequence meter Calculate platform or small end sequence computing platform.
4. a kind of file verification method using MD5 calculation process as described in claim 1, which is characterized in that including Following steps:
Step 1:The MD5 values of raw data file are obtained according to above-mentioned MD5 calculation process on PC;
Step 2:Composite document packet, the file packet include MD5 values, hold sequence type and raw data file;
Step 3:It is handled on veneer, the original number in file packet is obtained further according to the calculation process of MD5 described in claim 1 According to the MD5 values of file, wherein the end sequence type that acquisition MD5 is used is the end sequence type in file packet;
Step 4:The MD5 values of raw data file obtained above are compared with the MD5 values in the file packet, if one It causes, then it is assumed that raw data file is complete, otherwise, then it is assumed that file is imperfect.
CN201410123911.3A 2014-03-28 2014-03-28 The calculation process and file verification method of MD5 Active CN103886087B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410123911.3A CN103886087B (en) 2014-03-28 2014-03-28 The calculation process and file verification method of MD5

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410123911.3A CN103886087B (en) 2014-03-28 2014-03-28 The calculation process and file verification method of MD5

Publications (2)

Publication Number Publication Date
CN103886087A CN103886087A (en) 2014-06-25
CN103886087B true CN103886087B (en) 2018-10-12

Family

ID=50954979

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410123911.3A Active CN103886087B (en) 2014-03-28 2014-03-28 The calculation process and file verification method of MD5

Country Status (1)

Country Link
CN (1) CN103886087B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006065702A (en) * 2004-08-30 2006-03-09 Mitsubishi Electric Corp Data processor, data processing method, and program
CN1838666A (en) * 2005-03-24 2006-09-27 华为技术有限公司 Byte sequence switching method for crossing operating system platform
CN101453478A (en) * 2007-11-28 2009-06-10 新奥特(北京)视频技术有限公司 Integrity checking method in document transmission
CN101645017A (en) * 2009-09-07 2010-02-10 深圳市茁壮网络股份有限公司 Cross-platform byte order processing method, device and byte code running platform
CN102932474A (en) * 2012-11-14 2013-02-13 北京星网锐捷网络技术有限公司 Method, device and system for analyzing message

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006065702A (en) * 2004-08-30 2006-03-09 Mitsubishi Electric Corp Data processor, data processing method, and program
CN1838666A (en) * 2005-03-24 2006-09-27 华为技术有限公司 Byte sequence switching method for crossing operating system platform
CN101453478A (en) * 2007-11-28 2009-06-10 新奥特(北京)视频技术有限公司 Integrity checking method in document transmission
CN101645017A (en) * 2009-09-07 2010-02-10 深圳市茁壮网络股份有限公司 Cross-platform byte order processing method, device and byte code running platform
CN102932474A (en) * 2012-11-14 2013-02-13 北京星网锐捷网络技术有限公司 Method, device and system for analyzing message

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
MD5算法研究;张裔智 等;《计算机科学》;20081231;第35卷(第7期);第295页第6-7段,图2 *

Also Published As

Publication number Publication date
CN103886087A (en) 2014-06-25

Similar Documents

Publication Publication Date Title
CN103647777B (en) Safety certificate method and bidirectional forwarding detection BFD equipment
CN104978253B (en) A kind of method and apparatus of file destination verification
WO2017036228A1 (en) Method and apparatus for implementing system upgrading
WO2007103141A3 (en) Method and apparatus for providing virtual machine backup
RU2013108211A (en) METHOD FOR PREVENTING RE-USE OF DIGITAL DATA PACKAGES IN A NETWORK DATA TRANSFER SYSTEM
EP3384406A1 (en) Combining hashes of data blocks
CN104077373A (en) Data consistency checking method
WO2017112339A1 (en) Serial i/o functional tester
CN108170461A (en) Difference upgrade package generation method, difference upgrade method and device
CN108804315A (en) Applied to the test method of dynamic development, device, electronic equipment and storage medium
CN103886087B (en) The calculation process and file verification method of MD5
CN104503803B (en) Linux kernel and file system upgrading method
TW200515150A (en) Secure storage system and method for solid memory
CN104503862B (en) The method and apparatus for obtaining the check value using channel bag
CN107193685B (en) Erasure method and device based on flash memory storage device
CN103399804A (en) Method and system for repairing remote package files
CN113448764A (en) Check code generation method and device, electronic equipment and computer storage medium
CN103425922A (en) Method and system for acquiring far-end encryption command based on CSP (Cryptographic Service Provider)
CN102495778A (en) System and method for testing single-packet regular matching logic
CN110515604A (en) The acquisition methods and device of the executable program file of verification environment
CN105354107A (en) Data transmission method and system for NOR Flash
CN110018854B (en) Firmware matching method, equipment and computer readable storage medium
US9838229B2 (en) Method for verifying the functionality of a digital circuit
CN105162594B (en) A kind of quick endorsement method and signature device
CN114371863A (en) Data processing method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201103

Address after: Room 201, building a, No. 1, Qianwan 1st Road, Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong Province (settled in Shenzhen Qianhai business secretary Co., Ltd.) business premises: 25-26 / F, *** international building, No. 8, Haisi Road, Yuehai street, Nanshan District, Guangdong Province

Patentee after: China Resources Network (Shenzhen) Co.,Ltd.

Address before: 201616 Shanghai city Songjiang District Guangfulin road 4855 Lane 20, No. 90

Patentee before: Phicomm (Shanghai) Co.,Ltd.

CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: No. 1106-B092, Qianhai Xiangbin Building, No. 18, Zimao West Street, Nanshan Street, Qianhai Shenzhen Hong Kong Cooperation Zone, Shenzhen, Guangdong 518000

Patentee after: China Resources Network (Shenzhen) Co.,Ltd.

Address before: 518000 Room 201, Building A, No. 1, Qianwan 1st Road, Qianhai Shenzhen Hong Kong Cooperation Zone, Shenzhen, Guangdong Province (settled in Shenzhen Qianhai Business Secretary Co., Ltd.) Business premises: 25-26, Baidu International Building, No. 8, Haisi Road, Yuehai Street, Nanshan District, Shenzhen

Patentee before: China Resources Network (Shenzhen) Co.,Ltd.