]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - src/matrix.h
generate key upload json + json signing
[matrix_esp_thesis] / src / matrix.h
index 60561aa04087d4c0c81d5881a9a235e216120e18..38fb767742cdaf23948313d06ac47a6cfe09d9e3 100644 (file)
 #define KEY_SHARE_EVENT_LEN 1024\r
 \r
 #define OLM_ACCOUNT_MEMORY_SIZE 7528\r
-#define OLM_ACCOUNT_RANDOM_SIZE 32+32\r
+#define OLM_ACCOUNT_RANDOM_SIZE (32+32)\r
 \r
 #define OLM_SESSION_MEMORY_SIZE 3352\r
 #define OLM_ENCRYPT_RANDOM_SIZE 32\r
 \r
+#define OLM_ONETIME_KEYS_RANDOM_SIZE 32*10\r
+#define OLM_KEY_ID_SIZE 32\r
+\r
+#define OLM_SIGNATURE_SIZE 128\r
+\r
 #define MEGOLM_OUTBOUND_SESSION_MEMORY_SIZE 232\r
 #define MEGOLM_SESSION_ID_SIZE 44\r
 #define MEGOLM_SESSION_KEY_SIZE 306\r
 #define MEGOLM_INIT_RANDOM_SIZE (4*32 + 32)\r
 \r
+#define JSON_ONETIME_KEY_SIZE 128\r
+#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
@@ -46,12 +55,33 @@ bool
 JsonEscape(\r
     char * sIn, int sInLen,\r
     char * sOut, int sOutCap);\r
+    \r
+bool JsonSign(\r
+    char * sIn, int sInLen,\r
+    char * sOut, int sOutCap);\r
+\r
+// Matrix Device\r
 \r
 typedef struct MatrixDevice {\r
     char deviceId[DEVICE_ID_SIZE];\r
     char deviceKey[DEVICE_KEY_SIZE];\r
 } MatrixDevice;\r
 \r
+\r
+// Matrix Olm Account\r
+\r
+typedef struct MatrixOlmAccount {\r
+    OlmAccount * account;\r
+    char memory[OLM_ACCOUNT_MEMORY_SIZE];\r
+} MatrixOlmAccount;\r
+\r
+bool\r
+MatrixOlmAccountInit(\r
+    MatrixOlmAccount * account);\r
+\r
+\r
+// Matrix Olm Session\r
+\r
 typedef struct MatrixOlmSession {\r
     const char * deviceId;\r
 \r
@@ -72,6 +102,7 @@ MatrixOlmSessionEncrypt(
     char * outBuffer, int outBufferCap);\r
 \r
 \r
+// Matrix Megolm Session\r
 \r
 typedef struct MatrixMegolmInSession {\r
     OlmInboundGroupSession * session;\r
@@ -99,10 +130,10 @@ MatrixMegolmOutSessionEncrypt(
     char * outBuffer, int outBufferCap);\r
 \r
 \r
+// Matrix Client\r
 \r
 typedef struct MatrixClient {\r
-    OlmAccount * olmAccount;\r
-    char olmAccountMemory[OLM_ACCOUNT_MEMORY_SIZE];\r
+    MatrixOlmAccount olmAccount;\r
 \r
     MatrixMegolmInSession megolmInSessions[NUM_MEGOLM_SESSIONS];\r
     int numMegolmInSessions;\r
@@ -142,6 +173,24 @@ MatrixClientSetDeviceId(
     MatrixClient * client,\r
     const char * deviceId);\r
 \r
+bool\r
+MatrixClientSetUserId(\r
+    MatrixClient * client,\r
+    const char * userId);\r
+\r
+bool\r
+MatrixClientGenerateOnetimeKeys(\r
+    MatrixClient * client,\r
+    int numberOfKeys);\r
+\r
+bool\r
+MatrixClientUploadOnetimeKeys(\r
+    MatrixClient * client);\r
+\r
+bool\r
+MatrixClientUploadDeviceKeys(\r
+    MatrixClient * client);\r
+\r
 bool\r
 MatrixClientLoginPassword(\r
     MatrixClient * client,\r
@@ -174,6 +223,12 @@ MatrixClientShareMegolmOutSession(
     const char * deviceId,\r
     MatrixMegolmOutSession * session);\r
 \r
+bool\r
+MatrixClientShareMegolmOutSessionTest(\r
+    MatrixClient * client,\r
+    const char * deviceId,\r
+    MatrixMegolmOutSession * session);\r
+\r
 bool\r
 MatrixClientGetMegolmOutSession(\r
     MatrixClient * client,\r