64510b1dfc72227409f90c641bdc41dd081cbcce
[silc.git] / lib / silcmath / silcmath.h
1 /*
2
3   silcmath.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/SILC Math Interface
22  *
23  * DESCRIPTION
24  *
25  * SILC Math interface includes various utility functions such as
26  * prime generation, and conversion routines. See the silcmp.h for the
27  * SILC MP interface.
28  *
29  ***/
30
31 #ifndef SILCMATH_H
32 #define SILCMATH_H
33
34 #include "silcrng.h"
35
36 /****f* silcmath/SilcMathAPI/silc_math_gen_prime
37  *
38  * SYNOPSIS
39  *
40  *    int silc_math_gen_prime(SilcMPInt *prime, SilcUInt32 bits, bool verbose,
41  *                            SilcRng);
42  *
43  * DESCRIPTION
44  *
45  *    Find appropriate prime. It generates a number by taking random bytes. 
46  *    It then tests the number that it's not divisible by any of the small 
47  *    primes and then it performs Fermat's prime test. I thank Rieks Joosten 
48  *    (r.joosten@pijnenburg.nl) for such a good help with prime tests. 
49  *
50  *    If argument verbose is TRUE this will display some status information
51  *    about the progress of generation.  If the `rng' is NULL then global
52  *    RNG is used, if non-NULL then `rng' is used to generate the random
53  *    number number.
54  *
55  ***/
56 bool silc_math_gen_prime(SilcMPInt *prime, SilcUInt32 bits, bool verbose,
57                          SilcRng rng);
58
59 /****f* silcmath/SilcMathAPI/silc_math_prime_test
60  *
61  * SYNOPSIS
62  *
63  *    int silc_math_prime_test(SilcMPInt *p);
64  *
65  * DESCRIPTION
66  *
67  *    Performs primality testings for given number. Returns TRUE if the 
68  *    number is probably a prime.
69  *
70  ***/
71 bool silc_math_prime_test(SilcMPInt *p);
72
73 #endif