summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/x_x509a.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/x_x509a.c')
-rw-r--r--src/lib/libcrypto/asn1/x_x509a.c85
1 files changed, 54 insertions, 31 deletions
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c
index 287d780830..69ea725709 100644
--- a/src/lib/libcrypto/asn1/x_x509a.c
+++ b/src/lib/libcrypto/asn1/x_x509a.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
@@ -66,7 +66,7 @@
66 * user modifiable data about a certificate. This data is 66 * user modifiable data about a certificate. This data is
67 * appended to the X509 encoding when the *_X509_AUX routines 67 * appended to the X509 encoding when the *_X509_AUX routines
68 * are used. This means that the "traditional" X509 routines 68 * are used. This means that the "traditional" X509 routines
69 * will simply ignore the extra data. 69 * will simply ignore the extra data.
70 */ 70 */
71 71
72static X509_CERT_AUX *aux_get(X509 *x); 72static X509_CERT_AUX *aux_get(X509 *x);
@@ -81,14 +81,18 @@ ASN1_SEQUENCE(X509_CERT_AUX) = {
81 81
82IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX) 82IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX)
83 83
84static X509_CERT_AUX *aux_get(X509 *x) 84static X509_CERT_AUX *
85aux_get(X509 *x)
85{ 86{
86 if(!x) return NULL; 87 if (!x)
87 if(!x->aux && !(x->aux = X509_CERT_AUX_new())) return NULL; 88 return NULL;
89 if (!x->aux && !(x->aux = X509_CERT_AUX_new()))
90 return NULL;
88 return x->aux; 91 return x->aux;
89} 92}
90 93
91int X509_alias_set1(X509 *x, unsigned char *name, int len) 94int
95X509_alias_set1(X509 *x, unsigned char *name, int len)
92{ 96{
93 X509_CERT_AUX *aux; 97 X509_CERT_AUX *aux;
94 if (!name) { 98 if (!name) {
@@ -98,12 +102,15 @@ int X509_alias_set1(X509 *x, unsigned char *name, int len)
98 x->aux->alias = NULL; 102 x->aux->alias = NULL;
99 return 1; 103 return 1;
100 } 104 }
101 if(!(aux = aux_get(x))) return 0; 105 if (!(aux = aux_get(x)))
102 if(!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) return 0; 106 return 0;
107 if (!aux->alias && !(aux->alias = ASN1_UTF8STRING_new()))
108 return 0;
103 return ASN1_STRING_set(aux->alias, name, len); 109 return ASN1_STRING_set(aux->alias, name, len);
104} 110}
105 111
106int X509_keyid_set1(X509 *x, unsigned char *id, int len) 112int
113X509_keyid_set1(X509 *x, unsigned char *id, int len)
107{ 114{
108 X509_CERT_AUX *aux; 115 X509_CERT_AUX *aux;
109 if (!id) { 116 if (!id) {
@@ -113,58 +120,74 @@ int X509_keyid_set1(X509 *x, unsigned char *id, int len)
113 x->aux->keyid = NULL; 120 x->aux->keyid = NULL;
114 return 1; 121 return 1;
115 } 122 }
116 if(!(aux = aux_get(x))) return 0; 123 if (!(aux = aux_get(x)))
117 if(!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) return 0; 124 return 0;
125 if (!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new()))
126 return 0;
118 return ASN1_STRING_set(aux->keyid, id, len); 127 return ASN1_STRING_set(aux->keyid, id, len);
119} 128}
120 129
121unsigned char *X509_alias_get0(X509 *x, int *len) 130unsigned char *
131X509_alias_get0(X509 *x, int *len)
122{ 132{
123 if(!x->aux || !x->aux->alias) return NULL; 133 if (!x->aux || !x->aux->alias)
124 if(len) *len = x->aux->alias->length; 134 return NULL;
135 if (len)
136 *len = x->aux->alias->length;
125 return x->aux->alias->data; 137 return x->aux->alias->data;
126} 138}
127 139
128unsigned char *X509_keyid_get0(X509 *x, int *len) 140unsigned char *
141X509_keyid_get0(X509 *x, int *len)
129{ 142{
130 if(!x->aux || !x->aux->keyid) return NULL; 143 if (!x->aux || !x->aux->keyid)
131 if(len) *len = x->aux->keyid->length; 144 return NULL;
145 if (len)
146 *len = x->aux->keyid->length;
132 return x->aux->keyid->data; 147 return x->aux->keyid->data;
133} 148}
134 149
135int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj) 150int
151X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
136{ 152{
137 X509_CERT_AUX *aux; 153 X509_CERT_AUX *aux;
138 ASN1_OBJECT *objtmp; 154 ASN1_OBJECT *objtmp;
139 if(!(objtmp = OBJ_dup(obj))) return 0; 155 if (!(objtmp = OBJ_dup(obj)))
140 if(!(aux = aux_get(x))) return 0; 156 return 0;
141 if(!aux->trust 157 if (!(aux = aux_get(x)))
142 && !(aux->trust = sk_ASN1_OBJECT_new_null())) return 0; 158 return 0;
159 if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null()))
160 return 0;
143 return sk_ASN1_OBJECT_push(aux->trust, objtmp); 161 return sk_ASN1_OBJECT_push(aux->trust, objtmp);
144} 162}
145 163
146int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj) 164int
165X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
147{ 166{
148 X509_CERT_AUX *aux; 167 X509_CERT_AUX *aux;
149 ASN1_OBJECT *objtmp; 168 ASN1_OBJECT *objtmp;
150 if(!(objtmp = OBJ_dup(obj))) return 0; 169 if (!(objtmp = OBJ_dup(obj)))
151 if(!(aux = aux_get(x))) return 0; 170 return 0;
152 if(!aux->reject 171 if (!(aux = aux_get(x)))
153 && !(aux->reject = sk_ASN1_OBJECT_new_null())) return 0; 172 return 0;
173 if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null()))
174 return 0;
154 return sk_ASN1_OBJECT_push(aux->reject, objtmp); 175 return sk_ASN1_OBJECT_push(aux->reject, objtmp);
155} 176}
156 177
157void X509_trust_clear(X509 *x) 178void
179X509_trust_clear(X509 *x)
158{ 180{
159 if(x->aux && x->aux->trust) { 181 if (x->aux && x->aux->trust) {
160 sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free); 182 sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free);
161 x->aux->trust = NULL; 183 x->aux->trust = NULL;
162 } 184 }
163} 185}
164 186
165void X509_reject_clear(X509 *x) 187void
188X509_reject_clear(X509 *x)
166{ 189{
167 if(x->aux && x->aux->reject) { 190 if (x->aux && x->aux->reject) {
168 sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free); 191 sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free);
169 x->aux->reject = NULL; 192 x->aux->reject = NULL;
170 } 193 }