Skip to content

Commit

Permalink
move GENERAL_NAME_create() to v3_genn.c in x509
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeev-0 committed Feb 24, 2024
1 parent a1a821b commit 8adfac2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
29 changes: 0 additions & 29 deletions crypto/cmp/cmp_hdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,6 @@ int ossl_cmp_general_name_is_NULL_DN(GENERAL_NAME *name)
|| (name->type == GEN_DIRNAME && IS_NULL_DN(name->d.directoryName));
}

/* assign to *tgt a copy of src (which may be NULL to indicate an empty DN) */
/* TODO move to ../x509/ and use also for OCSP, ESS, etc. */
int GENERAL_NAME_create(GENERAL_NAME **tgt, const X509_NAME *src)
{
GENERAL_NAME *name;

if (!ossl_assert(tgt != NULL))
return 0;
if ((name = GENERAL_NAME_new()) == NULL)
goto err;
name->type = GEN_DIRNAME;

if (src == NULL) { /* NULL-DN */
if ((name->d.directoryName = X509_NAME_new()) == NULL)
goto err;
} else if (!X509_NAME_set(&name->d.directoryName, src)) {
goto err;
}

GENERAL_NAME_free(*tgt);
*tgt = name;

return 1;

err:
GENERAL_NAME_free(name);
return 0;
}

/*
* Set the sender name in PKIHeader.
* when nm is NULL, sender is set to an empty string
Expand Down
26 changes: 26 additions & 0 deletions crypto/x509/v3_genn.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,32 @@ GENERAL_NAME *GENERAL_NAME_dup(const GENERAL_NAME *a)
(char *)a);
}

int GENERAL_NAME_create(GENERAL_NAME **tgt, const X509_NAME *src)
{
GENERAL_NAME *name;

if (!ossl_assert(tgt != NULL))
return 0;
if ((name = GENERAL_NAME_new()) == NULL)
goto err;
name->type = GEN_DIRNAME;

if (src == NULL) { /* NULL-DN */
if ((name->d.directoryName = X509_NAME_new()) == NULL)
goto err;
} else if (!X509_NAME_set(&name->d.directoryName, src)) {
goto err;
}

GENERAL_NAME_free(*tgt);
*tgt = name;
return 1;

err:
GENERAL_NAME_free(name);
return 0;
}

static int edipartyname_cmp(const EDIPARTYNAME *a, const EDIPARTYNAME *b)
{
int res;
Expand Down
3 changes: 0 additions & 3 deletions include/openssl/cmp.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ use OpenSSL::stackhash qw(generate_stack_macros);
# include <openssl/x509.h>
# include <openssl/x509v3.h>

/* TODO move to x509v3.h.in and use also for OCSP, ESS, etc. */
int GENERAL_NAME_create(GENERAL_NAME **tgt, const X509_NAME *src);

# ifdef __cplusplus
extern "C" {
# endif
Expand Down
2 changes: 2 additions & 0 deletions include/openssl/x509v3.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ typedef struct ACCESS_DESCRIPTION_st {
GENERAL_NAME *location;
} ACCESS_DESCRIPTION;

int GENERAL_NAME_create(GENERAL_NAME **tgt, const X509_NAME *src);

{-
generate_stack_macros("ACCESS_DESCRIPTION")
.generate_stack_macros("GENERAL_NAME");
Expand Down

0 comments on commit 8adfac2

Please sign in to comment.