Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / rsa-decrypt-tr.c
blob312b182a243f4d2b844048da8ce181b986d7cf0f
1 /* rsa-decrypt-tr.c
3 * RSA decryption, using randomized RSA blinding to be more resistant
4 * to timing attacks.
5 */
7 /* nettle, low-level cryptographics library
9 * Copyright (C) 2001, 2012 Niels Möller, Nikos Mavrogiannopoulos
11 * The nettle library is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or (at your
14 * option) any later version.
16 * The nettle library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with the nettle library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 * MA 02111-1301, USA.
27 #if HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include "rsa.h"
33 #include "bignum.h"
34 #include "pkcs1.h"
36 int
37 rsa_decrypt_tr(const struct rsa_public_key *pub,
38 const struct rsa_private_key *key,
39 void *random_ctx, nettle_random_func *random,
40 unsigned *length, uint8_t *message,
41 const mpz_t gibberish)
43 mpz_t m, ri;
44 int res;
46 mpz_init_set(m, gibberish);
47 mpz_init (ri);
49 _rsa_blind (pub, random_ctx, random, m, ri);
50 rsa_compute_root(key, m, m);
51 _rsa_unblind (pub, m, ri);
52 mpz_clear (ri);
54 res = pkcs1_decrypt (key->size, m, length, message);
55 mpz_clear(m);
56 return res;