projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test framework: Correctly generate new paths in noopchroot
[apt.git]
/
apt-pkg
/
contrib
/
sha2.h
diff --git
a/apt-pkg/contrib/sha2.h
b/apt-pkg/contrib/sha2.h
index bd54725278b10205b187cace2e296c9a31dc7d92..8b4bdd439b1c80aef55b7a2799aefdd748ce1713 100644
(file)
--- a/
apt-pkg/contrib/sha2.h
+++ b/
apt-pkg/contrib/sha2.h
@@
-14,39
+14,28
@@
#ifndef APTPKG_SHA2_H
#define APTPKG_SHA2_H
#ifndef APTPKG_SHA2_H
#define APTPKG_SHA2_H
-#include <string>
#include <cstring>
#include <cstring>
-#include <algorithm>
-#include <stdint.h>
#include "sha2_internal.h"
#include "hashsum_template.h"
#include "sha2_internal.h"
#include "hashsum_template.h"
-using std::string;
-using std::min;
+#ifndef APT_10_CLEANER_HEADERS
+#include <string>
+#include <algorithm>
+#include <stdint.h>
+#endif
-class SHA512Summation;
-class SHA256Summation;
typedef HashSumValue<512> SHA512SumValue;
typedef HashSumValue<256> SHA256SumValue;
typedef HashSumValue<512> SHA512SumValue;
typedef HashSumValue<256> SHA256SumValue;
-class SHA2SummationBase
+class SHA2SummationBase
: public SummationImplementation
{
protected:
bool Done;
public:
{
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 long len) APT_OVERRIDE = 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();
};
void Result();
};
@@
-56,13
+45,15
@@
class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
unsigned char Sum[32];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
{
if (Done)
return false;
SHA256_Update(&ctx, inbuf, len);
return true;
};
{
if (Done)
return false;
SHA256_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA256SumValue Result()
{
if (!Done) {
SHA256SumValue Result()
{
if (!Done) {
@@
-73,10
+64,11
@@
class SHA256Summation : public SHA2SummationBase
res.Set(Sum);
return res;
};
res.Set(Sum);
return res;
};
- SHA256Summation()
+ SHA256Summation()
{
SHA256_Init(&ctx);
Done = false;
{
SHA256_Init(&ctx);
Done = false;
+ memset(&Sum, 0, sizeof(Sum));
};
};
};
};
@@
-86,13
+78,15
@@
class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
unsigned char Sum[64];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
{
if (Done)
return false;
SHA512_Update(&ctx, inbuf, len);
return true;
};
{
if (Done)
return false;
SHA512_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA512SumValue Result()
{
if (!Done) {
SHA512SumValue Result()
{
if (!Done) {
@@
-107,6
+101,7
@@
class SHA512Summation : public SHA2SummationBase
{
SHA512_Init(&ctx);
Done = false;
{
SHA512_Init(&ctx);
Done = false;
+ memset(&Sum, 0, sizeof(Sum));
};
};
};
};