|
||||
File indexing completed on 2025-01-18 10:05:40
0001 /* 0002 * Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved. 0003 * 0004 * Licensed under the Apache License 2.0 (the "License"). You may not use 0005 * this file except in compliance with the License. You can obtain a copy 0006 * in the file LICENSE in the source distribution or at 0007 * https://www.openssl.org/source/license.html 0008 */ 0009 0010 #ifndef OPENSSL_CORE_H 0011 # define OPENSSL_CORE_H 0012 # pragma once 0013 0014 # include <stddef.h> 0015 # include <openssl/types.h> 0016 0017 # ifdef __cplusplus 0018 extern "C" { 0019 # endif 0020 0021 /*- 0022 * Base types 0023 * ---------- 0024 * 0025 * These are the types that the OpenSSL core and providers have in common 0026 * to communicate data between them. 0027 */ 0028 0029 /* Opaque handles to be used with core upcall functions from providers */ 0030 typedef struct ossl_core_handle_st OSSL_CORE_HANDLE; 0031 typedef struct openssl_core_ctx_st OPENSSL_CORE_CTX; 0032 typedef struct ossl_core_bio_st OSSL_CORE_BIO; 0033 0034 /* 0035 * Dispatch table element. function_id numbers and the functions are defined 0036 * in core_dispatch.h, see macros with 'OSSL_CORE_MAKE_FUNC' in their names. 0037 * 0038 * An array of these is always terminated by function_id == 0 0039 */ 0040 struct ossl_dispatch_st { 0041 int function_id; 0042 void (*function)(void); 0043 }; 0044 0045 # define OSSL_DISPATCH_END \ 0046 { 0, NULL } 0047 0048 /* 0049 * Other items, essentially an int<->pointer map element. 0050 * 0051 * We make this type distinct from OSSL_DISPATCH to ensure that dispatch 0052 * tables remain tables with function pointers only. 0053 * 0054 * This is used whenever we need to pass things like a table of error reason 0055 * codes <-> reason string maps, ... 0056 * 0057 * Usage determines which field works as key if any, rather than field order. 0058 * 0059 * An array of these is always terminated by id == 0 && ptr == NULL 0060 */ 0061 struct ossl_item_st { 0062 unsigned int id; 0063 void *ptr; 0064 }; 0065 0066 /* 0067 * Type to tie together algorithm names, property definition string and 0068 * the algorithm implementation in the form of a dispatch table. 0069 * 0070 * An array of these is always terminated by algorithm_names == NULL 0071 */ 0072 struct ossl_algorithm_st { 0073 const char *algorithm_names; /* key */ 0074 const char *property_definition; /* key */ 0075 const OSSL_DISPATCH *implementation; 0076 const char *algorithm_description; 0077 }; 0078 0079 /* 0080 * Type to pass object data in a uniform way, without exposing the object 0081 * structure. 0082 * 0083 * An array of these is always terminated by key == NULL 0084 */ 0085 struct ossl_param_st { 0086 const char *key; /* the name of the parameter */ 0087 unsigned int data_type; /* declare what kind of content is in buffer */ 0088 void *data; /* value being passed in or out */ 0089 size_t data_size; /* data size */ 0090 size_t return_size; /* returned content size */ 0091 }; 0092 0093 /* Currently supported OSSL_PARAM data types */ 0094 /* 0095 * OSSL_PARAM_INTEGER and OSSL_PARAM_UNSIGNED_INTEGER 0096 * are arbitrary length and therefore require an arbitrarily sized buffer, 0097 * since they may be used to pass numbers larger than what is natively 0098 * available. 0099 * 0100 * The number must be buffered in native form, i.e. MSB first on B_ENDIAN 0101 * systems and LSB first on L_ENDIAN systems. This means that arbitrary 0102 * native integers can be stored in the buffer, just make sure that the 0103 * buffer size is correct and the buffer itself is properly aligned (for 0104 * example by having the buffer field point at a C integer). 0105 */ 0106 # define OSSL_PARAM_INTEGER 1 0107 # define OSSL_PARAM_UNSIGNED_INTEGER 2 0108 /*- 0109 * OSSL_PARAM_REAL 0110 * is a C binary floating point values in native form and alignment. 0111 */ 0112 # define OSSL_PARAM_REAL 3 0113 /*- 0114 * OSSL_PARAM_UTF8_STRING 0115 * is a printable string. It is expected to be printed as it is. 0116 */ 0117 # define OSSL_PARAM_UTF8_STRING 4 0118 /*- 0119 * OSSL_PARAM_OCTET_STRING 0120 * is a string of bytes with no further specification. It is expected to be 0121 * printed as a hexdump. 0122 */ 0123 # define OSSL_PARAM_OCTET_STRING 5 0124 /*- 0125 * OSSL_PARAM_UTF8_PTR 0126 * is a pointer to a printable string. It is expected to be printed as it is. 0127 * 0128 * The difference between this and OSSL_PARAM_UTF8_STRING is that only pointers 0129 * are manipulated for this type. 0130 * 0131 * This is more relevant for parameter requests, where the responding 0132 * function doesn't need to copy the data to the provided buffer, but 0133 * sets the provided buffer to point at the actual data instead. 0134 * 0135 * WARNING! Using these is FRAGILE, as it assumes that the actual 0136 * data and its location are constant. 0137 * 0138 * EXTRA WARNING! If you are not completely sure you most likely want 0139 * to use the OSSL_PARAM_UTF8_STRING type. 0140 */ 0141 # define OSSL_PARAM_UTF8_PTR 6 0142 /*- 0143 * OSSL_PARAM_OCTET_PTR 0144 * is a pointer to a string of bytes with no further specification. It is 0145 * expected to be printed as a hexdump. 0146 * 0147 * The difference between this and OSSL_PARAM_OCTET_STRING is that only pointers 0148 * are manipulated for this type. 0149 * 0150 * This is more relevant for parameter requests, where the responding 0151 * function doesn't need to copy the data to the provided buffer, but 0152 * sets the provided buffer to point at the actual data instead. 0153 * 0154 * WARNING! Using these is FRAGILE, as it assumes that the actual 0155 * data and its location are constant. 0156 * 0157 * EXTRA WARNING! If you are not completely sure you most likely want 0158 * to use the OSSL_PARAM_OCTET_STRING type. 0159 */ 0160 # define OSSL_PARAM_OCTET_PTR 7 0161 0162 /* 0163 * Typedef for the thread stop handling callback. Used both internally and by 0164 * providers. 0165 * 0166 * Providers may register for notifications about threads stopping by 0167 * registering a callback to hear about such events. Providers register the 0168 * callback using the OSSL_FUNC_CORE_THREAD_START function in the |in| dispatch 0169 * table passed to OSSL_provider_init(). The arg passed back to a provider will 0170 * be the provider side context object. 0171 */ 0172 typedef void (*OSSL_thread_stop_handler_fn)(void *arg); 0173 0174 0175 /*- 0176 * Provider entry point 0177 * -------------------- 0178 * 0179 * This function is expected to be present in any dynamically loadable 0180 * provider module. By definition, if this function doesn't exist in a 0181 * module, that module is not an OpenSSL provider module. 0182 */ 0183 /*- 0184 * |handle| pointer to opaque type OSSL_CORE_HANDLE. This can be used 0185 * together with some functions passed via |in| to query data. 0186 * |in| is the array of functions that the Core passes to the provider. 0187 * |out| will be the array of base functions that the provider passes 0188 * back to the Core. 0189 * |provctx| a provider side context object, optionally created if the 0190 * provider needs it. This value is passed to other provider 0191 * functions, notably other context constructors. 0192 */ 0193 typedef int (OSSL_provider_init_fn)(const OSSL_CORE_HANDLE *handle, 0194 const OSSL_DISPATCH *in, 0195 const OSSL_DISPATCH **out, 0196 void **provctx); 0197 # ifdef __VMS 0198 # pragma names save 0199 # pragma names uppercase,truncated 0200 # endif 0201 OPENSSL_EXPORT OSSL_provider_init_fn OSSL_provider_init; 0202 # ifdef __VMS 0203 # pragma names restore 0204 # endif 0205 0206 /* 0207 * Generic callback function signature. 0208 * 0209 * The expectation is that any provider function that wants to offer 0210 * a callback / hook can do so by taking an argument with this type, 0211 * as well as a pointer to caller-specific data. When calling the 0212 * callback, the provider function can populate an OSSL_PARAM array 0213 * with data of its choice and pass that in the callback call, along 0214 * with the caller data argument. 0215 * 0216 * libcrypto may use the OSSL_PARAM array to create arguments for an 0217 * application callback it knows about. 0218 */ 0219 typedef int (OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg); 0220 typedef int (OSSL_INOUT_CALLBACK)(const OSSL_PARAM in_params[], 0221 OSSL_PARAM out_params[], void *arg); 0222 /* 0223 * Passphrase callback function signature 0224 * 0225 * This is similar to the generic callback function above, but adds a 0226 * result parameter. 0227 */ 0228 typedef int (OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size, 0229 size_t *pass_len, 0230 const OSSL_PARAM params[], void *arg); 0231 0232 # ifdef __cplusplus 0233 } 0234 # endif 0235 0236 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |