comparison libtommath/bn_error.c @ 1655:f52919ffd3b1

update ltm to 1.1.0 and enable FIPS 186.4 compliant key-generation (#79) * make key-generation compliant to FIPS 186.4 * fix includes in tommath_class.h * update fuzzcorpus instead of error-out * fixup fuzzing make-targets * update Makefile.in * apply necessary patches to ltm sources * clean-up not required ltm files * update to vanilla ltm 1.1.0 this already only contains the required files * remove set/get double
author Steffen Jaeckel <s_jaeckel@gmx.de>
date Mon, 16 Sep 2019 15:50:38 +0200
parents 8bba51a55704
children
comparison
equal deleted inserted replaced
1654:cc0fc5131c5c 1655:f52919ffd3b1
1 #include <tommath_private.h> 1 #include "tommath_private.h"
2 #ifdef BN_ERROR_C 2 #ifdef BN_ERROR_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 * 4 *
5 * LibTomMath is a library that provides multiple-precision 5 * LibTomMath is a library that provides multiple-precision
6 * integer arithmetic as well as number theoretic functionality. 6 * integer arithmetic as well as number theoretic functionality.
7 * 7 *
8 * The library was designed directly after the MPI library by 8 * The library was designed directly after the MPI library by
9 * Michael Fromberger but has been written from scratch with 9 * Michael Fromberger but has been written from scratch with
10 * additional optimizations in place. 10 * additional optimizations in place.
11 * 11 *
12 * The library is free for all purposes without any express 12 * SPDX-License-Identifier: Unlicense
13 * guarantee it works.
14 *
15 * Tom St Denis, [email protected], http://libtom.org
16 */ 13 */
17 14
18 static const struct { 15 static const struct {
19 int code; 16 int code;
20 const char *msg; 17 const char *msg;
21 } msgs[] = { 18 } msgs[] = {
22 { MP_OKAY, "Successful" }, 19 { MP_OKAY, "Successful" },
23 { MP_MEM, "Out of heap" }, 20 { MP_MEM, "Out of heap" },
24 { MP_VAL, "Value out of range" } 21 { MP_VAL, "Value out of range" }
25 }; 22 };
26 23
27 /* return a char * string for a given code */ 24 /* return a char * string for a given code */
28 const char *mp_error_to_string(int code) 25 const char *mp_error_to_string(int code)
29 { 26 {
30 int x; 27 size_t x;
31 28
32 /* scan the lookup table for the given message */ 29 /* scan the lookup table for the given message */
33 for (x = 0; x < (int)(sizeof(msgs) / sizeof(msgs[0])); x++) { 30 for (x = 0; x < (sizeof(msgs) / sizeof(msgs[0])); x++) {
34 if (msgs[x].code == code) { 31 if (msgs[x].code == code) {
35 return msgs[x].msg; 32 return msgs[x].msg;
36 } 33 }
37 } 34 }
38 35
39 /* generic reply for invalid code */ 36 /* generic reply for invalid code */
40 return "Invalid error code"; 37 return "Invalid error code";
41 } 38 }
42 39
43 #endif 40 #endif
44 41
45 /* ref: $Format:%D$ */ 42 /* ref: HEAD -> master, tag: v1.1.0 */
46 /* git commit: $Format:%H$ */ 43 /* git commit: 08549ad6bc8b0cede0b357a9c341c5c6473a9c55 */
47 /* commit time: $Format:%ai$ */ 44 /* commit time: 2019-01-28 20:32:32 +0100 */