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; 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 #ifndef RSA_INTERNAL_H
22 #define RSA_INTERNAL_H
23
24 /* RSA Keys, includes both Private and Public key */
25 typedef struct {
26   int bits;                     /* bits in key */
27   SilcMPInt n;                  /* modulus */
28   SilcMPInt e;                  /* public exponent */
29   SilcMPInt d;                  /* private exponent (no CRT) */
30   SilcMPInt p;                  /* p */
31   SilcMPInt q;                  /* q */
32   SilcMPInt dP;                 /* CRT, d mod p - 1 */
33   SilcMPInt dQ;                 /* CRT, d mod q - 1 */
34   SilcMPInt pQ;                 /* CRT, p * (p ^ -1 mod q) mod n */
35   SilcMPInt qP;                 /* CRT, q * (q ^ -1 mod p) mod n */
36   unsigned int pub_set : 1;     /* TRUE if n and e is set */
37   unsigned int prv_set : 1;     /* TRUE if d is set */
38   unsigned int crt     : 1;     /* TRUE if CRT is used */
39 } RsaKey;
40
41 bool rsa_generate_keys(RsaKey *key, SilcUInt32 bits,
42                        SilcMPInt *p, SilcMPInt *q);
43 bool rsa_clear_keys(RsaKey *key);
44 bool rsa_public_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
45 bool rsa_private_operation(RsaKey *key, SilcMPInt *src, SilcMPInt *dst);
46
47 #endif