Merged silc_1_0_branch to trunk.
[silc.git] / lib / silccrypt / rsa_internal.h
1 /*
2
3   rsa_internal.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2003 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; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 #ifndef RSA_INTERNAL_H
21 #define RSA_INTERNAL_H
22
23 /* RSA Keys, includes both Private and Public key */
24 typedef struct {
25   int bits;                     /* bits in key */
26   SilcMPInt n;                  /* modulus */
27   SilcMPInt e;                  /* public exponent */
28   SilcMPInt d;                  /* private exponent (no CRT) */
29   SilcMPInt p;                  /* p */
30   SilcMPInt q;                  /* q */
31   SilcMPInt dP;                 /* CRT, d mod p - 1 */
32   SilcMPInt dQ;                 /* CRT, d mod q - 1 */
33   SilcMPInt pQ;                 /* CRT, p * (p ^ -1 mod q) mod n */
34   SilcMPInt qP;                 /* CRT, q * (q ^ -1 mod p) mod n */
35   unsigned int pub_set : 1;     /* TRUE if n and e is set */
36   unsigned int prv_set : 1;     /* TRUE if d is set */
37   unsigned int crt     : 1;     /* TRUE if CRT is used */
38 } RsaKey;
39
40 bool rsa_generate_keys(RsaKey *key, SilcUInt32 bits,
41                        SilcMPInt *p, SilcMPInt *q);
42 bool rsa_clear_keys(RsaKey *key);
43 bool rsa_public_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
44 bool rsa_private_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
45
46 #endif