xref: /freebsd/crypto/openssl/test/testutil/apps_shims.c (revision 56b17de1e8360fe131d425de20b5e75ff3ea897c)
1 /*
2  * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (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 <stdlib.h>
11 #include "apps.h"
12 #include "../testutil.h"
13 
14 /* shim that avoids sucking in too much from apps/apps.c */
15 
16 void *app_malloc(size_t sz, const char *what)
17 {
18     void *vp;
19 
20     /*
21      * This isn't ideal but it is what the app's app_malloc() does on failure.
22      * Instead of exiting with a failure, abort() is called which makes sure
23      * that there will be a good stack trace for debugging purposes.
24      */
25     if (!TEST_ptr(vp = OPENSSL_malloc(sz))) {
26         TEST_info("Could not allocate %zu bytes for %s\n", sz, what);
27         abort();
28     }
29     return vp;
30 }
31 
32 /* shim to prevent sucking in too much from apps */
33 
34 int opt_legacy_okay(void)
35 {
36     return 1;
37 }
38 
39 /*
40  * These three functions are defined here so that they don't need to come from
41  * the apps source code and pull in a lot of additional things.
42  */
43 int opt_provider_option_given(void)
44 {
45     return 0;
46 }
47 
48 const char *app_get0_propq(void)
49 {
50     return NULL;
51 }
52 
53 OSSL_LIB_CTX *app_get0_libctx(void)
54 {
55     return NULL;
56 }
57