xref: /freebsd/crypto/openssl/test/testutil/apps_shims.c (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
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 
app_malloc(size_t sz,const char * what)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 
opt_legacy_okay(void)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  */
opt_provider_option_given(void)43 int opt_provider_option_given(void)
44 {
45     return 0;
46 }
47 
app_get0_propq(void)48 const char *app_get0_propq(void)
49 {
50     return NULL;
51 }
52 
app_get0_libctx(void)53 OSSL_LIB_CTX *app_get0_libctx(void)
54 {
55     return NULL;
56 }
57