-/* $OpenBSD: x509_v3.c,v 1.22 2024/05/16 13:19:09 tb Exp $ */
+/* $OpenBSD: x509_v3.c,v 1.23 2024/05/23 01:40:23 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
const ASN1_OBJECT *obj, int lastpos)
{
int n;
- X509_EXTENSION *ex;
+ X509_EXTENSION *ext;
if (sk == NULL)
return -1;
lastpos = 0;
n = sk_X509_EXTENSION_num(sk);
for (; lastpos < n; lastpos++) {
- ex = sk_X509_EXTENSION_value(sk, lastpos);
- if (OBJ_cmp(ex->object, obj) == 0)
+ ext = sk_X509_EXTENSION_value(sk, lastpos);
+ if (OBJ_cmp(ext->object, obj) == 0)
return lastpos;
}
return -1;
int lastpos)
{
int n;
- X509_EXTENSION *ex;
+ X509_EXTENSION *ext;
if (sk == NULL)
return -1;
lastpos = 0;
n = sk_X509_EXTENSION_num(sk);
for (; lastpos < n; lastpos++) {
- ex = sk_X509_EXTENSION_value(sk, lastpos);
- if ((ex->critical > 0 && crit) ||
- (ex->critical <= 0 && !crit))
+ ext = sk_X509_EXTENSION_value(sk, lastpos);
+ if ((ext->critical > 0 && crit) ||
+ (ext->critical <= 0 && !crit))
return lastpos;
}
return -1;
LCRYPTO_ALIAS(X509v3_delete_ext);
STACK_OF(X509_EXTENSION) *
-X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc)
+X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ext, int loc)
{
- X509_EXTENSION *new_ex = NULL;
+ X509_EXTENSION *new_ext = NULL;
int n;
STACK_OF(X509_EXTENSION) *sk = NULL;
else if (loc < 0)
loc = n;
- if ((new_ex = X509_EXTENSION_dup(ex)) == NULL)
+ if ((new_ext = X509_EXTENSION_dup(ext)) == NULL)
goto err2;
- if (!sk_X509_EXTENSION_insert(sk, new_ex, loc))
+ if (!sk_X509_EXTENSION_insert(sk, new_ext, loc))
goto err;
if (*x == NULL)
*x = sk;
err:
X509error(ERR_R_MALLOC_FAILURE);
err2:
- if (new_ex != NULL)
- X509_EXTENSION_free(new_ex);
+ if (new_ext != NULL)
+ X509_EXTENSION_free(new_ext);
if (sk != NULL && x != NULL && sk != *x)
sk_X509_EXTENSION_free(sk);
return NULL;
LCRYPTO_ALIAS(X509v3_add_ext);
X509_EXTENSION *
-X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit,
+X509_EXTENSION_create_by_NID(X509_EXTENSION **ext, int nid, int crit,
ASN1_OCTET_STRING *data)
{
ASN1_OBJECT *obj;
X509error(X509_R_UNKNOWN_NID);
return NULL;
}
- ret = X509_EXTENSION_create_by_OBJ(ex, obj, crit, data);
+ ret = X509_EXTENSION_create_by_OBJ(ext, obj, crit, data);
if (ret == NULL)
ASN1_OBJECT_free(obj);
return ret;
LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID);
X509_EXTENSION *
-X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj,
+X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ext, const ASN1_OBJECT *obj,
int crit, ASN1_OCTET_STRING *data)
{
X509_EXTENSION *ret;
- if (ex == NULL || *ex == NULL) {
+ if (ext == NULL || *ext == NULL) {
if ((ret = X509_EXTENSION_new()) == NULL) {
X509error(ERR_R_MALLOC_FAILURE);
return NULL;
}
} else
- ret= *ex;
+ ret= *ext;
if (!X509_EXTENSION_set_object(ret, obj))
goto err;
if (!X509_EXTENSION_set_data(ret, data))
goto err;
- if (ex != NULL && *ex == NULL)
- *ex = ret;
+ if (ext != NULL && *ext == NULL)
+ *ext = ret;
return ret;
err:
- if (ex == NULL || ret != *ex)
+ if (ext == NULL || ret != *ext)
X509_EXTENSION_free(ret);
return NULL;
}
LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ);
int
-X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj)
+X509_EXTENSION_set_object(X509_EXTENSION *ext, const ASN1_OBJECT *obj)
{
- if (ex == NULL || obj == NULL)
+ if (ext == NULL || obj == NULL)
return 0;
- ASN1_OBJECT_free(ex->object);
- ex->object = OBJ_dup(obj);
- return ex->object != NULL;
+ ASN1_OBJECT_free(ext->object);
+ ext->object = OBJ_dup(obj);
+ return ext->object != NULL;
}
LCRYPTO_ALIAS(X509_EXTENSION_set_object);
int
-X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit)
+X509_EXTENSION_set_critical(X509_EXTENSION *ext, int crit)
{
- if (ex == NULL)
+ if (ext == NULL)
return 0;
- ex->critical = crit ? 0xFF : -1;
+ ext->critical = crit ? 0xFF : -1;
return 1;
}
LCRYPTO_ALIAS(X509_EXTENSION_set_critical);
int
-X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data)
+X509_EXTENSION_set_data(X509_EXTENSION *ext, ASN1_OCTET_STRING *data)
{
int i;
- if (ex == NULL)
+ if (ext == NULL)
return 0;
- i = ASN1_STRING_set(ex->value, data->data, data->length);
+ i = ASN1_STRING_set(ext->value, data->data, data->length);
if (!i)
return 0;
return 1;
LCRYPTO_ALIAS(X509_EXTENSION_set_data);
ASN1_OBJECT *
-X509_EXTENSION_get_object(X509_EXTENSION *ex)
+X509_EXTENSION_get_object(X509_EXTENSION *ext)
{
- if (ex == NULL)
+ if (ext == NULL)
return NULL;
- return ex->object;
+ return ext->object;
}
LCRYPTO_ALIAS(X509_EXTENSION_get_object);
ASN1_OCTET_STRING *
-X509_EXTENSION_get_data(X509_EXTENSION *ex)
+X509_EXTENSION_get_data(X509_EXTENSION *ext)
{
- if (ex == NULL)
+ if (ext == NULL)
return NULL;
- return ex->value;
+ return ext->value;
}
LCRYPTO_ALIAS(X509_EXTENSION_get_data);
int
-X509_EXTENSION_get_critical(const X509_EXTENSION *ex)
+X509_EXTENSION_get_critical(const X509_EXTENSION *ext)
{
- if (ex == NULL)
+ if (ext == NULL)
return 0;
- if (ex->critical > 0)
+ if (ext->critical > 0)
return 1;
return 0;
}