diff options
author | tb <> | 2024-05-23 01:40:23 +0000 |
---|---|---|
committer | tb <> | 2024-05-23 01:40:23 +0000 |
commit | e2bda78b3a7e748473943f21e44c1d217a5a8840 (patch) | |
tree | a71b8f3c99e719e32b537d9de6c42402d172791a /src/lib | |
parent | 3e142bb6f4125f567c0eb4cf50bbbd84ecae8a7f (diff) | |
download | openbsd-e2bda78b3a7e748473943f21e44c1d217a5a8840.tar.gz openbsd-e2bda78b3a7e748473943f21e44c1d217a5a8840.tar.bz2 openbsd-e2bda78b3a7e748473943f21e44c1d217a5a8840.zip |
x509_v3.c: mechanically replace ex with ext and new_ex with new_ext
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_v3.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/lib/libcrypto/x509/x509_v3.c b/src/lib/libcrypto/x509/x509_v3.c index 3dee31e195..4321c09c19 100644 --- a/src/lib/libcrypto/x509/x509_v3.c +++ b/src/lib/libcrypto/x509/x509_v3.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_v3.c,v 1.22 2024/05/16 13:19:09 tb Exp $ */ | 1 | /* $OpenBSD: x509_v3.c,v 1.23 2024/05/23 01:40:23 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -94,7 +94,7 @@ X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, | |||
94 | const ASN1_OBJECT *obj, int lastpos) | 94 | const ASN1_OBJECT *obj, int lastpos) |
95 | { | 95 | { |
96 | int n; | 96 | int n; |
97 | X509_EXTENSION *ex; | 97 | X509_EXTENSION *ext; |
98 | 98 | ||
99 | if (sk == NULL) | 99 | if (sk == NULL) |
100 | return -1; | 100 | return -1; |
@@ -103,8 +103,8 @@ X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, | |||
103 | lastpos = 0; | 103 | lastpos = 0; |
104 | n = sk_X509_EXTENSION_num(sk); | 104 | n = sk_X509_EXTENSION_num(sk); |
105 | for (; lastpos < n; lastpos++) { | 105 | for (; lastpos < n; lastpos++) { |
106 | ex = sk_X509_EXTENSION_value(sk, lastpos); | 106 | ext = sk_X509_EXTENSION_value(sk, lastpos); |
107 | if (OBJ_cmp(ex->object, obj) == 0) | 107 | if (OBJ_cmp(ext->object, obj) == 0) |
108 | return lastpos; | 108 | return lastpos; |
109 | } | 109 | } |
110 | return -1; | 110 | return -1; |
@@ -116,7 +116,7 @@ X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, | |||
116 | int lastpos) | 116 | int lastpos) |
117 | { | 117 | { |
118 | int n; | 118 | int n; |
119 | X509_EXTENSION *ex; | 119 | X509_EXTENSION *ext; |
120 | 120 | ||
121 | if (sk == NULL) | 121 | if (sk == NULL) |
122 | return -1; | 122 | return -1; |
@@ -125,9 +125,9 @@ X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, | |||
125 | lastpos = 0; | 125 | lastpos = 0; |
126 | n = sk_X509_EXTENSION_num(sk); | 126 | n = sk_X509_EXTENSION_num(sk); |
127 | for (; lastpos < n; lastpos++) { | 127 | for (; lastpos < n; lastpos++) { |
128 | ex = sk_X509_EXTENSION_value(sk, lastpos); | 128 | ext = sk_X509_EXTENSION_value(sk, lastpos); |
129 | if ((ex->critical > 0 && crit) || | 129 | if ((ext->critical > 0 && crit) || |
130 | (ex->critical <= 0 && !crit)) | 130 | (ext->critical <= 0 && !crit)) |
131 | return lastpos; | 131 | return lastpos; |
132 | } | 132 | } |
133 | return -1; | 133 | return -1; |
@@ -157,9 +157,9 @@ X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc) | |||
157 | LCRYPTO_ALIAS(X509v3_delete_ext); | 157 | LCRYPTO_ALIAS(X509v3_delete_ext); |
158 | 158 | ||
159 | STACK_OF(X509_EXTENSION) * | 159 | STACK_OF(X509_EXTENSION) * |
160 | X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) | 160 | X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ext, int loc) |
161 | { | 161 | { |
162 | X509_EXTENSION *new_ex = NULL; | 162 | X509_EXTENSION *new_ext = NULL; |
163 | int n; | 163 | int n; |
164 | STACK_OF(X509_EXTENSION) *sk = NULL; | 164 | STACK_OF(X509_EXTENSION) *sk = NULL; |
165 | 165 | ||
@@ -180,9 +180,9 @@ X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) | |||
180 | else if (loc < 0) | 180 | else if (loc < 0) |
181 | loc = n; | 181 | loc = n; |
182 | 182 | ||
183 | if ((new_ex = X509_EXTENSION_dup(ex)) == NULL) | 183 | if ((new_ext = X509_EXTENSION_dup(ext)) == NULL) |
184 | goto err2; | 184 | goto err2; |
185 | if (!sk_X509_EXTENSION_insert(sk, new_ex, loc)) | 185 | if (!sk_X509_EXTENSION_insert(sk, new_ext, loc)) |
186 | goto err; | 186 | goto err; |
187 | if (*x == NULL) | 187 | if (*x == NULL) |
188 | *x = sk; | 188 | *x = sk; |
@@ -191,8 +191,8 @@ X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) | |||
191 | err: | 191 | err: |
192 | X509error(ERR_R_MALLOC_FAILURE); | 192 | X509error(ERR_R_MALLOC_FAILURE); |
193 | err2: | 193 | err2: |
194 | if (new_ex != NULL) | 194 | if (new_ext != NULL) |
195 | X509_EXTENSION_free(new_ex); | 195 | X509_EXTENSION_free(new_ext); |
196 | if (sk != NULL && x != NULL && sk != *x) | 196 | if (sk != NULL && x != NULL && sk != *x) |
197 | sk_X509_EXTENSION_free(sk); | 197 | sk_X509_EXTENSION_free(sk); |
198 | return NULL; | 198 | return NULL; |
@@ -200,7 +200,7 @@ err2: | |||
200 | LCRYPTO_ALIAS(X509v3_add_ext); | 200 | LCRYPTO_ALIAS(X509v3_add_ext); |
201 | 201 | ||
202 | X509_EXTENSION * | 202 | X509_EXTENSION * |
203 | X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, | 203 | X509_EXTENSION_create_by_NID(X509_EXTENSION **ext, int nid, int crit, |
204 | ASN1_OCTET_STRING *data) | 204 | ASN1_OCTET_STRING *data) |
205 | { | 205 | { |
206 | ASN1_OBJECT *obj; | 206 | ASN1_OBJECT *obj; |
@@ -211,7 +211,7 @@ X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, | |||
211 | X509error(X509_R_UNKNOWN_NID); | 211 | X509error(X509_R_UNKNOWN_NID); |
212 | return NULL; | 212 | return NULL; |
213 | } | 213 | } |
214 | ret = X509_EXTENSION_create_by_OBJ(ex, obj, crit, data); | 214 | ret = X509_EXTENSION_create_by_OBJ(ext, obj, crit, data); |
215 | if (ret == NULL) | 215 | if (ret == NULL) |
216 | ASN1_OBJECT_free(obj); | 216 | ASN1_OBJECT_free(obj); |
217 | return ret; | 217 | return ret; |
@@ -219,18 +219,18 @@ X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, | |||
219 | LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID); | 219 | LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID); |
220 | 220 | ||
221 | X509_EXTENSION * | 221 | X509_EXTENSION * |
222 | X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, | 222 | X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj, |
223 | int crit, ASN1_OCTET_STRING *data) | 223 | int crit, ASN1_OCTET_STRING *data) |
224 | { | 224 | { |
225 | X509_EXTENSION *ret; | 225 | X509_EXTENSION *ret; |
226 | 226 | ||
227 | if (ex == NULL || *ex == NULL) { | 227 | if (ext == NULL || *ext == NULL) { |
228 | if ((ret = X509_EXTENSION_new()) == NULL) { | 228 | if ((ret = X509_EXTENSION_new()) == NULL) { |
229 | X509error(ERR_R_MALLOC_FAILURE); | 229 | X509error(ERR_R_MALLOC_FAILURE); |
230 | return NULL; | 230 | return NULL; |
231 | } | 231 | } |
232 | } else | 232 | } else |
233 | ret= *ex; | 233 | ret= *ext; |
234 | 234 | ||
235 | if (!X509_EXTENSION_set_object(ret, obj)) | 235 | if (!X509_EXTENSION_set_object(ret, obj)) |
236 | goto err; | 236 | goto err; |
@@ -239,46 +239,46 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, | |||
239 | if (!X509_EXTENSION_set_data(ret, data)) | 239 | if (!X509_EXTENSION_set_data(ret, data)) |
240 | goto err; | 240 | goto err; |
241 | 241 | ||
242 | if (ex != NULL && *ex == NULL) | 242 | if (ext != NULL && *ext == NULL) |
243 | *ex = ret; | 243 | *ext = ret; |
244 | return ret; | 244 | return ret; |
245 | 245 | ||
246 | err: | 246 | err: |
247 | if (ex == NULL || ret != *ex) | 247 | if (ext == NULL || ret != *ext) |
248 | X509_EXTENSION_free(ret); | 248 | X509_EXTENSION_free(ret); |
249 | return NULL; | 249 | return NULL; |
250 | } | 250 | } |
251 | LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ); | 251 | LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ); |
252 | 252 | ||
253 | int | 253 | int |
254 | X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj) | 254 | X509_EXTENSION_set_object(X509_EXTENSION *ext, const ASN1_OBJECT *obj) |
255 | { | 255 | { |
256 | if (ex == NULL || obj == NULL) | 256 | if (ext == NULL || obj == NULL) |
257 | return 0; | 257 | return 0; |
258 | ASN1_OBJECT_free(ex->object); | 258 | ASN1_OBJECT_free(ext->object); |
259 | ex->object = OBJ_dup(obj); | 259 | ext->object = OBJ_dup(obj); |
260 | return ex->object != NULL; | 260 | return ext->object != NULL; |
261 | } | 261 | } |
262 | LCRYPTO_ALIAS(X509_EXTENSION_set_object); | 262 | LCRYPTO_ALIAS(X509_EXTENSION_set_object); |
263 | 263 | ||
264 | int | 264 | int |
265 | X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) | 265 | X509_EXTENSION_set_critical(X509_EXTENSION *ext, int crit) |
266 | { | 266 | { |
267 | if (ex == NULL) | 267 | if (ext == NULL) |
268 | return 0; | 268 | return 0; |
269 | ex->critical = crit ? 0xFF : -1; | 269 | ext->critical = crit ? 0xFF : -1; |
270 | return 1; | 270 | return 1; |
271 | } | 271 | } |
272 | LCRYPTO_ALIAS(X509_EXTENSION_set_critical); | 272 | LCRYPTO_ALIAS(X509_EXTENSION_set_critical); |
273 | 273 | ||
274 | int | 274 | int |
275 | X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) | 275 | X509_EXTENSION_set_data(X509_EXTENSION *ext, ASN1_OCTET_STRING *data) |
276 | { | 276 | { |
277 | int i; | 277 | int i; |
278 | 278 | ||
279 | if (ex == NULL) | 279 | if (ext == NULL) |
280 | return 0; | 280 | return 0; |
281 | i = ASN1_STRING_set(ex->value, data->data, data->length); | 281 | i = ASN1_STRING_set(ext->value, data->data, data->length); |
282 | if (!i) | 282 | if (!i) |
283 | return 0; | 283 | return 0; |
284 | return 1; | 284 | return 1; |
@@ -286,29 +286,29 @@ X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) | |||
286 | LCRYPTO_ALIAS(X509_EXTENSION_set_data); | 286 | LCRYPTO_ALIAS(X509_EXTENSION_set_data); |
287 | 287 | ||
288 | ASN1_OBJECT * | 288 | ASN1_OBJECT * |
289 | X509_EXTENSION_get_object(X509_EXTENSION *ex) | 289 | X509_EXTENSION_get_object(X509_EXTENSION *ext) |
290 | { | 290 | { |
291 | if (ex == NULL) | 291 | if (ext == NULL) |
292 | return NULL; | 292 | return NULL; |
293 | return ex->object; | 293 | return ext->object; |
294 | } | 294 | } |
295 | LCRYPTO_ALIAS(X509_EXTENSION_get_object); | 295 | LCRYPTO_ALIAS(X509_EXTENSION_get_object); |
296 | 296 | ||
297 | ASN1_OCTET_STRING * | 297 | ASN1_OCTET_STRING * |
298 | X509_EXTENSION_get_data(X509_EXTENSION *ex) | 298 | X509_EXTENSION_get_data(X509_EXTENSION *ext) |
299 | { | 299 | { |
300 | if (ex == NULL) | 300 | if (ext == NULL) |
301 | return NULL; | 301 | return NULL; |
302 | return ex->value; | 302 | return ext->value; |
303 | } | 303 | } |
304 | LCRYPTO_ALIAS(X509_EXTENSION_get_data); | 304 | LCRYPTO_ALIAS(X509_EXTENSION_get_data); |
305 | 305 | ||
306 | int | 306 | int |
307 | X509_EXTENSION_get_critical(const X509_EXTENSION *ex) | 307 | X509_EXTENSION_get_critical(const X509_EXTENSION *ext) |
308 | { | 308 | { |
309 | if (ex == NULL) | 309 | if (ext == NULL) |
310 | return 0; | 310 | return 0; |
311 | if (ex->critical > 0) | 311 | if (ext->critical > 0) |
312 | return 1; | 312 | return 1; |
313 | return 0; | 313 | return 0; |
314 | } | 314 | } |