[cse] use PKCS5_PBKDF2_HMAC_SHA1 on the random-word passphrase

This commit is contained in:
Tomaz Canabrava 2017-09-14 21:41:31 +02:00 committed by Roeland Jago Douma
parent 5395fc56b1
commit 77c0309e02
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -231,9 +231,11 @@ void ClientSideEncryption::encryptPrivateKey(EVP_PKEY *keyPair)
// Send the encrypted key to the server. // Send the encrypted key to the server.
// I have no idea what I'm doing. // I have no idea what I'm doing.
static const char* salt = "$4$YmBjm3hk$Qb74D5IUYwghUmzsMqeNFx5z0/8$"; using ucharp = unsigned char *;
static const int iterationCount = 1024; const char *salt = "$4$YmBjm3hk$Qb74D5IUYwghUmzsMqeNFx5z0/8$";
static const int keyStrength = 256; const int saltLen = 40;
const int iterationCount = 1024;
const int keyStrength = 256;
BIO* bio = BIO_new(BIO_s_mem()); BIO* bio = BIO_new(BIO_s_mem());
QString passPhrase = WordList::getUnifiedString(WordList::getRandomWords(12)); QString passPhrase = WordList::getUnifiedString(WordList::getRandomWords(12));
@ -257,6 +259,27 @@ void ClientSideEncryption::encryptPrivateKey(EVP_PKEY *keyPair)
qCInfo(lcCse()) << "Private Key Extracted"; qCInfo(lcCse()) << "Private Key Extracted";
qCInfo(lcCse()) << output; qCInfo(lcCse()) << output;
/* Jesus. the OpenSSL docs do not help at all.
* This PKCS5_PBKDF2_HMAC_SHA1 call will generate
* a new password from the password that was submited.
*/
unsigned char secretKey[keyStrength];
ret = PKCS5_PBKDF2_HMAC_SHA1(
passPhrasePtr, // const char *password,
passPhrase.size(), // int password length,
(ucharp) salt, // const unsigned char *salt,
saltLen, // int saltlen,
iterationCount, // int iterations,
keyStrength, // int keylen,
secretKey // unsigned char *out
);
qCInfo(lcCse()) << "Return of the PKCS5" << ret;
qCInfo(lcCse()) << "Result String" << secretKey;
const EVP_CIPHER *cipher = EVP_get_cipherbyname("aes-256-cbc");
// Now, Try to encrypt it.
} }
void ClientSideEncryption::getPrivateKeyFromServer() void ClientSideEncryption::getPrivateKeyFromServer()