15 meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
17 // Open two new meshlink instance.
19 meshlink_handle_t *mesh_a, *mesh_b;
20 open_meshlink_pair(&mesh_a, &mesh_b, "sign_verify");
22 // Verify that a signature made on one node can be verified by its peer.
24 static const char testdata1[] = "Test data 1.";
25 static const char testdata2[] = "Test data 2.";
27 char sig[MESHLINK_SIGLEN * 2];
28 size_t siglen = sizeof(sig) * 2;
30 assert(meshlink_sign(mesh_a, testdata1, sizeof(testdata1), sig, &siglen));
31 assert(siglen == MESHLINK_SIGLEN);
33 meshlink_node_t *a = meshlink_get_node(mesh_b, "a");
36 meshlink_node_t *b = meshlink_get_node(mesh_b, "b");
39 assert(meshlink_verify(mesh_b, a, testdata1, sizeof(testdata1), sig, siglen));
41 // Check that bad signatures are revoked
43 assert(!meshlink_verify(mesh_b, a, testdata1, sizeof(testdata1), sig, siglen / 2));
44 assert(!meshlink_verify(mesh_b, a, testdata1, sizeof(testdata1), sig, siglen * 2));
45 assert(!meshlink_verify(mesh_b, a, testdata2, sizeof(testdata2), sig, siglen));
46 assert(!meshlink_verify(mesh_b, b, testdata1, sizeof(testdata1), sig, siglen));
50 close_meshlink_pair(mesh_a, mesh_b);