mirror of
https://github.com/vgough/encfs.git
synced 2024-12-29 10:09:20 +01:00
adds openssl implementation of PBKDF2 hmac-sha256
git-svn-id: http://encfs.googlecode.com/svn/trunk@103 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
parent
33b8c00a67
commit
3a34db8ce4
@ -457,6 +457,42 @@ class PbkdfPkcs5HmacSha1 : public PBKDF {
|
||||
};
|
||||
REGISTER_CLASS(PbkdfPkcs5HmacSha1, PBKDF);
|
||||
|
||||
class PbkdfPkcs5HmacSha256 : public PBKDF {
|
||||
public:
|
||||
PbkdfPkcs5HmacSha256() {}
|
||||
virtual ~PbkdfPkcs5HmacSha256() {}
|
||||
|
||||
virtual bool makeKey(const char *password, int passwordLength,
|
||||
const byte *salt, int saltLength,
|
||||
int numIterations,
|
||||
CipherKey *outKey) {
|
||||
return PKCS5_PBKDF2_HMAC(
|
||||
password, passwordLength,
|
||||
const_cast<byte *>(salt), saltLength,
|
||||
numIterations, EVP_sha256(),
|
||||
outKey->size(), outKey->data()) == 1;
|
||||
}
|
||||
|
||||
virtual CipherKey randomKey(int length) {
|
||||
CipherKey key(length);
|
||||
if (!OpenSSLCipher::randomize(&key))
|
||||
key.reset();
|
||||
return key;
|
||||
}
|
||||
|
||||
virtual bool pseudoRandom(byte *out, int length) {
|
||||
return OpenSSLCipher::pseudoRandomize(out, length);
|
||||
}
|
||||
|
||||
static Properties GetProperties() {
|
||||
Properties props;
|
||||
props.mode = NAME_PBKDF2_HMAC_SHA256;
|
||||
props.library = "OpenSSL";
|
||||
return props;
|
||||
}
|
||||
};
|
||||
REGISTER_CLASS(PbkdfPkcs5HmacSha256, PBKDF);
|
||||
|
||||
|
||||
unsigned long pthreads_thread_id()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user