X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/9eaa420b7bf51cc81c50e7f4ca0f256498a07c86..50f9d03ea29a8ae2f82d5edb5404fdebf4316b13:/src/matrix.h diff --git a/src/matrix.h b/src/matrix.h index d31a7f6..81b6170 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -23,6 +23,7 @@ #define DEVICE_KEY_SIZE 44 #define SIGNING_KEY_SIZE 44 #define ONETIME_KEY_SIZE 44 +#define MASTER_KEY_SIZE 44 #define KEY_SHARE_EVENT_LEN 1024 @@ -47,8 +48,8 @@ #define JSON_ONETIME_KEY_SIGNED_SIZE 256 #define JSON_SIGNATURE_SIZE 256 -#define NUM_MEGOLM_SESSIONS 10 -#define NUM_OLM_SESSIONS 10 +#define NUM_MEGOLM_SESSIONS 2 +#define NUM_OLM_SESSIONS 2 #define NUM_DEVICES 10 // HTTP @@ -60,10 +61,6 @@ MatrixHttpInit( MatrixHttpConnection ** hc, const char * host); -// bool -// MatrixHttpConnect( -// MatrixHttpConnection * hc); - bool MatrixHttpDeinit( MatrixHttpConnection ** hc); @@ -227,18 +224,6 @@ MatrixMegolmOutSessionEncrypt( const char * plaintext, char * outBuffer, int outBufferCap); -bool -MatrixMegolmOutSessionSave( - MatrixMegolmOutSession * session, - const char * filename, - const char * key); - -bool -MatrixMegolmOutSessionLoad( - MatrixMegolmOutSession * session, - const char * filename, - const char * key); - // Matrix Client @@ -263,6 +248,9 @@ typedef struct MatrixClient { char deviceId[DEVICE_ID_SIZE]; char expireMs[EXPIRE_MS_SIZE]; char refreshToken[REFRESH_TOKEN_SIZE]; + char masterKey[MASTER_KEY_SIZE]; + + bool verified; MatrixHttpConnection * hc; } MatrixClient; @@ -271,16 +259,6 @@ bool MatrixClientInit( MatrixClient * client); -bool -MatrixClientSave( - MatrixClient * client, - const char * filename); - -bool -MatrixClientLoad( - MatrixClient * client, - const char * filename); - bool MatrixClientSetAccessToken( MatrixClient * client, @@ -306,7 +284,7 @@ MatrixClientUploadOnetimeKeys( MatrixClient * client); bool -MatrixClientUploadDeviceKey( +MatrixClientUploadDeviceKeys( MatrixClient * client); bool @@ -337,11 +315,22 @@ MatrixClientSendEventEncrypted( const char * msgType, const char * msgBody); +void +HandleEvent( + MatrixClient * client, + const char * event, int eventLen); + +void +HandleRoomEvent( + MatrixClient * client, + const char * room, int roomLen, + const char * event, int eventLen); + bool MatrixClientSync( MatrixClient * client, - char * outSync, int outSyncCap, - const char * nextBatch); + char * outSyncBuffer, int outSyncCap, + char * nextBatch, int nextBatchCap); bool MatrixClientGetRoomEvent( @@ -401,7 +390,7 @@ MatrixClientRequestMegolmInSession( const char * deviceId); // TODO: remove deviceId (query all devices) bool -MatrixClientGetOlmSessionIn( +MatrixClientGetOlmSession( MatrixClient * client, const char * userId, const char * deviceId, @@ -415,13 +404,6 @@ MatrixClientNewOlmSessionIn( const char * encrypted, MatrixOlmSession ** outSession); -bool -MatrixClientGetOlmSessionOut( - MatrixClient * client, - const char * userId, - const char * deviceId, - MatrixOlmSession ** outSession); - bool MatrixClientNewOlmSessionOut( MatrixClient * client, @@ -463,6 +445,11 @@ MatrixClientRequestSigningKey( const char * deviceId, char * outSigningKey, int outSigningKeyCap); +bool +MatrixClientRequestMasterKey( + MatrixClient * client, + char * outMasterKey, int outMasterKeyCap); + bool MatrixClientRequestDeviceKeys( MatrixClient * client);