From 321c9f9d42a1699d45d7ba486cfc9ce40286bdd8 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 7 Jun 2018 22:53:46 +0200 Subject: [PATCH] add comments in usign-exec Signed-off-by: Daniel Golle This work was sponsored by WIO (wiowireless.com) --- usign-exec.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/usign-exec.c b/usign-exec.c index fe24f69..514de2a 100644 --- a/usign-exec.c +++ b/usign-exec.c @@ -20,6 +20,27 @@ #include "usign.h" +/* + * check for revoker deadlink in pubkeydir + * return true if a revoker exists, false otherwise + */ +int _usign_key_is_revoked(const char *fingerprint, const char *pubkeydir) { + char tml[64] = {0}; + char rfname[256] = {0}; + + snprintf(rfname, sizeof(rfname)-1, "%s/%s", pubkeydir, fingerprint); + if (readlink(rfname, tml, sizeof(tml)) > 0 && + !strcmp(tml, ".revoked.")) { + return true; + }; + + return false; +} + +/* + * call usign -S ... + * return WEXITSTATUS or -1 if fork or execv fails + */ int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bool quiet) { pid_t pid; int status; @@ -57,6 +78,10 @@ int usign_s(const char *msgfile, const char *seckeyfile, const char *sigfile, bo return -1; } +/* + * call usign -F ... and set fingerprint returned + * return WEXITSTATUS or -1 if fork or execv fails + */ static int usign_f(char *fingerprint, const char *pubkeyfile, const char *seckeyfile, const char *sigfile) { int fds[2]; pid_t pid; @@ -118,31 +143,32 @@ static int usign_f(char *fingerprint, const char *pubkeyfile, const char *seckey return -1; } +/* + * call usign -F -p ... + */ int usign_f_pubkey(char *fingerprint, const char *pubkeyfile) { return usign_f(fingerprint, pubkeyfile, NULL, NULL); } +/* + * call usign -F -s ... + */ int usign_f_seckey(char *fingerprint, const char *seckeyfile) { return usign_f(fingerprint, NULL, seckeyfile, NULL); } +/* + * call usign -F -x ... + */ int usign_f_sig(char *fingerprint, const char *sigfile) { return usign_f(fingerprint, NULL, NULL, sigfile); } -int _usign_key_is_revoked(const char *fingerprint, const char *pubkeydir) { - char tml[64] = {0}; - char rfname[256] = {0}; - - snprintf(rfname, sizeof(rfname)-1, "%s/%s", pubkeydir, fingerprint); - if (readlink(rfname, tml, sizeof(tml)) > 0 && - !strcmp(tml, ".revoked.")) { - return true; - }; - - return false; -} +/* + * call usign -V ... + * return WEXITSTATUS or -1 if fork or execv fails + */ int usign_v(const char *msgfile, const char *pubkeyfile, const char *pubkeydir, const char *sigfile, bool quiet) { pid_t pid; -- 2.25.1