kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

dist.h (1743B)


      1 #ifndef KIT_DIST_DIST_H
      2 #define KIT_DIST_DIST_H
      3 
      4 #include <stddef.h>
      5 #include <stdint.h>
      6 
      7 /* Shared constants and small helpers for the code-distribution subsystem
      8  * (`kit pkg`). See doc/DISTRIBUTE.md for the design.
      9  *
     10  * Cryptographic and compression primitives under driver/dist/ are vendored so
     11  * the package pipeline (manifest -> sign -> bundle -> verify -> unpack) has no
     12  * runtime dependency on host crypto/compression libraries. */
     13 
     14 /* Primitive output sizes. */
     15 #define DIST_BLAKE2B_LEN 32u
     16 #define DIST_HASH_LEN DIST_BLAKE2B_LEN
     17 #define DIST_MINISIG_PREHASH_LEN 64u
     18 #define DIST_ED25519_PK_LEN 32u
     19 #define DIST_ED25519_SK_LEN 64u
     20 #define DIST_ED25519_SIG_LEN 64u
     21 #define DIST_ED25519_SEED_LEN 32u
     22 #define DIST_KEYID_LEN 8u
     23 
     24 /* Fixed parse/build capacities. These caps bound a single package's metadata
     25  * and member count. */
     26 #define DIST_MAX_ARTIFACTS 64u
     27 #define DIST_MAX_DEPS 64u
     28 #define DIST_MAX_FILES 256u
     29 #define DIST_MAX_OUTPUTS 16u
     30 
     31 /* String field caps inside in-memory manifest structs. */
     32 #define DIST_NAME_MAX 128u
     33 #define DIST_VERSION_MAX 64u
     34 #define DIST_DESC_MAX 256u
     35 #define DIST_PATH_MAX 100u /* matches ustar name field */
     36 #define DIST_TRIPLE_MAX 64u
     37 #define DIST_KIND_MAX 16u
     38 #define DIST_PCONSTRAINT_MAX 64u
     39 
     40 /* Result convention: 0 = ok, non-zero = error. */
     41 #define DIST_OK 0
     42 #define DIST_ERR 1
     43 
     44 /* Lowercase-hex encode `n` bytes into `out`, which must hold 2*n+1 chars
     45  * (NUL-terminated). */
     46 void dist_hex_encode(char* out, const uint8_t* in, size_t n);
     47 
     48 /* Decode exactly `n` bytes of lowercase/uppercase hex from `in` (which must
     49  * have >= 2*n hex chars) into `out`. Returns DIST_OK on success, DIST_ERR on a
     50  * non-hex character. */
     51 int dist_hex_decode(uint8_t* out, const char* in, size_t n);
     52 
     53 #endif