diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt index fabcef768..0a392acd0 100644 --- a/src/libsync/CMakeLists.txt +++ b/src/libsync/CMakeLists.txt @@ -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 - ${CMAKE_BINARY_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 diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 020617eef..93a102050 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -19,6 +19,7 @@ #include #include +#include #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); + */ + +} + } diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index e143d1aae..a6501c150 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -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 files() const; + +private: + QVector _files; + QVector _metadataKeys; + + QJsonDocument _jsonMetadata; +}; + +} // namespace OCC #endif