Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / rsa2sexp.c
blob156aad8d030750581d0a929558b4fb3b8c723a75
1 /* rsa2sexp.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 "rsa.h"
31 #include "sexp.h"
33 int
34 rsa_keypair_to_sexp(struct nettle_buffer *buffer,
35 const char *algorithm_name,
36 const struct rsa_public_key *pub,
37 const struct rsa_private_key *priv)
39 if (!algorithm_name)
40 algorithm_name = "rsa-pkcs1";
42 if (priv)
43 return sexp_format(buffer,
44 "(private-key(%0s(n%b)(e%b)"
45 "(d%b)(p%b)(q%b)(a%b)(b%b)(c%b)))",
46 algorithm_name, pub->n, pub->e,
47 priv->d, priv->p, priv->q,
48 priv->a, priv->b, priv->c);
49 else
50 return sexp_format(buffer, "(public-key(%0s(n%b)(e%b)))",
51 algorithm_name, pub->n, pub->e);