summaryrefslogtreecommitdiff
path: root/powm.h
diff options
context:
space:
mode:
authorerdgeist <erdgeist@bauklotz-3.local>2014-10-22 16:32:32 +0200
committererdgeist <erdgeist@bauklotz-3.local>2014-10-22 16:32:32 +0200
commit1e6d868791ef0c22b86c620a6d38c0a7fe964c61 (patch)
tree047d57921e7962444609c7382b1addc69885000b /powm.h
parentaae5320226e9f0fcc764471337326ab690683df7 (diff)
Sync state of development with the other repository I've been working inHEADmaster
Diffstat (limited to 'powm.h')
-rw-r--r--powm.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/powm.h b/powm.h
new file mode 100644
index 0000000..7290165
--- /dev/null
+++ b/powm.h
@@ -0,0 +1,44 @@
1#ifndef __LIBGSMKBIGNUM_POWM_H__
2#define __LIBGSMKBIGNUM_POWM_H__
3
4#include <stdint.h>
5#include <stdlib.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#ifdef USE32BITLIMB
12typedef uint32_t limb_t;
13typedef uint64_t dlimb_t;
14#else
15typedef uint64_t limb_t;
16typedef unsigned int uint128_t __attribute__((mode(TI)));
17typedef uint128_t dlimb_t;
18#endif
19
20
21/* import from serialized format, big endian byte representation
22 return amount of limbs */
23uint32_t mp_import( limb_t *dest, uint8_t const * src, uint32_t byte_size );
24void mp_export( uint8_t *dest, const limb_t *scr, uint32_t limb_size );
25
26/* This function works with precalculated parameters passed in r_square
27 and r_inverse. The latter being 1, if the bottom limb_t is -1. */
28void powm_internal( limb_t * result,
29 const limb_t * base, uint32_t base_limbs,
30 const limb_t * exponent, uint32_t exp_limbs,
31 const limb_t * modulus, uint32_t mod_limbs,
32 const limb_t * r_square, const limb_t r_inverse );
33
34/* Not yet implemented */
35void powm( limb_t * result,
36 const limb_t * base, uint32_t base_limbs,
37 const limb_t * exponent, int expbits,
38 const limb_t * modulus, uint32_t mod_limbs );
39
40#ifdef __cplusplus
41}
42#endif
43
44#endif