Support large files in the complete toolset. Indexes of this
[ntk/apt.git] / apt-pkg / contrib / md5.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: md5.h,v 1.6 2001/05/07 05:06:52 jgg Exp $
4 /* ######################################################################
5
6 MD5SumValue - Storage for a MD5Sum
7 MD5Summation - MD5 Message Digest Algorithm.
8
9 This is a C++ interface to a set of MD5Sum functions. The class can
10 store a MD5Sum in 16 bytes of memory.
11
12 A MD5Sum is used to generate a (hopefully) unique 16 byte number for a
13 block of data. This can be used to gaurd against corruption of a file.
14 MD5 should not be used for tamper protection, use SHA or something more
15 secure.
16
17 There are two classes because computing a MD5 is not a continual
18 operation unless 64 byte blocks are used. Also the summation requires an
19 extra 18*4 bytes to operate.
20
21 ##################################################################### */
22 /*}}}*/
23 #ifndef APTPKG_MD5_H
24 #define APTPKG_MD5_H
25
26
27 #include <string>
28 #include <cstring>
29 #include <algorithm>
30 #include <stdint.h>
31
32 using std::string;
33 using std::min;
34
35 #include "hashsum_template.h"
36
37 typedef HashSumValue<128> MD5SumValue;
38
39 class MD5Summation : public SummationImplementation
40 {
41 uint32_t Buf[4];
42 unsigned char Bytes[2*4];
43 unsigned char In[16*4];
44 bool Done;
45
46 public:
47
48 bool Add(const unsigned char *inbuf, unsigned long long inlen);
49 using SummationImplementation::Add;
50
51 MD5SumValue Result();
52
53 MD5Summation();
54 };
55
56 #endif