comparison libtomcrypt/src/misc/error_to_string.c @ 285:1b9e69c058d2

propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3) to branch 'au.asn.ucc.matt.dropbear' (head fdf4a7a3b97ae5046139915de7e40399cceb2c01)
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 13:23:58 +0000
parents
children 827f87dfbc22 0cbe8f6dbf9e
comparison
equal deleted inserted replaced
281:997e6f7dc01e 285:1b9e69c058d2
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
71
72 /* $Source: /cvs/libtom/libtomcrypt/src/misc/error_to_string.c,v $ */
73 /* $Revision: 1.3 $ */
74 /* $Date: 2005/05/05 14:35:59 $ */