sick

sign and check files using ed25519
Log | Files | Refs | Submodules | README | LICENSE

commit 7da5e6eeeaafa4f29f629e0fe3b4ea4ee7db5f02
parent 90ff47779b49abf0edadf12c08039f6af7866706
Author: z3bra <willyatmailoodotorg>
Date:   Sun May 15 19:34:39 +12000

extractmsg() copies the message only to the buffer

Diffstat:
sick.c | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/sick.c b/sick.c @@ -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); @@ -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. */