Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:40

0001 /*
0002  * Copyright 2019-2024 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_NUMBERS_H
0011 # define OPENSSL_CORE_NUMBERS_H
0012 # pragma once
0013 
0014 # include <stdarg.h>
0015 # include <openssl/core.h>
0016 # include <openssl/indicator.h>
0017 
0018 # ifdef __cplusplus
0019 extern "C" {
0020 # endif
0021 
0022 /*-
0023  * Identities
0024  * ----------
0025  *
0026  * All series start with 1, to allow 0 to be an array terminator.
0027  * For any FUNC identity, we also provide a function signature typedef
0028  * and a static inline function to extract a function pointer from a
0029  * OSSL_DISPATCH element in a type safe manner.
0030  *
0031  * Names:
0032  * for any function base name 'foo' (uppercase form 'FOO'), we will have
0033  * the following:
0034  * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives
0035  *   thereof (to be specified further down)
0036  * - a function signature typedef with the name OSSL_FUNC_'foo'_fn
0037  * - a function pointer extractor function with the name OSSL_FUNC_'foo'
0038  */
0039 
0040 /*
0041  * Helper macro to create the function signature typedef and the extractor
0042  * |type| is the return-type of the function, |name| is the name of the
0043  * function to fetch, and |args| is a parenthesized list of parameters
0044  * for the function (that is, it is |name|'s function signature).
0045  * Note: This is considered a "reserved" internal macro. Applications should
0046  * not use this or assume its existence.
0047  */
0048 #define OSSL_CORE_MAKE_FUNC(type,name,args)                             \
0049     typedef type (OSSL_FUNC_##name##_fn)args;                           \
0050     static ossl_unused ossl_inline \
0051     OSSL_FUNC_##name##_fn *OSSL_FUNC_##name(const OSSL_DISPATCH *opf)   \
0052     {                                                                   \
0053         return (OSSL_FUNC_##name##_fn *)opf->function;                  \
0054     }
0055 
0056 /*
0057  * Core function identities, for the two OSSL_DISPATCH tables being passed
0058  * in the OSSL_provider_init call.
0059  *
0060  * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must
0061  * therefore NEVER be used as a function identity.
0062  */
0063 /* Functions provided by the Core to the provider, reserved numbers 1-1023 */
0064 # define OSSL_FUNC_CORE_GETTABLE_PARAMS        1
0065 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
0066                     core_gettable_params,(const OSSL_CORE_HANDLE *prov))
0067 # define OSSL_FUNC_CORE_GET_PARAMS             2
0068 OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_CORE_HANDLE *prov,
0069                                          OSSL_PARAM params[]))
0070 # define OSSL_FUNC_CORE_THREAD_START           3
0071 OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_CORE_HANDLE *prov,
0072                                            OSSL_thread_stop_handler_fn handfn,
0073                                            void *arg))
0074 # define OSSL_FUNC_CORE_GET_LIBCTX             4
0075 OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *,core_get_libctx,
0076                     (const OSSL_CORE_HANDLE *prov))
0077 # define OSSL_FUNC_CORE_NEW_ERROR              5
0078 OSSL_CORE_MAKE_FUNC(void,core_new_error,(const OSSL_CORE_HANDLE *prov))
0079 # define OSSL_FUNC_CORE_SET_ERROR_DEBUG        6
0080 OSSL_CORE_MAKE_FUNC(void,core_set_error_debug,
0081                     (const OSSL_CORE_HANDLE *prov,
0082                      const char *file, int line, const char *func))
0083 # define OSSL_FUNC_CORE_VSET_ERROR             7
0084 OSSL_CORE_MAKE_FUNC(void,core_vset_error,
0085                     (const OSSL_CORE_HANDLE *prov,
0086                      uint32_t reason, const char *fmt, va_list args))
0087 # define OSSL_FUNC_CORE_SET_ERROR_MARK         8
0088 OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov))
0089 # define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK  9
0090 OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark,
0091                     (const OSSL_CORE_HANDLE *prov))
0092 # define OSSL_FUNC_CORE_POP_ERROR_TO_MARK     10
0093 OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov))
0094 
0095 
0096 /* Functions to access the OBJ database */
0097 
0098 #define OSSL_FUNC_CORE_OBJ_ADD_SIGID          11
0099 #define OSSL_FUNC_CORE_OBJ_CREATE             12
0100 
0101 OSSL_CORE_MAKE_FUNC(int, core_obj_add_sigid,
0102                     (const OSSL_CORE_HANDLE *prov, const char  *sign_name,
0103                      const char *digest_name, const char *pkey_name))
0104 OSSL_CORE_MAKE_FUNC(int, core_obj_create,
0105                     (const OSSL_CORE_HANDLE *prov, const char *oid,
0106                      const char *sn, const char *ln))
0107 
0108 /* Memory allocation, freeing, clearing. */
0109 #define OSSL_FUNC_CRYPTO_MALLOC               20
0110 OSSL_CORE_MAKE_FUNC(void *,
0111         CRYPTO_malloc, (size_t num, const char *file, int line))
0112 #define OSSL_FUNC_CRYPTO_ZALLOC               21
0113 OSSL_CORE_MAKE_FUNC(void *,
0114         CRYPTO_zalloc, (size_t num, const char *file, int line))
0115 #define OSSL_FUNC_CRYPTO_FREE                 22
0116 OSSL_CORE_MAKE_FUNC(void,
0117         CRYPTO_free, (void *ptr, const char *file, int line))
0118 #define OSSL_FUNC_CRYPTO_CLEAR_FREE           23
0119 OSSL_CORE_MAKE_FUNC(void,
0120         CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line))
0121 #define OSSL_FUNC_CRYPTO_REALLOC              24
0122 OSSL_CORE_MAKE_FUNC(void *,
0123         CRYPTO_realloc, (void *addr, size_t num, const char *file, int line))
0124 #define OSSL_FUNC_CRYPTO_CLEAR_REALLOC        25
0125 OSSL_CORE_MAKE_FUNC(void *,
0126         CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num,
0127                                const char *file, int line))
0128 #define OSSL_FUNC_CRYPTO_SECURE_MALLOC        26
0129 OSSL_CORE_MAKE_FUNC(void *,
0130         CRYPTO_secure_malloc, (size_t num, const char *file, int line))
0131 #define OSSL_FUNC_CRYPTO_SECURE_ZALLOC        27
0132 OSSL_CORE_MAKE_FUNC(void *,
0133         CRYPTO_secure_zalloc, (size_t num, const char *file, int line))
0134 #define OSSL_FUNC_CRYPTO_SECURE_FREE          28
0135 OSSL_CORE_MAKE_FUNC(void,
0136         CRYPTO_secure_free, (void *ptr, const char *file, int line))
0137 #define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE    29
0138 OSSL_CORE_MAKE_FUNC(void,
0139         CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file,
0140                                    int line))
0141 #define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED     30
0142 OSSL_CORE_MAKE_FUNC(int,
0143         CRYPTO_secure_allocated, (const void *ptr))
0144 #define OSSL_FUNC_OPENSSL_CLEANSE             31
0145 OSSL_CORE_MAKE_FUNC(void,
0146         OPENSSL_cleanse, (void *ptr, size_t len))
0147 
0148 /* Bio functions provided by the core */
0149 #define OSSL_FUNC_BIO_NEW_FILE                40
0150 #define OSSL_FUNC_BIO_NEW_MEMBUF              41
0151 #define OSSL_FUNC_BIO_READ_EX                 42
0152 #define OSSL_FUNC_BIO_WRITE_EX                43
0153 #define OSSL_FUNC_BIO_UP_REF                  44
0154 #define OSSL_FUNC_BIO_FREE                    45
0155 #define OSSL_FUNC_BIO_VPRINTF                 46
0156 #define OSSL_FUNC_BIO_VSNPRINTF               47
0157 #define OSSL_FUNC_BIO_PUTS                    48
0158 #define OSSL_FUNC_BIO_GETS                    49
0159 #define OSSL_FUNC_BIO_CTRL                    50
0160 
0161 
0162 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename,
0163                                                     const char *mode))
0164 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_membuf, (const void *buf, int len))
0165 OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data,
0166                                        size_t data_len, size_t *bytes_read))
0167 OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data,
0168                                         size_t data_len, size_t *written))
0169 OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO *bio, char *buf, int size))
0170 OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO *bio, const char *str))
0171 OSSL_CORE_MAKE_FUNC(int, BIO_up_ref, (OSSL_CORE_BIO *bio))
0172 OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio))
0173 OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format,
0174                                        va_list args))
0175 OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf,
0176                    (char *buf, size_t n, const char *fmt, va_list args))
0177 OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, (OSSL_CORE_BIO *bio,
0178                                     int cmd, long num, void *ptr))
0179 
0180 /* New seeding functions prototypes with the 101-104 series */
0181 #define OSSL_FUNC_CLEANUP_USER_ENTROPY        96
0182 #define OSSL_FUNC_CLEANUP_USER_NONCE          97
0183 #define OSSL_FUNC_GET_USER_ENTROPY            98
0184 #define OSSL_FUNC_GET_USER_NONCE              99
0185 
0186 #define OSSL_FUNC_INDICATOR_CB                95
0187 OSSL_CORE_MAKE_FUNC(void, indicator_cb, (OPENSSL_CORE_CTX *ctx,
0188                                          OSSL_INDICATOR_CALLBACK **cb))
0189 #define OSSL_FUNC_SELF_TEST_CB               100
0190 OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX *ctx, OSSL_CALLBACK **cb,
0191                                          void **cbarg))
0192 
0193 /* Functions to get seed material from the operating system */
0194 #define OSSL_FUNC_GET_ENTROPY                101
0195 #define OSSL_FUNC_CLEANUP_ENTROPY            102
0196 #define OSSL_FUNC_GET_NONCE                  103
0197 #define OSSL_FUNC_CLEANUP_NONCE              104
0198 OSSL_CORE_MAKE_FUNC(size_t, get_entropy, (const OSSL_CORE_HANDLE *handle,
0199                                           unsigned char **pout, int entropy,
0200                                           size_t min_len, size_t max_len))
0201 OSSL_CORE_MAKE_FUNC(size_t, get_user_entropy, (const OSSL_CORE_HANDLE *handle,
0202                                                unsigned char **pout, int entropy,
0203                                                size_t min_len, size_t max_len))
0204 OSSL_CORE_MAKE_FUNC(void, cleanup_entropy, (const OSSL_CORE_HANDLE *handle,
0205                                             unsigned char *buf, size_t len))
0206 OSSL_CORE_MAKE_FUNC(void, cleanup_user_entropy, (const OSSL_CORE_HANDLE *handle,
0207                                                  unsigned char *buf, size_t len))
0208 OSSL_CORE_MAKE_FUNC(size_t, get_nonce, (const OSSL_CORE_HANDLE *handle,
0209                                         unsigned char **pout, size_t min_len,
0210                                         size_t max_len, const void *salt,
0211                                         size_t salt_len))
0212 OSSL_CORE_MAKE_FUNC(size_t, get_user_nonce, (const OSSL_CORE_HANDLE *handle,
0213                                              unsigned char **pout, size_t min_len,
0214                                              size_t max_len, const void *salt,
0215                                              size_t salt_len))
0216 OSSL_CORE_MAKE_FUNC(void, cleanup_nonce, (const OSSL_CORE_HANDLE *handle,
0217                                           unsigned char *buf, size_t len))
0218 OSSL_CORE_MAKE_FUNC(void, cleanup_user_nonce, (const OSSL_CORE_HANDLE *handle,
0219                                                unsigned char *buf, size_t len))
0220 
0221 /* Functions to access the core's providers */
0222 #define OSSL_FUNC_PROVIDER_REGISTER_CHILD_CB   105
0223 #define OSSL_FUNC_PROVIDER_DEREGISTER_CHILD_CB 106
0224 #define OSSL_FUNC_PROVIDER_NAME                107
0225 #define OSSL_FUNC_PROVIDER_GET0_PROVIDER_CTX   108
0226 #define OSSL_FUNC_PROVIDER_GET0_DISPATCH       109
0227 #define OSSL_FUNC_PROVIDER_UP_REF              110
0228 #define OSSL_FUNC_PROVIDER_FREE                111
0229 
0230 OSSL_CORE_MAKE_FUNC(int, provider_register_child_cb,
0231                     (const OSSL_CORE_HANDLE *handle,
0232                      int (*create_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata),
0233                      int (*remove_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata),
0234                      int (*global_props_cb)(const char *props, void *cbdata),
0235                      void *cbdata))
0236 OSSL_CORE_MAKE_FUNC(void, provider_deregister_child_cb,
0237                     (const OSSL_CORE_HANDLE *handle))
0238 OSSL_CORE_MAKE_FUNC(const char *, provider_name,
0239                     (const OSSL_CORE_HANDLE *prov))
0240 OSSL_CORE_MAKE_FUNC(void *, provider_get0_provider_ctx,
0241                     (const OSSL_CORE_HANDLE *prov))
0242 OSSL_CORE_MAKE_FUNC(const OSSL_DISPATCH *, provider_get0_dispatch,
0243                     (const OSSL_CORE_HANDLE *prov))
0244 OSSL_CORE_MAKE_FUNC(int, provider_up_ref,
0245                     (const OSSL_CORE_HANDLE *prov, int activate))
0246 OSSL_CORE_MAKE_FUNC(int, provider_free,
0247                     (const OSSL_CORE_HANDLE *prov, int deactivate))
0248 
0249 /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */
0250 # define OSSL_FUNC_PROVIDER_TEARDOWN           1024
0251 OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx))
0252 # define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS    1025
0253 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
0254                     provider_gettable_params,(void *provctx))
0255 # define OSSL_FUNC_PROVIDER_GET_PARAMS         1026
0256 OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx,
0257                                              OSSL_PARAM params[]))
0258 # define OSSL_FUNC_PROVIDER_QUERY_OPERATION    1027
0259 OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation,
0260                     (void *provctx, int operation_id, int *no_store))
0261 # define OSSL_FUNC_PROVIDER_UNQUERY_OPERATION  1028
0262 OSSL_CORE_MAKE_FUNC(void, provider_unquery_operation,
0263                     (void *provctx, int operation_id, const OSSL_ALGORITHM *))
0264 # define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1029
0265 OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings,
0266                     (void *provctx))
0267 # define OSSL_FUNC_PROVIDER_GET_CAPABILITIES   1030
0268 OSSL_CORE_MAKE_FUNC(int, provider_get_capabilities, (void *provctx,
0269                     const char *capability, OSSL_CALLBACK *cb, void *arg))
0270 # define OSSL_FUNC_PROVIDER_SELF_TEST          1031
0271 OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx))
0272 
0273 /* Operations */
0274 
0275 # define OSSL_OP_DIGEST                              1
0276 # define OSSL_OP_CIPHER                              2   /* Symmetric Ciphers */
0277 # define OSSL_OP_MAC                                 3
0278 # define OSSL_OP_KDF                                 4
0279 # define OSSL_OP_RAND                                5
0280 # define OSSL_OP_KEYMGMT                            10
0281 # define OSSL_OP_KEYEXCH                            11
0282 # define OSSL_OP_SIGNATURE                          12
0283 # define OSSL_OP_ASYM_CIPHER                        13
0284 # define OSSL_OP_KEM                                14
0285 /* New section for non-EVP operations */
0286 # define OSSL_OP_ENCODER                            20
0287 # define OSSL_OP_DECODER                            21
0288 # define OSSL_OP_STORE                              22
0289 /* Highest known operation number */
0290 # define OSSL_OP__HIGHEST                           22
0291 
0292 /* Digests */
0293 
0294 # define OSSL_FUNC_DIGEST_NEWCTX                     1
0295 # define OSSL_FUNC_DIGEST_INIT                       2
0296 # define OSSL_FUNC_DIGEST_UPDATE                     3
0297 # define OSSL_FUNC_DIGEST_FINAL                      4
0298 # define OSSL_FUNC_DIGEST_DIGEST                     5
0299 # define OSSL_FUNC_DIGEST_FREECTX                    6
0300 # define OSSL_FUNC_DIGEST_DUPCTX                     7
0301 # define OSSL_FUNC_DIGEST_GET_PARAMS                 8
0302 # define OSSL_FUNC_DIGEST_SET_CTX_PARAMS             9
0303 # define OSSL_FUNC_DIGEST_GET_CTX_PARAMS            10
0304 # define OSSL_FUNC_DIGEST_GETTABLE_PARAMS           11
0305 # define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS       12
0306 # define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS       13
0307 # define OSSL_FUNC_DIGEST_SQUEEZE                   14
0308 
0309 OSSL_CORE_MAKE_FUNC(void *, digest_newctx, (void *provctx))
0310 OSSL_CORE_MAKE_FUNC(int, digest_init, (void *dctx, const OSSL_PARAM params[]))
0311 OSSL_CORE_MAKE_FUNC(int, digest_update,
0312                     (void *dctx, const unsigned char *in, size_t inl))
0313 OSSL_CORE_MAKE_FUNC(int, digest_final,
0314                     (void *dctx,
0315                      unsigned char *out, size_t *outl, size_t outsz))
0316 OSSL_CORE_MAKE_FUNC(int, digest_squeeze,
0317                     (void *dctx,
0318                      unsigned char *out, size_t *outl, size_t outsz))
0319 OSSL_CORE_MAKE_FUNC(int, digest_digest,
0320                     (void *provctx, const unsigned char *in, size_t inl,
0321                      unsigned char *out, size_t *outl, size_t outsz))
0322 
0323 OSSL_CORE_MAKE_FUNC(void, digest_freectx, (void *dctx))
0324 OSSL_CORE_MAKE_FUNC(void *, digest_dupctx, (void *dctx))
0325 
0326 OSSL_CORE_MAKE_FUNC(int, digest_get_params, (OSSL_PARAM params[]))
0327 OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params,
0328                     (void *vctx, const OSSL_PARAM params[]))
0329 OSSL_CORE_MAKE_FUNC(int, digest_get_ctx_params,
0330                     (void *vctx, OSSL_PARAM params[]))
0331 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_params,
0332                     (void *provctx))
0333 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_settable_ctx_params,
0334                     (void *dctx, void *provctx))
0335 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params,
0336                     (void *dctx, void *provctx))
0337 
0338 /* Symmetric Ciphers */
0339 
0340 # define OSSL_FUNC_CIPHER_NEWCTX                     1
0341 # define OSSL_FUNC_CIPHER_ENCRYPT_INIT               2
0342 # define OSSL_FUNC_CIPHER_DECRYPT_INIT               3
0343 # define OSSL_FUNC_CIPHER_UPDATE                     4
0344 # define OSSL_FUNC_CIPHER_FINAL                      5
0345 # define OSSL_FUNC_CIPHER_CIPHER                     6
0346 # define OSSL_FUNC_CIPHER_FREECTX                    7
0347 # define OSSL_FUNC_CIPHER_DUPCTX                     8
0348 # define OSSL_FUNC_CIPHER_GET_PARAMS                 9
0349 # define OSSL_FUNC_CIPHER_GET_CTX_PARAMS            10
0350 # define OSSL_FUNC_CIPHER_SET_CTX_PARAMS            11
0351 # define OSSL_FUNC_CIPHER_GETTABLE_PARAMS           12
0352 # define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS       13
0353 # define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS       14
0354 
0355 OSSL_CORE_MAKE_FUNC(void *, cipher_newctx, (void *provctx))
0356 OSSL_CORE_MAKE_FUNC(int, cipher_encrypt_init, (void *cctx,
0357                                                   const unsigned char *key,
0358                                                   size_t keylen,
0359                                                   const unsigned char *iv,
0360                                                   size_t ivlen,
0361                                                   const OSSL_PARAM params[]))
0362 OSSL_CORE_MAKE_FUNC(int, cipher_decrypt_init, (void *cctx,
0363                                                   const unsigned char *key,
0364                                                   size_t keylen,
0365                                                   const unsigned char *iv,
0366                                                   size_t ivlen,
0367                                                   const OSSL_PARAM params[]))
0368 OSSL_CORE_MAKE_FUNC(int, cipher_update,
0369                     (void *cctx,
0370                      unsigned char *out, size_t *outl, size_t outsize,
0371                      const unsigned char *in, size_t inl))
0372 OSSL_CORE_MAKE_FUNC(int, cipher_final,
0373                     (void *cctx,
0374                      unsigned char *out, size_t *outl, size_t outsize))
0375 OSSL_CORE_MAKE_FUNC(int, cipher_cipher,
0376                     (void *cctx,
0377                      unsigned char *out, size_t *outl, size_t outsize,
0378                      const unsigned char *in, size_t inl))
0379 OSSL_CORE_MAKE_FUNC(void, cipher_freectx, (void *cctx))
0380 OSSL_CORE_MAKE_FUNC(void *, cipher_dupctx, (void *cctx))
0381 OSSL_CORE_MAKE_FUNC(int, cipher_get_params, (OSSL_PARAM params[]))
0382 OSSL_CORE_MAKE_FUNC(int, cipher_get_ctx_params, (void *cctx,
0383                                                     OSSL_PARAM params[]))
0384 OSSL_CORE_MAKE_FUNC(int, cipher_set_ctx_params, (void *cctx,
0385                                                     const OSSL_PARAM params[]))
0386 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_params,
0387                     (void *provctx))
0388 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_settable_ctx_params,
0389                     (void *cctx, void *provctx))
0390 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_ctx_params,
0391                     (void *cctx, void *provctx))
0392 
0393 /* MACs */
0394 
0395 # define OSSL_FUNC_MAC_NEWCTX                        1
0396 # define OSSL_FUNC_MAC_DUPCTX                        2
0397 # define OSSL_FUNC_MAC_FREECTX                       3
0398 # define OSSL_FUNC_MAC_INIT                          4
0399 # define OSSL_FUNC_MAC_UPDATE                        5
0400 # define OSSL_FUNC_MAC_FINAL                         6
0401 # define OSSL_FUNC_MAC_GET_PARAMS                    7
0402 # define OSSL_FUNC_MAC_GET_CTX_PARAMS                8
0403 # define OSSL_FUNC_MAC_SET_CTX_PARAMS                9
0404 # define OSSL_FUNC_MAC_GETTABLE_PARAMS              10
0405 # define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS          11
0406 # define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS          12
0407 
0408 OSSL_CORE_MAKE_FUNC(void *, mac_newctx, (void *provctx))
0409 OSSL_CORE_MAKE_FUNC(void *, mac_dupctx, (void *src))
0410 OSSL_CORE_MAKE_FUNC(void, mac_freectx, (void *mctx))
0411 OSSL_CORE_MAKE_FUNC(int, mac_init, (void *mctx, const unsigned char *key,
0412                                     size_t keylen, const OSSL_PARAM params[]))
0413 OSSL_CORE_MAKE_FUNC(int, mac_update,
0414                     (void *mctx, const unsigned char *in, size_t inl))
0415 OSSL_CORE_MAKE_FUNC(int, mac_final,
0416                     (void *mctx,
0417                      unsigned char *out, size_t *outl, size_t outsize))
0418 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_params, (void *provctx))
0419 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_ctx_params,
0420                     (void *mctx, void *provctx))
0421 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_settable_ctx_params,
0422                     (void *mctx, void *provctx))
0423 OSSL_CORE_MAKE_FUNC(int, mac_get_params, (OSSL_PARAM params[]))
0424 OSSL_CORE_MAKE_FUNC(int, mac_get_ctx_params,
0425                     (void *mctx, OSSL_PARAM params[]))
0426 OSSL_CORE_MAKE_FUNC(int, mac_set_ctx_params,
0427                     (void *mctx, const OSSL_PARAM params[]))
0428 
0429 /* KDFs and PRFs */
0430 
0431 # define OSSL_FUNC_KDF_NEWCTX                        1
0432 # define OSSL_FUNC_KDF_DUPCTX                        2
0433 # define OSSL_FUNC_KDF_FREECTX                       3
0434 # define OSSL_FUNC_KDF_RESET                         4
0435 # define OSSL_FUNC_KDF_DERIVE                        5
0436 # define OSSL_FUNC_KDF_GETTABLE_PARAMS               6
0437 # define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS           7
0438 # define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS           8
0439 # define OSSL_FUNC_KDF_GET_PARAMS                    9
0440 # define OSSL_FUNC_KDF_GET_CTX_PARAMS               10
0441 # define OSSL_FUNC_KDF_SET_CTX_PARAMS               11
0442 
0443 OSSL_CORE_MAKE_FUNC(void *, kdf_newctx, (void *provctx))
0444 OSSL_CORE_MAKE_FUNC(void *, kdf_dupctx, (void *src))
0445 OSSL_CORE_MAKE_FUNC(void, kdf_freectx, (void *kctx))
0446 OSSL_CORE_MAKE_FUNC(void, kdf_reset, (void *kctx))
0447 OSSL_CORE_MAKE_FUNC(int, kdf_derive, (void *kctx, unsigned char *key,
0448                                       size_t keylen, const OSSL_PARAM params[]))
0449 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_params, (void *provctx))
0450 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_ctx_params,
0451                     (void *kctx, void *provctx))
0452 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_settable_ctx_params,
0453                     (void *kctx, void *provctx))
0454 OSSL_CORE_MAKE_FUNC(int, kdf_get_params, (OSSL_PARAM params[]))
0455 OSSL_CORE_MAKE_FUNC(int, kdf_get_ctx_params,
0456                     (void *kctx, OSSL_PARAM params[]))
0457 OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params,
0458                     (void *kctx, const OSSL_PARAM params[]))
0459 
0460 /* RAND */
0461 
0462 # define OSSL_FUNC_RAND_NEWCTX                        1
0463 # define OSSL_FUNC_RAND_FREECTX                       2
0464 # define OSSL_FUNC_RAND_INSTANTIATE                   3
0465 # define OSSL_FUNC_RAND_UNINSTANTIATE                 4
0466 # define OSSL_FUNC_RAND_GENERATE                      5
0467 # define OSSL_FUNC_RAND_RESEED                        6
0468 # define OSSL_FUNC_RAND_NONCE                         7
0469 # define OSSL_FUNC_RAND_ENABLE_LOCKING                8
0470 # define OSSL_FUNC_RAND_LOCK                          9
0471 # define OSSL_FUNC_RAND_UNLOCK                       10
0472 # define OSSL_FUNC_RAND_GETTABLE_PARAMS              11
0473 # define OSSL_FUNC_RAND_GETTABLE_CTX_PARAMS          12
0474 # define OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS          13
0475 # define OSSL_FUNC_RAND_GET_PARAMS                   14
0476 # define OSSL_FUNC_RAND_GET_CTX_PARAMS               15
0477 # define OSSL_FUNC_RAND_SET_CTX_PARAMS               16
0478 # define OSSL_FUNC_RAND_VERIFY_ZEROIZATION           17
0479 # define OSSL_FUNC_RAND_GET_SEED                     18
0480 # define OSSL_FUNC_RAND_CLEAR_SEED                   19
0481 
0482 OSSL_CORE_MAKE_FUNC(void *,rand_newctx,
0483                     (void *provctx, void *parent,
0484                     const OSSL_DISPATCH *parent_calls))
0485 OSSL_CORE_MAKE_FUNC(void,rand_freectx, (void *vctx))
0486 OSSL_CORE_MAKE_FUNC(int,rand_instantiate,
0487                     (void *vdrbg, unsigned int strength,
0488                      int prediction_resistance,
0489                      const unsigned char *pstr, size_t pstr_len,
0490                      const OSSL_PARAM params[]))
0491 OSSL_CORE_MAKE_FUNC(int,rand_uninstantiate, (void *vdrbg))
0492 OSSL_CORE_MAKE_FUNC(int,rand_generate,
0493                     (void *vctx, unsigned char *out, size_t outlen,
0494                      unsigned int strength, int prediction_resistance,
0495                      const unsigned char *addin, size_t addin_len))
0496 OSSL_CORE_MAKE_FUNC(int,rand_reseed,
0497                     (void *vctx, int prediction_resistance,
0498                      const unsigned char *ent, size_t ent_len,
0499                      const unsigned char *addin, size_t addin_len))
0500 OSSL_CORE_MAKE_FUNC(size_t,rand_nonce,
0501                     (void *vctx, unsigned char *out, unsigned int strength,
0502                      size_t min_noncelen, size_t max_noncelen))
0503 OSSL_CORE_MAKE_FUNC(int,rand_enable_locking, (void *vctx))
0504 OSSL_CORE_MAKE_FUNC(int,rand_lock, (void *vctx))
0505 OSSL_CORE_MAKE_FUNC(void,rand_unlock, (void *vctx))
0506 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_params, (void *provctx))
0507 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_ctx_params,
0508                     (void *vctx, void *provctx))
0509 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_settable_ctx_params,
0510                     (void *vctx, void *provctx))
0511 OSSL_CORE_MAKE_FUNC(int,rand_get_params, (OSSL_PARAM params[]))
0512 OSSL_CORE_MAKE_FUNC(int,rand_get_ctx_params,
0513                     (void *vctx, OSSL_PARAM params[]))
0514 OSSL_CORE_MAKE_FUNC(int,rand_set_ctx_params,
0515                     (void *vctx, const OSSL_PARAM params[]))
0516 OSSL_CORE_MAKE_FUNC(void,rand_set_callbacks,
0517                     (void *vctx, OSSL_INOUT_CALLBACK *get_entropy,
0518                      OSSL_CALLBACK *cleanup_entropy,
0519                      OSSL_INOUT_CALLBACK *get_nonce,
0520                      OSSL_CALLBACK *cleanup_nonce, void *arg))
0521 OSSL_CORE_MAKE_FUNC(int,rand_verify_zeroization,
0522                     (void *vctx))
0523 OSSL_CORE_MAKE_FUNC(size_t,rand_get_seed,
0524                     (void *vctx, unsigned char **buffer,
0525                      int entropy, size_t min_len, size_t max_len,
0526                      int prediction_resistance,
0527                      const unsigned char *adin, size_t adin_len))
0528 OSSL_CORE_MAKE_FUNC(void,rand_clear_seed,
0529                     (void *vctx, unsigned char *buffer, size_t b_len))
0530 
0531 /*-
0532  * Key management
0533  *
0534  * The Key Management takes care of provider side key objects, and includes
0535  * all current functionality to create them, destroy them, set parameters
0536  * and key material, etc, essentially everything that manipulates the keys
0537  * themselves and their parameters.
0538  *
0539  * The key objects are commonly referred to as |keydata|, and it MUST be able
0540  * to contain parameters if the key has any, the public key and the private
0541  * key.  All parts are optional, but their presence determines what can be
0542  * done with the key object in terms of encryption, signature, and so on.
0543  * The assumption from libcrypto is that the key object contains any of the
0544  * following data combinations:
0545  *
0546  * - parameters only
0547  * - public key only
0548  * - public key + private key
0549  * - parameters + public key
0550  * - parameters + public key + private key
0551  *
0552  * What "parameters", "public key" and "private key" means in detail is left
0553  * to the implementation.  In the case of DH and DSA, they would typically
0554  * include domain parameters, while for certain variants of RSA, they would
0555  * typically include PSS or OAEP parameters.
0556  *
0557  * Key objects are created with OSSL_FUNC_keymgmt_new() and destroyed with
0558  * OSSL_FUNC_keymgmt_free().  Key objects can have data filled in with
0559  * OSSL_FUNC_keymgmt_import().
0560  *
0561  * Three functions are made available to check what selection of data is
0562  * present in a key object: OSSL_FUNC_keymgmt_has_parameters(),
0563  * OSSL_FUNC_keymgmt_has_public_key(), and OSSL_FUNC_keymgmt_has_private_key(),
0564  */
0565 
0566 /* Key data subset selection - individual bits */
0567 # define OSSL_KEYMGMT_SELECT_PRIVATE_KEY            0x01
0568 # define OSSL_KEYMGMT_SELECT_PUBLIC_KEY             0x02
0569 # define OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS      0x04
0570 # define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS       0x80
0571 
0572 /* Key data subset selection - combinations */
0573 # define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS     \
0574     ( OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS     \
0575       | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS)
0576 # define OSSL_KEYMGMT_SELECT_KEYPAIR            \
0577     ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY )
0578 # define OSSL_KEYMGMT_SELECT_ALL                \
0579     ( OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS )
0580 
0581 # define OSSL_KEYMGMT_VALIDATE_FULL_CHECK              0
0582 # define OSSL_KEYMGMT_VALIDATE_QUICK_CHECK             1
0583 
0584 /* Basic key object creation */
0585 # define OSSL_FUNC_KEYMGMT_NEW                         1
0586 OSSL_CORE_MAKE_FUNC(void *, keymgmt_new, (void *provctx))
0587 
0588 /* Generation, a more complex constructor */
0589 # define OSSL_FUNC_KEYMGMT_GEN_INIT                    2
0590 # define OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE            3
0591 # define OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS              4
0592 # define OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS         5
0593 # define OSSL_FUNC_KEYMGMT_GEN                         6
0594 # define OSSL_FUNC_KEYMGMT_GEN_CLEANUP                 7
0595 # define OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS              15
0596 # define OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS         16
0597 
0598 OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen_init,
0599                     (void *provctx, int selection, const OSSL_PARAM params[]))
0600 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_template,
0601                     (void *genctx, void *templ))
0602 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_params,
0603                     (void *genctx, const OSSL_PARAM params[]))
0604 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
0605                     keymgmt_gen_settable_params,
0606                     (void *genctx, void *provctx))
0607 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_get_params,
0608                     (void *genctx, OSSL_PARAM params[]))
0609 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gen_gettable_params,
0610                     (void *genctx, void *provctx))
0611 OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen,
0612                     (void *genctx, OSSL_CALLBACK *cb, void *cbarg))
0613 OSSL_CORE_MAKE_FUNC(void, keymgmt_gen_cleanup, (void *genctx))
0614 
0615 /* Key loading by object reference */
0616 # define OSSL_FUNC_KEYMGMT_LOAD                        8
0617 OSSL_CORE_MAKE_FUNC(void *, keymgmt_load,
0618                     (const void *reference, size_t reference_sz))
0619 
0620 /* Basic key object destruction */
0621 # define OSSL_FUNC_KEYMGMT_FREE                       10
0622 OSSL_CORE_MAKE_FUNC(void, keymgmt_free, (void *keydata))
0623 
0624 /* Key object information, with discovery */
0625 #define OSSL_FUNC_KEYMGMT_GET_PARAMS                  11
0626 #define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS             12
0627 OSSL_CORE_MAKE_FUNC(int, keymgmt_get_params,
0628                     (void *keydata, OSSL_PARAM params[]))
0629 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gettable_params,
0630                     (void *provctx))
0631 
0632 #define OSSL_FUNC_KEYMGMT_SET_PARAMS                  13
0633 #define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS             14
0634 OSSL_CORE_MAKE_FUNC(int, keymgmt_set_params,
0635                     (void *keydata, const OSSL_PARAM params[]))
0636 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_settable_params,
0637                     (void *provctx))
0638 
0639 /* Key checks - discovery of supported operations */
0640 # define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME       20
0641 OSSL_CORE_MAKE_FUNC(const char *, keymgmt_query_operation_name,
0642                     (int operation_id))
0643 
0644 /* Key checks - key data content checks */
0645 # define OSSL_FUNC_KEYMGMT_HAS                        21
0646 OSSL_CORE_MAKE_FUNC(int, keymgmt_has, (const void *keydata, int selection))
0647 
0648 /* Key checks - validation */
0649 # define OSSL_FUNC_KEYMGMT_VALIDATE                   22
0650 OSSL_CORE_MAKE_FUNC(int, keymgmt_validate, (const void *keydata, int selection,
0651                                             int checktype))
0652 
0653 /* Key checks - matching */
0654 # define OSSL_FUNC_KEYMGMT_MATCH                      23
0655 OSSL_CORE_MAKE_FUNC(int, keymgmt_match,
0656                     (const void *keydata1, const void *keydata2,
0657                      int selection))
0658 
0659 /* Import and export functions, with discovery */
0660 # define OSSL_FUNC_KEYMGMT_IMPORT                     40
0661 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES               41
0662 # define OSSL_FUNC_KEYMGMT_EXPORT                     42
0663 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES               43
0664 OSSL_CORE_MAKE_FUNC(int, keymgmt_import,
0665                     (void *keydata, int selection, const OSSL_PARAM params[]))
0666 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types,
0667                     (int selection))
0668 OSSL_CORE_MAKE_FUNC(int, keymgmt_export,
0669                     (void *keydata, int selection,
0670                      OSSL_CALLBACK *param_cb, void *cbarg))
0671 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types,
0672                     (int selection))
0673 
0674 /* Dup function, constructor */
0675 # define OSSL_FUNC_KEYMGMT_DUP                        44
0676 OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup,
0677                     (const void *keydata_from, int selection))
0678 
0679 /* Extended import and export functions */
0680 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX            45
0681 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX            46
0682 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types_ex,
0683                     (void *provctx, int selection))
0684 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types_ex,
0685                     (void *provctx, int selection))
0686 
0687 /* Key Exchange */
0688 
0689 # define OSSL_FUNC_KEYEXCH_NEWCTX                      1
0690 # define OSSL_FUNC_KEYEXCH_INIT                        2
0691 # define OSSL_FUNC_KEYEXCH_DERIVE                      3
0692 # define OSSL_FUNC_KEYEXCH_SET_PEER                    4
0693 # define OSSL_FUNC_KEYEXCH_FREECTX                     5
0694 # define OSSL_FUNC_KEYEXCH_DUPCTX                      6
0695 # define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS              7
0696 # define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS         8
0697 # define OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS              9
0698 # define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS        10
0699 
0700 OSSL_CORE_MAKE_FUNC(void *, keyexch_newctx, (void *provctx))
0701 OSSL_CORE_MAKE_FUNC(int, keyexch_init, (void *ctx, void *provkey,
0702                                         const OSSL_PARAM params[]))
0703 OSSL_CORE_MAKE_FUNC(int, keyexch_derive, (void *ctx,  unsigned char *secret,
0704                                              size_t *secretlen, size_t outlen))
0705 OSSL_CORE_MAKE_FUNC(int, keyexch_set_peer, (void *ctx, void *provkey))
0706 OSSL_CORE_MAKE_FUNC(void, keyexch_freectx, (void *ctx))
0707 OSSL_CORE_MAKE_FUNC(void *, keyexch_dupctx, (void *ctx))
0708 OSSL_CORE_MAKE_FUNC(int, keyexch_set_ctx_params, (void *ctx,
0709                                                      const OSSL_PARAM params[]))
0710 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_settable_ctx_params,
0711                     (void *ctx, void *provctx))
0712 OSSL_CORE_MAKE_FUNC(int, keyexch_get_ctx_params, (void *ctx,
0713                                                      OSSL_PARAM params[]))
0714 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params,
0715                     (void *ctx, void *provctx))
0716 
0717 /* Signature */
0718 
0719 # define OSSL_FUNC_SIGNATURE_NEWCTX                  1
0720 # define OSSL_FUNC_SIGNATURE_SIGN_INIT               2
0721 # define OSSL_FUNC_SIGNATURE_SIGN                    3
0722 # define OSSL_FUNC_SIGNATURE_VERIFY_INIT             4
0723 # define OSSL_FUNC_SIGNATURE_VERIFY                  5
0724 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT     6
0725 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER          7
0726 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT        8
0727 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE      9
0728 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL      10
0729 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN            11
0730 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT     12
0731 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE   13
0732 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL    14
0733 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY          15
0734 # define OSSL_FUNC_SIGNATURE_FREECTX                16
0735 # define OSSL_FUNC_SIGNATURE_DUPCTX                 17
0736 # define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS         18
0737 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS    19
0738 # define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS         20
0739 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS    21
0740 # define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS      22
0741 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 23
0742 # define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS      24
0743 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25
0744 # define OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES        26
0745 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT      27
0746 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE    28
0747 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL     29
0748 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT    30
0749 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE  31
0750 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL   32
0751 
0752 OSSL_CORE_MAKE_FUNC(void *, signature_newctx, (void *provctx,
0753                                                const char *propq))
0754 OSSL_CORE_MAKE_FUNC(int, signature_sign_init, (void *ctx, void *provkey,
0755                                                const OSSL_PARAM params[]))
0756 OSSL_CORE_MAKE_FUNC(int, signature_sign, (void *ctx,  unsigned char *sig,
0757                                           size_t *siglen, size_t sigsize,
0758                                           const unsigned char *tbs,
0759                                           size_t tbslen))
0760 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_init,
0761                     (void *ctx, void *provkey, const OSSL_PARAM params[]))
0762 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_update,
0763                     (void *ctx, const unsigned char *in, size_t inlen))
0764 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_final,
0765                     (void *ctx, unsigned char *sig,
0766                      size_t *siglen, size_t sigsize))
0767 OSSL_CORE_MAKE_FUNC(int, signature_verify_init, (void *ctx, void *provkey,
0768                                                  const OSSL_PARAM params[]))
0769 OSSL_CORE_MAKE_FUNC(int, signature_verify, (void *ctx,
0770                                             const unsigned char *sig,
0771                                             size_t siglen,
0772                                             const unsigned char *tbs,
0773                                             size_t tbslen))
0774 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_init,
0775                     (void *ctx, void *provkey, const OSSL_PARAM params[]))
0776 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_update,
0777                     (void *ctx, const unsigned char *in, size_t inlen))
0778 /*
0779  * signature_verify_final requires that the signature to be verified against
0780  * is specified via an OSSL_PARAM.
0781  */
0782 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_final, (void *ctx))
0783 OSSL_CORE_MAKE_FUNC(int, signature_verify_recover_init,
0784                     (void *ctx, void *provkey, const OSSL_PARAM params[]))
0785 OSSL_CORE_MAKE_FUNC(int, signature_verify_recover,
0786                     (void *ctx, unsigned char *rout, size_t *routlen,
0787                      size_t routsize, const unsigned char *sig, size_t siglen))
0788 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_init,
0789                     (void *ctx, const char *mdname, void *provkey,
0790                      const OSSL_PARAM params[]))
0791 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_update,
0792                     (void *ctx, const unsigned char *data, size_t datalen))
0793 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_final,
0794                     (void *ctx, unsigned char *sig, size_t *siglen,
0795                      size_t sigsize))
0796 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign,
0797                     (void *ctx, unsigned char *sigret, size_t *siglen,
0798                      size_t sigsize, const unsigned char *tbs, size_t tbslen))
0799 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_init,
0800                     (void *ctx, const char *mdname, void *provkey,
0801                      const OSSL_PARAM params[]))
0802 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_update,
0803                     (void *ctx, const unsigned char *data, size_t datalen))
0804 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_final,
0805                     (void *ctx, const unsigned char *sig, size_t siglen))
0806 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify,
0807                     (void *ctx, const unsigned char *sig, size_t siglen,
0808                      const unsigned char *tbs, size_t tbslen))
0809 OSSL_CORE_MAKE_FUNC(void, signature_freectx, (void *ctx))
0810 OSSL_CORE_MAKE_FUNC(void *, signature_dupctx, (void *ctx))
0811 OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_params,
0812                     (void *ctx, OSSL_PARAM params[]))
0813 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_params,
0814                     (void *ctx, void *provctx))
0815 OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_params,
0816                     (void *ctx, const OSSL_PARAM params[]))
0817 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_params,
0818                     (void *ctx, void *provctx))
0819 OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_md_params,
0820                     (void *ctx, OSSL_PARAM params[]))
0821 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_md_params,
0822                     (void *ctx))
0823 OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_md_params,
0824                     (void *ctx, const OSSL_PARAM params[]))
0825 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_md_params,
0826                     (void *ctx))
0827 OSSL_CORE_MAKE_FUNC(const char **, signature_query_key_types, (void))
0828 
0829 /* Asymmetric Ciphers */
0830 
0831 # define OSSL_FUNC_ASYM_CIPHER_NEWCTX                  1
0832 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT            2
0833 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT                 3
0834 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT            4
0835 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT                 5
0836 # define OSSL_FUNC_ASYM_CIPHER_FREECTX                 6
0837 # define OSSL_FUNC_ASYM_CIPHER_DUPCTX                  7
0838 # define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS          8
0839 # define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS     9
0840 # define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS         10
0841 # define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS    11
0842 
0843 OSSL_CORE_MAKE_FUNC(void *, asym_cipher_newctx, (void *provctx))
0844 OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt_init, (void *ctx, void *provkey,
0845                                                     const OSSL_PARAM params[]))
0846 OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt, (void *ctx, unsigned char *out,
0847                                                   size_t *outlen,
0848                                                   size_t outsize,
0849                                                   const unsigned char *in,
0850                                                   size_t inlen))
0851 OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt_init, (void *ctx, void *provkey,
0852                                                     const OSSL_PARAM params[]))
0853 OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt, (void *ctx, unsigned char *out,
0854                                                   size_t *outlen,
0855                                                   size_t outsize,
0856                                                   const unsigned char *in,
0857                                                   size_t inlen))
0858 OSSL_CORE_MAKE_FUNC(void, asym_cipher_freectx, (void *ctx))
0859 OSSL_CORE_MAKE_FUNC(void *, asym_cipher_dupctx, (void *ctx))
0860 OSSL_CORE_MAKE_FUNC(int, asym_cipher_get_ctx_params,
0861                     (void *ctx, OSSL_PARAM params[]))
0862 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_gettable_ctx_params,
0863                     (void *ctx, void *provctx))
0864 OSSL_CORE_MAKE_FUNC(int, asym_cipher_set_ctx_params,
0865                     (void *ctx, const OSSL_PARAM params[]))
0866 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_settable_ctx_params,
0867                     (void *ctx, void *provctx))
0868 
0869 /* Asymmetric Key encapsulation */
0870 # define OSSL_FUNC_KEM_NEWCTX                  1
0871 # define OSSL_FUNC_KEM_ENCAPSULATE_INIT        2
0872 # define OSSL_FUNC_KEM_ENCAPSULATE             3
0873 # define OSSL_FUNC_KEM_DECAPSULATE_INIT        4
0874 # define OSSL_FUNC_KEM_DECAPSULATE             5
0875 # define OSSL_FUNC_KEM_FREECTX                 6
0876 # define OSSL_FUNC_KEM_DUPCTX                  7
0877 # define OSSL_FUNC_KEM_GET_CTX_PARAMS          8
0878 # define OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS     9
0879 # define OSSL_FUNC_KEM_SET_CTX_PARAMS         10
0880 # define OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS    11
0881 # define OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT  12
0882 # define OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT  13
0883 
0884 OSSL_CORE_MAKE_FUNC(void *, kem_newctx, (void *provctx))
0885 OSSL_CORE_MAKE_FUNC(int, kem_encapsulate_init, (void *ctx, void *provkey,
0886                                                 const OSSL_PARAM params[]))
0887 OSSL_CORE_MAKE_FUNC(int, kem_auth_encapsulate_init, (void *ctx, void *provkey,
0888                                                      void *authprivkey,
0889                                                      const OSSL_PARAM params[]))
0890 OSSL_CORE_MAKE_FUNC(int, kem_encapsulate, (void *ctx,
0891                                            unsigned char *out, size_t *outlen,
0892                                            unsigned char *secret,
0893                                            size_t *secretlen))
0894 OSSL_CORE_MAKE_FUNC(int, kem_decapsulate_init, (void *ctx, void *provkey,
0895                                                 const OSSL_PARAM params[]))
0896 OSSL_CORE_MAKE_FUNC(int, kem_auth_decapsulate_init, (void *ctx, void *provkey,
0897                                                      void *authpubkey,
0898                                                      const OSSL_PARAM params[]))
0899 OSSL_CORE_MAKE_FUNC(int, kem_decapsulate, (void *ctx,
0900                                            unsigned char *out, size_t *outlen,
0901                                            const unsigned char *in, size_t inlen))
0902 OSSL_CORE_MAKE_FUNC(void, kem_freectx, (void *ctx))
0903 OSSL_CORE_MAKE_FUNC(void *, kem_dupctx, (void *ctx))
0904 OSSL_CORE_MAKE_FUNC(int, kem_get_ctx_params, (void *ctx, OSSL_PARAM params[]))
0905 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_gettable_ctx_params,
0906                     (void *ctx, void *provctx))
0907 OSSL_CORE_MAKE_FUNC(int, kem_set_ctx_params,
0908                     (void *ctx, const OSSL_PARAM params[]))
0909 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params,
0910                     (void *ctx, void *provctx))
0911 
0912 /* Encoders and decoders */
0913 # define OSSL_FUNC_ENCODER_NEWCTX                      1
0914 # define OSSL_FUNC_ENCODER_FREECTX                     2
0915 # define OSSL_FUNC_ENCODER_GET_PARAMS                  3
0916 # define OSSL_FUNC_ENCODER_GETTABLE_PARAMS             4
0917 # define OSSL_FUNC_ENCODER_SET_CTX_PARAMS              5
0918 # define OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS         6
0919 # define OSSL_FUNC_ENCODER_DOES_SELECTION             10
0920 # define OSSL_FUNC_ENCODER_ENCODE                     11
0921 # define OSSL_FUNC_ENCODER_IMPORT_OBJECT              20
0922 # define OSSL_FUNC_ENCODER_FREE_OBJECT                21
0923 OSSL_CORE_MAKE_FUNC(void *, encoder_newctx, (void *provctx))
0924 OSSL_CORE_MAKE_FUNC(void, encoder_freectx, (void *ctx))
0925 OSSL_CORE_MAKE_FUNC(int, encoder_get_params, (OSSL_PARAM params[]))
0926 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_gettable_params,
0927                     (void *provctx))
0928 OSSL_CORE_MAKE_FUNC(int, encoder_set_ctx_params,
0929                     (void *ctx, const OSSL_PARAM params[]))
0930 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_settable_ctx_params,
0931                     (void *provctx))
0932 
0933 OSSL_CORE_MAKE_FUNC(int, encoder_does_selection,
0934                     (void *provctx, int selection))
0935 OSSL_CORE_MAKE_FUNC(int, encoder_encode,
0936                     (void *ctx, OSSL_CORE_BIO *out,
0937                      const void *obj_raw, const OSSL_PARAM obj_abstract[],
0938                      int selection,
0939                      OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))
0940 
0941 OSSL_CORE_MAKE_FUNC(void *, encoder_import_object,
0942                     (void *ctx, int selection, const OSSL_PARAM params[]))
0943 OSSL_CORE_MAKE_FUNC(void, encoder_free_object, (void *obj))
0944 
0945 # define OSSL_FUNC_DECODER_NEWCTX                      1
0946 # define OSSL_FUNC_DECODER_FREECTX                     2
0947 # define OSSL_FUNC_DECODER_GET_PARAMS                  3
0948 # define OSSL_FUNC_DECODER_GETTABLE_PARAMS             4
0949 # define OSSL_FUNC_DECODER_SET_CTX_PARAMS              5
0950 # define OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS         6
0951 # define OSSL_FUNC_DECODER_DOES_SELECTION             10
0952 # define OSSL_FUNC_DECODER_DECODE                     11
0953 # define OSSL_FUNC_DECODER_EXPORT_OBJECT              20
0954 OSSL_CORE_MAKE_FUNC(void *, decoder_newctx, (void *provctx))
0955 OSSL_CORE_MAKE_FUNC(void, decoder_freectx, (void *ctx))
0956 OSSL_CORE_MAKE_FUNC(int, decoder_get_params, (OSSL_PARAM params[]))
0957 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_gettable_params,
0958                     (void *provctx))
0959 OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params,
0960                     (void *ctx, const OSSL_PARAM params[]))
0961 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params,
0962                     (void *provctx))
0963 
0964 OSSL_CORE_MAKE_FUNC(int, decoder_does_selection,
0965                     (void *provctx, int selection))
0966 OSSL_CORE_MAKE_FUNC(int, decoder_decode,
0967                     (void *ctx, OSSL_CORE_BIO *in, int selection,
0968                      OSSL_CALLBACK *data_cb, void *data_cbarg,
0969                      OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg))
0970 OSSL_CORE_MAKE_FUNC(int, decoder_export_object,
0971                     (void *ctx, const void *objref, size_t objref_sz,
0972                      OSSL_CALLBACK *export_cb, void *export_cbarg))
0973 
0974 /*-
0975  * Store
0976  *
0977  * Objects are scanned by using the 'open', 'load', 'eof' and 'close'
0978  * functions, which implement an OSSL_STORE loader.
0979  *
0980  * store_load() works in a way that's very similar to the decoders, in
0981  * that they pass an abstract object through a callback, either as a DER
0982  * octet string or as an object reference, which libcrypto will have to
0983  * deal with.
0984  */
0985 
0986 #define OSSL_FUNC_STORE_OPEN                        1
0987 #define OSSL_FUNC_STORE_ATTACH                      2
0988 #define OSSL_FUNC_STORE_SETTABLE_CTX_PARAMS         3
0989 #define OSSL_FUNC_STORE_SET_CTX_PARAMS              4
0990 #define OSSL_FUNC_STORE_LOAD                        5
0991 #define OSSL_FUNC_STORE_EOF                         6
0992 #define OSSL_FUNC_STORE_CLOSE                       7
0993 #define OSSL_FUNC_STORE_EXPORT_OBJECT               8
0994 #define OSSL_FUNC_STORE_DELETE                      9
0995 #define OSSL_FUNC_STORE_OPEN_EX                     10
0996 OSSL_CORE_MAKE_FUNC(void *, store_open, (void *provctx, const char *uri))
0997 OSSL_CORE_MAKE_FUNC(void *, store_attach, (void *provctx, OSSL_CORE_BIO *in))
0998 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, store_settable_ctx_params,
0999                     (void *provctx))
1000 OSSL_CORE_MAKE_FUNC(int, store_set_ctx_params,
1001                     (void *loaderctx, const OSSL_PARAM params[]))
1002 OSSL_CORE_MAKE_FUNC(int, store_load,
1003                     (void *loaderctx,
1004                      OSSL_CALLBACK *object_cb, void *object_cbarg,
1005                      OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg))
1006 OSSL_CORE_MAKE_FUNC(int, store_eof, (void *loaderctx))
1007 OSSL_CORE_MAKE_FUNC(int, store_close, (void *loaderctx))
1008 OSSL_CORE_MAKE_FUNC(int, store_export_object,
1009                     (void *loaderctx, const void *objref, size_t objref_sz,
1010                      OSSL_CALLBACK *export_cb, void *export_cbarg))
1011 OSSL_CORE_MAKE_FUNC(int, store_delete,
1012                     (void *provctx, const char *uri, const OSSL_PARAM params[],
1013                      OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg))
1014 OSSL_CORE_MAKE_FUNC(void *, store_open_ex,
1015                     (void *provctx, const char *uri, const OSSL_PARAM params[],
1016                      OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg))
1017 
1018 # ifdef __cplusplus
1019 }
1020 # endif
1021 
1022 #endif