#define JSON_ONETIME_KEY_SIGNED_SIZE 256\r
#define JSON_SIGNATURE_SIZE 256\r
\r
-#define NUM_MEGOLM_SESSIONS 10\r
-#define NUM_OLM_SESSIONS 10\r
-#define NUM_DEVICES 10\r
+#define NUM_MEGOLM_SESSIONS 2\r
+#define NUM_OLM_SESSIONS 2\r
+#define NUM_DEVICES 5\r
+\r
+// HTTP\r
+\r
+typedef struct MatrixHttpConnection MatrixHttpConnection;\r
+\r
+bool\r
+MatrixHttpInit(\r
+ MatrixHttpConnection ** hc,\r
+ const char * host);\r
+\r
+// bool\r
+// MatrixHttpConnect(\r
+// MatrixHttpConnection * hc);\r
+\r
+bool\r
+MatrixHttpDeinit(\r
+ MatrixHttpConnection ** hc);\r
+ \r
+bool\r
+MatrixHttpSetAccessToken(\r
+ MatrixHttpConnection * hc,\r
+ const char * accessToken);\r
+\r
+bool\r
+MatrixHttpGet(\r
+ MatrixHttpConnection * hc,\r
+ const char * url,\r
+ char * outResponseBuffer, int outResponseCap,\r
+ bool authenticated);\r
+\r
+bool\r
+MatrixHttpPost(\r
+ MatrixHttpConnection * hc,\r
+ const char * url,\r
+ const char * requestBuffer,\r
+ char * outResponseBuffer, int outResponseCap,\r
+ bool authenticated);\r
+\r
+bool\r
+MatrixHttpPut(\r
+ MatrixHttpConnection * hc,\r
+ const char * url,\r
+ const char * requestBuffer,\r
+ char * outResponseBuffer, int outResponseCap,\r
+ bool authenticated);\r
+\r
+\r
\r
// Matrix Device\r
\r
void * pickled, int pickledLen,\r
const void * key, int keyLen);\r
\r
+bool\r
+MatrixOlmSessionFrom(\r
+ MatrixOlmSession * session,\r
+ OlmAccount * olmAccount,\r
+ const char * deviceId,\r
+ const char * deviceKey,\r
+ const char * encrypted);\r
+\r
bool\r
MatrixOlmSessionTo(\r
MatrixOlmSession * session,\r
// Matrix Megolm Session\r
\r
typedef struct MatrixMegolmInSession {\r
+ char roomId[ROOM_ID_SIZE];\r
+ char id[MEGOLM_SESSION_ID_SIZE];\r
+ char key[MEGOLM_SESSION_KEY_SIZE];\r
+\r
OlmInboundGroupSession * session;\r
+ char memory[MEGOLM_OUTBOUND_SESSION_MEMORY_SIZE];\r
+\r
} MatrixMegolmInSession;\r
\r
+bool\r
+MatrixMegolmInSessionInit(\r
+ MatrixMegolmInSession * session,\r
+ const char * roomId,\r
+ const char * sessionId,\r
+ const char * sessionKey, int sessionKeyLen);\r
+\r
bool\r
MatrixMegolmInSessionDecrypt(\r
- MatrixMegolmInSession * megolmInSession,\r
- const char * encrypted,\r
+ MatrixMegolmInSession * session,\r
+ const char * encrypted, int encryptedLen,\r
char * outDecrypted, int outDecryptedCap);\r
\r
typedef struct MatrixMegolmOutSession {\r
char roomId[ROOM_ID_SIZE];\r
+ char id[MEGOLM_SESSION_ID_SIZE];\r
+ char key[MEGOLM_SESSION_KEY_SIZE];\r
\r
OlmOutboundGroupSession * session;\r
char memory[MEGOLM_OUTBOUND_SESSION_MEMORY_SIZE];\r
-\r
- char id[MEGOLM_SESSION_ID_SIZE];\r
- char key[MEGOLM_SESSION_KEY_SIZE];\r
} MatrixMegolmOutSession;\r
\r
bool\r
// char signingKey[DEVICE_KEY_SIZE];\r
\r
char userId[USER_ID_SIZE];\r
- char server[SERVER_SIZE];\r
char accessToken[ACCESS_TOKEN_SIZE];\r
char deviceId[DEVICE_ID_SIZE];\r
char expireMs[EXPIRE_MS_SIZE];\r
char refreshToken[REFRESH_TOKEN_SIZE];\r
\r
- void * httpUserData;\r
+ MatrixHttpConnection * hc;\r
} MatrixClient;\r
\r
bool\r
MatrixClientInit(\r
- MatrixClient * client,\r
- const char * server);\r
+ MatrixClient * client);\r
\r
bool\r
MatrixClientSave(\r
MatrixMegolmOutSession ** outSession);\r
\r
bool\r
-MatrixClientSetMegolmOutSession(\r
+MatrixClientNewMegolmOutSession(\r
MatrixClient * client,\r
const char * roomId,\r
- MatrixMegolmOutSession session);\r
+ MatrixMegolmOutSession ** outSession);\r
\r
bool\r
-MatrixClientInitMegolmOutSession(\r
+MatrixClientGetMegolmInSession(\r
MatrixClient * client,\r
- const char * roomId);\r
+ const char * roomId, int roomIdLen,\r
+ const char * sessionId, int sessionIdLen,\r
+ MatrixMegolmInSession ** outSession);\r
+\r
+bool\r
+MatrixClientNewMegolmInSession(\r
+ MatrixClient * client,\r
+ const char * roomId,\r
+ const char * sessionId,\r
+ const char * sessionKey,\r
+ MatrixMegolmInSession ** outSession);\r
\r
bool\r
MatrixClientRequestMegolmInSession(\r
const char * sessionId,\r
const char * senderKey,\r
const char * userId,\r
- const char * deviceId, // TODO: remove deviceId (query all devices)\r
- MatrixMegolmInSession * outMegolmInSession);\r
+ const char * deviceId); // TODO: remove deviceId (query all devices)\r
\r
bool\r
MatrixClientGetOlmSession(\r
const char * deviceId,\r
MatrixOlmSession ** outSession);\r
\r
+bool\r
+MatrixClientNewOlmSessionIn(\r
+ MatrixClient * client,\r
+ const char * userId,\r
+ const char * deviceId,\r
+ const char * encrypted,\r
+ MatrixOlmSession ** outSession);\r
+ \r
+bool\r
+MatrixClientNewOlmSessionOut(\r
+ MatrixClient * client,\r
+ const char * userId,\r
+ const char * deviceId,\r
+ MatrixOlmSession ** outSession);\r
+\r
bool\r
MatrixClientSendToDevice(\r
MatrixClient * client,\r
MatrixClient * client);\r
\r
\r
-\r
-\r
-bool\r
-MatrixHttpInit(\r
- MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpConnect(\r
- MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpDeinit(\r
- MatrixClient * client);\r
-\r
-bool\r
-MatrixHttpGet(\r
- MatrixClient * client,\r
- const char * url,\r
- char * outResponseBuffer, int outResponseCap,\r
- bool authenticated);\r
-\r
-bool\r
-MatrixHttpPost(\r
- MatrixClient * client,\r
- const char * url,\r
- const char * requestBuffer,\r
- char * outResponseBuffer, int outResponseCap,\r
- bool authenticated);\r
-\r
-bool\r
-MatrixHttpPut(\r
- MatrixClient * client,\r
- const char * url,\r
- const char * requestBuffer,\r
- char * outResponseBuffer, int outResponseCap,\r
- bool authenticated);\r
-\r
// util\r
\r
void\r
const char * sIn, int sInLen,\r
char * sOut, int sOutCap);\r
\r
+bool\r
+JsonCanonicalize(\r
+ const char * sIn, int sInLen,\r
+ char * sOut, int sOutCap);\r
+ \r
bool\r
JsonSign(\r
MatrixClient * client,\r