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