Rename SSL_write_early() to SSL_write_early_data()
[openssl.git] / apps / openssl.c
1 /*
2  * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <openssl/bio.h>
14 #include <openssl/crypto.h>
15 #include <openssl/lhash.h>
16 #include <openssl/conf.h>
17 #include <openssl/x509.h>
18 #include <openssl/pem.h>
19 #include <openssl/ssl.h>
20 #ifndef OPENSSL_NO_ENGINE
21 # include <openssl/engine.h>
22 #endif
23 #include <openssl/err.h>
24 #define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
25 #include "s_apps.h"
26 /* Needed to get the other O_xxx flags. */
27 #ifdef OPENSSL_SYS_VMS
28 # include <unixio.h>
29 #endif
30 #define INCLUDE_FUNCTION_TABLE
31 #include "apps.h"
32
33
34 #ifdef OPENSSL_NO_CAMELLIA
35 # define FORMAT "%-15s"
36 # define COLUMNS 5
37 #else
38 # define FORMAT "%-18s"
39 # define COLUMNS 4
40 #endif
41
42 /* Special sentinel to exit the program. */
43 #define EXIT_THE_PROGRAM (-1)
44
45 /*
46  * The LHASH callbacks ("hash" & "cmp") have been replaced by functions with
47  * the base prototypes (we cast each variable inside the function to the
48  * required type of "FUNCTION*"). This removes the necessity for
49  * macro-generated wrapper functions.
50  */
51 static LHASH_OF(FUNCTION) *prog_init(void);
52 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
53 static void list_pkey(void);
54 static void list_type(FUNC_TYPE ft);
55 static void list_disabled(void);
56 char *default_config_file = NULL;
57
58 BIO *bio_in = NULL;
59 BIO *bio_out = NULL;
60 BIO *bio_err = NULL;
61
62 static int apps_startup()
63 {
64 #ifdef SIGPIPE
65     signal(SIGPIPE, SIG_IGN);
66 #endif
67
68     /* Set non-default library initialisation settings */
69     if (!OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN
70                              | OPENSSL_INIT_LOAD_CONFIG, NULL))
71         return 0;
72
73 #ifndef OPENSSL_NO_UI
74     setup_ui_method();
75 #endif
76
77     return 1;
78 }
79
80 static void apps_shutdown()
81 {
82 #ifndef OPENSSL_NO_UI
83     destroy_ui_method();
84 #endif
85 }
86
87 static char *make_config_name()
88 {
89     const char *t;
90     size_t len;
91     char *p;
92
93     if ((t = getenv("OPENSSL_CONF")) != NULL)
94         return OPENSSL_strdup(t);
95
96     t = X509_get_default_cert_area();
97     len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
98     p = app_malloc(len, "config filename buffer");
99     strcpy(p, t);
100 #ifndef OPENSSL_SYS_VMS
101     strcat(p, "/");
102 #endif
103     strcat(p, OPENSSL_CONF);
104
105     return p;
106 }
107
108 int main(int argc, char *argv[])
109 {
110     FUNCTION f, *fp;
111     LHASH_OF(FUNCTION) *prog = NULL;
112     char **copied_argv = NULL;
113     char *p, *pname;
114     char buf[1024];
115     const char *prompt;
116     ARGS arg;
117     int first, n, i, ret = 0;
118
119     arg.argv = NULL;
120     arg.size = 0;
121
122     /* Set up some of the environment. */
123     default_config_file = make_config_name();
124     bio_in = dup_bio_in(FORMAT_TEXT);
125     bio_out = dup_bio_out(FORMAT_TEXT);
126     bio_err = dup_bio_err(FORMAT_TEXT);
127
128 #if defined(OPENSSL_SYS_VMS) && defined(__DECC)
129     copied_argv = argv = copy_argv(&argc, argv);
130 #elif defined(_WIN32)
131     /*
132      * Replace argv[] with UTF-8 encoded strings.
133      */
134     win32_utf8argv(&argc, &argv);
135 #endif
136
137     p = getenv("OPENSSL_DEBUG_MEMORY");
138     if (p != NULL && strcmp(p, "on") == 0)
139         CRYPTO_set_mem_debug(1);
140     CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
141
142     if (getenv("OPENSSL_FIPS")) {
143         BIO_printf(bio_err, "FIPS mode not supported.\n");
144         return 1;
145     }
146
147     if (!apps_startup())
148         goto end;
149
150     prog = prog_init();
151     pname = opt_progname(argv[0]);
152
153     /* first check the program name */
154     f.name = pname;
155     fp = lh_FUNCTION_retrieve(prog, &f);
156     if (fp != NULL) {
157         argv[0] = pname;
158         ret = fp->func(argc, argv);
159         goto end;
160     }
161
162     /* If there is stuff on the command line, run with that. */
163     if (argc != 1) {
164         argc--;
165         argv++;
166         ret = do_cmd(prog, argc, argv);
167         if (ret < 0)
168             ret = 0;
169         goto end;
170     }
171
172     /* ok, lets enter interactive mode */
173     for (;;) {
174         ret = 0;
175         /* Read a line, continue reading if line ends with \ */
176         for (p = buf, n = sizeof buf, i = 0, first = 1; n > 0; first = 0) {
177             prompt = first ? "OpenSSL> " : "> ";
178             p[0] = '\0';
179 #ifndef READLINE
180             fputs(prompt, stdout);
181             fflush(stdout);
182             if (!fgets(p, n, stdin))
183                 goto end;
184             if (p[0] == '\0')
185                 goto end;
186             i = strlen(p);
187             if (i <= 1)
188                 break;
189             if (p[i - 2] != '\\')
190                 break;
191             i -= 2;
192             p += i;
193             n -= i;
194 #else
195             {
196                 extern char *readline(const char *);
197                 extern void add_history(const char *cp);
198                 char *text;
199
200                 text = readline(prompt);
201                 if (text == NULL)
202                     goto end;
203                 i = strlen(text);
204                 if (i == 0 || i > n)
205                     break;
206                 if (text[i - 1] != '\\') {
207                     p += strlen(strcpy(p, text));
208                     free(text);
209                     add_history(buf);
210                     break;
211                 }
212
213                 text[i - 1] = '\0';
214                 p += strlen(strcpy(p, text));
215                 free(text);
216                 n -= i;
217             }
218 #endif
219         }
220
221         if (!chopup_args(&arg, buf)) {
222             BIO_printf(bio_err, "Can't parse (no memory?)\n");
223             break;
224         }
225
226         ret = do_cmd(prog, arg.argc, arg.argv);
227         if (ret == EXIT_THE_PROGRAM) {
228             ret = 0;
229             goto end;
230         }
231         if (ret != 0)
232             BIO_printf(bio_err, "error in %s\n", arg.argv[0]);
233         (void)BIO_flush(bio_out);
234         (void)BIO_flush(bio_err);
235     }
236     ret = 1;
237  end:
238     OPENSSL_free(copied_argv);
239     OPENSSL_free(default_config_file);
240     lh_FUNCTION_free(prog);
241     OPENSSL_free(arg.argv);
242
243     BIO_free(bio_in);
244     BIO_free_all(bio_out);
245     apps_shutdown();
246 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
247     if (CRYPTO_mem_leaks(bio_err) <= 0)
248         ret = 1;
249 #endif
250     BIO_free(bio_err);
251     EXIT(ret);
252 }
253
254 const OPTIONS exit_options[] = {
255     {NULL}
256 };
257
258 static void list_cipher_fn(const EVP_CIPHER *c,
259                            const char *from, const char *to, void *arg)
260 {
261     if (c)
262         BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
263     else {
264         if (!from)
265             from = "<undefined>";
266         if (!to)
267             to = "<undefined>";
268         BIO_printf(arg, "%s => %s\n", from, to);
269     }
270 }
271
272 static void list_md_fn(const EVP_MD *m,
273                        const char *from, const char *to, void *arg)
274 {
275     if (m)
276         BIO_printf(arg, "%s\n", EVP_MD_name(m));
277     else {
278         if (!from)
279             from = "<undefined>";
280         if (!to)
281             to = "<undefined>";
282         BIO_printf((BIO *)arg, "%s => %s\n", from, to);
283     }
284 }
285
286 static void list_missing_help(void)
287 {
288     const FUNCTION *fp;
289     const OPTIONS *o;
290
291     for (fp = functions; fp->name != NULL; fp++) {
292         if ((o = fp->help) == NULL) {
293             BIO_printf(bio_out, "%s *\n", fp->name);
294             continue;
295         }
296         for ( ; o->name != NULL; o++) {
297             if (o->helpstr == NULL)
298                 BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
299         }
300     }
301 }
302
303
304 /* Unified enum for help and list commands. */
305 typedef enum HELPLIST_CHOICE {
306     OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
307     OPT_COMMANDS, OPT_DIGEST_COMMANDS,
308     OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
309     OPT_PK_ALGORITHMS, OPT_DISABLED, OPT_MISSING_HELP
310 } HELPLIST_CHOICE;
311
312 const OPTIONS list_options[] = {
313     {"help", OPT_HELP, '-', "Display this summary"},
314     {"commands", OPT_COMMANDS, '-', "List of standard commands"},
315     {"digest-commands", OPT_DIGEST_COMMANDS, '-',
316      "List of message digest commands"},
317     {"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
318      "List of message digest algorithms"},
319     {"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
320     {"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
321      "List of cipher algorithms"},
322     {"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
323      "List of public key algorithms"},
324     {"disabled", OPT_DISABLED, '-',
325      "List of disabled features"},
326     {"missing-help", OPT_MISSING_HELP, '-',
327      "List missing detailed help strings"},
328     {NULL}
329 };
330
331 int list_main(int argc, char **argv)
332 {
333     char *prog;
334     HELPLIST_CHOICE o;
335     int done = 0;
336
337     prog = opt_init(argc, argv, list_options);
338     while ((o = opt_next()) != OPT_EOF) {
339         switch (o) {
340         case OPT_EOF:  /* Never hit, but suppresses warning */
341         case OPT_ERR:
342             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
343             return 1;
344         case OPT_HELP:
345             opt_help(list_options);
346             break;
347         case OPT_COMMANDS:
348             list_type(FT_general);
349             break;
350         case OPT_DIGEST_COMMANDS:
351             list_type(FT_md);
352             break;
353         case OPT_DIGEST_ALGORITHMS:
354             EVP_MD_do_all_sorted(list_md_fn, bio_out);
355             break;
356         case OPT_CIPHER_COMMANDS:
357             list_type(FT_cipher);
358             break;
359         case OPT_CIPHER_ALGORITHMS:
360             EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
361             break;
362         case OPT_PK_ALGORITHMS:
363             list_pkey();
364             break;
365         case OPT_DISABLED:
366             list_disabled();
367             break;
368         case OPT_MISSING_HELP:
369             list_missing_help();
370             break;
371         }
372         done = 1;
373     }
374
375     if (!done) {
376         BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
377         return 1;
378     }
379
380     return 0;
381 }
382
383 typedef enum HELP_CHOICE {
384     OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
385 } HELP_CHOICE;
386
387 const OPTIONS help_options[] = {
388     {"help", OPT_hHELP, '-', "Display this summary"},
389     {NULL}
390 };
391
392
393 int help_main(int argc, char **argv)
394 {
395     FUNCTION *fp;
396     int i, nl;
397     FUNC_TYPE tp;
398     char *prog;
399     HELP_CHOICE o;
400
401     prog = opt_init(argc, argv, help_options);
402     while ((o = opt_next()) != OPT_hEOF) {
403         switch (o) {
404         case OPT_hERR:
405         case OPT_hEOF:
406             BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
407             return 1;
408         case OPT_hHELP:
409             opt_help(help_options);
410             return 0;
411         }
412     }
413
414     if (opt_num_rest() != 0) {
415         BIO_printf(bio_err, "Usage: %s\n", prog);
416         return 1;
417     }
418
419     BIO_printf(bio_err, "\nStandard commands");
420     i = 0;
421     tp = FT_none;
422     for (fp = functions; fp->name != NULL; fp++) {
423         nl = 0;
424         if (((i++) % COLUMNS) == 0) {
425             BIO_printf(bio_err, "\n");
426             nl = 1;
427         }
428         if (fp->type != tp) {
429             tp = fp->type;
430             if (!nl)
431                 BIO_printf(bio_err, "\n");
432             if (tp == FT_md) {
433                 i = 1;
434                 BIO_printf(bio_err,
435                            "\nMessage Digest commands (see the `dgst' command for more details)\n");
436             } else if (tp == FT_cipher) {
437                 i = 1;
438                 BIO_printf(bio_err,
439                            "\nCipher commands (see the `enc' command for more details)\n");
440             }
441         }
442         BIO_printf(bio_err, FORMAT, fp->name);
443     }
444     BIO_printf(bio_err, "\n\n");
445     return 0;
446 }
447
448 int exit_main(int argc, char **argv)
449 {
450     return EXIT_THE_PROGRAM;
451 }
452
453 static void list_type(FUNC_TYPE ft)
454 {
455     FUNCTION *fp;
456     int i = 0;
457
458     for (fp = functions; fp->name != NULL; fp++)
459         if (fp->type == ft) {
460             if ((i++ % COLUMNS) == 0)
461                 BIO_printf(bio_out, "\n");
462             BIO_printf(bio_out, FORMAT, fp->name);
463         }
464     BIO_printf(bio_out, "\n");
465 }
466
467 static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
468 {
469     FUNCTION f, *fp;
470
471     if (argc <= 0 || argv[0] == NULL)
472         return (0);
473     f.name = argv[0];
474     fp = lh_FUNCTION_retrieve(prog, &f);
475     if (fp == NULL) {
476         if (EVP_get_digestbyname(argv[0])) {
477             f.type = FT_md;
478             f.func = dgst_main;
479             fp = &f;
480         } else if (EVP_get_cipherbyname(argv[0])) {
481             f.type = FT_cipher;
482             f.func = enc_main;
483             fp = &f;
484         }
485     }
486     if (fp != NULL) {
487         return (fp->func(argc, argv));
488     }
489     if ((strncmp(argv[0], "no-", 3)) == 0) {
490         /*
491          * User is asking if foo is unsupported, by trying to "run" the
492          * no-foo command.  Strange.
493          */
494         f.name = argv[0] + 3;
495         if (lh_FUNCTION_retrieve(prog, &f) == NULL) {
496             BIO_printf(bio_out, "%s\n", argv[0]);
497             return (0);
498         }
499         BIO_printf(bio_out, "%s\n", argv[0] + 3);
500         return 1;
501     }
502     if (strcmp(argv[0], "quit") == 0 || strcmp(argv[0], "q") == 0 ||
503         strcmp(argv[0], "exit") == 0 || strcmp(argv[0], "bye") == 0)
504         /* Special value to mean "exit the program. */
505         return EXIT_THE_PROGRAM;
506
507     BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
508                argv[0]);
509     return (1);
510 }
511
512 static void list_pkey(void)
513 {
514     int i;
515
516     for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
517         const EVP_PKEY_ASN1_METHOD *ameth;
518         int pkey_id, pkey_base_id, pkey_flags;
519         const char *pinfo, *pem_str;
520         ameth = EVP_PKEY_asn1_get0(i);
521         EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
522                                 &pinfo, &pem_str, ameth);
523         if (pkey_flags & ASN1_PKEY_ALIAS) {
524             BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
525             BIO_printf(bio_out, "\tAlias for: %s\n",
526                        OBJ_nid2ln(pkey_base_id));
527         } else {
528             BIO_printf(bio_out, "Name: %s\n", pinfo);
529             BIO_printf(bio_out, "\tType: %s Algorithm\n",
530                        pkey_flags & ASN1_PKEY_DYNAMIC ?
531                        "External" : "Builtin");
532             BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
533             if (pem_str == NULL)
534                 pem_str = "(none)";
535             BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
536         }
537
538     }
539 }
540
541 static int function_cmp(const FUNCTION * a, const FUNCTION * b)
542 {
543     return strncmp(a->name, b->name, 8);
544 }
545
546 static unsigned long function_hash(const FUNCTION * a)
547 {
548     return OPENSSL_LH_strhash(a->name);
549 }
550
551 static int SortFnByName(const void *_f1, const void *_f2)
552 {
553     const FUNCTION *f1 = _f1;
554     const FUNCTION *f2 = _f2;
555
556     if (f1->type != f2->type)
557         return f1->type - f2->type;
558     return strcmp(f1->name, f2->name);
559 }
560
561 static void list_disabled(void)
562 {
563     BIO_puts(bio_out, "Disabled algorithms:\n");
564 #ifdef OPENSSL_NO_ARIA
565     BIO_puts(bio_out, "ARIA\n");
566 #endif
567 #ifdef OPENSSL_NO_BF
568     BIO_puts(bio_out, "BF\n");
569 #endif
570 #ifdef OPENSSL_NO_BLAKE2
571     BIO_puts(bio_out, "BLAKE2\n");
572 #endif
573 #ifdef OPENSSL_NO_CAMELLIA
574     BIO_puts(bio_out, "CAMELLIA\n");
575 #endif
576 #ifdef OPENSSL_NO_CAST
577     BIO_puts(bio_out, "CAST\n");
578 #endif
579 #ifdef OPENSSL_NO_CMAC
580     BIO_puts(bio_out, "CMAC\n");
581 #endif
582 #ifdef OPENSSL_NO_CMS
583     BIO_puts(bio_out, "CMS\n");
584 #endif
585 #ifdef OPENSSL_NO_COMP
586     BIO_puts(bio_out, "COMP\n");
587 #endif
588 #ifdef OPENSSL_NO_DES
589     BIO_puts(bio_out, "DES\n");
590 #endif
591 #ifdef OPENSSL_NO_DGRAM
592     BIO_puts(bio_out, "DGRAM\n");
593 #endif
594 #ifdef OPENSSL_NO_DH
595     BIO_puts(bio_out, "DH\n");
596 #endif
597 #ifdef OPENSSL_NO_DSA
598     BIO_puts(bio_out, "DSA\n");
599 #endif
600 #if defined(OPENSSL_NO_DTLS)
601     BIO_puts(bio_out, "DTLS\n");
602 #endif
603 #if defined(OPENSSL_NO_DTLS1)
604     BIO_puts(bio_out, "DTLS1\n");
605 #endif
606 #if defined(OPENSSL_NO_DTLS1_2)
607     BIO_puts(bio_out, "DTLS1_2\n");
608 #endif
609 #ifdef OPENSSL_NO_EC
610     BIO_puts(bio_out, "EC\n");
611 #endif
612 #ifdef OPENSSL_NO_EC2M
613     BIO_puts(bio_out, "EC2M\n");
614 #endif
615 #ifdef OPENSSL_NO_ENGINE
616     BIO_puts(bio_out, "ENGINE\n");
617 #endif
618 #ifdef OPENSSL_NO_GOST
619     BIO_puts(bio_out, "GOST\n");
620 #endif
621 #ifdef OPENSSL_NO_HEARTBEATS
622     BIO_puts(bio_out, "HEARTBEATS\n");
623 #endif
624 #ifdef OPENSSL_NO_IDEA
625     BIO_puts(bio_out, "IDEA\n");
626 #endif
627 #ifdef OPENSSL_NO_MD2
628     BIO_puts(bio_out, "MD2\n");
629 #endif
630 #ifdef OPENSSL_NO_MD4
631     BIO_puts(bio_out, "MD4\n");
632 #endif
633 #ifdef OPENSSL_NO_MD5
634     BIO_puts(bio_out, "MD5\n");
635 #endif
636 #ifdef OPENSSL_NO_MDC2
637     BIO_puts(bio_out, "MDC2\n");
638 #endif
639 #ifdef OPENSSL_NO_OCB
640     BIO_puts(bio_out, "OCB\n");
641 #endif
642 #ifdef OPENSSL_NO_OCSP
643     BIO_puts(bio_out, "OCSP\n");
644 #endif
645 #ifdef OPENSSL_NO_PSK
646     BIO_puts(bio_out, "PSK\n");
647 #endif
648 #ifdef OPENSSL_NO_RC2
649     BIO_puts(bio_out, "RC2\n");
650 #endif
651 #ifdef OPENSSL_NO_RC4
652     BIO_puts(bio_out, "RC4\n");
653 #endif
654 #ifdef OPENSSL_NO_RC5
655     BIO_puts(bio_out, "RC5\n");
656 #endif
657 #ifdef OPENSSL_NO_RMD160
658     BIO_puts(bio_out, "RMD160\n");
659 #endif
660 #ifdef OPENSSL_NO_RSA
661     BIO_puts(bio_out, "RSA\n");
662 #endif
663 #ifdef OPENSSL_NO_SCRYPT
664     BIO_puts(bio_out, "SCRYPT\n");
665 #endif
666 #ifdef OPENSSL_NO_SCTP
667     BIO_puts(bio_out, "SCTP\n");
668 #endif
669 #ifdef OPENSSL_NO_SEED
670     BIO_puts(bio_out, "SEED\n");
671 #endif
672 #ifdef OPENSSL_NO_SOCK
673     BIO_puts(bio_out, "SOCK\n");
674 #endif
675 #ifdef OPENSSL_NO_SRP
676     BIO_puts(bio_out, "SRP\n");
677 #endif
678 #ifdef OPENSSL_NO_SRTP
679     BIO_puts(bio_out, "SRTP\n");
680 #endif
681 #ifdef OPENSSL_NO_SSL3
682     BIO_puts(bio_out, "SSL3\n");
683 #endif
684 #ifdef OPENSSL_NO_TLS1
685     BIO_puts(bio_out, "TLS1\n");
686 #endif
687 #ifdef OPENSSL_NO_TLS1_1
688     BIO_puts(bio_out, "TLS1_1\n");
689 #endif
690 #ifdef OPENSSL_NO_TLS1_2
691     BIO_puts(bio_out, "TLS1_2\n");
692 #endif
693 #ifdef OPENSSL_NO_WHIRLPOOL
694     BIO_puts(bio_out, "WHIRLPOOL\n");
695 #endif
696 #ifndef ZLIB
697     BIO_puts(bio_out, "ZLIB\n");
698 #endif
699 }
700
701 static LHASH_OF(FUNCTION) *prog_init(void)
702 {
703     LHASH_OF(FUNCTION) *ret;
704     FUNCTION *f;
705     size_t i;
706
707     /* Sort alphabetically within category. For nicer help displays. */
708     for (i = 0, f = functions; f->name != NULL; ++f, ++i) ;
709     qsort(functions, i, sizeof(*functions), SortFnByName);
710
711     if ((ret = lh_FUNCTION_new(function_hash, function_cmp)) == NULL)
712         return (NULL);
713
714     for (f = functions; f->name != NULL; f++)
715         (void)lh_FUNCTION_insert(ret, f);
716     return (ret);
717 }