]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/sha2.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: sha512.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
4 /* ######################################################################
6 SHA{512,256}SumValue - Storage for a SHA-{512,256} hash.
7 SHA{512,256}Summation - SHA-{512,256} Secure Hash Algorithm.
9 This is a C++ interface to a set of SHA{512,256}Sum functions, that mirrors
10 the equivalent MD5 & SHA1 classes.
12 ##################################################################### */
22 #include "sha2_internal.h"
28 class SHA512Summation
;
32 friend class SHA512Summation
;
33 unsigned char Sum
[64];
38 bool operator ==(const SHA512SumValue
&rhs
) const;
40 inline void Value(unsigned char S
[64])
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
[64])
45 {for (int I
= 0; I
!= sizeof(Sum
); I
++) Sum
[I
] = S
[I
];};
47 SHA512SumValue(string Str
);
54 unsigned char Sum
[64];
59 bool Add(const unsigned char *inbuf
,unsigned long inlen
);
60 inline bool Add(const char *Data
) {return Add((unsigned char *)Data
,strlen(Data
));};
61 bool AddFD(int Fd
,unsigned long Size
);
62 inline bool Add(const unsigned char *Beg
,const unsigned char *End
)
63 {return Add(Beg
,End
-Beg
);};
64 SHA512SumValue
Result();
70 class SHA256Summation
;
74 friend class SHA256Summation
;
75 unsigned char Sum
[32];
80 bool operator ==(const SHA256SumValue
&rhs
) const;
82 inline void Value(unsigned char S
[32])
83 {for (int I
= 0; I
!= sizeof(Sum
); I
++) S
[I
] = Sum
[I
];};
84 inline operator string() const {return Value();};
86 inline void Set(unsigned char S
[32])
87 {for (int I
= 0; I
!= sizeof(Sum
); I
++) Sum
[I
] = S
[I
];};
89 SHA256SumValue(string Str
);
96 unsigned char Sum
[32];
101 bool Add(const unsigned char *inbuf
,unsigned long inlen
);
102 inline bool Add(const char *Data
) {return Add((unsigned char *)Data
,strlen(Data
));};
103 bool AddFD(int Fd
,unsigned long Size
);
104 inline bool Add(const unsigned char *Beg
,const unsigned char *End
)
105 {return Add(Beg
,End
-Beg
);};
106 SHA256SumValue
Result();