Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
#endif

#define MP_WUR /* TODO: result checks disabled for now */
#include "tommath.h"
#include "tommath_private.h"

extern void ndraw(mp_int* a, const char* name);
1 change: 0 additions & 1 deletion demo/test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "shared.h"
#include "tommath_private.h"

static long rand_long(void)
{
Expand Down
13 changes: 8 additions & 5 deletions tommath.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@ extern "C" {
*/
#ifdef MP_8BIT
typedef uint8_t mp_digit;
typedef uint16_t mp_word;
typedef uint16_t private_mp_word;
# define MP_SIZEOF_MP_DIGIT 1
# ifdef MP_DIGIT_BIT
# error You must not define MP_DIGIT_BIT when using MP_8BIT
# endif
#elif defined(MP_16BIT)
typedef uint16_t mp_digit;
typedef uint32_t mp_word;
typedef uint32_t private_mp_word;
# define MP_SIZEOF_MP_DIGIT 2
# ifdef MP_DIGIT_BIT
# error You must not define MP_DIGIT_BIT when using MP_16BIT
# endif
#elif defined(MP_64BIT)
/* for GCC only on supported platforms */
typedef uint64_t mp_digit;
typedef unsigned long mp_word __attribute__((mode(TI)));
typedef unsigned long private_mp_word __attribute__((mode(TI)));
# define MP_DIGIT_BIT 60
#else
/* this is the default case, 28-bit digits */

/* this is to make porting into LibTomCrypt easier :-) */
typedef uint32_t mp_digit;
typedef uint64_t mp_word;
typedef uint64_t private_mp_word;

# ifdef MP_31BIT
/* this is an extension that uses 31-bit digits */
Expand All @@ -89,6 +89,9 @@ typedef uint64_t mp_word;
# endif
#endif

/* mp_word is a private type */
#define mp_word MP_DEPRECATED_PRAGMA("mp_word has been made private") private_mp_word

/* otherwise the bits per digit is calculated automatically from the size of a mp_digit */
#ifndef MP_DIGIT_BIT
# define MP_DIGIT_BIT (((CHAR_BIT * MP_SIZEOF_MP_DIGIT) - 1)) /* bits per digit */
Expand Down Expand Up @@ -172,7 +175,7 @@ TOOM_SQR_CUTOFF;
#endif

/* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
#define PRIVATE_MP_WARRAY (1uLL << (((CHAR_BIT * sizeof(mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
#define PRIVATE_MP_WARRAY (1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
#define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)

#if defined(__GNUC__) && __GNUC__ >= 4
Expand Down
4 changes: 4 additions & 0 deletions tommath_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ extern void MP_FREE(void *mem, size_t size);
#undef MP_WARRAY
#define MP_WARRAY PRIVATE_MP_WARRAY

/* TODO: Remove private_mp_word as soon as deprecated mp_word is removed from tommath. */
#undef mp_word
typedef private_mp_word mp_word;

#define MP_MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MP_MAX(x, y) (((x) > (y)) ? (x) : (y))

Expand Down