]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/sha256.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: sha1.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
4 /* ######################################################################
6 SHA256SumValue - Storage for a SHA-256 hash.
7 SHA256Summation - SHA-256 Secure Hash Algorithm.
9 This is a C++ interface to a set of SHA256Sum functions, that mirrors
10 the equivalent MD5 & SHA1 classes.
12 ##################################################################### */
14 #ifndef APTPKG_SHA256_H
15 #define APTPKG_SHA256_H
18 #pragma interface "apt-pkg/sha256.h"
28 class SHA256Summation
;
32 friend class SHA256Summation
;
33 unsigned char Sum
[32];
38 bool operator ==(const SHA256SumValue
&rhs
) const;
40 inline void Value(unsigned char S
[32])
41 {for (int I
= 0; I
!= sizeof(Sum
); I
++) S
[I
] = Sum
[I
];};
42 inline operator string() const {return Value();};
44 inline void Set(unsigned char S
[32])
45 {for (int I
= 0; I
!= sizeof(Sum
); I
++) Sum
[I
] = S
[I
];};
47 SHA256SumValue(string Str
);
59 struct sha256_ctx Sum
;
65 bool Add(const unsigned char *inbuf
,unsigned long inlen
);
66 inline bool Add(const char *Data
) {return Add((unsigned char *)Data
,strlen(Data
));};
67 bool AddFD(int Fd
,unsigned long Size
);
68 inline bool Add(const unsigned char *Beg
,const unsigned char *End
)
69 {return Add(Beg
,End
-Beg
);};
70 SHA256SumValue
Result();