45 static const char *
const error_strings[] = {
53 "Remote public key required",
54 "Local keypair required",
55 "Pre shared key required",
60 "Invalid private key",
66 #define num_error_strings (sizeof(error_strings) / sizeof(error_strings[0]) - 1)
76 static const char *noise_errstr(
int err)
79 return error_strings[0];
82 return error_strings[err -
NOISE_ID(
'E', 0)];
94 const char *errstr = noise_errstr(err);
98 fprintf(stderr,
"%s: %s\n", s, errstr);
100 fprintf(stderr,
"%s: Unknown error 0x%x\n", s, err);
118 const char *errstr = noise_errstr(err);
122 strncpy(buf, errstr, size);
124 snprintf(buf, size,
"Unknown error 0x%x", err);
125 buf[size - 1] =
'\0';
#define NOISE_ERROR_NONE
Success, no error.
size_t size
Total size of the structure including subclass state.
Internal definitions for the library.
void noise_perror(const char *s, int err)
Prints a descriptive string for an error to stderr.
#define NOISE_ID(ch, num)
Builds an algorithm identifier for the library.
int noise_strerror(int err, char *buf, size_t size)
Gets the descriptive string for an error code.