Mercurial > dropbear
comparison libtomcrypt/src/misc/error_to_string.c @ 399:a707e6148060
merge of '5fdf69ca60d1683cdd9f4c2595134bed26394834'
and '6b61c50f4cf888bea302ac8fcf5dbb573b443251'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 03 Feb 2007 08:20:34 +0000 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
394:17d097fc111c | 399:a707e6148060 |
---|---|
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.com | |
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 | |
71 | |
72 /* $Source: /cvs/libtom/libtomcrypt/src/misc/error_to_string.c,v $ */ | |
73 /* $Revision: 1.4 $ */ | |
74 /* $Date: 2006/03/31 14:15:35 $ */ |