2013-03-05 07:32:27 +01:00
|
|
|
#ifndef ENCFS_MAC_H
|
|
|
|
#define ENCFS_MAC_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/Registry.h"
|
|
|
|
#include "base/types.h"
|
2013-03-05 07:36:32 +01:00
|
|
|
#include "cipher/CipherKey.h"
|
2013-03-05 07:32:27 +01:00
|
|
|
|
|
|
|
namespace encfs {
|
|
|
|
|
2013-03-05 07:36:32 +01:00
|
|
|
static const char NAME_SHA1_HMAC[] = "SHA-1/HMAC";
|
|
|
|
|
|
|
|
// MAC provides keyed MessageAuthenticationCode algorithms, eg HMAC.
|
2013-10-20 00:35:26 +02:00
|
|
|
class MAC {
|
2013-03-05 07:32:27 +01:00
|
|
|
public:
|
2013-03-05 07:36:32 +01:00
|
|
|
DECLARE_REGISTERABLE_TYPE(MAC);
|
2013-03-05 07:32:27 +01:00
|
|
|
|
|
|
|
struct Properties {
|
2013-10-20 00:35:26 +02:00
|
|
|
int blockSize; // Block length of hash function.
|
2013-03-05 07:32:27 +01:00
|
|
|
std::string hashFunction;
|
|
|
|
std::string mode;
|
|
|
|
std::string library;
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
std::string toString() const { return hashFunction + "/" + mode; }
|
2013-03-05 07:32:27 +01:00
|
|
|
};
|
|
|
|
|
2013-03-05 07:36:32 +01:00
|
|
|
MAC();
|
|
|
|
virtual ~MAC();
|
2013-03-05 07:32:27 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
virtual int outputSize() const = 0;
|
2013-03-05 07:32:27 +01:00
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
virtual bool setKey(const CipherKey &key) = 0;
|
2013-03-05 07:32:27 +01:00
|
|
|
|
2013-03-05 07:39:51 +01:00
|
|
|
// Init must be called before any calls to update.
|
2013-10-20 00:35:26 +02:00
|
|
|
virtual void init() = 0;
|
|
|
|
virtual bool update(const byte *in, int length) = 0;
|
|
|
|
virtual bool write(byte *out) = 0;
|
2013-03-05 07:32:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace encfs
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
#endif // ENCFS_MAC_H
|