1ebfedea0SLionel Sambuc /* apps/ecparam.c */
2ebfedea0SLionel Sambuc /*
3ebfedea0SLionel Sambuc * Written by Nils Larsch for the OpenSSL project.
4ebfedea0SLionel Sambuc */
5ebfedea0SLionel Sambuc /* ====================================================================
6ebfedea0SLionel Sambuc * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
7ebfedea0SLionel Sambuc *
8ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
9ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
10ebfedea0SLionel Sambuc * are met:
11ebfedea0SLionel Sambuc *
12ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
13ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
14ebfedea0SLionel Sambuc *
15ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
16ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in
17ebfedea0SLionel Sambuc * the documentation and/or other materials provided with the
18ebfedea0SLionel Sambuc * distribution.
19ebfedea0SLionel Sambuc *
20ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this
21ebfedea0SLionel Sambuc * software must display the following acknowledgment:
22ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
23ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24ebfedea0SLionel Sambuc *
25ebfedea0SLionel Sambuc * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26ebfedea0SLionel Sambuc * endorse or promote products derived from this software without
27ebfedea0SLionel Sambuc * prior written permission. For written permission, please contact
28ebfedea0SLionel Sambuc * openssl-core@openssl.org.
29ebfedea0SLionel Sambuc *
30ebfedea0SLionel Sambuc * 5. Products derived from this software may not be called "OpenSSL"
31ebfedea0SLionel Sambuc * nor may "OpenSSL" appear in their names without prior written
32ebfedea0SLionel Sambuc * permission of the OpenSSL Project.
33ebfedea0SLionel Sambuc *
34ebfedea0SLionel Sambuc * 6. Redistributions of any form whatsoever must retain the following
35ebfedea0SLionel Sambuc * acknowledgment:
36ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
37ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38ebfedea0SLionel Sambuc *
39ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40ebfedea0SLionel Sambuc * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42ebfedea0SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43ebfedea0SLionel Sambuc * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44ebfedea0SLionel Sambuc * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45ebfedea0SLionel Sambuc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46ebfedea0SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48ebfedea0SLionel Sambuc * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49ebfedea0SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50ebfedea0SLionel Sambuc * OF THE POSSIBILITY OF SUCH DAMAGE.
51ebfedea0SLionel Sambuc * ====================================================================
52ebfedea0SLionel Sambuc *
53ebfedea0SLionel Sambuc * This product includes cryptographic software written by Eric Young
54ebfedea0SLionel Sambuc * (eay@cryptsoft.com). This product includes software written by Tim
55ebfedea0SLionel Sambuc * Hudson (tjh@cryptsoft.com).
56ebfedea0SLionel Sambuc *
57ebfedea0SLionel Sambuc */
58ebfedea0SLionel Sambuc /* ====================================================================
59ebfedea0SLionel Sambuc * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60ebfedea0SLionel Sambuc *
61ebfedea0SLionel Sambuc * Portions of the attached software ("Contribution") are developed by
62ebfedea0SLionel Sambuc * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
63ebfedea0SLionel Sambuc *
64ebfedea0SLionel Sambuc * The Contribution is licensed pursuant to the OpenSSL open source
65ebfedea0SLionel Sambuc * license provided above.
66ebfedea0SLionel Sambuc *
67ebfedea0SLionel Sambuc * The elliptic curve binary polynomial software is originally written by
68ebfedea0SLionel Sambuc * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
69ebfedea0SLionel Sambuc *
70ebfedea0SLionel Sambuc */
71ebfedea0SLionel Sambuc
72ebfedea0SLionel Sambuc #include <openssl/opensslconf.h>
73ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_EC
74ebfedea0SLionel Sambuc # include <assert.h>
75ebfedea0SLionel Sambuc # include <stdio.h>
76ebfedea0SLionel Sambuc # include <stdlib.h>
77ebfedea0SLionel Sambuc # include <time.h>
78ebfedea0SLionel Sambuc # include <string.h>
79ebfedea0SLionel Sambuc # include "apps.h"
80ebfedea0SLionel Sambuc # include <openssl/bio.h>
81ebfedea0SLionel Sambuc # include <openssl/err.h>
82ebfedea0SLionel Sambuc # include <openssl/bn.h>
83ebfedea0SLionel Sambuc # include <openssl/ec.h>
84ebfedea0SLionel Sambuc # include <openssl/x509.h>
85ebfedea0SLionel Sambuc # include <openssl/pem.h>
86ebfedea0SLionel Sambuc
87ebfedea0SLionel Sambuc # undef PROG
88ebfedea0SLionel Sambuc # define PROG ecparam_main
89ebfedea0SLionel Sambuc
90*0a6a1f1dSLionel Sambuc /*-
91*0a6a1f1dSLionel Sambuc * -inform arg - input format - default PEM (DER or PEM)
92ebfedea0SLionel Sambuc * -outform arg - output format - default PEM
93ebfedea0SLionel Sambuc * -in arg - input file - default stdin
94ebfedea0SLionel Sambuc * -out arg - output file - default stdout
95ebfedea0SLionel Sambuc * -noout - do not print the ec parameter
96ebfedea0SLionel Sambuc * -text - print the ec parameters in text form
97ebfedea0SLionel Sambuc * -check - validate the ec parameters
98ebfedea0SLionel Sambuc * -C - print a 'C' function creating the parameters
99ebfedea0SLionel Sambuc * -name arg - use the ec parameters with 'short name' name
100ebfedea0SLionel Sambuc * -list_curves - prints a list of all currently available curve 'short names'
101ebfedea0SLionel Sambuc * -conv_form arg - specifies the point conversion form
102ebfedea0SLionel Sambuc * - possible values: compressed
103ebfedea0SLionel Sambuc * uncompressed (default)
104ebfedea0SLionel Sambuc * hybrid
105ebfedea0SLionel Sambuc * -param_enc arg - specifies the way the ec parameters are encoded
106ebfedea0SLionel Sambuc * in the asn1 der encoding
107ebfedea0SLionel Sambuc * possible values: named_curve (default)
108ebfedea0SLionel Sambuc * explicit
109*0a6a1f1dSLionel Sambuc * -no_seed - if 'explicit' parameters are chosen do not use the seed
110ebfedea0SLionel Sambuc * -genkey - generate ec key
111ebfedea0SLionel Sambuc * -rand file - files to use for random number input
112ebfedea0SLionel Sambuc * -engine e - use engine e, possibly a hardware device
113ebfedea0SLionel Sambuc */
114ebfedea0SLionel Sambuc
115*0a6a1f1dSLionel Sambuc static int ecparam_print_var(BIO *, BIGNUM *, const char *, int,
116*0a6a1f1dSLionel Sambuc unsigned char *);
117ebfedea0SLionel Sambuc
118ebfedea0SLionel Sambuc int MAIN(int, char **);
119ebfedea0SLionel Sambuc
MAIN(int argc,char ** argv)120ebfedea0SLionel Sambuc int MAIN(int argc, char **argv)
121ebfedea0SLionel Sambuc {
122ebfedea0SLionel Sambuc EC_GROUP *group = NULL;
123ebfedea0SLionel Sambuc point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
124ebfedea0SLionel Sambuc int new_form = 0;
125ebfedea0SLionel Sambuc int asn1_flag = OPENSSL_EC_NAMED_CURVE;
126ebfedea0SLionel Sambuc int new_asn1_flag = 0;
127ebfedea0SLionel Sambuc char *curve_name = NULL, *inrand = NULL;
128ebfedea0SLionel Sambuc int list_curves = 0, no_seed = 0, check = 0,
129ebfedea0SLionel Sambuc badops = 0, text = 0, i, need_rand = 0, genkey = 0;
130ebfedea0SLionel Sambuc char *infile = NULL, *outfile = NULL, *prog;
131ebfedea0SLionel Sambuc BIO *in = NULL, *out = NULL;
132ebfedea0SLionel Sambuc int informat, outformat, noout = 0, C = 0, ret = 1;
133ebfedea0SLionel Sambuc char *engine = NULL;
134ebfedea0SLionel Sambuc
135ebfedea0SLionel Sambuc BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
136ebfedea0SLionel Sambuc *ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL;
137ebfedea0SLionel Sambuc unsigned char *buffer = NULL;
138ebfedea0SLionel Sambuc
139ebfedea0SLionel Sambuc apps_startup();
140ebfedea0SLionel Sambuc
141ebfedea0SLionel Sambuc if (bio_err == NULL)
142ebfedea0SLionel Sambuc if ((bio_err = BIO_new(BIO_s_file())) != NULL)
143ebfedea0SLionel Sambuc BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
144ebfedea0SLionel Sambuc
145ebfedea0SLionel Sambuc if (!load_config(bio_err, NULL))
146ebfedea0SLionel Sambuc goto end;
147ebfedea0SLionel Sambuc
148ebfedea0SLionel Sambuc informat = FORMAT_PEM;
149ebfedea0SLionel Sambuc outformat = FORMAT_PEM;
150ebfedea0SLionel Sambuc
151ebfedea0SLionel Sambuc prog = argv[0];
152ebfedea0SLionel Sambuc argc--;
153ebfedea0SLionel Sambuc argv++;
154*0a6a1f1dSLionel Sambuc while (argc >= 1) {
155*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "-inform") == 0) {
156*0a6a1f1dSLionel Sambuc if (--argc < 1)
157*0a6a1f1dSLionel Sambuc goto bad;
158ebfedea0SLionel Sambuc informat = str2fmt(*(++argv));
159*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-outform") == 0) {
160*0a6a1f1dSLionel Sambuc if (--argc < 1)
161*0a6a1f1dSLionel Sambuc goto bad;
162ebfedea0SLionel Sambuc outformat = str2fmt(*(++argv));
163*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-in") == 0) {
164*0a6a1f1dSLionel Sambuc if (--argc < 1)
165*0a6a1f1dSLionel Sambuc goto bad;
166ebfedea0SLionel Sambuc infile = *(++argv);
167*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-out") == 0) {
168*0a6a1f1dSLionel Sambuc if (--argc < 1)
169*0a6a1f1dSLionel Sambuc goto bad;
170ebfedea0SLionel Sambuc outfile = *(++argv);
171*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-text") == 0)
172ebfedea0SLionel Sambuc text = 1;
173ebfedea0SLionel Sambuc else if (strcmp(*argv, "-C") == 0)
174ebfedea0SLionel Sambuc C = 1;
175ebfedea0SLionel Sambuc else if (strcmp(*argv, "-check") == 0)
176ebfedea0SLionel Sambuc check = 1;
177*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-name") == 0) {
178ebfedea0SLionel Sambuc if (--argc < 1)
179ebfedea0SLionel Sambuc goto bad;
180ebfedea0SLionel Sambuc curve_name = *(++argv);
181*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-list_curves") == 0)
182ebfedea0SLionel Sambuc list_curves = 1;
183*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-conv_form") == 0) {
184ebfedea0SLionel Sambuc if (--argc < 1)
185ebfedea0SLionel Sambuc goto bad;
186ebfedea0SLionel Sambuc ++argv;
187ebfedea0SLionel Sambuc new_form = 1;
188ebfedea0SLionel Sambuc if (strcmp(*argv, "compressed") == 0)
189ebfedea0SLionel Sambuc form = POINT_CONVERSION_COMPRESSED;
190ebfedea0SLionel Sambuc else if (strcmp(*argv, "uncompressed") == 0)
191ebfedea0SLionel Sambuc form = POINT_CONVERSION_UNCOMPRESSED;
192ebfedea0SLionel Sambuc else if (strcmp(*argv, "hybrid") == 0)
193ebfedea0SLionel Sambuc form = POINT_CONVERSION_HYBRID;
194ebfedea0SLionel Sambuc else
195ebfedea0SLionel Sambuc goto bad;
196*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-param_enc") == 0) {
197ebfedea0SLionel Sambuc if (--argc < 1)
198ebfedea0SLionel Sambuc goto bad;
199ebfedea0SLionel Sambuc ++argv;
200ebfedea0SLionel Sambuc new_asn1_flag = 1;
201ebfedea0SLionel Sambuc if (strcmp(*argv, "named_curve") == 0)
202ebfedea0SLionel Sambuc asn1_flag = OPENSSL_EC_NAMED_CURVE;
203ebfedea0SLionel Sambuc else if (strcmp(*argv, "explicit") == 0)
204ebfedea0SLionel Sambuc asn1_flag = 0;
205ebfedea0SLionel Sambuc else
206ebfedea0SLionel Sambuc goto bad;
207*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-no_seed") == 0)
208ebfedea0SLionel Sambuc no_seed = 1;
209ebfedea0SLionel Sambuc else if (strcmp(*argv, "-noout") == 0)
210ebfedea0SLionel Sambuc noout = 1;
211*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-genkey") == 0) {
212ebfedea0SLionel Sambuc genkey = 1;
213ebfedea0SLionel Sambuc need_rand = 1;
214*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-rand") == 0) {
215*0a6a1f1dSLionel Sambuc if (--argc < 1)
216*0a6a1f1dSLionel Sambuc goto bad;
217ebfedea0SLionel Sambuc inrand = *(++argv);
218ebfedea0SLionel Sambuc need_rand = 1;
219*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-engine") == 0) {
220*0a6a1f1dSLionel Sambuc if (--argc < 1)
221*0a6a1f1dSLionel Sambuc goto bad;
222ebfedea0SLionel Sambuc engine = *(++argv);
223*0a6a1f1dSLionel Sambuc } else {
224ebfedea0SLionel Sambuc BIO_printf(bio_err, "unknown option %s\n", *argv);
225ebfedea0SLionel Sambuc badops = 1;
226ebfedea0SLionel Sambuc break;
227ebfedea0SLionel Sambuc }
228ebfedea0SLionel Sambuc argc--;
229ebfedea0SLionel Sambuc argv++;
230ebfedea0SLionel Sambuc }
231ebfedea0SLionel Sambuc
232*0a6a1f1dSLionel Sambuc if (badops) {
233ebfedea0SLionel Sambuc bad:
234ebfedea0SLionel Sambuc BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
235ebfedea0SLionel Sambuc BIO_printf(bio_err, "where options are\n");
236ebfedea0SLionel Sambuc BIO_printf(bio_err, " -inform arg input format - "
237ebfedea0SLionel Sambuc "default PEM (DER or PEM)\n");
238ebfedea0SLionel Sambuc BIO_printf(bio_err, " -outform arg output format - "
239ebfedea0SLionel Sambuc "default PEM\n");
240ebfedea0SLionel Sambuc BIO_printf(bio_err, " -in arg input file - "
241ebfedea0SLionel Sambuc "default stdin\n");
242ebfedea0SLionel Sambuc BIO_printf(bio_err, " -out arg output file - "
243ebfedea0SLionel Sambuc "default stdout\n");
244ebfedea0SLionel Sambuc BIO_printf(bio_err, " -noout do not print the "
245ebfedea0SLionel Sambuc "ec parameter\n");
246ebfedea0SLionel Sambuc BIO_printf(bio_err, " -text print the ec "
247ebfedea0SLionel Sambuc "parameters in text form\n");
248ebfedea0SLionel Sambuc BIO_printf(bio_err, " -check validate the ec "
249ebfedea0SLionel Sambuc "parameters\n");
250ebfedea0SLionel Sambuc BIO_printf(bio_err, " -C print a 'C' "
251ebfedea0SLionel Sambuc "function creating the parameters\n");
252ebfedea0SLionel Sambuc BIO_printf(bio_err, " -name arg use the "
253ebfedea0SLionel Sambuc "ec parameters with 'short name' name\n");
254ebfedea0SLionel Sambuc BIO_printf(bio_err, " -list_curves prints a list of "
255ebfedea0SLionel Sambuc "all currently available curve 'short names'\n");
256ebfedea0SLionel Sambuc BIO_printf(bio_err, " -conv_form arg specifies the "
257ebfedea0SLionel Sambuc "point conversion form \n");
258ebfedea0SLionel Sambuc BIO_printf(bio_err, " possible values:"
259ebfedea0SLionel Sambuc " compressed\n");
260ebfedea0SLionel Sambuc BIO_printf(bio_err, " "
261ebfedea0SLionel Sambuc " uncompressed (default)\n");
262ebfedea0SLionel Sambuc BIO_printf(bio_err, " "
263ebfedea0SLionel Sambuc " hybrid\n");
264ebfedea0SLionel Sambuc BIO_printf(bio_err, " -param_enc arg specifies the way"
265ebfedea0SLionel Sambuc " the ec parameters are encoded\n");
266ebfedea0SLionel Sambuc BIO_printf(bio_err, " in the asn1 der "
267ebfedea0SLionel Sambuc "encoding\n");
268ebfedea0SLionel Sambuc BIO_printf(bio_err, " possible values:"
269ebfedea0SLionel Sambuc " named_curve (default)\n");
270ebfedea0SLionel Sambuc BIO_printf(bio_err, " "
271ebfedea0SLionel Sambuc " explicit\n");
272ebfedea0SLionel Sambuc BIO_printf(bio_err, " -no_seed if 'explicit'"
273*0a6a1f1dSLionel Sambuc " parameters are chosen do not" " use the seed\n");
274*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, " -genkey generate ec" " key\n");
275ebfedea0SLionel Sambuc BIO_printf(bio_err, " -rand file files to use for"
276ebfedea0SLionel Sambuc " random number input\n");
277ebfedea0SLionel Sambuc BIO_printf(bio_err, " -engine e use engine e, "
278ebfedea0SLionel Sambuc "possibly a hardware device\n");
279ebfedea0SLionel Sambuc goto end;
280ebfedea0SLionel Sambuc }
281ebfedea0SLionel Sambuc
282ebfedea0SLionel Sambuc ERR_load_crypto_strings();
283ebfedea0SLionel Sambuc
284ebfedea0SLionel Sambuc in = BIO_new(BIO_s_file());
285ebfedea0SLionel Sambuc out = BIO_new(BIO_s_file());
286*0a6a1f1dSLionel Sambuc if ((in == NULL) || (out == NULL)) {
287ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
288ebfedea0SLionel Sambuc goto end;
289ebfedea0SLionel Sambuc }
290ebfedea0SLionel Sambuc
291ebfedea0SLionel Sambuc if (infile == NULL)
292ebfedea0SLionel Sambuc BIO_set_fp(in, stdin, BIO_NOCLOSE);
293*0a6a1f1dSLionel Sambuc else {
294*0a6a1f1dSLionel Sambuc if (BIO_read_filename(in, infile) <= 0) {
295ebfedea0SLionel Sambuc perror(infile);
296ebfedea0SLionel Sambuc goto end;
297ebfedea0SLionel Sambuc }
298ebfedea0SLionel Sambuc }
299*0a6a1f1dSLionel Sambuc if (outfile == NULL) {
300ebfedea0SLionel Sambuc BIO_set_fp(out, stdout, BIO_NOCLOSE);
301ebfedea0SLionel Sambuc # ifdef OPENSSL_SYS_VMS
302ebfedea0SLionel Sambuc {
303ebfedea0SLionel Sambuc BIO *tmpbio = BIO_new(BIO_f_linebuffer());
304ebfedea0SLionel Sambuc out = BIO_push(tmpbio, out);
305ebfedea0SLionel Sambuc }
306ebfedea0SLionel Sambuc # endif
307*0a6a1f1dSLionel Sambuc } else {
308*0a6a1f1dSLionel Sambuc if (BIO_write_filename(out, outfile) <= 0) {
309ebfedea0SLionel Sambuc perror(outfile);
310ebfedea0SLionel Sambuc goto end;
311ebfedea0SLionel Sambuc }
312ebfedea0SLionel Sambuc }
313ebfedea0SLionel Sambuc
314ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
315ebfedea0SLionel Sambuc setup_engine(bio_err, engine, 0);
316ebfedea0SLionel Sambuc # endif
317ebfedea0SLionel Sambuc
318*0a6a1f1dSLionel Sambuc if (list_curves) {
319ebfedea0SLionel Sambuc EC_builtin_curve *curves = NULL;
320ebfedea0SLionel Sambuc size_t crv_len = 0;
321ebfedea0SLionel Sambuc size_t n = 0;
322ebfedea0SLionel Sambuc
323ebfedea0SLionel Sambuc crv_len = EC_get_builtin_curves(NULL, 0);
324ebfedea0SLionel Sambuc
325ebfedea0SLionel Sambuc curves = OPENSSL_malloc((int)(sizeof(EC_builtin_curve) * crv_len));
326ebfedea0SLionel Sambuc
327ebfedea0SLionel Sambuc if (curves == NULL)
328ebfedea0SLionel Sambuc goto end;
329ebfedea0SLionel Sambuc
330*0a6a1f1dSLionel Sambuc if (!EC_get_builtin_curves(curves, crv_len)) {
331ebfedea0SLionel Sambuc OPENSSL_free(curves);
332ebfedea0SLionel Sambuc goto end;
333ebfedea0SLionel Sambuc }
334ebfedea0SLionel Sambuc
335*0a6a1f1dSLionel Sambuc for (n = 0; n < crv_len; n++) {
336ebfedea0SLionel Sambuc const char *comment;
337ebfedea0SLionel Sambuc const char *sname;
338ebfedea0SLionel Sambuc comment = curves[n].comment;
339ebfedea0SLionel Sambuc sname = OBJ_nid2sn(curves[n].nid);
340ebfedea0SLionel Sambuc if (comment == NULL)
341ebfedea0SLionel Sambuc comment = "CURVE DESCRIPTION NOT AVAILABLE";
342ebfedea0SLionel Sambuc if (sname == NULL)
343ebfedea0SLionel Sambuc sname = "";
344ebfedea0SLionel Sambuc
345ebfedea0SLionel Sambuc BIO_printf(out, " %-10s: ", sname);
346ebfedea0SLionel Sambuc BIO_printf(out, "%s\n", comment);
347ebfedea0SLionel Sambuc }
348ebfedea0SLionel Sambuc
349ebfedea0SLionel Sambuc OPENSSL_free(curves);
350ebfedea0SLionel Sambuc ret = 0;
351ebfedea0SLionel Sambuc goto end;
352ebfedea0SLionel Sambuc }
353ebfedea0SLionel Sambuc
354*0a6a1f1dSLionel Sambuc if (curve_name != NULL) {
355ebfedea0SLionel Sambuc int nid;
356ebfedea0SLionel Sambuc
357*0a6a1f1dSLionel Sambuc /*
358*0a6a1f1dSLionel Sambuc * workaround for the SECG curve names secp192r1 and secp256r1 (which
359*0a6a1f1dSLionel Sambuc * are the same as the curves prime192v1 and prime256v1 defined in
360*0a6a1f1dSLionel Sambuc * X9.62)
361ebfedea0SLionel Sambuc */
362*0a6a1f1dSLionel Sambuc if (!strcmp(curve_name, "secp192r1")) {
363ebfedea0SLionel Sambuc BIO_printf(bio_err, "using curve name prime192v1 "
364ebfedea0SLionel Sambuc "instead of secp192r1\n");
365ebfedea0SLionel Sambuc nid = NID_X9_62_prime192v1;
366*0a6a1f1dSLionel Sambuc } else if (!strcmp(curve_name, "secp256r1")) {
367ebfedea0SLionel Sambuc BIO_printf(bio_err, "using curve name prime256v1 "
368ebfedea0SLionel Sambuc "instead of secp256r1\n");
369ebfedea0SLionel Sambuc nid = NID_X9_62_prime256v1;
370*0a6a1f1dSLionel Sambuc } else
371ebfedea0SLionel Sambuc nid = OBJ_sn2nid(curve_name);
372ebfedea0SLionel Sambuc
373*0a6a1f1dSLionel Sambuc if (nid == 0) {
374*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "unknown curve name (%s)\n", curve_name);
375ebfedea0SLionel Sambuc goto end;
376ebfedea0SLionel Sambuc }
377ebfedea0SLionel Sambuc
378ebfedea0SLionel Sambuc group = EC_GROUP_new_by_curve_name(nid);
379*0a6a1f1dSLionel Sambuc if (group == NULL) {
380*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "unable to create curve (%s)\n", curve_name);
381ebfedea0SLionel Sambuc goto end;
382ebfedea0SLionel Sambuc }
383ebfedea0SLionel Sambuc EC_GROUP_set_asn1_flag(group, asn1_flag);
384ebfedea0SLionel Sambuc EC_GROUP_set_point_conversion_form(group, form);
385*0a6a1f1dSLionel Sambuc } else if (informat == FORMAT_ASN1) {
386ebfedea0SLionel Sambuc group = d2i_ECPKParameters_bio(in, NULL);
387*0a6a1f1dSLionel Sambuc } else if (informat == FORMAT_PEM) {
388ebfedea0SLionel Sambuc group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
389*0a6a1f1dSLionel Sambuc } else {
390ebfedea0SLionel Sambuc BIO_printf(bio_err, "bad input format specified\n");
391ebfedea0SLionel Sambuc goto end;
392ebfedea0SLionel Sambuc }
393ebfedea0SLionel Sambuc
394*0a6a1f1dSLionel Sambuc if (group == NULL) {
395*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, "unable to load elliptic curve parameters\n");
396ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
397ebfedea0SLionel Sambuc goto end;
398ebfedea0SLionel Sambuc }
399ebfedea0SLionel Sambuc
400ebfedea0SLionel Sambuc if (new_form)
401ebfedea0SLionel Sambuc EC_GROUP_set_point_conversion_form(group, form);
402ebfedea0SLionel Sambuc
403ebfedea0SLionel Sambuc if (new_asn1_flag)
404ebfedea0SLionel Sambuc EC_GROUP_set_asn1_flag(group, asn1_flag);
405ebfedea0SLionel Sambuc
406*0a6a1f1dSLionel Sambuc if (no_seed) {
407ebfedea0SLionel Sambuc EC_GROUP_set_seed(group, NULL, 0);
408ebfedea0SLionel Sambuc }
409ebfedea0SLionel Sambuc
410*0a6a1f1dSLionel Sambuc if (text) {
411ebfedea0SLionel Sambuc if (!ECPKParameters_print(out, group, 0))
412ebfedea0SLionel Sambuc goto end;
413ebfedea0SLionel Sambuc }
414ebfedea0SLionel Sambuc
415*0a6a1f1dSLionel Sambuc if (check) {
416ebfedea0SLionel Sambuc if (group == NULL)
417ebfedea0SLionel Sambuc BIO_printf(bio_err, "no elliptic curve parameters\n");
418ebfedea0SLionel Sambuc BIO_printf(bio_err, "checking elliptic curve parameters: ");
419*0a6a1f1dSLionel Sambuc if (!EC_GROUP_check(group, NULL)) {
420ebfedea0SLionel Sambuc BIO_printf(bio_err, "failed\n");
421ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
422*0a6a1f1dSLionel Sambuc } else
423ebfedea0SLionel Sambuc BIO_printf(bio_err, "ok\n");
424ebfedea0SLionel Sambuc
425ebfedea0SLionel Sambuc }
426ebfedea0SLionel Sambuc
427*0a6a1f1dSLionel Sambuc if (C) {
428ebfedea0SLionel Sambuc size_t buf_len = 0, tmp_len = 0;
429ebfedea0SLionel Sambuc const EC_POINT *point;
430ebfedea0SLionel Sambuc int is_prime, len = 0;
431ebfedea0SLionel Sambuc const EC_METHOD *meth = EC_GROUP_method_of(group);
432ebfedea0SLionel Sambuc
433ebfedea0SLionel Sambuc if ((ec_p = BN_new()) == NULL || (ec_a = BN_new()) == NULL ||
434ebfedea0SLionel Sambuc (ec_b = BN_new()) == NULL || (ec_gen = BN_new()) == NULL ||
435ebfedea0SLionel Sambuc (ec_order = BN_new()) == NULL ||
436*0a6a1f1dSLionel Sambuc (ec_cofactor = BN_new()) == NULL) {
437ebfedea0SLionel Sambuc perror("OPENSSL_malloc");
438ebfedea0SLionel Sambuc goto end;
439ebfedea0SLionel Sambuc }
440ebfedea0SLionel Sambuc
441*0a6a1f1dSLionel Sambuc is_prime = (EC_METHOD_get_field_type(meth) == NID_X9_62_prime_field);
442ebfedea0SLionel Sambuc
443*0a6a1f1dSLionel Sambuc if (is_prime) {
444*0a6a1f1dSLionel Sambuc if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a, ec_b, NULL))
445ebfedea0SLionel Sambuc goto end;
446*0a6a1f1dSLionel Sambuc } else {
447ebfedea0SLionel Sambuc /* TODO */
448ebfedea0SLionel Sambuc goto end;
449ebfedea0SLionel Sambuc }
450ebfedea0SLionel Sambuc
451ebfedea0SLionel Sambuc if ((point = EC_GROUP_get0_generator(group)) == NULL)
452ebfedea0SLionel Sambuc goto end;
453ebfedea0SLionel Sambuc if (!EC_POINT_point2bn(group, point,
454*0a6a1f1dSLionel Sambuc EC_GROUP_get_point_conversion_form(group),
455*0a6a1f1dSLionel Sambuc ec_gen, NULL))
456ebfedea0SLionel Sambuc goto end;
457ebfedea0SLionel Sambuc if (!EC_GROUP_get_order(group, ec_order, NULL))
458ebfedea0SLionel Sambuc goto end;
459ebfedea0SLionel Sambuc if (!EC_GROUP_get_cofactor(group, ec_cofactor, NULL))
460ebfedea0SLionel Sambuc goto end;
461ebfedea0SLionel Sambuc
462*0a6a1f1dSLionel Sambuc if (!ec_p || !ec_a || !ec_b || !ec_gen || !ec_order || !ec_cofactor)
463ebfedea0SLionel Sambuc goto end;
464ebfedea0SLionel Sambuc
465ebfedea0SLionel Sambuc len = BN_num_bits(ec_order);
466ebfedea0SLionel Sambuc
467ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_p)) > buf_len)
468ebfedea0SLionel Sambuc buf_len = tmp_len;
469ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_a)) > buf_len)
470ebfedea0SLionel Sambuc buf_len = tmp_len;
471ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_b)) > buf_len)
472ebfedea0SLionel Sambuc buf_len = tmp_len;
473ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_gen)) > buf_len)
474ebfedea0SLionel Sambuc buf_len = tmp_len;
475ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_order)) > buf_len)
476ebfedea0SLionel Sambuc buf_len = tmp_len;
477ebfedea0SLionel Sambuc if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len)
478ebfedea0SLionel Sambuc buf_len = tmp_len;
479ebfedea0SLionel Sambuc
480ebfedea0SLionel Sambuc buffer = (unsigned char *)OPENSSL_malloc(buf_len);
481ebfedea0SLionel Sambuc
482*0a6a1f1dSLionel Sambuc if (buffer == NULL) {
483ebfedea0SLionel Sambuc perror("OPENSSL_malloc");
484ebfedea0SLionel Sambuc goto end;
485ebfedea0SLionel Sambuc }
486ebfedea0SLionel Sambuc
487ebfedea0SLionel Sambuc ecparam_print_var(out, ec_p, "ec_p", len, buffer);
488ebfedea0SLionel Sambuc ecparam_print_var(out, ec_a, "ec_a", len, buffer);
489ebfedea0SLionel Sambuc ecparam_print_var(out, ec_b, "ec_b", len, buffer);
490ebfedea0SLionel Sambuc ecparam_print_var(out, ec_gen, "ec_gen", len, buffer);
491ebfedea0SLionel Sambuc ecparam_print_var(out, ec_order, "ec_order", len, buffer);
492*0a6a1f1dSLionel Sambuc ecparam_print_var(out, ec_cofactor, "ec_cofactor", len, buffer);
493ebfedea0SLionel Sambuc
494ebfedea0SLionel Sambuc BIO_printf(out, "\n\n");
495ebfedea0SLionel Sambuc
496ebfedea0SLionel Sambuc BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n\t{\n", len);
497ebfedea0SLionel Sambuc BIO_printf(out, "\tint ok=0;\n");
498ebfedea0SLionel Sambuc BIO_printf(out, "\tEC_GROUP *group = NULL;\n");
499ebfedea0SLionel Sambuc BIO_printf(out, "\tEC_POINT *point = NULL;\n");
500ebfedea0SLionel Sambuc BIO_printf(out, "\tBIGNUM *tmp_1 = NULL, *tmp_2 = NULL, "
501ebfedea0SLionel Sambuc "*tmp_3 = NULL;\n\n");
502ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_p_%d, "
503ebfedea0SLionel Sambuc "sizeof(ec_p_%d), NULL)) == NULL)\n\t\t"
504ebfedea0SLionel Sambuc "goto err;\n", len, len);
505ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_a_%d, "
506ebfedea0SLionel Sambuc "sizeof(ec_a_%d), NULL)) == NULL)\n\t\t"
507ebfedea0SLionel Sambuc "goto err;\n", len, len);
508ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_b_%d, "
509ebfedea0SLionel Sambuc "sizeof(ec_b_%d), NULL)) == NULL)\n\t\t"
510ebfedea0SLionel Sambuc "goto err;\n", len, len);
511*0a6a1f1dSLionel Sambuc if (is_prime) {
512ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((group = EC_GROUP_new_curve_"
513ebfedea0SLionel Sambuc "GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)"
514ebfedea0SLionel Sambuc "\n\t\tgoto err;\n\n");
515*0a6a1f1dSLionel Sambuc } else {
516ebfedea0SLionel Sambuc /* TODO */
517ebfedea0SLionel Sambuc goto end;
518ebfedea0SLionel Sambuc }
519ebfedea0SLionel Sambuc BIO_printf(out, "\t/* build generator */\n");
520ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_gen_%d, "
521ebfedea0SLionel Sambuc "sizeof(ec_gen_%d), tmp_1)) == NULL)"
522ebfedea0SLionel Sambuc "\n\t\tgoto err;\n", len, len);
523ebfedea0SLionel Sambuc BIO_printf(out, "\tpoint = EC_POINT_bn2point(group, tmp_1, "
524ebfedea0SLionel Sambuc "NULL, NULL);\n");
525ebfedea0SLionel Sambuc BIO_printf(out, "\tif (point == NULL)\n\t\tgoto err;\n");
526ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_order_%d, "
527ebfedea0SLionel Sambuc "sizeof(ec_order_%d), tmp_2)) == NULL)"
528ebfedea0SLionel Sambuc "\n\t\tgoto err;\n", len, len);
529ebfedea0SLionel Sambuc BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_cofactor_%d, "
530ebfedea0SLionel Sambuc "sizeof(ec_cofactor_%d), tmp_3)) == NULL)"
531ebfedea0SLionel Sambuc "\n\t\tgoto err;\n", len, len);
532ebfedea0SLionel Sambuc BIO_printf(out, "\tif (!EC_GROUP_set_generator(group, point,"
533ebfedea0SLionel Sambuc " tmp_2, tmp_3))\n\t\tgoto err;\n");
534ebfedea0SLionel Sambuc BIO_printf(out, "\n\tok=1;\n");
535ebfedea0SLionel Sambuc BIO_printf(out, "err:\n");
536ebfedea0SLionel Sambuc BIO_printf(out, "\tif (tmp_1)\n\t\tBN_free(tmp_1);\n");
537ebfedea0SLionel Sambuc BIO_printf(out, "\tif (tmp_2)\n\t\tBN_free(tmp_2);\n");
538ebfedea0SLionel Sambuc BIO_printf(out, "\tif (tmp_3)\n\t\tBN_free(tmp_3);\n");
539ebfedea0SLionel Sambuc BIO_printf(out, "\tif (point)\n\t\tEC_POINT_free(point);\n");
540ebfedea0SLionel Sambuc BIO_printf(out, "\tif (!ok)\n");
541ebfedea0SLionel Sambuc BIO_printf(out, "\t\t{\n");
542ebfedea0SLionel Sambuc BIO_printf(out, "\t\tEC_GROUP_free(group);\n");
543ebfedea0SLionel Sambuc BIO_printf(out, "\t\tgroup = NULL;\n");
544ebfedea0SLionel Sambuc BIO_printf(out, "\t\t}\n");
545ebfedea0SLionel Sambuc BIO_printf(out, "\treturn(group);\n\t}\n");
546ebfedea0SLionel Sambuc }
547ebfedea0SLionel Sambuc
548*0a6a1f1dSLionel Sambuc if (!noout) {
549ebfedea0SLionel Sambuc if (outformat == FORMAT_ASN1)
550ebfedea0SLionel Sambuc i = i2d_ECPKParameters_bio(out, group);
551ebfedea0SLionel Sambuc else if (outformat == FORMAT_PEM)
552ebfedea0SLionel Sambuc i = PEM_write_bio_ECPKParameters(out, group);
553*0a6a1f1dSLionel Sambuc else {
554ebfedea0SLionel Sambuc BIO_printf(bio_err, "bad output format specified for"
555ebfedea0SLionel Sambuc " outfile\n");
556ebfedea0SLionel Sambuc goto end;
557ebfedea0SLionel Sambuc }
558*0a6a1f1dSLionel Sambuc if (!i) {
559ebfedea0SLionel Sambuc BIO_printf(bio_err, "unable to write elliptic "
560ebfedea0SLionel Sambuc "curve parameters\n");
561ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
562ebfedea0SLionel Sambuc goto end;
563ebfedea0SLionel Sambuc }
564ebfedea0SLionel Sambuc }
565ebfedea0SLionel Sambuc
566*0a6a1f1dSLionel Sambuc if (need_rand) {
567ebfedea0SLionel Sambuc app_RAND_load_file(NULL, bio_err, (inrand != NULL));
568ebfedea0SLionel Sambuc if (inrand != NULL)
569ebfedea0SLionel Sambuc BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
570ebfedea0SLionel Sambuc app_RAND_load_files(inrand));
571ebfedea0SLionel Sambuc }
572ebfedea0SLionel Sambuc
573*0a6a1f1dSLionel Sambuc if (genkey) {
574ebfedea0SLionel Sambuc EC_KEY *eckey = EC_KEY_new();
575ebfedea0SLionel Sambuc
576ebfedea0SLionel Sambuc if (eckey == NULL)
577ebfedea0SLionel Sambuc goto end;
578ebfedea0SLionel Sambuc
579ebfedea0SLionel Sambuc assert(need_rand);
580ebfedea0SLionel Sambuc
581ebfedea0SLionel Sambuc if (EC_KEY_set_group(eckey, group) == 0)
582ebfedea0SLionel Sambuc goto end;
583ebfedea0SLionel Sambuc
584*0a6a1f1dSLionel Sambuc if (!EC_KEY_generate_key(eckey)) {
585ebfedea0SLionel Sambuc EC_KEY_free(eckey);
586ebfedea0SLionel Sambuc goto end;
587ebfedea0SLionel Sambuc }
588ebfedea0SLionel Sambuc if (outformat == FORMAT_ASN1)
589ebfedea0SLionel Sambuc i = i2d_ECPrivateKey_bio(out, eckey);
590ebfedea0SLionel Sambuc else if (outformat == FORMAT_PEM)
591ebfedea0SLionel Sambuc i = PEM_write_bio_ECPrivateKey(out, eckey, NULL,
592ebfedea0SLionel Sambuc NULL, 0, NULL, NULL);
593*0a6a1f1dSLionel Sambuc else {
594ebfedea0SLionel Sambuc BIO_printf(bio_err, "bad output format specified "
595ebfedea0SLionel Sambuc "for outfile\n");
596ebfedea0SLionel Sambuc EC_KEY_free(eckey);
597ebfedea0SLionel Sambuc goto end;
598ebfedea0SLionel Sambuc }
599ebfedea0SLionel Sambuc EC_KEY_free(eckey);
600ebfedea0SLionel Sambuc }
601ebfedea0SLionel Sambuc
602ebfedea0SLionel Sambuc if (need_rand)
603ebfedea0SLionel Sambuc app_RAND_write_file(NULL, bio_err);
604ebfedea0SLionel Sambuc
605ebfedea0SLionel Sambuc ret = 0;
606ebfedea0SLionel Sambuc end:
607ebfedea0SLionel Sambuc if (ec_p)
608ebfedea0SLionel Sambuc BN_free(ec_p);
609ebfedea0SLionel Sambuc if (ec_a)
610ebfedea0SLionel Sambuc BN_free(ec_a);
611ebfedea0SLionel Sambuc if (ec_b)
612ebfedea0SLionel Sambuc BN_free(ec_b);
613ebfedea0SLionel Sambuc if (ec_gen)
614ebfedea0SLionel Sambuc BN_free(ec_gen);
615ebfedea0SLionel Sambuc if (ec_order)
616ebfedea0SLionel Sambuc BN_free(ec_order);
617ebfedea0SLionel Sambuc if (ec_cofactor)
618ebfedea0SLionel Sambuc BN_free(ec_cofactor);
619ebfedea0SLionel Sambuc if (buffer)
620ebfedea0SLionel Sambuc OPENSSL_free(buffer);
621ebfedea0SLionel Sambuc if (in != NULL)
622ebfedea0SLionel Sambuc BIO_free(in);
623ebfedea0SLionel Sambuc if (out != NULL)
624ebfedea0SLionel Sambuc BIO_free_all(out);
625ebfedea0SLionel Sambuc if (group != NULL)
626ebfedea0SLionel Sambuc EC_GROUP_free(group);
627ebfedea0SLionel Sambuc apps_shutdown();
628ebfedea0SLionel Sambuc OPENSSL_EXIT(ret);
629ebfedea0SLionel Sambuc }
630ebfedea0SLionel Sambuc
ecparam_print_var(BIO * out,BIGNUM * in,const char * var,int len,unsigned char * buffer)631ebfedea0SLionel Sambuc static int ecparam_print_var(BIO *out, BIGNUM *in, const char *var,
632ebfedea0SLionel Sambuc int len, unsigned char *buffer)
633ebfedea0SLionel Sambuc {
634ebfedea0SLionel Sambuc BIO_printf(out, "static unsigned char %s_%d[] = {", var, len);
635ebfedea0SLionel Sambuc if (BN_is_zero(in))
636ebfedea0SLionel Sambuc BIO_printf(out, "\n\t0x00");
637*0a6a1f1dSLionel Sambuc else {
638ebfedea0SLionel Sambuc int i, l;
639ebfedea0SLionel Sambuc
640ebfedea0SLionel Sambuc l = BN_bn2bin(in, buffer);
641*0a6a1f1dSLionel Sambuc for (i = 0; i < l - 1; i++) {
642ebfedea0SLionel Sambuc if ((i % 12) == 0)
643ebfedea0SLionel Sambuc BIO_printf(out, "\n\t");
644ebfedea0SLionel Sambuc BIO_printf(out, "0x%02X,", buffer[i]);
645ebfedea0SLionel Sambuc }
646ebfedea0SLionel Sambuc if ((i % 12) == 0)
647ebfedea0SLionel Sambuc BIO_printf(out, "\n\t");
648ebfedea0SLionel Sambuc BIO_printf(out, "0x%02X", buffer[i]);
649ebfedea0SLionel Sambuc }
650ebfedea0SLionel Sambuc BIO_printf(out, "\n\t};\n\n");
651ebfedea0SLionel Sambuc return 1;
652ebfedea0SLionel Sambuc }
653ebfedea0SLionel Sambuc #else /* !OPENSSL_NO_EC */
654ebfedea0SLionel Sambuc
655ebfedea0SLionel Sambuc # if PEDANTIC
656ebfedea0SLionel Sambuc static void *dummy = &dummy;
657ebfedea0SLionel Sambuc # endif
658ebfedea0SLionel Sambuc
659ebfedea0SLionel Sambuc #endif
660