X-Git-Url: https://gitweb.ps.run/matrix_esp_thesis/blobdiff_plain/30bde47d1d5d9b6f0b59c318ff16caed6268d1a8..c351768df98c8239eb123ff9af036e574f47df99:/examples/Decrypt.c diff --git a/examples/Decrypt.c b/examples/Decrypt.c index fe305cc..7923693 100644 --- a/examples/Decrypt.c +++ b/examples/Decrypt.c @@ -26,10 +26,9 @@ int main(void) { MatrixClient client; - MatrixClientInit(&client, - SERVER); + MatrixClientInit(&client); - MatrixHttpInit(&client); + MatrixHttpInit(&client.hc, SERVER); MatrixClientSetUserId(&client, USER_ID); @@ -42,7 +41,7 @@ main(void) MatrixClientGenerateOnetimeKeys(&client, 10); MatrixClientUploadOnetimeKeys(&client); - MatrixClientUploadDeviceKey(&client); + MatrixClientUploadDeviceKeys(&client); static char eventBuffer[1024]; MatrixClientGetRoomEvent(&client, @@ -53,10 +52,10 @@ main(void) printf("event: %s\n", eventBuffer); // verify - char theirDeviceKey[DEVICE_KEY_SIZE]; - MatrixClientRequestDeviceKey(&client, - DEVICE_ID, - theirDeviceKey, DEVICE_KEY_SIZE); + // char theirDeviceKey[DEVICE_KEY_SIZE]; + // MatrixClientRequestDeviceKey(&client, + // DEVICE_ID, + // theirDeviceKey, DEVICE_KEY_SIZE); char transactionId[256]; GetLine(transactionId, 128); @@ -94,8 +93,7 @@ main(void) 128); GetLine(keyStartJson, 1024); printf("keyStartJson: %s\n", keyStartJson); - int concatLen = - snprintf(concat, 1024, "%s%s", publicKey, keyStartJson); + snprintf(concat, 1024, "%s%s", publicKey, keyStartJson); printf("concat: %s\n", concat); olm_sha256(olmUtil, concat, strlen(concat), commitment, 256); printf("hash: %s\n", commitment); @@ -290,15 +288,12 @@ main(void) getchar(); - MatrixMegolmInSession megolmSession; - MatrixClientRequestMegolmInSession(&client, ROOM_ID, SESSION_ID, SENDER_KEY, USER_ID, - DEVICE_ID, - &megolmSession); + DEVICE_ID); // // decrypt room key @@ -310,7 +305,7 @@ main(void) static char encrypted[2048]; static char decrypted[2048]; printf("encrypted:"); - gets(encrypted); + fgets(encrypted, 2048, stdin); printf("(%d) %s;\n", strlen(encrypted), encrypted); MatrixOlmSessionDecrypt(olmSession, 1, encrypted, decrypted, 2048); @@ -337,7 +332,7 @@ main(void) MatrixClientDeleteDevice(&client); - MatrixHttpDeinit(&client); + MatrixHttpDeinit(&client.hc); return 0; }