Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / sexp2bignum.c
blob10e0c9dde5a1b814cd86462f9281a2219832fb3a
1 /* sexp2bignum.c
3 */
5 /* nettle, low-level cryptographics library
7 * Copyright (C) 2002 Niels Möller
8 *
9 * The nettle library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or (at your
12 * option) any later version.
14 * The nettle library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 * License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the nettle library; see the file COPYING.LIB. If not, write to
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02111-1301, USA.
25 #if HAVE_CONFIG_H
26 # include "config.h"
27 #endif
29 #include "sexp.h"
30 #include "bignum.h"
32 int
33 nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i)
35 if (i->type == SEXP_ATOM
36 && i->atom_length
37 && !i->display)
39 /* Allow some extra here, for leading sign octets. */
40 if (limit && (8 * i->atom_length > (16 + limit)))
41 return 0;
43 nettle_mpz_set_str_256_s(x, i->atom_length, i->atom);
45 /* FIXME: How to interpret a limit for negative numbers? */
46 if (limit && mpz_sizeinbase(x, 2) > limit)
47 return 0;
49 return sexp_iterator_next(i);
51 else
52 return 0;