1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner.
6 * The library is free for all purposes without any express
13 @file error_to_string.c
14 Convert error codes to ASCII strings, Tom St Denis
17 static const char * const err_2_str[] =
21 "Non-fatal 'no-operation' requested.",
24 "Invalid number of rounds for block cipher.",
25 "Algorithm failed test vectors.",
28 "Invalid input packet.",
30 "Invalid number of bits for a PRNG.",
31 "Error reading the PRNG.",
33 "Invalid cipher specified.",
34 "Invalid hash specified.",
35 "Invalid PRNG specified.",
39 "Invalid PK key or key type specified for function.",
40 "A private PK key is required.",
42 "Invalid argument provided.",
47 "An overflow of a value was detected/prevented.",
51 "The input was longer than expected.",
53 "Invalid sized parameter.",
55 "Invalid size for prime.",
59 "Hash applied to too many bits.",
63 Convert an LTC error code to ASCII
64 @param err The error code
65 @return A pointer to the ASCII NUL terminated string for the error or "Invalid error code." if the err code was not valid.
67 const char *error_to_string(int err)
69 if (err < 0 || err >= (int)(sizeof(err_2_str)/sizeof(err_2_str[0]))) {
70 return "Invalid error code.";
72 return err_2_str[err];
77 /* ref: $Format:%D$ */
78 /* git commit: $Format:%H$ */
79 /* commit time: $Format:%ai$ */