]> git.meshlink.io Git - meshlink/blobdiff - src/meshlink.h
Implement meshlink_sign() and _verify().
[meshlink] / src / meshlink.h
index 036637b08cadb6c3ec693cccbedd2c25bd3eda50..afa6032cf9550cd7aa08c6a28656694faba96978 100644 (file)
@@ -27,6 +27,8 @@
 extern "C" {
 #endif
 
+#define MESHLINK_SIGLEN 64
+
 /// A handle for an instance of MeshLink.
 typedef struct meshlink_handle meshlink_handle_t;
 
@@ -220,11 +222,12 @@ extern size_t meshlink_get_all_nodes(meshlink_handle_t *mesh, meshlink_node_t **
  *  @param mesh         A handle which represents an instance of MeshLink.
  *  @param data         A pointer to a buffer containing the data to be signed.
  *  @param len          The length of the data to be signed.
+ *  @param signature    A pointer to a buffer where the signature will be stored.
+ *  @param siglen       The size of the signature buffer. Will be changed after the call to match the size of the signature itself.
  *
- *  @return             This function returns a pointer to a string containing the signature, or NULL in case of an error. 
- *                      The application should call free() after it has finished using the signature.
+ *  @return             This function returns true if the signature was correctly generated, false otherwise.
  */
-extern char *meshlink_sign(meshlink_handle_t *mesh, const char *data, size_t len);
+extern bool meshlink_sign(meshlink_handle_t *mesh, const void *data, size_t len, void *signature, size_t *siglen);
 
 /// Verify the signature generated by another node of a piece of data.
 /** This function verifies the signature that another node generated for a piece of data.
@@ -234,10 +237,11 @@ extern char *meshlink_sign(meshlink_handle_t *mesh, const char *data, size_t len
  *  @param data         A pointer to a buffer containing the data to be verified.
  *  @param len          The length of the data to be verified.
  *  @param signature    A pointer to a string containing the signature.
+ *  @param siglen       The size of the signature.
  *
  *  @return             This function returns true if the signature is valid, false otherwise.
  */
-extern bool meshlink_verify(meshlink_handle_t *mesh, meshlink_node_t *source, const char *data, size_t len, const char *signature);
+extern bool meshlink_verify(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len, const void *signature, size_t siglen);
 
 /// Add an Address for the local node.
 /** This function adds an Address for the local node, which will be used for invitation URLs.