2004-01-25 17:40:34 +00:00
|
|
|
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
|
|
|
|
*
|
|
|
|
|
* LibTomCrypt is a library that provides various cryptographic
|
|
|
|
|
* algorithms in a highly modular and flexible manner.
|
|
|
|
|
*
|
|
|
|
|
* The library is free for all purposes without any express
|
2004-05-12 20:42:16 +00:00
|
|
|
* guarantee it works.
|
2004-01-25 17:40:34 +00:00
|
|
|
*/
|
|
|
|
|
|
2004-12-30 23:55:53 +00:00
|
|
|
#include "tomcrypt.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@file error_to_string.c
|
|
|
|
|
Convert error codes to ASCII strings, Tom St Denis
|
|
|
|
|
*/
|
2003-03-03 00:59:24 +00:00
|
|
|
|
2015-12-19 17:52:30 +01:00
|
|
|
static const char * const err_2_str[] =
|
2003-03-03 00:59:24 +00:00
|
|
|
{
|
|
|
|
|
"CRYPT_OK",
|
|
|
|
|
"CRYPT_ERROR",
|
2003-03-29 18:19:07 +00:00
|
|
|
"Non-fatal 'no-operation' requested.",
|
2003-03-03 00:59:24 +00:00
|
|
|
|
2017-08-26 12:03:35 +02:00
|
|
|
"Invalid key size.",
|
2003-03-03 00:59:24 +00:00
|
|
|
"Invalid number of rounds for block cipher.",
|
|
|
|
|
"Algorithm failed test vectors.",
|
|
|
|
|
|
|
|
|
|
"Buffer overflow.",
|
|
|
|
|
"Invalid input packet.",
|
|
|
|
|
|
|
|
|
|
"Invalid number of bits for a PRNG.",
|
|
|
|
|
"Error reading the PRNG.",
|
|
|
|
|
|
|
|
|
|
"Invalid cipher specified.",
|
|
|
|
|
"Invalid hash specified.",
|
|
|
|
|
"Invalid PRNG specified.",
|
|
|
|
|
|
|
|
|
|
"Out of memory.",
|
|
|
|
|
|
|
|
|
|
"Invalid PK key or key type specified for function.",
|
|
|
|
|
"A private PK key is required.",
|
|
|
|
|
|
|
|
|
|
"Invalid argument provided.",
|
2003-09-26 01:16:18 +00:00
|
|
|
"File Not Found",
|
2003-03-03 00:59:24 +00:00
|
|
|
|
|
|
|
|
"Invalid PK type.",
|
2017-03-31 15:12:12 +02:00
|
|
|
|
|
|
|
|
"An overflow of a value was detected/prevented.",
|
|
|
|
|
|
|
|
|
|
"UNUSED1.",
|
2017-09-25 21:58:50 +02:00
|
|
|
|
|
|
|
|
"The input was longer than expected.",
|
2017-03-31 15:12:12 +02:00
|
|
|
|
2003-03-03 00:59:24 +00:00
|
|
|
"Invalid sized parameter.",
|
|
|
|
|
|
2003-09-26 01:16:18 +00:00
|
|
|
"Invalid size for prime.",
|
|
|
|
|
|
2008-01-20 21:57:25 -08:00
|
|
|
"Invalid padding.",
|
|
|
|
|
|
|
|
|
|
"Hash applied to too many bits.",
|
2003-03-03 00:59:24 +00:00
|
|
|
};
|
|
|
|
|
|
2004-12-30 23:55:53 +00:00
|
|
|
/**
|
|
|
|
|
Convert an LTC error code to ASCII
|
|
|
|
|
@param err The error code
|
|
|
|
|
@return A pointer to the ASCII NUL terminated string for the error or "Invalid error code." if the err code was not valid.
|
|
|
|
|
*/
|
2003-06-15 22:37:45 +00:00
|
|
|
const char *error_to_string(int err)
|
2003-03-03 00:59:24 +00:00
|
|
|
{
|
2003-06-15 22:37:45 +00:00
|
|
|
if (err < 0 || err >= (int)(sizeof(err_2_str)/sizeof(err_2_str[0]))) {
|
2003-03-03 00:59:24 +00:00
|
|
|
return "Invalid error code.";
|
|
|
|
|
} else {
|
2003-06-15 22:37:45 +00:00
|
|
|
return err_2_str[err];
|
2015-12-20 17:05:58 +01:00
|
|
|
}
|
2003-03-03 00:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-09 00:08:13 +00:00
|
|
|
|
2017-06-19 13:43:49 +02:00
|
|
|
/* ref: $Format:%D$ */
|
|
|
|
|
/* git commit: $Format:%H$ */
|
|
|
|
|
/* commit time: $Format:%ai$ */
|