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