]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/md5.h
Prepare release 1.1~exp17
[apt.git] / apt-pkg / contrib / md5.h
CommitLineData
17a10bf5
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
233b185f 3// $Id: md5.h,v 1.6 2001/05/07 05:06:52 jgg Exp $
17a10bf5
AL
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
1e3f4083 13 block of data. This can be used to guard against corruption of a file.
6e52073f
AL
14 MD5 should not be used for tamper protection, use SHA or something more
15 secure.
17a10bf5
AL
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
aa97e2e3 26#include <stdint.h>
17a10bf5 27
7ac56f8f 28#include "hashsum_template.h"
17a10bf5 29
453b82a3
DK
30#ifndef APT_10_CLEANER_HEADERS
31#include <string>
32#include <cstring>
33#include <algorithm>
34#endif
a4f6bdc8
DK
35#ifndef APT_8_CLEANER_HEADERS
36using std::string;
37using std::min;
38#endif
39
7ac56f8f 40typedef HashSumValue<128> MD5SumValue;
17a10bf5 41
c31c1dde 42class MD5Summation : public SummationImplementation
17a10bf5 43{
ed478d8c 44 uint32_t Buf[4];
17a10bf5
AL
45 unsigned char Bytes[2*4];
46 unsigned char In[16*4];
47 bool Done;
c31c1dde 48
17a10bf5
AL
49 public:
50
3b302846 51 bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE;
c31c1dde
DK
52 using SummationImplementation::Add;
53
17a10bf5 54 MD5SumValue Result();
c31c1dde 55
17a10bf5
AL
56 MD5Summation();
57};
58
59#endif