]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - examples/Canonical.c
actually add Canonical and Verify examples :()
[matrix_esp_thesis] / examples / Canonical.c
diff --git a/examples/Canonical.c b/examples/Canonical.c
new file mode 100644 (file)
index 0000000..d3a1905
--- /dev/null
@@ -0,0 +1,28 @@
+#include <matrix.h>\r
+#include <mjson.h>\r
+#include <olm/sas.h>\r
+\r
+#include <stdio.h>\r
+\r
+int\r
+main(void)\r
+{\r
+    const char json[] =\r
+    "{"\r
+    "\"method\":\"m.sas.v1\","\r
+    "\"from_device\":\"ULZZOKJBYN\","\r
+    "\"key_agreement_protocols\":[\"curve25519-hkdf-sha256\",\"curve25519\"],"\r
+    "\"hashes\":[\"sha256\"],"\r
+    "\"message_authentication_codes\":[\"hkdf-hmac-sha256.v2\",\"org.matrix.msc3783.hkdf-hmac-sha256\",\"hkdf-hmac-sha256\",\"hmac-sha256\"],"\r
+    "\"short_authentication_string\":[\"decimal\",\"emoji\"],"\r
+    "\"transaction_id\":\"CmMReoy5AK59qd7pa6EO7ocbFwX03isB\""\r
+    "}";\r
+    \r
+    char canonical[1024];\r
+\r
+    JsonCanonicalize(json, strlen(json), canonical, 1024);\r
+\r
+    printf("%s\n", canonical);\r
+\r
+    return 0;\r
+}\r