X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/464bfb1912d0806143386f61c33dd45fbafc38e8..30bde47d1d5d9b6f0b59c318ff16caed6268d1a8:/src/matrix.h diff --git a/src/matrix.h b/src/matrix.h index 91ed208..20cdc8c 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -11,6 +11,7 @@ #define USER_ID_SIZE 64 +#define ROOM_ID_SIZE 128 #define SERVER_SIZE 20 #define ACCESS_TOKEN_SIZE 40 #define DEVICE_ID_SIZE 20 @@ -55,6 +56,7 @@ typedef struct MatrixDevice { char deviceId[DEVICE_ID_SIZE]; char deviceKey[DEVICE_KEY_SIZE]; + char signingKey[SIGNING_KEY_SIZE]; } MatrixDevice; @@ -69,17 +71,40 @@ bool MatrixOlmAccountInit( MatrixOlmAccount * account); +bool +MatrixOlmAccountUnpickle( + MatrixOlmAccount * account, + void * pickled, int pickledLen, + const void * key, int keyLen); + +bool +MatrixOlmAccountGetDeviceKey( + MatrixOlmAccount * account, + char * key, int keyCap); + +bool +MatrixOlmAccountGetSigningKey( + MatrixOlmAccount * account, + char * key, int keyCap); + // Matrix Olm Session typedef struct MatrixOlmSession { - const char * deviceId; + const char * deviceId; // TODO: char[] int type; OlmSession * session; char memory[OLM_SESSION_MEMORY_SIZE]; } MatrixOlmSession; +bool +MatrixOlmSessionUnpickle( + MatrixOlmSession * session, + const char * deviceId, + void * pickled, int pickledLen, + const void * key, int keyLen); + bool MatrixOlmSessionTo( MatrixOlmSession * session, @@ -94,6 +119,13 @@ MatrixOlmSessionEncrypt( const char * plaintext, char * outBuffer, int outBufferCap); +bool +MatrixOlmSessionDecrypt( + MatrixOlmSession * session, + size_t messageType, + char * encrypted, + char * outBuffer, int outBufferCap); + // Matrix Megolm Session @@ -101,8 +133,14 @@ typedef struct MatrixMegolmInSession { OlmInboundGroupSession * session; } MatrixMegolmInSession; +bool +MatrixMegolmInSessionDecrypt( + MatrixMegolmInSession * megolmInSession, + const char * encrypted, + char * outDecrypted, int outDecryptedCap); + typedef struct MatrixMegolmOutSession { - const char * roomId; + char roomId[ROOM_ID_SIZE]; OlmOutboundGroupSession * session; char memory[MEGOLM_OUTBOUND_SESSION_MEMORY_SIZE]; @@ -115,13 +153,25 @@ bool MatrixMegolmOutSessionInit( MatrixMegolmOutSession * session, const char * roomId); - + bool MatrixMegolmOutSessionEncrypt( MatrixMegolmOutSession * session, 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 @@ -138,8 +188,8 @@ typedef struct MatrixClient { MatrixDevice devices[NUM_DEVICES]; int numDevices; - char deviceKey[DEVICE_KEY_SIZE]; - char signingKey[DEVICE_KEY_SIZE]; + // char deviceKey[DEVICE_KEY_SIZE]; + // char signingKey[DEVICE_KEY_SIZE]; char userId[USER_ID_SIZE]; char server[SERVER_SIZE]; @@ -191,7 +241,7 @@ MatrixClientUploadOnetimeKeys( MatrixClient * client); bool -MatrixClientUploadDeviceKeys( +MatrixClientUploadDeviceKey( MatrixClient * client); bool @@ -227,6 +277,13 @@ MatrixClientSync( MatrixClient * client, char * outSync, int outSyncCap); +bool +MatrixClientGetRoomEvent( + MatrixClient * client, + const char * roomId, + const char * eventId, + char * outEvent, int outEventCap); + bool MatrixClientShareMegolmOutSession( MatrixClient * client, @@ -237,6 +294,7 @@ MatrixClientShareMegolmOutSession( bool MatrixClientShareMegolmOutSessionTest( MatrixClient * client, + const char * userId, const char * deviceId, MatrixMegolmOutSession * session); @@ -252,6 +310,21 @@ MatrixClientSetMegolmOutSession( const char * roomId, MatrixMegolmOutSession session); +bool +MatrixClientInitMegolmOutSession( + MatrixClient * client, + const char * roomId); + +bool +MatrixClientRequestMegolmInSession( + MatrixClient * client, + const char * roomId, + const char * sessionId, + const char * senderKey, + const char * userId, + const char * deviceId, // TODO: remove deviceId (query all devices) + MatrixMegolmInSession * outMegolmInSession); + bool MatrixClientGetOlmSession( MatrixClient * client, @@ -276,21 +349,31 @@ MatrixClientSendToDeviceEncrypted( const char * msgType); bool -MatrixClientGetDeviceKey( +MatrixClientSendDummy( MatrixClient * client, - const char * deviceId, - char * outDeviceKey, int outDeviceKeyCap); + const char * userId, + const char * deviceId); bool -MatrixClientGetDeviceKey( +MatrixClientRequestDeviceKey( MatrixClient * client, const char * deviceId, char * outDeviceKey, int outDeviceKeyCap); + +bool +MatrixClientRequestSigningKey( + MatrixClient * client, + const char * deviceId, + char * outSigningKey, int outSigningKeyCap); bool MatrixClientRequestDeviceKeys( MatrixClient * client); +bool +MatrixClientDeleteDevice( + MatrixClient * client); + @@ -339,7 +422,8 @@ JsonEscape( const char * sIn, int sInLen, char * sOut, int sOutCap); -bool JsonSign( +bool +JsonSign( MatrixClient * client, const char * sIn, int sInLen, char * sOut, int sOutCap);