/src/openssl36/include/openssl/objects.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 1995-2024 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 OPENSSL_OBJECTS_H |
11 | | #define OPENSSL_OBJECTS_H |
12 | | #pragma once |
13 | | |
14 | | #include <openssl/macros.h> |
15 | | #ifndef OPENSSL_NO_DEPRECATED_3_0 |
16 | | #define HEADER_OBJECTS_H |
17 | | #endif |
18 | | |
19 | | #include <openssl/obj_mac.h> |
20 | | #include <openssl/bio.h> |
21 | | #include <openssl/asn1.h> |
22 | | #include <openssl/objectserr.h> |
23 | | |
24 | | #define OBJ_NAME_TYPE_UNDEF 0x00 |
25 | 211k | #define OBJ_NAME_TYPE_MD_METH 0x01 |
26 | 72.4k | #define OBJ_NAME_TYPE_CIPHER_METH 0x02 |
27 | | #define OBJ_NAME_TYPE_PKEY_METH 0x03 |
28 | | #define OBJ_NAME_TYPE_COMP_METH 0x04 |
29 | | #define OBJ_NAME_TYPE_MAC_METH 0x05 |
30 | 220 | #define OBJ_NAME_TYPE_KDF_METH 0x06 |
31 | | #define OBJ_NAME_TYPE_NUM 0x07 |
32 | | |
33 | 660k | #define OBJ_NAME_ALIAS 0x8000 |
34 | | |
35 | | #define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 |
36 | | #define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 |
37 | | |
38 | | #ifdef __cplusplus |
39 | | extern "C" { |
40 | | #endif |
41 | | |
42 | | typedef struct obj_name_st { |
43 | | int type; |
44 | | int alias; |
45 | | const char *name; |
46 | | const char *data; |
47 | | } OBJ_NAME; |
48 | | |
49 | | #define OBJ_create_and_add_object(a, b, c) OBJ_create(a, b, c) |
50 | | |
51 | | int OBJ_NAME_init(void); |
52 | | int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *), |
53 | | int (*cmp_func)(const char *, const char *), |
54 | | void (*free_func)(const char *, int, const char *)); |
55 | | const char *OBJ_NAME_get(const char *name, int type); |
56 | | int OBJ_NAME_add(const char *name, int type, const char *data); |
57 | | int OBJ_NAME_remove(const char *name, int type); |
58 | | void OBJ_NAME_cleanup(int type); /* -1 for everything */ |
59 | | void OBJ_NAME_do_all(int type, void (*fn)(const OBJ_NAME *, void *arg), |
60 | | void *arg); |
61 | | void OBJ_NAME_do_all_sorted(int type, |
62 | | void (*fn)(const OBJ_NAME *, void *arg), |
63 | | void *arg); |
64 | | |
65 | | DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, OBJ) |
66 | | ASN1_OBJECT *OBJ_nid2obj(int n); |
67 | | const char *OBJ_nid2ln(int n); |
68 | | const char *OBJ_nid2sn(int n); |
69 | | int OBJ_obj2nid(const ASN1_OBJECT *o); |
70 | | ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name); |
71 | | int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); |
72 | | int OBJ_txt2nid(const char *s); |
73 | | int OBJ_ln2nid(const char *s); |
74 | | int OBJ_sn2nid(const char *s); |
75 | | int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); |
76 | | const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, |
77 | | int (*cmp)(const void *, const void *)); |
78 | | const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, |
79 | | int size, |
80 | | int (*cmp)(const void *, const void *), |
81 | | int flags); |
82 | | |
83 | | #define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ |
84 | | static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ |
85 | | static int nm##_cmp(type1 const *, type2 const *); \ |
86 | | scope type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) |
87 | | |
88 | | #define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ |
89 | | _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) |
90 | | #define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ |
91 | | type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) |
92 | | |
93 | | /*- |
94 | | * Unsolved problem: if a type is actually a pointer type, like |
95 | | * nid_triple is, then its impossible to get a const where you need |
96 | | * it. Consider: |
97 | | * |
98 | | * typedef int nid_triple[3]; |
99 | | * const void *a_; |
100 | | * const nid_triple const *a = a_; |
101 | | * |
102 | | * The assignment discards a const because what you really want is: |
103 | | * |
104 | | * const int const * const *a = a_; |
105 | | * |
106 | | * But if you do that, you lose the fact that a is an array of 3 ints, |
107 | | * which breaks comparison functions. |
108 | | * |
109 | | * Thus we end up having to cast, sadly, or unpack the |
110 | | * declarations. Or, as I finally did in this case, declare nid_triple |
111 | | * to be a struct, which it should have been in the first place. |
112 | | * |
113 | | * Ben, August 2008. |
114 | | * |
115 | | * Also, strictly speaking not all types need be const, but handling |
116 | | * the non-constness means a lot of complication, and in practice |
117 | | * comparison routines do always not touch their arguments. |
118 | | */ |
119 | | |
120 | | #define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ |
121 | | static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ |
122 | 537M | { \ |
123 | 537M | type1 const *a = a_; \ |
124 | 537M | type2 const *b = b_; \ |
125 | 537M | return nm##_cmp(a, b); \ |
126 | 537M | } \ ameth_lib.c:ameth_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 17.0M | { \ | 123 | 17.0M | type1 const *a = a_; \ | 124 | 17.0M | type2 const *b = b_; \ | 125 | 17.0M | return nm##_cmp(a, b); \ | 126 | 17.0M | } \ |
Unexecuted instantiation: pmeth_lib.c:pmeth_func_cmp_BSEARCH_CMP_FN obj_dat.c:ln_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 24.2M | { \ | 123 | 24.2M | type1 const *a = a_; \ | 124 | 24.2M | type2 const *b = b_; \ | 125 | 24.2M | return nm##_cmp(a, b); \ | 126 | 24.2M | } \ |
obj_dat.c:sn_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 34.7M | { \ | 123 | 34.7M | type1 const *a = a_; \ | 124 | 34.7M | type2 const *b = b_; \ | 125 | 34.7M | return nm##_cmp(a, b); \ | 126 | 34.7M | } \ |
obj_dat.c:obj_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 439M | { \ | 123 | 439M | type1 const *a = a_; \ | 124 | 439M | type2 const *b = b_; \ | 125 | 439M | return nm##_cmp(a, b); \ | 126 | 439M | } \ |
obj_xref.c:sig_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 3.41M | { \ | 123 | 3.41M | type1 const *a = a_; \ | 124 | 3.41M | type2 const *b = b_; \ | 125 | 3.41M | return nm##_cmp(a, b); \ | 126 | 3.41M | } \ |
Unexecuted instantiation: obj_xref.c:sigx_cmp_BSEARCH_CMP_FN v3_lib.c:ext_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 18.2M | { \ | 123 | 18.2M | type1 const *a = a_; \ | 124 | 18.2M | type2 const *b = b_; \ | 125 | 18.2M | return nm##_cmp(a, b); \ | 126 | 18.2M | } \ |
v3_purp.c:nid_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 236k | { \ | 123 | 236k | type1 const *a = a_; \ | 124 | 236k | type2 const *b = b_; \ | 125 | 236k | return nm##_cmp(a, b); \ | 126 | 236k | } \ |
x509_vpm.c:table_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 208k | { \ | 123 | 208k | type1 const *a = a_; \ | 124 | 208k | type2 const *b = b_; \ | 125 | 208k | return nm##_cmp(a, b); \ | 126 | 208k | } \ |
Unexecuted instantiation: a_strnid.c:table_cmp_BSEARCH_CMP_FN evp_pbe.c:pbe2_cmp_BSEARCH_CMP_FN Line | Count | Source | 122 | 3.19k | { \ | 123 | 3.19k | type1 const *a = a_; \ | 124 | 3.19k | type2 const *b = b_; \ | 125 | 3.19k | return nm##_cmp(a, b); \ | 126 | 3.19k | } \ |
|
127 | | static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ |
128 | 59.9M | { \ |
129 | 59.9M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ |
130 | 59.9M | nm##_cmp_BSEARCH_CMP_FN); \ |
131 | 59.9M | } \ ameth_lib.c:OBJ_bsearch_ameth Line | Count | Source | 128 | 5.55M | { \ | 129 | 5.55M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 5.55M | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 5.55M | } \ |
Unexecuted instantiation: pmeth_lib.c:OBJ_bsearch_pmeth_func Line | Count | Source | 128 | 2.47M | { \ | 129 | 2.47M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 2.47M | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 2.47M | } \ |
Line | Count | Source | 128 | 3.33M | { \ | 129 | 3.33M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 3.33M | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 3.33M | } \ |
obj_dat.c:OBJ_bsearch_obj Line | Count | Source | 128 | 44.2M | { \ | 129 | 44.2M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 44.2M | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 44.2M | } \ |
obj_xref.c:OBJ_bsearch_sig Line | Count | Source | 128 | 696k | { \ | 129 | 696k | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 696k | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 696k | } \ |
Unexecuted instantiation: obj_xref.c:OBJ_bsearch_sigx Line | Count | Source | 128 | 3.48M | { \ | 129 | 3.48M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 3.48M | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 3.48M | } \ |
v3_purp.c:OBJ_bsearch_nid Line | Count | Source | 128 | 96.4k | { \ | 129 | 96.4k | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 96.4k | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 96.4k | } \ |
x509_vpm.c:OBJ_bsearch_table Line | Count | Source | 128 | 101k | { \ | 129 | 101k | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 101k | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 101k | } \ |
Unexecuted instantiation: a_strnid.c:OBJ_bsearch_table evp_pbe.c:OBJ_bsearch_pbe2 Line | Count | Source | 128 | 672 | { \ | 129 | 672 | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ | 130 | 672 | nm##_cmp_BSEARCH_CMP_FN); \ | 131 | 672 | } \ |
|
132 | | extern void dummy_prototype(void) |
133 | | |
134 | | #define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ |
135 | | static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ |
136 | 7.81M | { \ |
137 | 7.81M | type1 const *a = a_; \ |
138 | 7.81M | type2 const *b = b_; \ |
139 | 7.81M | return nm##_cmp(a, b); \ |
140 | 7.81M | } \ |
141 | | type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ |
142 | 1.81M | { \ |
143 | 1.81M | return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ |
144 | 1.81M | nm##_cmp_BSEARCH_CMP_FN); \ |
145 | 1.81M | } \ |
146 | | extern void dummy_prototype(void) |
147 | | |
148 | | #define OBJ_bsearch(type1, key, type2, base, num, cmp) \ |
149 | | ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1, key), CHECKED_PTR_OF(type2, base), \ |
150 | | num, sizeof(type2), \ |
151 | | ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ |
152 | | (void)CHECKED_PTR_OF(type2, cmp##_type_2), \ |
153 | | cmp##_BSEARCH_CMP_FN))) |
154 | | |
155 | | #define OBJ_bsearch_ex(type1, key, type2, base, num, cmp, flags) \ |
156 | | ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1, key), CHECKED_PTR_OF(type2, base), \ |
157 | | num, sizeof(type2), \ |
158 | | ((void)CHECKED_PTR_OF(type1, cmp##_type_1), \ |
159 | | (void)type_2 = CHECKED_PTR_OF(type2, cmp##_type_2), \ |
160 | | cmp##_BSEARCH_CMP_FN)), \ |
161 | | flags) |
162 | | |
163 | | int OBJ_new_nid(int num); |
164 | | int OBJ_add_object(const ASN1_OBJECT *obj); |
165 | | int OBJ_create(const char *oid, const char *sn, const char *ln); |
166 | | #ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
167 | | #define OBJ_cleanup() \ |
168 | | while (0) \ |
169 | | continue |
170 | | #endif |
171 | | int OBJ_create_objects(BIO *in); |
172 | | |
173 | | size_t OBJ_length(const ASN1_OBJECT *obj); |
174 | | const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj); |
175 | | |
176 | | int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid); |
177 | | int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid); |
178 | | int OBJ_add_sigid(int signid, int dig_id, int pkey_id); |
179 | | void OBJ_sigid_free(void); |
180 | | |
181 | | #define SN_ac_auditEntity SN_ac_auditIdentity |
182 | | |
183 | | #ifdef __cplusplus |
184 | | } |
185 | | #endif |
186 | | #endif |