comparison src/misc/error_to_string.c @ 280:59400faa4b44 libtomcrypt-orig libtomcrypt-1.05

Re-import libtomcrypt 1.05 for cleaner propagating. From crypt-1.05.tar.bz2, SHA1 of 88250202bb51570dc64f7e8f1c943cda9479258f
author Matt Johnston <matt@ucc.asn.au>
date Wed, 08 Mar 2006 12:58:00 +0000
parents
children d5faf4814ddb
comparison
equal deleted inserted replaced
-1:000000000000 280:59400faa4b44
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 $ */