Mercurial > dropbear
annotate libtommath/bn_mp_expt_d_ex.c @ 1653:76189c9ffea2
External Public-Key Authentication API (#72)
* Implemented dynamic loading of an external plug-in shared library to delegate public key authentication
* Moved conditional compilation of the plugin infrastructure into the configure.ac script to be able to add -ldl to dropbear build only when the flag is enabled
* Added tags file to the ignore list
* Updated API to have the constructor to return function pointers in the pliugin instance. Added support for passing user name to the checkpubkey function. Added options to the session returned by the plugin and have dropbear to parse and process them
* Added -rdynamic to the linker flags when EPKA is enabled
* Changed the API to pass a previously created session to the checkPubKey function (created during preauth)
* Added documentation to the API
* Added parameter addrstring to plugin creation function
* Modified the API to retrieve the auth options. Instead of having them as field of the EPKASession struct, they are stored internally (plugin-dependent) in the plugin/session and retrieved through a pointer to a function (in the session)
* Changed option string to be a simple char * instead of unsigned char *
author | fabriziobertocci <fabriziobertocci@gmail.com> |
---|---|
date | Wed, 15 May 2019 09:43:57 -0400 |
parents | 8bba51a55704 |
children | f52919ffd3b1 |
rev | line source |
---|---|
1436 | 1 #include <tommath_private.h> |
2 #ifdef BN_MP_EXPT_D_EX_C | |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis | |
4 * | |
5 * LibTomMath is a library that provides multiple-precision | |
6 * integer arithmetic as well as number theoretic functionality. | |
7 * | |
8 * The library was designed directly after the MPI library by | |
9 * Michael Fromberger but has been written from scratch with | |
10 * additional optimizations in place. | |
11 * | |
12 * The library is free for all purposes without any express | |
13 * guarantee it works. | |
14 * | |
15 * Tom St Denis, [email protected], http://libtom.org | |
16 */ | |
17 | |
18 /* calculate c = a**b using a square-multiply algorithm */ | |
19 int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast) | |
20 { | |
21 int res; | |
22 unsigned int x; | |
23 | |
24 mp_int g; | |
25 | |
26 if ((res = mp_init_copy (&g, a)) != MP_OKAY) { | |
27 return res; | |
28 } | |
29 | |
30 /* set initial result */ | |
31 mp_set (c, 1); | |
32 | |
33 if (fast != 0) { | |
34 while (b > 0) { | |
35 /* if the bit is set multiply */ | |
36 if ((b & 1) != 0) { | |
37 if ((res = mp_mul (c, &g, c)) != MP_OKAY) { | |
38 mp_clear (&g); | |
39 return res; | |
40 } | |
41 } | |
42 | |
43 /* square */ | |
44 if (b > 1) { | |
45 if ((res = mp_sqr (&g, &g)) != MP_OKAY) { | |
46 mp_clear (&g); | |
47 return res; | |
48 } | |
49 } | |
50 | |
51 /* shift to next bit */ | |
52 b >>= 1; | |
53 } | |
54 } | |
55 else { | |
56 for (x = 0; x < DIGIT_BIT; x++) { | |
57 /* square */ | |
58 if ((res = mp_sqr (c, c)) != MP_OKAY) { | |
59 mp_clear (&g); | |
60 return res; | |
61 } | |
62 | |
63 /* if the bit is set multiply */ | |
64 if ((b & (mp_digit) (((mp_digit)1) << (DIGIT_BIT - 1))) != 0) { | |
65 if ((res = mp_mul (c, &g, c)) != MP_OKAY) { | |
66 mp_clear (&g); | |
67 return res; | |
68 } | |
69 } | |
70 | |
71 /* shift to next bit */ | |
72 b <<= 1; | |
73 } | |
74 } /* if ... else */ | |
75 | |
76 mp_clear (&g); | |
77 return MP_OKAY; | |
78 } | |
79 #endif | |
80 | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
81 /* ref: $Format:%D$ */ |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
82 /* git commit: $Format:%H$ */ |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
83 /* commit time: $Format:%ai$ */ |