Mercurial > dropbear
comparison src/misc/error_to_string.c @ 191:1c15b283127b libtomcrypt-orig
Import of libtomcrypt 1.02 with manual path rename rearrangement etc
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 06 May 2005 13:23:02 +0000 |
parents | |
children | 39d5d58461d6 |
comparison
equal
deleted
inserted
replaced
143:5d99163f7e32 | 191:1c15b283127b |
---|---|
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis | |
2 * | |
3 * LibTomCrypt is a library that provides various cryptographic | |
4 * algorithms in a highly modular and flexible manner. | |
5 * | |
6 * The library is free for all purposes without any express | |
7 * guarantee it works. | |
8 * | |
9 * Tom St Denis, [email protected], http://libtomcrypt.org | |
10 */ | |
11 | |
12 #include "tomcrypt.h" | |
13 | |
14 /** | |
15 @file error_to_string.c | |
16 Convert error codes to ASCII strings, Tom St Denis | |
17 */ | |
18 | |
19 static const char *err_2_str[] = | |
20 { | |
21 "CRYPT_OK", | |
22 "CRYPT_ERROR", | |
23 "Non-fatal 'no-operation' requested.", | |
24 | |
25 "Invalid keysize for block cipher.", | |
26 "Invalid number of rounds for block cipher.", | |
27 "Algorithm failed test vectors.", | |
28 | |
29 "Buffer overflow.", | |
30 "Invalid input packet.", | |
31 | |
32 "Invalid number of bits for a PRNG.", | |
33 "Error reading the PRNG.", | |
34 | |
35 "Invalid cipher specified.", | |
36 "Invalid hash specified.", | |
37 "Invalid PRNG specified.", | |
38 | |
39 "Out of memory.", | |
40 | |
41 "Invalid PK key or key type specified for function.", | |
42 "A private PK key is required.", | |
43 | |
44 "Invalid argument provided.", | |
45 "File Not Found", | |
46 | |
47 "Invalid PK type.", | |
48 "Invalid PK system.", | |
49 "Duplicate PK key found on keyring.", | |
50 "Key not found in keyring.", | |
51 "Invalid sized parameter.", | |
52 | |
53 "Invalid size for prime.", | |
54 | |
55 }; | |
56 | |
57 /** | |
58 Convert an LTC error code to ASCII | |
59 @param err The error code | |
60 @return A pointer to the ASCII NUL terminated string for the error or "Invalid error code." if the err code was not valid. | |
61 */ | |
62 const char *error_to_string(int err) | |
63 { | |
64 if (err < 0 || err >= (int)(sizeof(err_2_str)/sizeof(err_2_str[0]))) { | |
65 return "Invalid error code."; | |
66 } else { | |
67 return err_2_str[err]; | |
68 } | |
69 } | |
70 |