00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_SECURITY_MESSAGEDIGEST_H_
00019 #define _DECAF_SECURITY_MESSAGEDIGEST_H_
00020
00021 #include <decaf/util/Config.h>
00022
00023 #include <decaf/security/MessageDigestSpi.h>
00024 #include <decaf/nio/ByteBuffer.h>
00025
00026 #include <string>
00027
00028 namespace decaf {
00029 namespace security {
00030
00031 class MessageDigestSpi;
00032 class MessageDigestImpl;
00033 class Provider;
00034
00071 class DECAF_API MessageDigest {
00072 private:
00073
00074 MessageDigestImpl* impl;
00075
00076 MessageDigestSpi* spi;
00077 const Provider* provider;
00078 std::string algorithm;
00079
00080 private:
00081
00082 MessageDigest(const MessageDigest&);
00083 MessageDigest& operator= (const MessageDigest&);
00084
00085 protected:
00086
00087 MessageDigest(const std::string& name);
00088
00089 public:
00090
00091 virtual ~MessageDigest();
00092
00097 std::vector<unsigned char> digest();
00098
00116 int digest(unsigned char* input, int size, int offset, int length);
00117
00130 std::vector<unsigned char> digest(const unsigned char* input, int size);
00131
00142 std::vector<unsigned char> digest(const std::vector<unsigned char>& input);
00143
00150 std::string getAlgorithmName() const {
00151 return this->algorithm;
00152 }
00153
00162 const Provider* getProvider() const {
00163 return this->provider;
00164 }
00165
00173 int getDigestLength() const;
00174
00183 MessageDigest* clone();
00184
00188 void reset();
00189
00195 std::string toString() const;
00196
00203 void update(unsigned char input);
00204
00217 void update(unsigned char* input, int size, int offset, int len);
00218
00225 void update(const std::vector<unsigned char>& input);
00226
00235 void update(nio::ByteBuffer& input);
00236
00237 public:
00238
00256 static MessageDigest* getInstance(const std::string& algorithm);
00257
00268 static bool isEqual(const std::vector<unsigned char>& digesta,
00269 const std::vector<unsigned char>& digestb);
00270
00271 };
00272
00273 }}
00274
00275 #endif