summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/sha2.h
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-07-15 09:42:37 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-07-15 09:42:37 +0200
commit35555c1826da5df9f2c06a74f2e91be843ad8142 (patch)
tree9127cb9461a2de987748600c08682f7051ba12b7 /apt-pkg/contrib/sha2.h
parentcec8c646c79e40d928464b08a6f2e3ea62bb1611 (diff)
parent4b42f43bed369817398b6c8d538f08e5bf6dff76 (diff)
merged from donkult
Diffstat (limited to 'apt-pkg/contrib/sha2.h')
-rw-r--r--apt-pkg/contrib/sha2.h27
1 files changed, 8 insertions, 19 deletions
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index bd5472527..386225889 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -22,31 +22,16 @@
#include "sha2_internal.h"
#include "hashsum_template.h"
-using std::string;
-using std::min;
-
-class SHA512Summation;
-class SHA256Summation;
-
typedef HashSumValue<512> SHA512SumValue;
typedef HashSumValue<256> SHA256SumValue;
-class SHA2SummationBase
+class SHA2SummationBase : public SummationImplementation
{
protected:
bool Done;
public:
- virtual bool Add(const unsigned char *inbuf,unsigned long inlen) = 0;
- virtual bool AddFD(int Fd,unsigned long Size);
+ bool Add(const unsigned char *inbuf, unsigned long len) = 0;
- inline bool Add(const char *Data)
- {
- return Add((unsigned char *)Data,strlen(Data));
- };
- inline bool Add(const unsigned char *Beg,const unsigned char *End)
- {
- return Add(Beg,End-Beg);
- };
void Result();
};
@@ -56,13 +41,15 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long len)
{
if (Done)
return false;
SHA256_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA256SumValue Result()
{
if (!Done) {
@@ -86,13 +73,15 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long len)
{
if (Done)
return false;
SHA512_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA512SumValue Result()
{
if (!Done) {