Edit

kc3-lang/libtommath/bn_mp_error_to_string.c

Branch :

  • Show log

    Commit

  • Author : Francois Perrad
    Date : 2019-10-20 16:37:46
    Hash : 2ef4c9bd
    Message : handles MP_BUF in mp_error_to_string (cherry picked from commit a825e0a3601f81ddf1a6753c45e5b74d44c23d78)

  • bn_mp_error_to_string.c
  • #include "tommath_private.h"
    #ifdef BN_MP_ERROR_TO_STRING_C
    /* LibTomMath, multiple-precision integer library -- Tom St Denis */
    /* SPDX-License-Identifier: Unlicense */
    
    /* return a char * string for a given code */
    const char *mp_error_to_string(mp_err code)
    {
       switch (code) {
       case MP_OKAY:
          return "Successful";
       case MP_ERR:
          return "Unknown error";
       case MP_MEM:
          return "Out of heap";
       case MP_VAL:
          return "Value out of range";
       case MP_ITER:
          return "Max. iterations reached";
       case MP_BUF:
          return "Buffer overflow";
       default:
          return "Invalid error code";
       }
    }
    
    #endif