aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

signify.h (1456B)


      1 /* see LICENSE file for copyright and license details */
      2 #ifndef SIGNIFY_H
      3 #define SIGNIFY_H
      4 
      5 #include <stddef.h>
      6 #include <stdint.h>
      7 
      8 #include "ed25519.h"
      9 
     10 /*
     11  * openbsd signify's key and signature files, so either program reads what
     12  * the other wrote: an "untrusted comment:" line, then a line of base64. the
     13  * keys are ed25519. a secret key is kept unencrypted (kdf rounds 0); one
     14  * made with a passphrase is refused here, signify -n makes one we take
     15  */
     16 
     17 struct signify_pub {
     18   uint8_t keynum[8];
     19   uint8_t pk[ED25519_PUBLIC];
     20 };
     21 
     22 struct signify_sec {
     23   uint8_t keynum[8];
     24   uint8_t sk[ED25519_SECRET];
     25 };
     26 
     27 /* a new key pair into pubpath and secpath, neither there before. 0 when made */
     28 int signify_generate(const char *pubpath, const char *secpath, const char *comment);
     29 
     30 /* the key in path. 0 when read, -1 said otherwise */
     31 int signify_read_pub(const char *path, struct signify_pub *out);
     32 int signify_read_sec(const char *path, struct signify_sec *out);
     33 
     34 /* the signature of m into sigpath, its comment naming the public key
     35    pubname to check it with. 0 when written */
     36 int signify_sign(
     37     const struct signify_sec *sec,
     38     const uint8_t            *m,
     39     size_t                    n,
     40     const char               *pubname,
     41     const char               *sigpath
     42 );
     43 
     44 /* 0 when sigpath is pub's signature of m, -1 said otherwise */
     45 int signify_verify(const struct signify_pub *pub, const uint8_t *m, size_t n, const char *sigpath);
     46 
     47 #endif