[CSE] Add beginnign of the code to deal with the metadata

This commit is contained in:
Tomaz Canabrava 2017-10-23 19:27:34 +02:00
parent bb53c2586f
commit 476fe66043
3 changed files with 83 additions and 5 deletions

View file

@ -3,9 +3,11 @@ set(CMAKE_AUTOMOC TRUE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
# csync is required.
include_directories(${CMAKE_SOURCE_DIR}/src/csync
include_directories(
${CMAKE_SOURCE_DIR}/src/csync
${CMAKE_BINARY_DIR}/src/csync
)
${CMAKE_SOURCE_DIR}/src/3rdparty
)
if ( APPLE )
list(APPEND OS_SPECIFIC_LINK_LIBRARIES

View file

@ -19,6 +19,7 @@
#include <QDir>
#include <QJsonObject>
#include <nlohmann/json.hpp>
#include "wordlist.h"
namespace OCC
@ -638,4 +639,55 @@ bool SetEncryptionFlagApiJob::finished()
emit jsonReceived(json, reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
/* Test metdata:
{
// Metadata about the share
"metadata": {
// Encryption algorithm: RSA/ECB/OAEPWithSHA-256AndMGF1Padding, encrypted via private/public key (asymmetric)
"metadataKeys": {
"0": "OLDESTMETADATAKEY",
"2": "",
"3": "NEWESTMETADATAKEY"
},
// Encryption algorithm: AES/GCM/NoPadding (128 bit key size) with metadata key from above (symmetric)
"sharing": {
// Name of recipients as well as public keys of the recipients
"recipient": {
"recipient1@example.com": "PUBLIC KEY",
"recipient2@example.com": "PUBLIC KEY"
},
},
"version": 1
},
// A JSON blob referencing all files
"files": {
"ia7OEEEyXMoRa1QWQk8r": {
// Encryption algorithm: AES/GCM/NoPadding (128 bit key size) with metadata key from above (symmetric)
"encrypted": {
"key": "jtboLmgGR1OQf2uneqCVHpklQLlIwWL5TXAQ0keK",
"filename": "/foo/test.txt",
"mimetype": "plain/text",
"version": 1
},
"initializationVector": "+mHu52HyZq+pAAIN",
"authenticationTag": "GCM authentication tag",
"metadataKey": 1
}
}
}
*/
FolderMetadata::FolderMetadata(const QByteArray& metadata)
{
// This is a new folder
/*
if (metadata.isEmpty()) {
}
QJsonParseError err;
_doc = QJsonDocument::fromJson(metadata, err);
*/
}
}

View file

@ -40,7 +40,6 @@ private:
bool isInitialized = false;
};
/*
* @brief Job to sigh the CSR that return JSON
*
@ -163,6 +162,31 @@ private:
QString _fileId;
};
} // namespace OCC
/* Generates the Metadata for the folder */
struct EncryptedFile {
QByteArray encryptionKey;
QByteArray mimetype;
QByteArray initializationVector;
QByteArray authenticationTag;
QString encryptedFilename;
QString originalFilename;
int fileVersion;
int metadataKey;
};
class FolderMetadata {
FolderMetadata(const QByteArray& metadata = QByteArray());
QByteArray encryptedMetadata();
void addEncryptedFile(const EncryptedFile& f);
QVector<EncryptedFile> files() const;
private:
QVector<EncryptedFile> _files;
QVector<int> _metadataKeys;
QJsonDocument _jsonMetadata;
};
} // namespace OCC
#endif