[CSE] Convert the base64 data to raw, for the decyrption

This commit is contained in:
Tomaz Canabrava 2017-10-31 13:17:22 +01:00
parent 3628f3739d
commit 4bb7ebb6aa

View file

@ -776,9 +776,7 @@ std::string FolderMetadata::decryptMetadataKeys(const std::string& encryptedMeta
{
qCInfo(lcCse()) << "Starting to decrypt the metadata key";
unsigned char *out;
unsigned char *in;
size_t outlen;
size_t inlen;
int err = -1;
auto path = privateKeyPath(_account);
@ -786,6 +784,12 @@ std::string FolderMetadata::decryptMetadataKeys(const std::string& encryptedMeta
auto pkeyFile = fopen(pathC, "r");
auto key = PEM_read_PrivateKey(pkeyFile, NULL, NULL, NULL);
// Data is base64 encoded.
auto raw = QByteArray(encryptedMetadata.c_str(), encryptedMetadata.length());
auto b64d = QByteArray::fromBase64(raw);
auto in = (unsigned char *) b64d.constData();
size_t inlen = b64d.length();
/* NB: assumes key in, inlen are already set up
* and that key is an RSA private key
*/