textractmsg() copies the message only to the buffer - sick - sign and check files using ed25519
(HTM) git clone git://z3bra.org/sick
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 7da5e6eeeaafa4f29f629e0fe3b4ea4ee7db5f02
(DIR) parent 90ff47779b49abf0edadf12c08039f6af7866706
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Sun, 15 May 2016 19:34:39 +0200
extractmsg() copies the message only to the buffer
Diffstat:
M sick.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/sick.c b/sick.c
t@@ -19,6 +19,7 @@ enum {
static void usage();
static size_t bufferize(char **buf, FILE *fp);
+static size_t extractmsg(unsigned char *msg[], char *buf);
static int createkeypair(const char *);
static int sign(FILE *fp, FILE *key);
t@@ -56,6 +57,24 @@ bufferize(char **buf, FILE *fp)
return len;
}
+static size_t
+extractmsg(unsigned char **msg, char *buf)
+{
+ size_t len = 0;
+ char *sig;
+
+ sig = strstr(buf, SIGBEGIN);
+
+ if (sig == NULL)
+ return -1;
+
+ len = sig - buf;
+ *msg = malloc(len);
+ memcpy(*msg, buf, len);
+
+ return len;
+}
+
/*
* Creates a set of ed25519 key pairs on disk.
*/