mpi_class.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. /* mpi_class.h
  2. *
  3. * Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * CyaSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. */
  21. #if !(defined(LTM1) && defined(LTM2) && defined(LTM3))
  22. #if defined(LTM2)
  23. #define LTM3
  24. #endif
  25. #if defined(LTM1)
  26. #define LTM2
  27. #endif
  28. #define LTM1
  29. #if defined(LTM_ALL)
  30. #define BN_ERROR_C
  31. #define BN_FAST_MP_INVMOD_C
  32. #define BN_FAST_MP_MONTGOMERY_REDUCE_C
  33. #define BN_FAST_S_MP_MUL_DIGS_C
  34. #define BN_FAST_S_MP_MUL_HIGH_DIGS_C
  35. #define BN_FAST_S_MP_SQR_C
  36. #define BN_MP_2EXPT_C
  37. #define BN_MP_ABS_C
  38. #define BN_MP_ADD_C
  39. #define BN_MP_ADD_D_C
  40. #define BN_MP_ADDMOD_C
  41. #define BN_MP_AND_C
  42. #define BN_MP_CLAMP_C
  43. #define BN_MP_CLEAR_C
  44. #define BN_MP_CLEAR_MULTI_C
  45. #define BN_MP_CMP_C
  46. #define BN_MP_CMP_D_C
  47. #define BN_MP_CMP_MAG_C
  48. #define BN_MP_CNT_LSB_C
  49. #define BN_MP_COPY_C
  50. #define BN_MP_COUNT_BITS_C
  51. #define BN_MP_DIV_C
  52. #define BN_MP_DIV_2_C
  53. #define BN_MP_DIV_2D_C
  54. #define BN_MP_DIV_3_C
  55. #define BN_MP_DIV_D_C
  56. #define BN_MP_DR_IS_MODULUS_C
  57. #define BN_MP_DR_REDUCE_C
  58. #define BN_MP_DR_SETUP_C
  59. #define BN_MP_EXCH_C
  60. #define BN_MP_EXPT_D_C
  61. #define BN_MP_EXPTMOD_C
  62. #define BN_MP_EXPTMOD_FAST_C
  63. #define BN_MP_EXTEUCLID_C
  64. #define BN_MP_FREAD_C
  65. #define BN_MP_FWRITE_C
  66. #define BN_MP_GCD_C
  67. #define BN_MP_GET_INT_C
  68. #define BN_MP_GROW_C
  69. #define BN_MP_INIT_C
  70. #define BN_MP_INIT_COPY_C
  71. #define BN_MP_INIT_MULTI_C
  72. #define BN_MP_INIT_SET_C
  73. #define BN_MP_INIT_SET_INT_C
  74. #define BN_MP_INIT_SIZE_C
  75. #define BN_MP_INVMOD_C
  76. #define BN_MP_INVMOD_SLOW_C
  77. #define BN_MP_IS_SQUARE_C
  78. #define BN_MP_JACOBI_C
  79. #define BN_MP_KARATSUBA_MUL_C
  80. #define BN_MP_KARATSUBA_SQR_C
  81. #define BN_MP_LCM_C
  82. #define BN_MP_LSHD_C
  83. #define BN_MP_MOD_C
  84. #define BN_MP_MOD_2D_C
  85. #define BN_MP_MOD_D_C
  86. #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
  87. #define BN_MP_MONTGOMERY_REDUCE_C
  88. #define BN_MP_MONTGOMERY_SETUP_C
  89. #define BN_MP_MUL_C
  90. #define BN_MP_MUL_2_C
  91. #define BN_MP_MUL_2D_C
  92. #define BN_MP_MUL_D_C
  93. #define BN_MP_MULMOD_C
  94. #define BN_MP_N_ROOT_C
  95. #define BN_MP_NEG_C
  96. #define BN_MP_OR_C
  97. #define BN_MP_PRIME_FERMAT_C
  98. #define BN_MP_PRIME_IS_DIVISIBLE_C
  99. #define BN_MP_PRIME_IS_PRIME_C
  100. #define BN_MP_PRIME_MILLER_RABIN_C
  101. #define BN_MP_PRIME_NEXT_PRIME_C
  102. #define BN_MP_PRIME_RABIN_MILLER_TRIALS_C
  103. #define BN_MP_PRIME_RANDOM_EX_C
  104. #define BN_MP_RADIX_SIZE_C
  105. #define BN_MP_RADIX_SMAP_C
  106. #define BN_MP_RAND_C
  107. #define BN_MP_READ_RADIX_C
  108. #define BN_MP_READ_SIGNED_BIN_C
  109. #define BN_MP_READ_UNSIGNED_BIN_C
  110. #define BN_MP_REDUCE_C
  111. #define BN_MP_REDUCE_2K_C
  112. #define BN_MP_REDUCE_2K_L_C
  113. #define BN_MP_REDUCE_2K_SETUP_C
  114. #define BN_MP_REDUCE_2K_SETUP_L_C
  115. #define BN_MP_REDUCE_IS_2K_C
  116. #define BN_MP_REDUCE_IS_2K_L_C
  117. #define BN_MP_REDUCE_SETUP_C
  118. #define BN_MP_RSHD_C
  119. #define BN_MP_SET_C
  120. #define BN_MP_SET_INT_C
  121. #define BN_MP_SHRINK_C
  122. #define BN_MP_SIGNED_BIN_SIZE_C
  123. #define BN_MP_SQR_C
  124. #define BN_MP_SQRMOD_C
  125. #define BN_MP_SQRT_C
  126. #define BN_MP_SUB_C
  127. #define BN_MP_SUB_D_C
  128. #define BN_MP_SUBMOD_C
  129. #define BN_MP_TO_SIGNED_BIN_C
  130. #define BN_MP_TO_SIGNED_BIN_N_C
  131. #define BN_MP_TO_UNSIGNED_BIN_C
  132. #define BN_MP_TO_UNSIGNED_BIN_N_C
  133. #define BN_MP_TOOM_MUL_C
  134. #define BN_MP_TOOM_SQR_C
  135. #define BN_MP_TORADIX_C
  136. #define BN_MP_TORADIX_N_C
  137. #define BN_MP_UNSIGNED_BIN_SIZE_C
  138. #define BN_MP_XOR_C
  139. #define BN_MP_ZERO_C
  140. #define BN_PRIME_TAB_C
  141. #define BN_REVERSE_C
  142. #define BN_S_MP_ADD_C
  143. #define BN_S_MP_EXPTMOD_C
  144. #define BN_S_MP_MUL_DIGS_C
  145. #define BN_S_MP_MUL_HIGH_DIGS_C
  146. #define BN_S_MP_SQR_C
  147. #define BN_S_MP_SUB_C
  148. #define BNCORE_C
  149. #endif
  150. #if defined(BN_ERROR_C)
  151. #define BN_MP_ERROR_TO_STRING_C
  152. #endif
  153. #if defined(BN_FAST_MP_INVMOD_C)
  154. #define BN_MP_ISEVEN_C
  155. #define BN_MP_INIT_MULTI_C
  156. #define BN_MP_COPY_C
  157. #define BN_MP_MOD_C
  158. #define BN_MP_SET_C
  159. #define BN_MP_DIV_2_C
  160. #define BN_MP_ISODD_C
  161. #define BN_MP_SUB_C
  162. #define BN_MP_CMP_C
  163. #define BN_MP_ISZERO_C
  164. #define BN_MP_CMP_D_C
  165. #define BN_MP_ADD_C
  166. #define BN_MP_EXCH_C
  167. #define BN_MP_CLEAR_MULTI_C
  168. #endif
  169. #if defined(BN_FAST_MP_MONTGOMERY_REDUCE_C)
  170. #define BN_MP_GROW_C
  171. #define BN_MP_RSHD_C
  172. #define BN_MP_CLAMP_C
  173. #define BN_MP_CMP_MAG_C
  174. #define BN_S_MP_SUB_C
  175. #endif
  176. #if defined(BN_FAST_S_MP_MUL_DIGS_C)
  177. #define BN_MP_GROW_C
  178. #define BN_MP_CLAMP_C
  179. #endif
  180. #if defined(BN_FAST_S_MP_MUL_HIGH_DIGS_C)
  181. #define BN_MP_GROW_C
  182. #define BN_MP_CLAMP_C
  183. #endif
  184. #if defined(BN_FAST_S_MP_SQR_C)
  185. #define BN_MP_GROW_C
  186. #define BN_MP_CLAMP_C
  187. #endif
  188. #if defined(BN_MP_2EXPT_C)
  189. #define BN_MP_ZERO_C
  190. #define BN_MP_GROW_C
  191. #endif
  192. #if defined(BN_MP_ABS_C)
  193. #define BN_MP_COPY_C
  194. #endif
  195. #if defined(BN_MP_ADD_C)
  196. #define BN_S_MP_ADD_C
  197. #define BN_MP_CMP_MAG_C
  198. #define BN_S_MP_SUB_C
  199. #endif
  200. #if defined(BN_MP_ADD_D_C)
  201. #define BN_MP_GROW_C
  202. #define BN_MP_SUB_D_C
  203. #define BN_MP_CLAMP_C
  204. #endif
  205. #if defined(BN_MP_ADDMOD_C)
  206. #define BN_MP_INIT_C
  207. #define BN_MP_ADD_C
  208. #define BN_MP_CLEAR_C
  209. #define BN_MP_MOD_C
  210. #endif
  211. #if defined(BN_MP_AND_C)
  212. #define BN_MP_INIT_COPY_C
  213. #define BN_MP_CLAMP_C
  214. #define BN_MP_EXCH_C
  215. #define BN_MP_CLEAR_C
  216. #endif
  217. #if defined(BN_MP_CLAMP_C)
  218. #endif
  219. #if defined(BN_MP_CLEAR_C)
  220. #endif
  221. #if defined(BN_MP_CLEAR_MULTI_C)
  222. #define BN_MP_CLEAR_C
  223. #endif
  224. #if defined(BN_MP_CMP_C)
  225. #define BN_MP_CMP_MAG_C
  226. #endif
  227. #if defined(BN_MP_CMP_D_C)
  228. #endif
  229. #if defined(BN_MP_CMP_MAG_C)
  230. #endif
  231. #if defined(BN_MP_CNT_LSB_C)
  232. #define BN_MP_ISZERO_C
  233. #endif
  234. #if defined(BN_MP_COPY_C)
  235. #define BN_MP_GROW_C
  236. #endif
  237. #if defined(BN_MP_COUNT_BITS_C)
  238. #endif
  239. #if defined(BN_MP_DIV_C)
  240. #define BN_MP_ISZERO_C
  241. #define BN_MP_CMP_MAG_C
  242. #define BN_MP_COPY_C
  243. #define BN_MP_ZERO_C
  244. #define BN_MP_INIT_MULTI_C
  245. #define BN_MP_SET_C
  246. #define BN_MP_COUNT_BITS_C
  247. #define BN_MP_ABS_C
  248. #define BN_MP_MUL_2D_C
  249. #define BN_MP_CMP_C
  250. #define BN_MP_SUB_C
  251. #define BN_MP_ADD_C
  252. #define BN_MP_DIV_2D_C
  253. #define BN_MP_EXCH_C
  254. #define BN_MP_CLEAR_MULTI_C
  255. #define BN_MP_INIT_SIZE_C
  256. #define BN_MP_INIT_C
  257. #define BN_MP_INIT_COPY_C
  258. #define BN_MP_LSHD_C
  259. #define BN_MP_RSHD_C
  260. #define BN_MP_MUL_D_C
  261. #define BN_MP_CLAMP_C
  262. #define BN_MP_CLEAR_C
  263. #endif
  264. #if defined(BN_MP_DIV_2_C)
  265. #define BN_MP_GROW_C
  266. #define BN_MP_CLAMP_C
  267. #endif
  268. #if defined(BN_MP_DIV_2D_C)
  269. #define BN_MP_COPY_C
  270. #define BN_MP_ZERO_C
  271. #define BN_MP_INIT_C
  272. #define BN_MP_MOD_2D_C
  273. #define BN_MP_CLEAR_C
  274. #define BN_MP_RSHD_C
  275. #define BN_MP_CLAMP_C
  276. #define BN_MP_EXCH_C
  277. #endif
  278. #if defined(BN_MP_DIV_3_C)
  279. #define BN_MP_INIT_SIZE_C
  280. #define BN_MP_CLAMP_C
  281. #define BN_MP_EXCH_C
  282. #define BN_MP_CLEAR_C
  283. #endif
  284. #if defined(BN_MP_DIV_D_C)
  285. #define BN_MP_ISZERO_C
  286. #define BN_MP_COPY_C
  287. #define BN_MP_DIV_2D_C
  288. #define BN_MP_DIV_3_C
  289. #define BN_MP_INIT_SIZE_C
  290. #define BN_MP_CLAMP_C
  291. #define BN_MP_EXCH_C
  292. #define BN_MP_CLEAR_C
  293. #endif
  294. #if defined(BN_MP_DR_IS_MODULUS_C)
  295. #endif
  296. #if defined(BN_MP_DR_REDUCE_C)
  297. #define BN_MP_GROW_C
  298. #define BN_MP_CLAMP_C
  299. #define BN_MP_CMP_MAG_C
  300. #define BN_S_MP_SUB_C
  301. #endif
  302. #if defined(BN_MP_DR_SETUP_C)
  303. #endif
  304. #if defined(BN_MP_EXCH_C)
  305. #endif
  306. #if defined(BN_MP_EXPT_D_C)
  307. #define BN_MP_INIT_COPY_C
  308. #define BN_MP_SET_C
  309. #define BN_MP_SQR_C
  310. #define BN_MP_CLEAR_C
  311. #define BN_MP_MUL_C
  312. #endif
  313. #if defined(BN_MP_EXPTMOD_C)
  314. #define BN_MP_INIT_C
  315. #define BN_MP_INVMOD_C
  316. #define BN_MP_CLEAR_C
  317. #define BN_MP_ABS_C
  318. #define BN_MP_CLEAR_MULTI_C
  319. #define BN_MP_REDUCE_IS_2K_L_C
  320. #define BN_S_MP_EXPTMOD_C
  321. #define BN_MP_DR_IS_MODULUS_C
  322. #define BN_MP_REDUCE_IS_2K_C
  323. #define BN_MP_ISODD_C
  324. #define BN_MP_EXPTMOD_FAST_C
  325. #endif
  326. #if defined(BN_MP_EXPTMOD_FAST_C)
  327. #define BN_MP_COUNT_BITS_C
  328. #define BN_MP_INIT_C
  329. #define BN_MP_CLEAR_C
  330. #define BN_MP_MONTGOMERY_SETUP_C
  331. #define BN_FAST_MP_MONTGOMERY_REDUCE_C
  332. #define BN_MP_MONTGOMERY_REDUCE_C
  333. #define BN_MP_DR_SETUP_C
  334. #define BN_MP_DR_REDUCE_C
  335. #define BN_MP_REDUCE_2K_SETUP_C
  336. #define BN_MP_REDUCE_2K_C
  337. #define BN_MP_MONTGOMERY_CALC_NORMALIZATION_C
  338. #define BN_MP_MULMOD_C
  339. #define BN_MP_SET_C
  340. #define BN_MP_MOD_C
  341. #define BN_MP_COPY_C
  342. #define BN_MP_SQR_C
  343. #define BN_MP_MUL_C
  344. #define BN_MP_EXCH_C
  345. #endif
  346. #if defined(BN_MP_EXTEUCLID_C)
  347. #define BN_MP_INIT_MULTI_C
  348. #define BN_MP_SET_C
  349. #define BN_MP_COPY_C
  350. #define BN_MP_ISZERO_C
  351. #define BN_MP_DIV_C
  352. #define BN_MP_MUL_C
  353. #define BN_MP_SUB_C
  354. #define BN_MP_NEG_C
  355. #define BN_MP_EXCH_C
  356. #define BN_MP_CLEAR_MULTI_C
  357. #endif
  358. #if defined(BN_MP_FREAD_C)
  359. #define BN_MP_ZERO_C
  360. #define BN_MP_S_RMAP_C
  361. #define BN_MP_MUL_D_C
  362. #define BN_MP_ADD_D_C
  363. #define BN_MP_CMP_D_C
  364. #endif
  365. #if defined(BN_MP_FWRITE_C)
  366. #define BN_MP_RADIX_SIZE_C
  367. #define BN_MP_TORADIX_C
  368. #endif
  369. #if defined(BN_MP_GCD_C)
  370. #define BN_MP_ISZERO_C
  371. #define BN_MP_ABS_C
  372. #define BN_MP_ZERO_C
  373. #define BN_MP_INIT_COPY_C
  374. #define BN_MP_CNT_LSB_C
  375. #define BN_MP_DIV_2D_C
  376. #define BN_MP_CMP_MAG_C
  377. #define BN_MP_EXCH_C
  378. #define BN_S_MP_SUB_C
  379. #define BN_MP_MUL_2D_C
  380. #define BN_MP_CLEAR_C
  381. #endif
  382. #if defined(BN_MP_GET_INT_C)
  383. #endif
  384. #if defined(BN_MP_GROW_C)
  385. #endif
  386. #if defined(BN_MP_INIT_C)
  387. #endif
  388. #if defined(BN_MP_INIT_COPY_C)
  389. #define BN_MP_COPY_C
  390. #endif
  391. #if defined(BN_MP_INIT_MULTI_C)
  392. #define BN_MP_ERR_C
  393. #define BN_MP_INIT_C
  394. #define BN_MP_CLEAR_C
  395. #endif
  396. #if defined(BN_MP_INIT_SET_C)
  397. #define BN_MP_INIT_C
  398. #define BN_MP_SET_C
  399. #endif
  400. #if defined(BN_MP_INIT_SET_INT_C)
  401. #define BN_MP_INIT_C
  402. #define BN_MP_SET_INT_C
  403. #endif
  404. #if defined(BN_MP_INIT_SIZE_C)
  405. #define BN_MP_INIT_C
  406. #endif
  407. #if defined(BN_MP_INVMOD_C)
  408. #define BN_MP_ISZERO_C
  409. #define BN_MP_ISODD_C
  410. #define BN_FAST_MP_INVMOD_C
  411. #define BN_MP_INVMOD_SLOW_C
  412. #endif
  413. #if defined(BN_MP_INVMOD_SLOW_C)
  414. #define BN_MP_ISZERO_C
  415. #define BN_MP_INIT_MULTI_C
  416. #define BN_MP_MOD_C
  417. #define BN_MP_COPY_C
  418. #define BN_MP_ISEVEN_C
  419. #define BN_MP_SET_C
  420. #define BN_MP_DIV_2_C
  421. #define BN_MP_ISODD_C
  422. #define BN_MP_ADD_C
  423. #define BN_MP_SUB_C
  424. #define BN_MP_CMP_C
  425. #define BN_MP_CMP_D_C
  426. #define BN_MP_CMP_MAG_C
  427. #define BN_MP_EXCH_C
  428. #define BN_MP_CLEAR_MULTI_C
  429. #endif
  430. #if defined(BN_MP_IS_SQUARE_C)
  431. #define BN_MP_MOD_D_C
  432. #define BN_MP_INIT_SET_INT_C
  433. #define BN_MP_MOD_C
  434. #define BN_MP_GET_INT_C
  435. #define BN_MP_SQRT_C
  436. #define BN_MP_SQR_C
  437. #define BN_MP_CMP_MAG_C
  438. #define BN_MP_CLEAR_C
  439. #endif
  440. #if defined(BN_MP_JACOBI_C)
  441. #define BN_MP_CMP_D_C
  442. #define BN_MP_ISZERO_C
  443. #define BN_MP_INIT_COPY_C
  444. #define BN_MP_CNT_LSB_C
  445. #define BN_MP_DIV_2D_C
  446. #define BN_MP_MOD_C
  447. #define BN_MP_CLEAR_C
  448. #endif
  449. #if defined(BN_MP_KARATSUBA_MUL_C)
  450. #define BN_MP_MUL_C
  451. #define BN_MP_INIT_SIZE_C
  452. #define BN_MP_CLAMP_C
  453. #define BN_MP_SUB_C
  454. #define BN_MP_ADD_C
  455. #define BN_MP_LSHD_C
  456. #define BN_MP_CLEAR_C
  457. #endif
  458. #if defined(BN_MP_KARATSUBA_SQR_C)
  459. #define BN_MP_INIT_SIZE_C
  460. #define BN_MP_CLAMP_C
  461. #define BN_MP_SQR_C
  462. #define BN_MP_SUB_C
  463. #define BN_S_MP_ADD_C
  464. #define BN_MP_LSHD_C
  465. #define BN_MP_ADD_C
  466. #define BN_MP_CLEAR_C
  467. #endif
  468. #if defined(BN_MP_LCM_C)
  469. #define BN_MP_INIT_MULTI_C
  470. #define BN_MP_GCD_C
  471. #define BN_MP_CMP_MAG_C
  472. #define BN_MP_DIV_C
  473. #define BN_MP_MUL_C
  474. #define BN_MP_CLEAR_MULTI_C
  475. #endif
  476. #if defined(BN_MP_LSHD_C)
  477. #define BN_MP_GROW_C
  478. #define BN_MP_RSHD_C
  479. #endif
  480. #if defined(BN_MP_MOD_C)
  481. #define BN_MP_INIT_C
  482. #define BN_MP_DIV_C
  483. #define BN_MP_CLEAR_C
  484. #define BN_MP_ADD_C
  485. #define BN_MP_EXCH_C
  486. #endif
  487. #if defined(BN_MP_MOD_2D_C)
  488. #define BN_MP_ZERO_C
  489. #define BN_MP_COPY_C
  490. #define BN_MP_CLAMP_C
  491. #endif
  492. #if defined(BN_MP_MOD_D_C)
  493. #define BN_MP_DIV_D_C
  494. #endif
  495. #if defined(BN_MP_MONTGOMERY_CALC_NORMALIZATION_C)
  496. #define BN_MP_COUNT_BITS_C
  497. #define BN_MP_2EXPT_C
  498. #define BN_MP_SET_C
  499. #define BN_MP_MUL_2_C
  500. #define BN_MP_CMP_MAG_C
  501. #define BN_S_MP_SUB_C
  502. #endif
  503. #if defined(BN_MP_MONTGOMERY_REDUCE_C)
  504. #define BN_FAST_MP_MONTGOMERY_REDUCE_C
  505. #define BN_MP_GROW_C
  506. #define BN_MP_CLAMP_C
  507. #define BN_MP_RSHD_C
  508. #define BN_MP_CMP_MAG_C
  509. #define BN_S_MP_SUB_C
  510. #endif
  511. #if defined(BN_MP_MONTGOMERY_SETUP_C)
  512. #endif
  513. #if defined(BN_MP_MUL_C)
  514. #define BN_MP_TOOM_MUL_C
  515. #define BN_MP_KARATSUBA_MUL_C
  516. #define BN_FAST_S_MP_MUL_DIGS_C
  517. #define BN_S_MP_MUL_C
  518. #define BN_S_MP_MUL_DIGS_C
  519. #endif
  520. #if defined(BN_MP_MUL_2_C)
  521. #define BN_MP_GROW_C
  522. #endif
  523. #if defined(BN_MP_MUL_2D_C)
  524. #define BN_MP_COPY_C
  525. #define BN_MP_GROW_C
  526. #define BN_MP_LSHD_C
  527. #define BN_MP_CLAMP_C
  528. #endif
  529. #if defined(BN_MP_MUL_D_C)
  530. #define BN_MP_GROW_C
  531. #define BN_MP_CLAMP_C
  532. #endif
  533. #if defined(BN_MP_MULMOD_C)
  534. #define BN_MP_INIT_C
  535. #define BN_MP_MUL_C
  536. #define BN_MP_CLEAR_C
  537. #define BN_MP_MOD_C
  538. #endif
  539. #if defined(BN_MP_N_ROOT_C)
  540. #define BN_MP_INIT_C
  541. #define BN_MP_SET_C
  542. #define BN_MP_COPY_C
  543. #define BN_MP_EXPT_D_C
  544. #define BN_MP_MUL_C
  545. #define BN_MP_SUB_C
  546. #define BN_MP_MUL_D_C
  547. #define BN_MP_DIV_C
  548. #define BN_MP_CMP_C
  549. #define BN_MP_SUB_D_C
  550. #define BN_MP_EXCH_C
  551. #define BN_MP_CLEAR_C
  552. #endif
  553. #if defined(BN_MP_NEG_C)
  554. #define BN_MP_COPY_C
  555. #define BN_MP_ISZERO_C
  556. #endif
  557. #if defined(BN_MP_OR_C)
  558. #define BN_MP_INIT_COPY_C
  559. #define BN_MP_CLAMP_C
  560. #define BN_MP_EXCH_C
  561. #define BN_MP_CLEAR_C
  562. #endif
  563. #if defined(BN_MP_PRIME_FERMAT_C)
  564. #define BN_MP_CMP_D_C
  565. #define BN_MP_INIT_C
  566. #define BN_MP_EXPTMOD_C
  567. #define BN_MP_CMP_C
  568. #define BN_MP_CLEAR_C
  569. #endif
  570. #if defined(BN_MP_PRIME_IS_DIVISIBLE_C)
  571. #define BN_MP_MOD_D_C
  572. #endif
  573. #if defined(BN_MP_PRIME_IS_PRIME_C)
  574. #define BN_MP_CMP_D_C
  575. #define BN_MP_PRIME_IS_DIVISIBLE_C
  576. #define BN_MP_INIT_C
  577. #define BN_MP_SET_C
  578. #define BN_MP_PRIME_MILLER_RABIN_C
  579. #define BN_MP_CLEAR_C
  580. #endif
  581. #if defined(BN_MP_PRIME_MILLER_RABIN_C)
  582. #define BN_MP_CMP_D_C
  583. #define BN_MP_INIT_COPY_C
  584. #define BN_MP_SUB_D_C
  585. #define BN_MP_CNT_LSB_C
  586. #define BN_MP_DIV_2D_C
  587. #define BN_MP_EXPTMOD_C
  588. #define BN_MP_CMP_C
  589. #define BN_MP_SQRMOD_C
  590. #define BN_MP_CLEAR_C
  591. #endif
  592. #if defined(BN_MP_PRIME_NEXT_PRIME_C)
  593. #define BN_MP_CMP_D_C
  594. #define BN_MP_SET_C
  595. #define BN_MP_SUB_D_C
  596. #define BN_MP_ISEVEN_C
  597. #define BN_MP_MOD_D_C
  598. #define BN_MP_INIT_C
  599. #define BN_MP_ADD_D_C
  600. #define BN_MP_PRIME_MILLER_RABIN_C
  601. #define BN_MP_CLEAR_C
  602. #endif
  603. #if defined(BN_MP_PRIME_RABIN_MILLER_TRIALS_C)
  604. #endif
  605. #if defined(BN_MP_PRIME_RANDOM_EX_C)
  606. #define BN_MP_READ_UNSIGNED_BIN_C
  607. #define BN_MP_PRIME_IS_PRIME_C
  608. #define BN_MP_SUB_D_C
  609. #define BN_MP_DIV_2_C
  610. #define BN_MP_MUL_2_C
  611. #define BN_MP_ADD_D_C
  612. #endif
  613. #if defined(BN_MP_RADIX_SIZE_C)
  614. #define BN_MP_COUNT_BITS_C
  615. #define BN_MP_INIT_COPY_C
  616. #define BN_MP_ISZERO_C
  617. #define BN_MP_DIV_D_C
  618. #define BN_MP_CLEAR_C
  619. #endif
  620. #if defined(BN_MP_RADIX_SMAP_C)
  621. #define BN_MP_S_RMAP_C
  622. #endif
  623. #if defined(BN_MP_RAND_C)
  624. #define BN_MP_ZERO_C
  625. #define BN_MP_ADD_D_C
  626. #define BN_MP_LSHD_C
  627. #endif
  628. #if defined(BN_MP_READ_RADIX_C)
  629. #define BN_MP_ZERO_C
  630. #define BN_MP_S_RMAP_C
  631. #define BN_MP_RADIX_SMAP_C
  632. #define BN_MP_MUL_D_C
  633. #define BN_MP_ADD_D_C
  634. #define BN_MP_ISZERO_C
  635. #endif
  636. #if defined(BN_MP_READ_SIGNED_BIN_C)
  637. #define BN_MP_READ_UNSIGNED_BIN_C
  638. #endif
  639. #if defined(BN_MP_READ_UNSIGNED_BIN_C)
  640. #define BN_MP_GROW_C
  641. #define BN_MP_ZERO_C
  642. #define BN_MP_MUL_2D_C
  643. #define BN_MP_CLAMP_C
  644. #endif
  645. #if defined(BN_MP_REDUCE_C)
  646. #define BN_MP_REDUCE_SETUP_C
  647. #define BN_MP_INIT_COPY_C
  648. #define BN_MP_RSHD_C
  649. #define BN_MP_MUL_C
  650. #define BN_S_MP_MUL_HIGH_DIGS_C
  651. #define BN_FAST_S_MP_MUL_HIGH_DIGS_C
  652. #define BN_MP_MOD_2D_C
  653. #define BN_S_MP_MUL_DIGS_C
  654. #define BN_MP_SUB_C
  655. #define BN_MP_CMP_D_C
  656. #define BN_MP_SET_C
  657. #define BN_MP_LSHD_C
  658. #define BN_MP_ADD_C
  659. #define BN_MP_CMP_C
  660. #define BN_S_MP_SUB_C
  661. #define BN_MP_CLEAR_C
  662. #endif
  663. #if defined(BN_MP_REDUCE_2K_C)
  664. #define BN_MP_INIT_C
  665. #define BN_MP_COUNT_BITS_C
  666. #define BN_MP_DIV_2D_C
  667. #define BN_MP_MUL_D_C
  668. #define BN_S_MP_ADD_C
  669. #define BN_MP_CMP_MAG_C
  670. #define BN_S_MP_SUB_C
  671. #define BN_MP_CLEAR_C
  672. #endif
  673. #if defined(BN_MP_REDUCE_2K_L_C)
  674. #define BN_MP_INIT_C
  675. #define BN_MP_COUNT_BITS_C
  676. #define BN_MP_DIV_2D_C
  677. #define BN_MP_MUL_C
  678. #define BN_S_MP_ADD_C
  679. #define BN_MP_CMP_MAG_C
  680. #define BN_S_MP_SUB_C
  681. #define BN_MP_CLEAR_C
  682. #endif
  683. #if defined(BN_MP_REDUCE_2K_SETUP_C)
  684. #define BN_MP_INIT_C
  685. #define BN_MP_COUNT_BITS_C
  686. #define BN_MP_2EXPT_C
  687. #define BN_MP_CLEAR_C
  688. #define BN_S_MP_SUB_C
  689. #endif
  690. #if defined(BN_MP_REDUCE_2K_SETUP_L_C)
  691. #define BN_MP_INIT_C
  692. #define BN_MP_2EXPT_C
  693. #define BN_MP_COUNT_BITS_C
  694. #define BN_S_MP_SUB_C
  695. #define BN_MP_CLEAR_C
  696. #endif
  697. #if defined(BN_MP_REDUCE_IS_2K_C)
  698. #define BN_MP_REDUCE_2K_C
  699. #define BN_MP_COUNT_BITS_C
  700. #endif
  701. #if defined(BN_MP_REDUCE_IS_2K_L_C)
  702. #endif
  703. #if defined(BN_MP_REDUCE_SETUP_C)
  704. #define BN_MP_2EXPT_C
  705. #define BN_MP_DIV_C
  706. #endif
  707. #if defined(BN_MP_RSHD_C)
  708. #define BN_MP_ZERO_C
  709. #endif
  710. #if defined(BN_MP_SET_C)
  711. #define BN_MP_ZERO_C
  712. #endif
  713. #if defined(BN_MP_SET_INT_C)
  714. #define BN_MP_ZERO_C
  715. #define BN_MP_MUL_2D_C
  716. #define BN_MP_CLAMP_C
  717. #endif
  718. #if defined(BN_MP_SHRINK_C)
  719. #endif
  720. #if defined(BN_MP_SIGNED_BIN_SIZE_C)
  721. #define BN_MP_UNSIGNED_BIN_SIZE_C
  722. #endif
  723. #if defined(BN_MP_SQR_C)
  724. #define BN_MP_TOOM_SQR_C
  725. #define BN_MP_KARATSUBA_SQR_C
  726. #define BN_FAST_S_MP_SQR_C
  727. #define BN_S_MP_SQR_C
  728. #endif
  729. #if defined(BN_MP_SQRMOD_C)
  730. #define BN_MP_INIT_C
  731. #define BN_MP_SQR_C
  732. #define BN_MP_CLEAR_C
  733. #define BN_MP_MOD_C
  734. #endif
  735. #if defined(BN_MP_SQRT_C)
  736. #define BN_MP_N_ROOT_C
  737. #define BN_MP_ISZERO_C
  738. #define BN_MP_ZERO_C
  739. #define BN_MP_INIT_COPY_C
  740. #define BN_MP_RSHD_C
  741. #define BN_MP_DIV_C
  742. #define BN_MP_ADD_C
  743. #define BN_MP_DIV_2_C
  744. #define BN_MP_CMP_MAG_C
  745. #define BN_MP_EXCH_C
  746. #define BN_MP_CLEAR_C
  747. #endif
  748. #if defined(BN_MP_SUB_C)
  749. #define BN_S_MP_ADD_C
  750. #define BN_MP_CMP_MAG_C
  751. #define BN_S_MP_SUB_C
  752. #endif
  753. #if defined(BN_MP_SUB_D_C)
  754. #define BN_MP_GROW_C
  755. #define BN_MP_ADD_D_C
  756. #define BN_MP_CLAMP_C
  757. #endif
  758. #if defined(BN_MP_SUBMOD_C)
  759. #define BN_MP_INIT_C
  760. #define BN_MP_SUB_C
  761. #define BN_MP_CLEAR_C
  762. #define BN_MP_MOD_C
  763. #endif
  764. #if defined(BN_MP_TO_SIGNED_BIN_C)
  765. #define BN_MP_TO_UNSIGNED_BIN_C
  766. #endif
  767. #if defined(BN_MP_TO_SIGNED_BIN_N_C)
  768. #define BN_MP_SIGNED_BIN_SIZE_C
  769. #define BN_MP_TO_SIGNED_BIN_C
  770. #endif
  771. #if defined(BN_MP_TO_UNSIGNED_BIN_C)
  772. #define BN_MP_INIT_COPY_C
  773. #define BN_MP_ISZERO_C
  774. #define BN_MP_DIV_2D_C
  775. #define BN_MP_CLEAR_C
  776. #endif
  777. #if defined(BN_MP_TO_UNSIGNED_BIN_N_C)
  778. #define BN_MP_UNSIGNED_BIN_SIZE_C
  779. #define BN_MP_TO_UNSIGNED_BIN_C
  780. #endif
  781. #if defined(BN_MP_TOOM_MUL_C)
  782. #define BN_MP_INIT_MULTI_C
  783. #define BN_MP_MOD_2D_C
  784. #define BN_MP_COPY_C
  785. #define BN_MP_RSHD_C
  786. #define BN_MP_MUL_C
  787. #define BN_MP_MUL_2_C
  788. #define BN_MP_ADD_C
  789. #define BN_MP_SUB_C
  790. #define BN_MP_DIV_2_C
  791. #define BN_MP_MUL_2D_C
  792. #define BN_MP_MUL_D_C
  793. #define BN_MP_DIV_3_C
  794. #define BN_MP_LSHD_C
  795. #define BN_MP_CLEAR_MULTI_C
  796. #endif
  797. #if defined(BN_MP_TOOM_SQR_C)
  798. #define BN_MP_INIT_MULTI_C
  799. #define BN_MP_MOD_2D_C
  800. #define BN_MP_COPY_C
  801. #define BN_MP_RSHD_C
  802. #define BN_MP_SQR_C
  803. #define BN_MP_MUL_2_C
  804. #define BN_MP_ADD_C
  805. #define BN_MP_SUB_C
  806. #define BN_MP_DIV_2_C
  807. #define BN_MP_MUL_2D_C
  808. #define BN_MP_MUL_D_C
  809. #define BN_MP_DIV_3_C
  810. #define BN_MP_LSHD_C
  811. #define BN_MP_CLEAR_MULTI_C
  812. #endif
  813. #if defined(BN_MP_TORADIX_C)
  814. #define BN_MP_ISZERO_C
  815. #define BN_MP_INIT_COPY_C
  816. #define BN_MP_DIV_D_C
  817. #define BN_MP_CLEAR_C
  818. #define BN_MP_S_RMAP_C
  819. #endif
  820. #if defined(BN_MP_TORADIX_N_C)
  821. #define BN_MP_ISZERO_C
  822. #define BN_MP_INIT_COPY_C
  823. #define BN_MP_DIV_D_C
  824. #define BN_MP_CLEAR_C
  825. #define BN_MP_S_RMAP_C
  826. #endif
  827. #if defined(BN_MP_UNSIGNED_BIN_SIZE_C)
  828. #define BN_MP_COUNT_BITS_C
  829. #endif
  830. #if defined(BN_MP_XOR_C)
  831. #define BN_MP_INIT_COPY_C
  832. #define BN_MP_CLAMP_C
  833. #define BN_MP_EXCH_C
  834. #define BN_MP_CLEAR_C
  835. #endif
  836. #if defined(BN_MP_ZERO_C)
  837. #endif
  838. #if defined(BN_PRIME_TAB_C)
  839. #endif
  840. #if defined(BN_REVERSE_C)
  841. #endif
  842. #if defined(BN_S_MP_ADD_C)
  843. #define BN_MP_GROW_C
  844. #define BN_MP_CLAMP_C
  845. #endif
  846. #if defined(BN_S_MP_EXPTMOD_C)
  847. #define BN_MP_COUNT_BITS_C
  848. #define BN_MP_INIT_C
  849. #define BN_MP_CLEAR_C
  850. #define BN_MP_REDUCE_SETUP_C
  851. #define BN_MP_REDUCE_C
  852. #define BN_MP_REDUCE_2K_SETUP_L_C
  853. #define BN_MP_REDUCE_2K_L_C
  854. #define BN_MP_MOD_C
  855. #define BN_MP_COPY_C
  856. #define BN_MP_SQR_C
  857. #define BN_MP_MUL_C
  858. #define BN_MP_SET_C
  859. #define BN_MP_EXCH_C
  860. #endif
  861. #if defined(BN_S_MP_MUL_DIGS_C)
  862. #define BN_FAST_S_MP_MUL_DIGS_C
  863. #define BN_MP_INIT_SIZE_C
  864. #define BN_MP_CLAMP_C
  865. #define BN_MP_EXCH_C
  866. #define BN_MP_CLEAR_C
  867. #endif
  868. #if defined(BN_S_MP_MUL_HIGH_DIGS_C)
  869. #define BN_FAST_S_MP_MUL_HIGH_DIGS_C
  870. #define BN_MP_INIT_SIZE_C
  871. #define BN_MP_CLAMP_C
  872. #define BN_MP_EXCH_C
  873. #define BN_MP_CLEAR_C
  874. #endif
  875. #if defined(BN_S_MP_SQR_C)
  876. #define BN_MP_INIT_SIZE_C
  877. #define BN_MP_CLAMP_C
  878. #define BN_MP_EXCH_C
  879. #define BN_MP_CLEAR_C
  880. #endif
  881. #if defined(BN_S_MP_SUB_C)
  882. #define BN_MP_GROW_C
  883. #define BN_MP_CLAMP_C
  884. #endif
  885. #if defined(BNCORE_C)
  886. #endif
  887. #ifdef LTM3
  888. #define LTM_LAST
  889. #endif
  890. #include "mpi_superclass.h"
  891. #include "mpi_class.h"
  892. #else
  893. #define LTM_LAST
  894. #endif