From 1e6d868791ef0c22b86c620a6d38c0a7fe964c61 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 22 Oct 2014 16:32:32 +0200 Subject: Sync state of development with the other repository I've been working in --- powm.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 powm.h (limited to 'powm.h') diff --git a/powm.h b/powm.h new file mode 100644 index 0000000..7290165 --- /dev/null +++ b/powm.h @@ -0,0 +1,44 @@ +#ifndef __LIBGSMKBIGNUM_POWM_H__ +#define __LIBGSMKBIGNUM_POWM_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef USE32BITLIMB +typedef uint32_t limb_t; +typedef uint64_t dlimb_t; +#else +typedef uint64_t limb_t; +typedef unsigned int uint128_t __attribute__((mode(TI))); +typedef uint128_t dlimb_t; +#endif + + +/* import from serialized format, big endian byte representation + return amount of limbs */ +uint32_t mp_import( limb_t *dest, uint8_t const * src, uint32_t byte_size ); +void mp_export( uint8_t *dest, const limb_t *scr, uint32_t limb_size ); + +/* This function works with precalculated parameters passed in r_square + and r_inverse. The latter being 1, if the bottom limb_t is -1. */ +void powm_internal( limb_t * result, + const limb_t * base, uint32_t base_limbs, + const limb_t * exponent, uint32_t exp_limbs, + const limb_t * modulus, uint32_t mod_limbs, + const limb_t * r_square, const limb_t r_inverse ); + +/* Not yet implemented */ +void powm( limb_t * result, + const limb_t * base, uint32_t base_limbs, + const limb_t * exponent, int expbits, + const limb_t * modulus, uint32_t mod_limbs ); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3