Integer type name change.
[silc.git] / lib / silcmath / silcmp.h
1 /*
2
3   silcmp.h
4  
5   Author: Pekka Riikonen <priikone@silcnet.org>
6  
7   Copyright (C) 1997 - 2001 Pekka Riikonen
8  
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13  
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18  
19 */
20
21 /****h* silcmath/SilcMPAPI
22  *
23  * DESCRIPTION
24  *
25  * SILC MP Library Interface. This interface defines the arbitrary
26  * precision arithmetic routines for SILC. Currently the actual routines
27  * are implemented separately, usually by some other MP library. The
28  * interface is generic but is mainly intended for crypto usage. This
29  * interface is used by SILC routines that needs big numbers, such as
30  * RSA implementation, Diffie-Hellman implementation etc.
31  *
32  ***/
33
34 #ifndef SILCMP_H
35 #define SILCMP_H
36
37 #ifdef SILC_MP_GMP
38 #include "mp_gmp.h"             /* SILC_MP_GMP */
39 #else
40 #include "mp_mpi.h"             /* SILC_MP_NSS_MPI */
41 #endif
42
43 /****d* silcmath/SilcMPAPI/SilcMPInt
44  *
45  * NAME
46  *
47  *    typedef SILC_MP_INT SilcMPInt;
48  *
49  * DESCRIPTION
50  *
51  *    The SILC MP Integer definition. This is the actual MP integer.
52  *    The type is defined as SILC_MP_INT as it is implementation specific
53  *    and is unknown to the application.
54  *
55  * SOURCE
56  */
57 typedef SILC_MP_INT SilcMPInt;
58 /***/
59
60 /****f* silcmath/SilcMPAPI/silc_mp_init
61  *
62  * SYNOPSIS
63  *
64  *    void silc_mp_init(SilcMPInt mp);
65  *
66  * DESCRIPTION
67  *
68  *    Initializes the SilcMPInt *that is the actual MP Integer.
69  *    This must be called before any of the silc_mp_ routines can be
70  *    used. The integer is uninitialized with the silc_mp_uninit function.
71  *
72  ***/
73 void silc_mp_init(SilcMPInt *mp);
74
75 /****f* silcmath/SilcMPAPI/silc_mp_uninit
76  *
77  * SYNOPSIS
78  *
79  *    void silc_mp_uninit(SilcMPInt *mp);
80  *
81  * DESCRIPTION
82  *
83  *    Uninitializes the MP Integer.
84  *
85  ***/
86 void silc_mp_uninit(SilcMPInt *mp);
87
88 /****f* silcmath/SilcMPAPI/silc_mp_size
89  *
90  * SYNOPSIS
91  *
92  *    size_t silc_mp_size(SilcMPInt *mp);
93  *
94  * DESCRIPTION
95  *
96  *    Return the precision size of the integer `mp'.
97  *
98  ***/
99 size_t silc_mp_size(SilcMPInt *mp);
100
101 /****f* silcmath/SilcMPAPI/silc_mp_sizeinbase
102  *
103  * SYNOPSIS
104  *
105  *    size_t silc_mp_sizeinbase(SilcMPInt *mp, int base);
106  *
107  * DESCRIPTION
108  *
109  *    Return the size of the integer in base `base'. Note that this size
110  *    is probably only an approximation.  However, it is guaranteed that
111  *    the returned size is always at least the size of the integer, however,
112  *    it may be larger.
113  *
114  ***/
115 size_t silc_mp_sizeinbase(SilcMPInt *mp, int base);
116
117 /****f* silcmath/SilcMPAPI/silc_mp_set
118  *
119  * SYNOPSIS
120  *
121  *    void silc_mp_set(SilcMPInt *dst, SilcMPInt *src);
122  *
123  * DESCRIPTION
124  *
125  *    Set `dst' integer from `src' integer. The `dst' must already be
126  *    initialized.
127  *
128  ***/
129 void silc_mp_set(SilcMPInt *dst, SilcMPInt *src);
130
131 /****f* silcmath/SilcMPAPI/silc_mp_set_ui
132  *
133  * SYNOPSIS
134  *
135  *    void silc_mp_set_ui(SilcMPInt *dst, SilcUInt32 ui);
136  *
137  * DESCRIPTION
138  *
139  *    Set `dst' integer from unsigned word `ui'. The `dst' must already be
140  *    initialized.
141  *
142  ***/
143 void silc_mp_set_ui(SilcMPInt *dst, SilcUInt32 ui);
144
145 /****f* silcmath/SilcMPAPI/silc_mp_set_si
146  *
147  * SYNOPSIS
148  *
149  *    void silc_mp_set_si(SilcMPInt *dst, SilcInt32 si);
150  *
151  * DESCRIPTION
152  *
153  *    Set `dst' integer from single word `si'. The `dst' must
154  *    already be initialized.
155  *
156  ***/
157 void silc_mp_set_si(SilcMPInt *dst, SilcInt32 si);
158
159 /****f* silcmath/SilcMPAPI/silc_mp_set_str
160  *
161  * SYNOPSIS
162  *
163  *    void silc_mp_set_str(SilcMPInt *dst, const char *str, int base);
164  *
165  * DESCRIPTION
166  *
167  *    Set `dst' integer from string `str' of base `base'. The `dst' must
168  *    already be initialized.
169  *
170  ***/
171 void silc_mp_set_str(SilcMPInt *dst, const char *str, int base);
172
173 /****f* silcmath/SilcMPAPI/silc_mp_get_ui
174  *
175  * SYNOPSIS
176  *
177  *    SilcUInt32 silc_mp_get_ui(SilcMPInt *mp);
178  *
179  * DESCRIPTION
180  *
181  *    Returns the least significant unsigned word from `mp'.
182  *
183  ***/
184 SilcUInt32 silc_mp_get_ui(SilcMPInt *mp);
185
186 /****f* silcmath/SilcMPAPI/silc_mp_get_str
187  *
188  * SYNOPSIS
189  *
190  *    void silc_mp_get_str(char *str, SilcMPInt *mp, int base);
191  *
192  * DESCRIPTION
193  *
194  *    Converts integer `mp' into a string of base `base'. The `str'
195  *    must already have space allocated. The function returns the same
196  *    as `str' or NULL on error.
197  *
198  ***/
199 char *silc_mp_get_str(char *str, SilcMPInt *mp, int base);
200
201 /****f* silcmath/SilcMPAPI/silc_mp_add
202  *
203  * SYNOPSIS
204  *
205  *    void silc_mp_add(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
206  *
207  * DESCRIPTION
208  *
209  *    Add two integers `mp1' and `mp2' and save the result to `dst'.
210  *
211  ***/
212 void silc_mp_add(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
213
214 /****f* silcmath/SilcMPAPI/silc_mp_add_ui
215  *
216  * SYNOPSIS
217  *
218  *    void silc_mp_add_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
219  *
220  * DESCRIPTION
221  *
222  *    Add two integers `mp1' and unsigned word `ui' and save the result
223  *    to `dst'.
224  *
225  ***/
226 void silc_mp_add_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
227
228 /****f* silcmath/SilcMPAPI/silc_mp_sub
229  *
230  * SYNOPSIS
231  *
232  *    void silc_mp_sub(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
233  *
234  * DESCRIPTION
235  *
236  *    Subtract two integers `mp1' and `mp2' and save the result to `dst'.
237  *
238  ***/
239 void silc_mp_sub(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
240
241 /****f* silcmath/SilcMPAPI/silc_mp_sub_ui
242  *
243  * SYNOPSIS
244  *
245  *    void silc_mp_sub_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
246  *
247  * DESCRIPTION
248  *
249  *    Subtract integers `mp1' and unsigned word `ui' and save the result
250  *    to `dst'.
251  *
252  ***/
253 void silc_mp_sub_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
254
255 /****f* silcmath/SilcMPAPI/silc_mp_mul
256  *
257  * SYNOPSIS
258  *
259  *    void silc_mp_mul(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
260  *
261  * DESCRIPTION
262  *
263  *    Multiply two integers `mp1' and `mp2' and save the result to `dst'.
264  *
265  ***/
266 void silc_mp_mul(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
267
268 /****f* silcmath/SilcMPAPI/silc_mp_mul_ui
269  *
270  * SYNOPSIS
271  *
272  *    void silc_mp_mul_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
273  *
274  * DESCRIPTION
275  *
276  *    Multiply integer `mp1' and unsigned word `ui' and save the result
277  *    to `dst'.
278  *
279  ***/
280 void silc_mp_mul_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
281
282 /****f* silcmath/SilcMPAPI/silc_mp_mul_2exp
283  *
284  * SYNOPSIS
285  *
286  *    void silc_mp_mul_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp);
287  *
288  * DESCRIPTION
289  *
290  *    Multiply integers `mp1' with 2 ** `exp' and save the result to 
291  *    `dst'. This is equivalent to dst = mp1 * (2 ^ exp).
292  *
293  ***/
294 void silc_mp_mul_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp);
295
296 /****f* silcmath/SilcMPAPI/silc_mp_sqrt
297  *
298  * SYNOPSIS
299  *
300  *    void silc_mp_sqrt(SilcMPInt *dst, SilcMPInt *src);
301  *
302  * DESCRIPTION
303  *
304  *    Compute square root of floor(sqrt(src)) and save the result to `dst'.
305  *
306  ***/
307 void silc_mp_sqrt(SilcMPInt *dst, SilcMPInt *src);
308
309 /****f* silcmath/SilcMPAPI/silc_mp_div
310  *
311  * SYNOPSIS
312  *
313  *    void silc_mp_div(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
314  *
315  * DESCRIPTION
316  *
317  *    Divide the `mp1' and `mp2' and save the result to the `dst'. This
318  *    is equivalent to dst = mp1 / mp2;
319  *
320  ***/
321 void silc_mp_div(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
322
323 /****f* silcmath/SilcMPAPI/silc_mp_div_ui
324  *
325  * SYNOPSIS
326  *
327  *    void silc_mp_div_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
328  *
329  * DESCRIPTION
330  *
331  *    Divide the `mp1' and unsigned word `ui' and save the result to the
332  *    `dst'. This is equivalent to dst = mp1 / ui;
333  *
334  ***/
335 void silc_mp_div_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
336
337 /****f* silcmath/SilcMPAPI/silc_mp_div_qr
338  *
339  * SYNOPSIS
340  *
341  *    void silc_mp_div_qr(SilcMPInt *q, SilcMPInt *r, SilcMPInt *mp1, 
342  *                        SilcMPInt *mp2);
343  *
344  * DESCRIPTION
345  *
346  *    Divide the `mp1' and `mp2' and save the quotient to the `q' and
347  *    the remainder to the `r'.  This is equivalent to the q = mp1 / mp2, 
348  *    r = mp1 mod mp2 (or mp1 = mp2 * q + r). If the `q' or `r' is NULL
349  *    then the operation is omitted.
350  *
351  ***/
352 void silc_mp_div_qr(SilcMPInt *q, SilcMPInt *r, SilcMPInt *mp1, 
353                     SilcMPInt *mp2);
354
355 /****f* silcmath/SilcMPAPI/silc_mp_div_2exp
356  *
357  * SYNOPSIS
358  *
359  *    void silc_mp_div_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
360  *
361  * DESCRIPTION
362  *
363  *    Divide the `mp1' with 2 ** `exp' and save the result to `dst'.
364  *    This is equivalent to dst = mp1 / (2 ^ exp).
365  *
366  ***/
367 void silc_mp_div_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp);
368
369 /****f* silcmath/SilcMPAPI/silc_mp_div_2exp_qr
370  *
371  * SYNOPSIS
372  *
373  *    void silc_mp_div_2exp_qr(SilcMPInt *q, SilcMPInt *r, SilcMPInt *mp1, 
374  *                             SilcUInt32 exp);
375  *
376  * DESCRIPTION
377  *
378  *    Divide the `mp1' with 2 ** `exp' and save the quotient to `q' and
379  *    the remainder to `r'. This is equivalent to q = mp1 / (2 ^ exp),
380  *    r = mp1 mod (2 ^ exp). If the `q' or `r' is NULL then the operation
381  *    is omitted.
382  *
383  ***/
384 void silc_mp_div_2exp_qr(SilcMPInt *q, SilcMPInt *r, SilcMPInt *mp1, 
385                          SilcUInt32 exp);
386
387 /****f* silcmath/SilcMPAPI/silc_mp_mod
388  *
389  * SYNOPSIS
390  *
391  *    void silc_mp_mod(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
392  *
393  * DESCRIPTION
394  *
395  *    Mathematical MOD function. Produces the remainder of `mp1' and `mp2'
396  *    and saves the result to `dst'. This is equivalent to dst = mp1 mod mp2.
397  *    The same result can also be get with silc_mp_div_qr as that function
398  *    returns the remainder as well.
399  *
400  ***/
401 void silc_mp_mod(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
402
403 /****f* silcmath/SilcMPAPI/silc_mp_mod_ui
404  *
405  * SYNOPSIS
406  *
407  *    void silc_mp_mod_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
408  *
409  * DESCRIPTION
410  *
411  *    Mathematical MOD function. Produces the remainder of `mp1' and 
412  *    unsigned word `ui' and saves the result to `dst'. This is equivalent
413  *    to dst = mp1 mod ui.
414  *
415  ***/
416 void silc_mp_mod_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
417
418 /****f* silcmath/SilcMPAPI/silc_mp_mod_2exp
419  *
420  * SYNOPSIS
421  *
422  *    void silc_mp_mod_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
423  *
424  * DESCRIPTION
425  *
426  *    Computes the remainder of `mp1' with 2 ** `exp' and saves the
427  *    result to `dst'. This is equivalent to dst = mp1 mod (2 ^ exp).
428  *    The same result can also be get with silc_mp_div_2exp_qr as that
429  *    function returns the remainder as well.
430  *
431  ***/
432 void silc_mp_mod_2exp(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 ui);
433
434 /****f* silcmath/SilcMPAPI/silc_mp_pow
435  *
436  * SYNOPSIS
437  *
438  *    void silc_mp_pow(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *exp);
439  *
440  * DESCRIPTION
441  *
442  *    Compute `mp1' ** `exp' and save the result to `dst'. This is
443  *    equivalent to dst = mp1 ^ exp.
444  *
445  ***/
446 void silc_mp_pow(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *exp);
447
448 /****f* silcmath/SilcMPAPI/silc_mp_pow_ui
449  *
450  * SYNOPSIS
451  *
452  *    void silc_mp_pow_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp);
453  *
454  * DESCRIPTION
455  *
456  *    Compute `mp1' ** `exp' and save the result to `dst'. This is
457  *    equivalent to dst = mp1 ^ exp.
458  *
459  ***/
460 void silc_mp_pow_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp);
461
462 /****f* silcmath/SilcMPAPI/silc_mp_pow_mod
463  *
464  * SYNOPSIS
465  *
466  *    void silc_mp_pow_mod(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *exp, 
467  *                         SilcMPInt *mod);
468  *
469  * DESCRIPTION
470  *
471  *    Compute (`mp1' ** `exp') mod `mod' and save the result to `dst'.
472  *    This is equivalent to dst = (mp1 ^ exp) mod mod.
473  *
474  ***/
475 void silc_mp_pow_mod(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *exp, 
476                      SilcMPInt *mod);
477
478 /****f* silcmath/SilcMPAPI/silc_mp_pow_mod_ui
479  *
480  * SYNOPSIS
481  *
482  *    void silc_mp_pow_mod_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp, 
483  *                            SilcMPInt *mod);
484  *
485  * DESCRIPTION
486  *
487  *    Compute (`mp1' ** `exp') mod `mod' and save the result to `dst'.
488  *    This is equivalent to dst = (mp1 ^ exp) mod mod.
489  *
490  ***/
491 void silc_mp_pow_mod_ui(SilcMPInt *dst, SilcMPInt *mp1, SilcUInt32 exp, 
492                         SilcMPInt *mod);
493
494 /****f* silcmath/SilcMPAPI/silc_mp_modinv
495  *
496  * SYNOPSIS
497  *
498  *    void silc_mp_modinv(SilcMPInt *inv, SilcMPInt *a, SilcMPInt *n);
499  *
500  * DESCRIPTION
501  *
502  *    Find multiplicative inverse using Euclid's extended algorithm. 
503  *    Computes inverse such that a * inv mod n = 1, where 0 < a < n. 
504  *    Algorithm goes like this:
505  *  
506  *    g(0) = n    v(0) = 0
507  *    g(1) = a    v(1) = 1
508  * 
509  *    y = g(i-1) / g(i)
510  *    g(i+1) = g(i-1) - y * g(i) = g(i)-1 mod g(i)
511  *    v(i+1) = v(i-1) - y * v(i)
512  * 
513  *    do until g(i) = 0, then inverse = v(i-1). If inverse is negative then n, 
514  *    is added to inverse making it positive again. (Sometimes the algorithm 
515  *    has a variable u defined too and it behaves just like v, except that 
516  *    initalize values are swapped (i.e. u(0) = 1, u(1) = 0). However, u is 
517  *    not needed by the algorithm so it does not have to be included.)
518  *
519  ***/
520 void silc_mp_modinv(SilcMPInt *inv, SilcMPInt *a, SilcMPInt *n);
521
522 /****f* silcmath/SilcMPAPI/silc_mp_gcd
523  *
524  * SYNOPSIS
525  *
526  *    void silc_mp_gcd(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
527  *
528  * DESCRIPTION
529  *
530  *    Calculate the greatest common divisor of the integers `mp1' and `mp2'
531  *    and save the result to `dst'.
532  *
533  ***/
534 void silc_mp_gcd(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
535
536 /****f* silcmath/SilcMPAPI/silc_mp_gcdext
537  *
538  * SYNOPSIS
539  *
540  *    void silc_mp_gcdext(SilcMPInt *g, SilcMPInt *s, SilcMPInt *t, 
541  *                        SilcMPInt *mp1, SilcMPInt *mp2);
542  *
543  * DESCRIPTION
544  *
545  *    Calculate the extended greatest common divisor `g', `s' and `t' such
546  *    that g = mp1 * s + mp2 * + t.
547  *
548  ***/
549 void silc_mp_gcdext(SilcMPInt *g, SilcMPInt *s, SilcMPInt *t, SilcMPInt *mp1,
550                     SilcMPInt *mp2);
551
552 /****f* silcmath/SilcMPAPI/silc_mp_cmp
553  *
554  * SYNOPSIS
555  *
556  *    int silc_mp_cmp(SilcMPInt *mp1, SilcMPInt *mp2);
557  *
558  * DESCRIPTION
559  *
560  *    Compare `mp1' and `mp2'. Returns posivite, zero, or negative
561  *    if `mp1' > `mp2', `mp1' == `mp2', or `mp1' < `mp2', respectively.
562  *
563  ***/
564 int silc_mp_cmp(SilcMPInt *mp1, SilcMPInt *mp2);
565
566 /****f* silcmath/SilcMPAPI/silc_mp_cmp_si
567  *
568  * SYNOPSIS
569  *
570  *    int silc_mp_cmp_si(SilcMPInt *mp1, SilcInt32 si);
571  *
572  * DESCRIPTION
573  *
574  *    Compare `mp1' and single word `si'. Returns posivite, zero, or negative
575  *    if `mp1' > `si', `mp1' == `si', or `mp1' < `si', respectively.
576  *
577  ***/
578 int silc_mp_cmp_si(SilcMPInt *mp1, SilcInt32 si);
579
580 /****f* silcmath/SilcMPAPI/silc_mp_cmp_ui
581  *
582  * SYNOPSIS
583  *
584  *    int silc_mp_cmp_ui(SilcMPInt *mp1, SilcUInt32 ui);
585  *
586  * DESCRIPTION
587  *
588  *    Compare `mp1' and unsigned word `ui'. Returns posivite, zero, or 
589  *    negative if `mp1' > `ui', `mp1' == `ui', or `mp1' < `ui', 
590  *    respectively.
591  *
592  ***/
593 int silc_mp_cmp_ui(SilcMPInt *mp1, SilcUInt32 ui);
594
595 /****f* silcmath/SilcMPAPI/silc_mp_mp2bin
596  *
597  * SYNOPSIS
598  *
599  *    unsigned char *silc_mp_mp2bin(SilcMPInt *val, SilcUInt32 len, 
600  *                                  SilcUInt32 *ret_len);
601  *
602  * DESCRIPTION
603  *
604  *    Encodes MP integer into binary data. Returns allocated data that
605  *    must be free'd by the caller. If `len' is provided the destination
606  *    buffer is allocated that large. If zero then the size is approximated.
607  *
608  ***/
609 unsigned char *silc_mp_mp2bin(SilcMPInt *val, SilcUInt32 len, 
610                               SilcUInt32 *ret_len);
611
612 /****f* silcmath/SilcMPAPI/silc_mp_mp2bin_noalloc
613  *
614  * SYNOPSIS
615  *
616  *    void silc_mp_mp2bin_noalloc(SilcMPInt *val, unsigned char *dst,
617  *                                SilcUInt32 dst_len);
618  *
619  * DESCRIPTION
620  *
621  *    Same as silc_mp_mp2bin but does not allocate any memory.  The
622  *    encoded data is returned into `dst' and it's length to the `ret_len'.
623  *
624  ***/
625 void silc_mp_mp2bin_noalloc(SilcMPInt *val, unsigned char *dst,
626                             SilcUInt32 dst_len);
627
628 /****f* silcmath/SilcMPAPI/silc_mp_bin2mp
629  *
630  * SYNOPSIS
631  *
632  *    void silc_mp_bin2mp(unsigned char *data, SilcUInt32 len, 
633  *                        SilcMPInt *ret);
634  *
635  * DESCRIPTION
636  *
637  *    Decodes binary data into MP integer. The integer sent as argument
638  *    must be initialized.
639  *
640  ***/
641 void silc_mp_bin2mp(unsigned char *data, SilcUInt32 len, SilcMPInt *ret);
642
643 /****f* silcmath/SilcMPAPI/silc_mp_abs
644  *
645  * SYNOPSIS
646  *
647  *    void silc_mp_abs(SilcMPInt *src, SilcMPInt *dst);
648  *
649  * DESCRIPTION
650  *
651  *    Assign the absolute value of `src' to `dst'.
652  *
653  ***/
654 void silc_mp_abs(SilcMPInt *dst, SilcMPInt *src);
655
656 /****f* silcmath/SilcMPAPI/silc_mp_neg
657  *
658  * SYNOPSIS
659  *
660  *    void silc_mp_neg(SilcMPInt *dst, SilcMPInt *src);
661  *
662  * DESCRIPTION
663  *
664  *    Negate `src' and save the result to `dst'.
665  *
666  ***/
667 void silc_mp_neg(SilcMPInt *dst, SilcMPInt *src);
668
669 /****f* silcmath/SilcMPAPI/silc_mp_and
670  *
671  * SYNOPSIS
672  *
673  *    void silc_mp_and(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
674  *
675  * DESCRIPTION
676  *
677  *    Logical and operator. The result is saved to `dst'.
678  *
679  ***/
680 void silc_mp_and(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
681
682 /****f* silcmath/SilcMPAPI/silc_mp_or
683  *
684  * SYNOPSIS
685  *
686  *    void silc_mp_or(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
687  *
688  * DESCRIPTION
689  *
690  *    Logical inclusive OR operator. The result is saved to `dst'.
691  *
692  ***/
693 void silc_mp_or(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
694
695 /****f* silcmath/SilcMPAPI/silc_mp_xor
696  *
697  * SYNOPSIS
698  *
699  *    void silc_mp_xor(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
700  *
701  * DESCRIPTION
702  *
703  *    Logical exclusive OR operator. The result is saved to `dst'.
704  *
705  ***/
706 void silc_mp_xor(SilcMPInt *dst, SilcMPInt *mp1, SilcMPInt *mp2);
707
708 #endif