apt
1.5
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: md5.h,v 1.6 2001/05/07 05:06:52 jgg Exp $ 00004 /* ###################################################################### 00005 00006 MD5SumValue - Storage for a MD5Sum 00007 MD5Summation - MD5 Message Digest Algorithm. 00008 00009 This is a C++ interface to a set of MD5Sum functions. The class can 00010 store a MD5Sum in 16 bytes of memory. 00011 00012 A MD5Sum is used to generate a (hopefully) unique 16 byte number for a 00013 block of data. This can be used to gaurd against corruption of a file. 00014 MD5 should not be used for tamper protection, use SHA or something more 00015 secure. 00016 00017 There are two classes because computing a MD5 is not a continual 00018 operation unless 64 byte blocks are used. Also the summation requires an 00019 extra 18*4 bytes to operate. 00020 00021 ##################################################################### */ 00022 /*}}}*/ 00023 #ifndef APTPKG_MD5_H 00024 #define APTPKG_MD5_H 00025 00026 00027 #include <string> 00028 #include <cstring> 00029 #include <algorithm> 00030 #include <stdint.h> 00031 00032 #include "hashsum_template.h" 00033 00034 #ifndef APT_8_CLEANER_HEADERS 00035 using std::string; 00036 using std::min; 00037 #endif 00038 00039 typedef HashSumValue<128> MD5SumValue; 00040 00041 class MD5Summation : public SummationImplementation 00042 { 00043 uint32_t Buf[4]; 00044 unsigned char Bytes[2*4]; 00045 unsigned char In[16*4]; 00046 bool Done; 00047 00048 public: 00049 00050 bool Add(const unsigned char *inbuf, unsigned long long inlen); 00051 using SummationImplementation::Add; 00052 00053 MD5SumValue Result(); 00054 00055 MD5Summation(); 00056 }; 00057 00058 #endif