apt @VERSION@
|
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 using std::string; 00033 using std::min; 00034 00035 #include "hashsum_template.h" 00036 00037 typedef HashSumValue<128> MD5SumValue; 00038 00039 class MD5Summation : public SummationImplementation 00040 { 00041 uint32_t Buf[4]; 00042 unsigned char Bytes[2*4]; 00043 unsigned char In[16*4]; 00044 bool Done; 00045 00046 public: 00047 00048 bool Add(const unsigned char *inbuf, unsigned long inlen); 00049 using SummationImplementation::Add; 00050 00051 MD5SumValue Result(); 00052 00053 MD5Summation(); 00054 }; 00055 00056 #endif