]>
Commit | Line | Data |
---|---|---|
4c2883a9 RL |
1 | /* |
2 | * Copyright 2019 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 | #ifndef OSSL_CORE_NUMBERS_H | |
11 | # define OSSL_CORE_NUMBERS_H | |
12 | ||
13 | # include <openssl/core.h> | |
14 | ||
15 | # ifdef __cplusplus | |
16 | extern "C" { | |
17 | # endif | |
18 | ||
19 | /*- | |
20 | * Identities | |
21 | * ---------- | |
22 | * | |
23 | * All series start with 1, to allow 0 to be an array terminator. | |
24 | * For any FUNC identity, we also provide a function signature typedef | |
25 | * and a static inline function to extract a function pointer from a | |
26 | * OSSL_DISPATCH element in a type safe manner. | |
27 | * | |
28 | * Names: | |
29 | * for any function base name 'foo' (uppercase form 'FOO'), we will have | |
30 | * the following: | |
31 | * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivates | |
32 | * thereof (to be specified further down) | |
33 | * - a function signature typedef with the name OSSL_'foo'_fn | |
34 | * - a function pointer extractor function with the name OSSL_'foo' | |
35 | */ | |
36 | ||
37 | /* Helper macro to create the function signature typedef and the extractor */ | |
38 | #define OSSL_CORE_MAKE_FUNC(type,name,args) \ | |
39 | typedef type (OSSL_##name##_fn)args; \ | |
40 | static ossl_inline \ | |
41 | OSSL_##name##_fn *OSSL_get_##name(const OSSL_DISPATCH *opf) \ | |
42 | { \ | |
43 | return (OSSL_##name##_fn *)opf->function; \ | |
44 | } | |
45 | ||
46 | /* | |
47 | * Core function identities, for the two OSSL_DISPATCH tables being passed | |
48 | * in the OSSL_provider_init call. | |
49 | * | |
50 | * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must | |
51 | * therefore NEVER be used as a function identity. | |
52 | */ | |
53 | /* Functions provided by the Core to the provider, reserved numbers 1-1023 */ | |
54 | # define OSSL_FUNC_CORE_GET_PARAM_TYPES 1 | |
55 | OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, | |
56 | core_get_param_types,(const OSSL_PROVIDER *prov)) | |
57 | # define OSSL_FUNC_CORE_GET_PARAMS 2 | |
58 | OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_PROVIDER *prov, | |
59 | const OSSL_PARAM params[])) | |
60 | ||
61 | /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */ | |
62 | # define OSSL_FUNC_PROVIDER_TEARDOWN 1024 | |
63 | OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void)) | |
64 | # define OSSL_FUNC_PROVIDER_GET_PARAM_TYPES 1025 | |
65 | OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, | |
66 | provider_get_param_types,(const OSSL_PROVIDER *prov)) | |
67 | # define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 | |
68 | OSSL_CORE_MAKE_FUNC(int,provider_get_params,(const OSSL_PROVIDER *prov, | |
69 | const OSSL_PARAM params[])) | |
099bd339 RL |
70 | # define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 |
71 | OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, | |
72 | (const OSSL_PROVIDER *, int operation_id, | |
73 | const int *no_store)) | |
4c2883a9 | 74 | |
3653d0c2 MC |
75 | /* Digests */ |
76 | ||
77 | # define OSSL_OP_DIGEST 1 | |
78 | ||
79 | # define OSSL_FUNC_DIGEST_NEWCTX 1 | |
80 | # define OSSL_FUNC_DIGEST_INIT 2 | |
df05f2ce | 81 | # define OSSL_FUNC_DIGEST_UPDATE 3 |
3653d0c2 MC |
82 | # define OSSL_FUNC_DIGEST_FINAL 4 |
83 | # define OSSL_FUNC_DIGEST_DIGEST 5 | |
84 | # define OSSL_FUNC_DIGEST_FREECTX 6 | |
8c8cf0d9 MC |
85 | # define OSSL_FUNC_DIGEST_DUPCTX 7 |
86 | # define OSSL_FUNC_DIGEST_SIZE 8 | |
7556b9df | 87 | # define OSSL_FUNC_DIGEST_BLOCK_SIZE 9 |
3653d0c2 | 88 | |
df05f2ce | 89 | |
3653d0c2 MC |
90 | OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void)) |
91 | OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *vctx)) | |
92 | OSSL_CORE_MAKE_FUNC(int, OP_digest_update, | |
8c8cf0d9 | 93 | (void *, const unsigned char *in, size_t inl)) |
3653d0c2 | 94 | OSSL_CORE_MAKE_FUNC(int, OP_digest_final, |
0ad50b4d | 95 | (void *, unsigned char *out, size_t *outl, size_t outsz)) |
3653d0c2 | 96 | OSSL_CORE_MAKE_FUNC(int, OP_digest_digest, |
8c8cf0d9 | 97 | (const unsigned char *in, size_t inl, unsigned char *out, |
0ad50b4d | 98 | size_t *out_l, size_t outsz)) |
df05f2ce | 99 | |
3653d0c2 MC |
100 | OSSL_CORE_MAKE_FUNC(void, OP_digest_cleanctx, (void *vctx)) |
101 | OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *vctx)) | |
8c8cf0d9 MC |
102 | OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *vctx)) |
103 | OSSL_CORE_MAKE_FUNC(size_t, OP_digest_size, (void)) | |
7556b9df | 104 | OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void)) |
4c2883a9 | 105 | |
df05f2ce MC |
106 | |
107 | /* Symmetric Ciphers */ | |
108 | ||
109 | # define OSSL_OP_CIPHER 2 | |
110 | ||
111 | # define OSSL_FUNC_CIPHER_NEWCTX 1 | |
112 | # define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2 | |
113 | # define OSSL_FUNC_CIPHER_DECRYPT_INIT 3 | |
114 | # define OSSL_FUNC_CIPHER_UPDATE 4 | |
115 | # define OSSL_FUNC_CIPHER_FINAL 5 | |
718b133a MC |
116 | # define OSSL_FUNC_CIPHER_CIPHER 6 |
117 | # define OSSL_FUNC_CIPHER_FREECTX 7 | |
118 | # define OSSL_FUNC_CIPHER_DUPCTX 8 | |
119 | # define OSSL_FUNC_CIPHER_KEY_LENGTH 9 | |
120 | # define OSSL_FUNC_CIPHER_IV_LENGTH 10 | |
121 | # define OSSL_FUNC_CIPHER_BLOCK_SIZE 11 | |
122 | # define OSSL_FUNC_CIPHER_GET_PARAMS 12 | |
123 | # define OSSL_FUNC_CIPHER_CTX_GET_PARAMS 13 | |
124 | # define OSSL_FUNC_CIPHER_CTX_SET_PARAMS 14 | |
df05f2ce MC |
125 | |
126 | OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void)) | |
127 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *vctx, | |
128 | const unsigned char *key, | |
129 | const unsigned char *iv)) | |
130 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *vctx, | |
131 | const unsigned char *key, | |
132 | const unsigned char *iv)) | |
133 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_update, | |
134 | (void *, unsigned char *out, size_t *outl, | |
135 | const unsigned char *in, size_t inl)) | |
136 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_final, | |
137 | (void *, unsigned char *out, size_t *outl)) | |
138 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher, | |
139 | (void *, unsigned char *out, const unsigned char *in, | |
140 | size_t inl)) | |
141 | OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *vctx)) | |
142 | OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *vctx)) | |
143 | OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_key_length, (void)) | |
718b133a MC |
144 | OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_iv_length, (void)) |
145 | OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_block_size, (void)) | |
146 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (const OSSL_PARAM params[])) | |
147 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_get_params, (void *vctx, | |
148 | const OSSL_PARAM params[])) | |
149 | OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_set_params, (void *vctx, | |
150 | const OSSL_PARAM params[])) | |
df05f2ce MC |
151 | |
152 | ||
4c2883a9 RL |
153 | # ifdef __cplusplus |
154 | } | |
155 | # endif | |
156 | ||
157 | #endif |