Skip to content
pi-c Artifact [dbe49eacd1]
Login

Artifact [dbe49eacd1]

Artifact dbe49eacd179a94bb015d5406735cbc8c7da8d091a5c433bfd5fd439b6ffe835:


/* pic's only credential code. A key is fetched into a caller buffer just
 * before a request and wiped right after; it is never journaled, logged or
 * put in an error message. Where keys come from is the model registry's
 * business (a variable name, or a key written in the models file); later the
 * credential project's helper command (docs/credential-project.md). */
#ifndef PIC_CRED_H
#define PIC_CRED_H

#include <stddef.h>

/* Fetches a key: the literal if one is given, else the variable ENV. 0 with
 * the key in buf; 1 when neither is configured (a server that needs no key);
 * -1 with err (never the value) when the variable is unset or unusable. */
int pic_cred_get(const char *env, const char *literal, char *buf, size_t cap, char *err, size_t errcap);
/* Overwrites n bytes in a way the compiler may not remove. */
void pic_cred_wipe(void *p, size_t n);

#endif