Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / bignum.h
blob746b21fd49b97283c57694dfeb6181e6ae3cf469
1 /* bignum.h
3 * bignum operations that are missing from gmp.
4 */
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001 Niels Möller
9 *
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02111-1301, USA.
26 #ifndef NETTLE_BIGNUM_H_INCLUDED
27 #define NETTLE_BIGNUM_H_INCLUDED
29 #include "nettle-meta.h"
31 #include <gmp.h>
32 #include "nettle-types.h"
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 /* Size needed for signed encoding, including extra sign byte if
39 * necessary. */
40 unsigned
41 nettle_mpz_sizeinbase_256_s(const mpz_t x);
43 /* Size needed for unsigned encoding */
44 unsigned
45 nettle_mpz_sizeinbase_256_u(const mpz_t x);
47 /* Writes an integer as length octets, using big endian byte order,
48 * and two's complement for negative numbers. */
49 void
50 nettle_mpz_get_str_256(unsigned length, uint8_t *s, const mpz_t x);
52 /* Reads a big endian, two's complement, integer. */
53 void
54 nettle_mpz_set_str_256_s(mpz_t x,
55 unsigned length, const uint8_t *s);
57 void
58 nettle_mpz_init_set_str_256_s(mpz_t x,
59 unsigned length, const uint8_t *s);
61 /* Similar, but for unsigned format. These function don't interpret
62 * the most significant bit as the sign. */
63 void
64 nettle_mpz_set_str_256_u(mpz_t x,
65 unsigned length, const uint8_t *s);
67 void
68 nettle_mpz_init_set_str_256_u(mpz_t x,
69 unsigned length, const uint8_t *s);
71 /* Returns a uniformly distributed random number 0 <= x < 2^n */
72 void
73 nettle_mpz_random_size(mpz_t x,
74 void *ctx, nettle_random_func *random,
75 unsigned bits);
77 /* Returns a number x, almost uniformly random in the range
78 * 0 <= x < n. */
79 void
80 nettle_mpz_random(mpz_t x,
81 void *ctx, nettle_random_func *random,
82 const mpz_t n);
84 void
85 nettle_next_prime(mpz_t p, mpz_t n, unsigned count, unsigned prime_limit,
86 void *progress_ctx, nettle_progress_func *progress);
88 void
89 nettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,
90 void *ctx, nettle_random_func *random,
91 void *progress_ctx, nettle_progress_func *progress);
93 void
94 _nettle_generate_pocklington_prime (mpz_t p, mpz_t r,
95 unsigned bits, int top_bits_set,
96 void *ctx, nettle_random_func *random,
97 const mpz_t p0,
98 const mpz_t q,
99 const mpz_t p0q);
101 /* sexp parsing */
102 struct sexp_iterator;
104 /* If LIMIT is non-zero, the number must be at most LIMIT bits.
105 * Implies sexp_iterator_next. */
107 nettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i);
110 /* der parsing */
111 struct asn1_der_iterator;
114 nettle_asn1_der_get_bignum(struct asn1_der_iterator *iterator,
115 mpz_t x, unsigned max_bits);
117 #ifdef __cplusplus
119 #endif
121 #endif /* NETTLE_BIGNUM_H_INCLUDED */