]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/objects.h
Update source files for pre-3.0 deprecation
[thirdparty/openssl.git] / include / openssl / objects.h
CommitLineData
21dcbebc 1/*
d2ba8123 2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
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
d02b48c6
RE
8 */
9
ae4186b0
DMSP
10#ifndef OPENSSL_OBJECTS_H
11# define OPENSSL_OBJECTS_H
d86167ec
DMSP
12# pragma once
13
14# include <openssl/macros.h>
936c2b9e 15# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
16# define HEADER_OBJECTS_H
17# endif
0f113f3e 18
2f0ca54c 19# include <openssl/obj_mac.h>
0f113f3e
MC
20# include <openssl/bio.h>
21# include <openssl/asn1.h>
52df25cf 22# include <openssl/objectserr.h>
d02b48c6 23
0f113f3e
MC
24# define OBJ_NAME_TYPE_UNDEF 0x00
25# define OBJ_NAME_TYPE_MD_METH 0x01
26# define OBJ_NAME_TYPE_CIPHER_METH 0x02
27# define OBJ_NAME_TYPE_PKEY_METH 0x03
28# define OBJ_NAME_TYPE_COMP_METH 0x04
567db2c1 29# define OBJ_NAME_TYPE_MAC_METH 0x05
d2ba8123
SL
30# define OBJ_NAME_TYPE_KDF_METH 0x06
31# define OBJ_NAME_TYPE_NUM 0x07
dfeab068 32
0f113f3e 33# define OBJ_NAME_ALIAS 0x8000
ea5240a5 34
0f113f3e
MC
35# define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01
36# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02
dfeab068
RE
37
38
82271cee
RL
39#ifdef __cplusplus
40extern "C" {
41#endif
42
0f113f3e
MC
43typedef struct obj_name_st {
44 int type;
45 int alias;
46 const char *name;
47 const char *data;
48} OBJ_NAME;
58964a49 49
0f113f3e 50# define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)
d02b48c6 51
dfeab068 52int OBJ_NAME_init(void);
0f113f3e
MC
53int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
54 int (*cmp_func) (const char *, const char *),
55 void (*free_func) (const char *, int, const char *));
56const char *OBJ_NAME_get(const char *name, int type);
57int OBJ_NAME_add(const char *name, int type, const char *data);
58int OBJ_NAME_remove(const char *name, int type);
dfeab068 59void OBJ_NAME_cleanup(int type); /* -1 for everything */
0f113f3e
MC
60void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg),
61 void *arg);
62void OBJ_NAME_do_all_sorted(int type,
63 void (*fn) (const OBJ_NAME *, void *arg),
64 void *arg);
65
9fdcc21f 66DECLARE_ASN1_DUP_FUNCTION_name(ASN1_OBJECT, OBJ)
0f113f3e
MC
67ASN1_OBJECT *OBJ_nid2obj(int n);
68const char *OBJ_nid2ln(int n);
69const char *OBJ_nid2sn(int n);
70int OBJ_obj2nid(const ASN1_OBJECT *o);
71ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name);
72int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
73int OBJ_txt2nid(const char *s);
74int OBJ_ln2nid(const char *s);
75int OBJ_sn2nid(const char *s);
76int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b);
77const void *OBJ_bsearch_(const void *key, const void *base, int num, int size,
78 int (*cmp) (const void *, const void *));
79const void *OBJ_bsearch_ex_(const void *key, const void *base, int num,
80 int size,
81 int (*cmp) (const void *, const void *),
82 int flags);
83
84# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \
e19106f5
DSH
85 static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \
86 static int nm##_cmp(type1 const *, type2 const *); \
87 scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
babb3798 88
0f113f3e 89# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \
babb3798 90 _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp)
0f113f3e 91# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
e19106f5 92 type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num)
babb3798 93
1d97c843 94/*-
babb3798
BL
95 * Unsolved problem: if a type is actually a pointer type, like
96 * nid_triple is, then its impossible to get a const where you need
97 * it. Consider:
98 *
99 * typedef int nid_triple[3];
100 * const void *a_;
101 * const nid_triple const *a = a_;
102 *
69687aa8 103 * The assignment discards a const because what you really want is:
babb3798
BL
104 *
105 * const int const * const *a = a_;
106 *
107 * But if you do that, you lose the fact that a is an array of 3 ints,
108 * which breaks comparison functions.
109 *
110 * Thus we end up having to cast, sadly, or unpack the
69687aa8 111 * declarations. Or, as I finally did in this case, declare nid_triple
babb3798
BL
112 * to be a struct, which it should have been in the first place.
113 *
114 * Ben, August 2008.
115 *
116 * Also, strictly speaking not all types need be const, but handling
117 * the non-constness means a lot of complication, and in practice
118 * comparison routines do always not touch their arguments.
119 */
06ddf8eb 120
0f113f3e
MC
121# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \
122 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
babb3798 123 { \
606f6c47
DSH
124 type1 const *a = a_; \
125 type2 const *b = b_; \
e19106f5
DSH
126 return nm##_cmp(a,b); \
127 } \
06ddf8eb 128 static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
e19106f5
DSH
129 { \
130 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
0f113f3e 131 nm##_cmp_BSEARCH_CMP_FN); \
606f6c47
DSH
132 } \
133 extern void dummy_prototype(void)
babb3798 134
0f113f3e
MC
135# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \
136 static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \
06ddf8eb
DSH
137 { \
138 type1 const *a = a_; \
139 type2 const *b = b_; \
140 return nm##_cmp(a,b); \
141 } \
142 type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \
143 { \
144 return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \
0f113f3e 145 nm##_cmp_BSEARCH_CMP_FN); \
06ddf8eb
DSH
146 } \
147 extern void dummy_prototype(void)
babb3798 148
0f113f3e 149# define OBJ_bsearch(type1,key,type2,base,num,cmp) \
babb3798 150 ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
0f113f3e
MC
151 num,sizeof(type2), \
152 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
153 (void)CHECKED_PTR_OF(type2,cmp##_type_2), \
154 cmp##_BSEARCH_CMP_FN)))
d02b48c6 155
0f113f3e 156# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \
606f6c47 157 ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \
0f113f3e
MC
158 num,sizeof(type2), \
159 ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \
160 (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \
161 cmp##_BSEARCH_CMP_FN)),flags)
1ea6472e 162
0f113f3e
MC
163int OBJ_new_nid(int num);
164int OBJ_add_object(const ASN1_OBJECT *obj);
165int OBJ_create(const char *oid, const char *sn, const char *ln);
00db8c60 166#ifndef OPENSSL_NO_DEPRECATED_1_1_0
6457615a 167# define OBJ_cleanup() while(0) continue
7b8cc9b3 168#endif
0f113f3e 169int OBJ_create_objects(BIO *in);
d02b48c6 170
2e430277
DSH
171size_t OBJ_length(const ASN1_OBJECT *obj);
172const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj);
173
d2027098
DSH
174int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid);
175int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid);
0ee2166c
DSH
176int OBJ_add_sigid(int signid, int dig_id, int pkey_id);
177void OBJ_sigid_free(void);
d2027098 178
6d311938 179
0cd0a820 180# ifdef __cplusplus
d02b48c6 181}
0cd0a820 182# endif
d02b48c6 183#endif