2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include <openssl/self_test.h>
11 #include "internal/cryptlib.h"
13 typedef struct self_test_cb_st
19 static void *self_test_set_callback_new(OPENSSL_CTX *ctx)
23 stcb = OPENSSL_zalloc(sizeof(*stcb));
27 static void self_test_set_callback_free(void *stcb)
32 static const OPENSSL_CTX_METHOD self_test_set_callback_method = {
33 self_test_set_callback_new,
34 self_test_set_callback_free,
37 static SELF_TEST_CB *get_self_test_callback(OPENSSL_CTX *libctx)
39 return openssl_ctx_get_data(libctx, OPENSSL_CTX_SELF_TEST_CB_INDEX,
40 &self_test_set_callback_method);
43 void OSSL_SELF_TEST_set_callback(OPENSSL_CTX *libctx, OSSL_CALLBACK *cb,
46 SELF_TEST_CB *stcb = get_self_test_callback(libctx);
53 void OSSL_SELF_TEST_get_callback(OPENSSL_CTX *libctx, OSSL_CALLBACK **cb,
56 SELF_TEST_CB *stcb = get_self_test_callback(libctx);
59 *cb = (stcb != NULL ? stcb->cb : NULL);
61 *cbarg = (stcb != NULL ? stcb->cbarg : NULL);