diff --git a/native/cpp/CommonCpp/CryptoTools/Session.h b/native/cpp/CommonCpp/CryptoTools/Session.h index 56a303c4b..ff19e3f7b 100644 --- a/native/cpp/CommonCpp/CryptoTools/Session.h +++ b/native/cpp/CommonCpp/CryptoTools/Session.h @@ -1,46 +1,48 @@ #pragma once #include #include #include "Tools.h" +#include "olm/olm.h" + namespace comm { namespace crypto { class Session { OlmAccount *ownerUserAccount; std::uint8_t *ownerIdentityKeys; OlmSession *olmSession = nullptr; OlmBuffer olmSessionBuffer; Session(OlmAccount *account, std::uint8_t *ownerIdentityKeys) : ownerUserAccount(account), ownerIdentityKeys(ownerIdentityKeys) { } public: static std::unique_ptr createSessionAsInitializer( OlmAccount *account, std::uint8_t *ownerIdentityKeys, const OlmBuffer &idKeys, const OlmBuffer &preKeys, const OlmBuffer &preKeySignature, const OlmBuffer &oneTimeKeys, size_t keyIndex = 0); static std::unique_ptr createSessionAsResponder( OlmAccount *account, std::uint8_t *ownerIdentityKeys, const OlmBuffer &encryptedMessage, const OlmBuffer &idKeys); OlmBuffer storeAsB64(const std::string &secretKey); static std::unique_ptr restoreFromB64( OlmAccount *account, std::uint8_t *ownerIdentityKeys, const std::string &secretKey, OlmBuffer &b64); OlmSession *getOlmSession(); }; } // namespace crypto } // namespace comm diff --git a/native/cpp/CommonCpp/CryptoTools/Tools.h b/native/cpp/CommonCpp/CryptoTools/Tools.h index 3ddb5d2d7..fadea6de4 100644 --- a/native/cpp/CommonCpp/CryptoTools/Tools.h +++ b/native/cpp/CommonCpp/CryptoTools/Tools.h @@ -1,47 +1,43 @@ #pragma once #include #include #include -#ifndef EMSCRIPTEN -#include "olm/olm.h" -#endif - // base64-encoded #define KEYSIZE 43 #define SIGNATURESIZE 86 #define ID_KEYS_PREFIX_OFFSET 15 #define SIGNING_KEYS_PREFIX_OFFSET 71 #define PRE_KEY_PREFIX_OFFSET 25 #define ONE_TIME_KEYS_PREFIX_OFFSET 25 #define ONE_TIME_KEYS_MIDDLE_OFFSET 12 namespace comm { namespace crypto { typedef std::vector OlmBuffer; struct Keys { OlmBuffer identityKeys; // size = 116 OlmBuffer oneTimeKeys; // size = 43 each }; struct EncryptedData { OlmBuffer message; size_t messageType; }; class Tools { private: static std::string generateRandomString(size_t size, const std::string &availableSigns); public: static std::string generateRandomString(size_t size); static std::string generateRandomHexString(size_t size); }; } // namespace crypto } // namespace comm