cfb8: Fix decrypt path
[gd/nettle] / rsa-internal.h
1 /* rsa-internal.h
2
3    The RSA publickey algorithm.
4
5    Copyright (C) 2001, 2002 Niels Möller
6
7    This file is part of GNU Nettle.
8
9    GNU Nettle is free software: you can redistribute it and/or
10    modify it under the terms of either:
11
12      * the GNU Lesser General Public License as published by the Free
13        Software Foundation; either version 3 of the License, or (at your
14        option) any later version.
15
16    or
17
18      * the GNU General Public License as published by the Free
19        Software Foundation; either version 2 of the License, or (at your
20        option) any later version.
21
22    or both in parallel, as here.
23
24    GNU Nettle is distributed in the hope that it will be useful,
25    but WITHOUT ANY WARRANTY; without even the implied warranty of
26    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27    General Public License for more details.
28
29    You should have received copies of the GNU General Public License and
30    the GNU Lesser General Public License along with this program.  If
31    not, see http://www.gnu.org/licenses/.
32 */
33
34 #ifndef NETTLE_RSA_INTERNAL_H_INCLUDED
35 #define NETTLE_RSA_INTERNAL_H_INCLUDED
36
37 #include "rsa.h"
38
39 #define _rsa_verify _nettle_rsa_verify
40 #define _rsa_verify_recover _nettle_rsa_verify_recover
41 #define _rsa_check_size _nettle_rsa_check_size
42 #define _rsa_blind _nettle_rsa_blind
43 #define _rsa_unblind _nettle_rsa_unblind
44 #define _rsa_sec_compute_root_itch _nettle_rsa_sec_compute_root_itch
45 #define _rsa_sec_compute_root _nettle_rsa_sec_compute_root
46 #define _rsa_sec_compute_root_tr _nettle_rsa_sec_compute_root_tr
47
48 /* Internal functions. */
49 int
50 _rsa_verify(const struct rsa_public_key *key,
51             const mpz_t m,
52             const mpz_t s);
53
54 int
55 _rsa_verify_recover(const struct rsa_public_key *key,
56                     mpz_t m,
57                     const mpz_t s);
58
59 size_t
60 _rsa_check_size(mpz_t n);
61
62 /* _rsa_blind and _rsa_unblind are deprecated, unused in the library,
63    and will likely be removed with the next ABI break. */
64 void
65 _rsa_blind (const struct rsa_public_key *pub,
66             void *random_ctx, nettle_random_func *random,
67             mpz_t c, mpz_t ri) _NETTLE_ATTRIBUTE_DEPRECATED;
68 void
69 _rsa_unblind (const struct rsa_public_key *pub, mpz_t c, const mpz_t ri)
70   _NETTLE_ATTRIBUTE_DEPRECATED;
71
72 /* side-channel silent root computation */
73 mp_size_t
74 _rsa_sec_compute_root_itch(const struct rsa_private_key *key);
75 void
76 _rsa_sec_compute_root(const struct rsa_private_key *key,
77                       mp_limb_t *rp, const mp_limb_t *mp,
78                       mp_limb_t *scratch);
79
80 /* Safe side-channel silent variant, using RSA blinding, and checking the
81  * result after CRT. */
82 int
83 _rsa_sec_compute_root_tr(const struct rsa_public_key *pub,
84                          const struct rsa_private_key *key,
85                          void *random_ctx, nettle_random_func *random,
86                          mp_limb_t *x, const mp_limb_t *m, size_t mn);
87
88 #endif /* NETTLE_RSA_INTERNAL_H_INCLUDED */