Skip to content

Commit 4ccd6df

Browse files
committed
Adding wolfSSL_GENERAL_NAME_set0_value() compat layer API.
1 parent 4bf6422 commit 4ccd6df

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

src/x509.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4426,8 +4426,9 @@ WOLFSSL_GENERAL_NAME* wolfSSL_GENERAL_NAME_dup(WOLFSSL_GENERAL_NAME* gn)
44264426
* @return WOLFSSL_FAILURE on invalid parameter or memory error,
44274427
* WOLFSSL_SUCCESS otherwise.
44284428
*/
4429-
int wolfSSL_GENERAL_NAME_set0_othername(GENERAL_NAME* gen, ASN1_OBJECT* oid,
4430-
ASN1_TYPE* value) {
4429+
int wolfSSL_GENERAL_NAME_set0_othername(WOLFSSL_GENERAL_NAME* gen,
4430+
ASN1_OBJECT* oid, ASN1_TYPE* value)
4431+
{
44314432
WOLFSSL_ASN1_OBJECT *x = NULL;
44324433

44334434
if ((gen == NULL) || (oid == NULL) || (value == NULL)) {
@@ -4830,6 +4831,37 @@ int wolfSSL_GENERAL_NAME_set_type(WOLFSSL_GENERAL_NAME* name, int typ)
48304831
return ret;
48314832
}
48324833

4834+
/* Set the value in a general name. This is a compat layer API.
4835+
*
4836+
* @param [out] a Pointer to the GENERAL_NAME where the othername is set.
4837+
* @param [in] type The type of this general name.
4838+
* @param [in] value The ASN.1 string that is the value.
4839+
* @return none
4840+
* @note the set0 indicates we take ownership so the user does NOT free value.
4841+
*/
4842+
void wolfSSL_GENERAL_NAME_set0_value(WOLFSSL_GENERAL_NAME *a, int type,
4843+
void *value)
4844+
{
4845+
WOLFSSL_ASN1_STRING *val = value;
4846+
if (a == NULL) {
4847+
WOLFSSL_MSG("a is NULL");
4848+
return;
4849+
}
4850+
4851+
if (val == NULL) {
4852+
WOLFSSL_MSG("value is NULL");
4853+
return;
4854+
}
4855+
4856+
if (type != GEN_DNS) {
4857+
WOLFSSL_MSG("Only GEN_DNS is supported");
4858+
return;
4859+
}
4860+
4861+
wolfSSL_GENERAL_NAME_type_free(a);
4862+
a->type = type;
4863+
a->d.dNSName = value;
4864+
}
48334865

48344866
/* Frees GENERAL_NAME objects.
48354867
*/

wolfssl/openssl/ssl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,11 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_
887887
#define ASN1_UTF8STRING_free wolfSSL_ASN1_STRING_free
888888
#define ASN1_UTF8STRING_set wolfSSL_ASN1_STRING_set
889889

890+
#define ASN1_IA5STRING WOLFSSL_ASN1_STRING
891+
#define ASN1_IA5STRING_new wolfSSL_ASN1_STRING_new
892+
#define ASN1_IA5STRING_free wolfSSL_ASN1_STRING_free
893+
#define ASN1_IA5STRING_set wolfSSL_ASN1_STRING_set
894+
890895
#define ASN1_PRINTABLE_type(...) V_ASN1_PRINTABLESTRING
891896

892897
#define ASN1_UTCTIME_pr wolfSSL_ASN1_UTCTIME_pr
@@ -1360,6 +1365,7 @@ typedef WOLFSSL_SRTP_PROTECTION_PROFILE SRTP_PROTECTION_PROFILE;
13601365
#define GENERAL_NAME_dup wolfSSL_GENERAL_NAME_dup
13611366
#define GENERAL_NAME_print wolfSSL_GENERAL_NAME_print
13621367
#define GENERAL_NAME_set0_othername wolfSSL_GENERAL_NAME_set0_othername
1368+
#define GENERAL_NAME_set0_value wolfSSL_GENERAL_NAME_set0_value
13631369
#define sk_GENERAL_NAME_push wolfSSL_sk_GENERAL_NAME_push
13641370
#define sk_GENERAL_NAME_value wolfSSL_sk_GENERAL_NAME_value
13651371

wolfssl/ssl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,8 @@ WOLFSSL_API WOLFSSL_GENERAL_NAMES* wolfSSL_GENERAL_NAMES_dup(
15621562
WOLFSSL_API int wolfSSL_GENERAL_NAME_set0_othername(WOLFSSL_GENERAL_NAME* gen,
15631563
WOLFSSL_ASN1_OBJECT* oid,
15641564
WOLFSSL_ASN1_TYPE* value);
1565+
WOLFSSL_API void wolfSSL_GENERAL_NAME_set0_value(WOLFSSL_GENERAL_NAME *a,
1566+
int type, void *value);
15651567

15661568
WOLFSSL_API WOLFSSL_STACK* wolfSSL_sk_GENERAL_NAME_new(void *cmpFunc);
15671569
WOLFSSL_API int wolfSSL_sk_GENERAL_NAME_push(WOLFSSL_GENERAL_NAMES* sk,

0 commit comments

Comments
 (0)