8 #ifndef CPPCMS_CRYPTO_H 9 #define CPPCMS_CRYPTO_H 11 #include <cppcms/defs.h> 12 #include <booster/noncopyable.h> 13 #include <booster/hold_ptr.h> 14 #include <booster/auto_ptr_inc.h> 34 class CPPCMS_API
key {
47 key const &operator=(
key const &);
55 key(
void const *data,
size_t length);
59 explicit key(
char const *s);
63 explicit key(std::string
const &);
67 char const *data()
const;
81 void set(
void const *ptr,
size_t len);
85 void set_hex(
char const *ptr,
size_t len);
91 void read_from_file(std::string
const &file_name);
94 static unsigned from_hex(
char c);
115 virtual unsigned digest_size()
const = 0;
119 virtual unsigned block_size()
const = 0;
124 virtual void append(
void const *ptr,
size_t size) = 0;
129 virtual void readout(
void *ptr) = 0;
140 virtual char const *name()
const = 0;
145 static std::auto_ptr<message_digest> md5();
149 static std::auto_ptr<message_digest> sha1();
154 static std::auto_ptr<message_digest> create_by_name(std::string
const &name);
165 hmac(std::auto_ptr<message_digest> digest,
key const &k);
169 hmac(std::string
const &name,
key const &k);
175 unsigned digest_size()
const;
180 void append(
void const *ptr,
size_t size);
188 void readout(
void *ptr);
193 std::auto_ptr<message_digest> md_,md_opad_;
218 static std::auto_ptr<cbc> create(
cbc_type type);
227 static std::auto_ptr<cbc> create(std::string
const &name);
232 virtual unsigned block_size()
const = 0;
236 virtual unsigned key_size()
const = 0;
241 virtual void set_key(
key const &) = 0;
245 virtual void set_iv(
void const *ptr,
size_t size) = 0;
249 virtual void set_nonce_iv() = 0;
253 virtual void encrypt(
void const *in,
void *out,
unsigned len) = 0;
257 virtual void decrypt(
void const *in,
void *out,
unsigned len) = 0;
this class provides an API to calculate various cryptographic hash functions
Definition: crypto.h:101
This object calculates the HMAC signature for the input data.
Definition: crypto.h:160
Cipher-block chaining encryption and decryption cryptographic service.
Definition: crypto.h:202
This is the namespace where all CppCMS functionality is placed.
Definition: application.h:19
cbc_type
Definition: crypto.h:207
message_digest()
It should be implemented in derived classes.
Definition: crypto.h:104
Key object, holds the string that represents the binary key.
Definition: crypto.h:34
This class makes impossible to copy any class derived from this one.
Definition: noncopyable.h:15