summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509v3/v3_bcons.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/x509v3/v3_bcons.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/lib/libcrypto/x509v3/v3_bcons.c b/src/lib/libcrypto/x509v3/v3_bcons.c
index 82aa488f75..e652b839bd 100644
--- a/src/lib/libcrypto/x509v3/v3_bcons.c
+++ b/src/lib/libcrypto/x509v3/v3_bcons.c
@@ -10,7 +10,7 @@
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 14 *
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
@@ -64,18 +64,20 @@
64#include <openssl/conf.h> 64#include <openssl/conf.h>
65#include <openssl/x509v3.h> 65#include <openssl/x509v3.h>
66 66
67static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist); 67static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
68static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values); 68 BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist);
69static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method,
70 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values);
69 71
70const X509V3_EXT_METHOD v3_bcons = { 72const X509V3_EXT_METHOD v3_bcons = {
71NID_basic_constraints, 0, 73 NID_basic_constraints, 0,
72ASN1_ITEM_ref(BASIC_CONSTRAINTS), 74 ASN1_ITEM_ref(BASIC_CONSTRAINTS),
730,0,0,0, 75 0, 0, 0, 0,
740,0, 76 0, 0,
75(X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS, 77 (X509V3_EXT_I2V)i2v_BASIC_CONSTRAINTS,
76(X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS, 78 (X509V3_EXT_V2I)v2i_BASIC_CONSTRAINTS,
77NULL,NULL, 79 NULL, NULL,
78NULL 80 NULL
79}; 81};
80 82
81ASN1_SEQUENCE(BASIC_CONSTRAINTS) = { 83ASN1_SEQUENCE(BASIC_CONSTRAINTS) = {
@@ -86,39 +88,45 @@ ASN1_SEQUENCE(BASIC_CONSTRAINTS) = {
86IMPLEMENT_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) 88IMPLEMENT_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
87 89
88 90
89static STACK_OF(CONF_VALUE) *i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 91static STACK_OF(CONF_VALUE) *
90 BASIC_CONSTRAINTS *bcons, STACK_OF(CONF_VALUE) *extlist) 92i2v_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, BASIC_CONSTRAINTS *bcons,
93 STACK_OF(CONF_VALUE) *extlist)
91{ 94{
92 X509V3_add_value_bool("CA", bcons->ca, &extlist); 95 X509V3_add_value_bool("CA", bcons->ca, &extlist);
93 X509V3_add_value_int("pathlen", bcons->pathlen, &extlist); 96 X509V3_add_value_int("pathlen", bcons->pathlen, &extlist);
94 return extlist; 97 return extlist;
95} 98}
96 99
97static BASIC_CONSTRAINTS *v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, 100static BASIC_CONSTRAINTS *
98 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *values) 101v2i_BASIC_CONSTRAINTS(X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
102 STACK_OF(CONF_VALUE) *values)
99{ 103{
100 BASIC_CONSTRAINTS *bcons=NULL; 104 BASIC_CONSTRAINTS *bcons = NULL;
101 CONF_VALUE *val; 105 CONF_VALUE *val;
102 int i; 106 int i;
103 if(!(bcons = BASIC_CONSTRAINTS_new())) { 107
108 if (!(bcons = BASIC_CONSTRAINTS_new())) {
104 X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE); 109 X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE);
105 return NULL; 110 return NULL;
106 } 111 }
107 for(i = 0; i < sk_CONF_VALUE_num(values); i++) { 112 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
108 val = sk_CONF_VALUE_value(values, i); 113 val = sk_CONF_VALUE_value(values, i);
109 if(!strcmp(val->name, "CA")) { 114 if (!strcmp(val->name, "CA")) {
110 if(!X509V3_get_value_bool(val, &bcons->ca)) goto err; 115 if (!X509V3_get_value_bool(val, &bcons->ca))
111 } else if(!strcmp(val->name, "pathlen")) { 116 goto err;
112 if(!X509V3_get_value_int(val, &bcons->pathlen)) goto err; 117 } else if (!strcmp(val->name, "pathlen")) {
118 if (!X509V3_get_value_int(val, &bcons->pathlen))
119 goto err;
113 } else { 120 } else {
114 X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, X509V3_R_INVALID_NAME); 121 X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS,
122 X509V3_R_INVALID_NAME);
115 X509V3_conf_err(val); 123 X509V3_conf_err(val);
116 goto err; 124 goto err;
117 } 125 }
118 } 126 }
119 return bcons; 127 return bcons;
120 err: 128
129err:
121 BASIC_CONSTRAINTS_free(bcons); 130 BASIC_CONSTRAINTS_free(bcons);
122 return NULL; 131 return NULL;
123} 132}
124