Skip to content

Commit

Permalink
Add misc. x509 un/lock and set1 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
WillChilds-Klein committed Feb 21, 2024
1 parent c8d82c7 commit 1fd1843
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions crypto/x509/x509_lu.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ X509_STORE *X509_STORE_new(void) {
return NULL;
}

int X509_STORE_lock(X509_STORE *v) {
CRYPTO_MUTEX_lock_write(&v->objs_lock);
return 1;
}

int X509_STORE_unlock(X509_STORE *v) {
CRYPTO_MUTEX_unlock_write(&v->objs_lock);
return 1;
}

int X509_STORE_up_ref(X509_STORE *store) {
CRYPTO_refcount_inc(&store->references);
return 1;
Expand Down Expand Up @@ -410,6 +420,24 @@ X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a) {
return a->data.crl;
}

int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj) {
if (a == NULL || !X509_up_ref(obj))
return 0;

a->type = X509_LU_X509;
a->data.x509 = obj;
return 1;
}

int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj) {
if (a == NULL || !X509_CRL_up_ref(obj))
return 0;

a->type = X509_LU_CRL;
a->data.crl = obj;
return 1;
}

static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, int type,
X509_NAME *name, int *pnmatch) {
X509_OBJECT stmp;
Expand Down
4 changes: 4 additions & 0 deletions include/openssl/x509.h
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,11 @@ OPENSSL_EXPORT int X509_OBJECT_get_type(const X509_OBJECT *a);
OPENSSL_EXPORT X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a);
// X509_OBJECT_get0_X509_CRL returns the |X509_CRL| associated with |a|
OPENSSL_EXPORT X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a);
int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj);
int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj);
OPENSSL_EXPORT X509_STORE *X509_STORE_new(void);
OPENSSL_EXPORT int X509_STORE_lock(X509_STORE *v);
OPENSSL_EXPORT int X509_STORE_unlock(X509_STORE *v);
OPENSSL_EXPORT int X509_STORE_up_ref(X509_STORE *store);
OPENSSL_EXPORT void X509_STORE_free(X509_STORE *v);

Expand Down

0 comments on commit 1fd1843

Please sign in to comment.