2013-03-05 07:32:27 +01:00
|
|
|
#ifndef ENCFS_PBKDF_H
|
|
|
|
#define ENCFS_PBKDF_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
|
|
|
// Well-known algorithms.
|
2013-03-06 09:02:23 +01:00
|
|
|
static const char NAME_PBKDF2_HMAC_SHA1[] = "PBKDF2_HMAC_SHA1";
|
|
|
|
static const char NAME_PBKDF2_HMAC_SHA256[] = "PBKDF2_HMAC_SHA256";
|
2013-03-05 07:36:32 +01:00
|
|
|
|
2013-03-05 07:32:27 +01:00
|
|
|
// Password Based Key Derivation Function.
|
2013-10-20 00:35:26 +02:00
|
|
|
class PBKDF {
|
2013-03-05 07:32:27 +01:00
|
|
|
public:
|
|
|
|
DECLARE_REGISTERABLE_TYPE(PBKDF);
|
|
|
|
|
|
|
|
struct Properties {
|
|
|
|
std::string mode;
|
|
|
|
std::string library;
|
|
|
|
|
|
|
|
std::string toString() const { return mode; }
|
|
|
|
};
|
|
|
|
|
|
|
|
PBKDF();
|
|
|
|
virtual ~PBKDF();
|
|
|
|
|
|
|
|
virtual bool makeKey(const char *password, int passwordLength,
|
2013-10-20 00:35:26 +02:00
|
|
|
const byte *salt, int saltLength, int numIterations,
|
|
|
|
CipherKey *outKey) = 0;
|
2013-03-05 07:36:32 +01:00
|
|
|
|
|
|
|
// Create a new key with strong randomization.
|
2013-10-20 00:35:26 +02:00
|
|
|
virtual CipherKey randomKey(int length) = 0;
|
2013-03-05 07:36:32 +01:00
|
|
|
|
|
|
|
// Randomize the output. Pseudo randomization is allowed, so this may not be
|
|
|
|
// used for keys or other critical values.
|
2013-10-20 00:35:26 +02:00
|
|
|
virtual bool pseudoRandom(byte *out, int byteLen) = 0;
|
2013-03-05 07:32:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace encfs
|
|
|
|
|
2013-10-20 00:35:26 +02:00
|
|
|
#endif // ENCFS_PBKDF_H
|