Added support for default hash functions in all PKCS algorithm schemes.
[crypto.git] / lib / silccrypt / rsa.h
1 /*
2
3   rsa.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 1997 - 2008 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_H
21 #define RSA_H
22
23 /* RSA Public Key */
24 typedef struct {
25   SilcHash hash;                /* Default hash */
26   SilcMPInt n;                  /* modulus */
27   SilcMPInt e;                  /* public exponent */
28   int bits;                     /* bits in key */
29 } RsaPublicKey;
30
31 /* RSA Private Key */
32 typedef struct {
33   SilcHash hash;                /* Default hash */
34   SilcMPInt n;                  /* modulus */
35   SilcMPInt e;                  /* public exponent */
36   SilcMPInt d;                  /* private exponent */
37   SilcMPInt p;                  /* CRT, p */
38   SilcMPInt q;                  /* CRT, q */
39   SilcMPInt dP;                 /* CRT, d mod p - 1 */
40   SilcMPInt dQ;                 /* CRT, d mod q - 1 */
41   SilcMPInt qP;                 /* CRT, q ^ -1 mod p (aka u, aka qInv) */
42   int bits;                     /* bits in key */
43 } RsaPrivateKey;
44
45 SilcBool silc_rsa_generate_keys(SilcUInt32 bits, SilcMPInt *p, SilcMPInt *q,
46                                 void **ret_public_key, void **ret_private_key);
47 SilcBool silc_rsa_public_operation(RsaPublicKey *key, SilcMPInt *src,
48                                    SilcMPInt *dst);
49 SilcBool silc_rsa_private_operation(RsaPrivateKey *key, SilcMPInt *src,
50                                     SilcMPInt *dst);
51
52 #endif /* RSA_H */