diff options
author | tedu <> | 2014-04-18 00:10:08 +0000 |
---|---|---|
committer | tedu <> | 2014-04-18 00:10:08 +0000 |
commit | 07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d (patch) | |
tree | 6327d50d69a1982f840dc68fe928ea459e2c41e0 /src/lib/libcrypto/asn1/tasn_utl.c | |
parent | 288a9e368d9d4a72792b12a00ad69e3592d94073 (diff) | |
download | openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.gz openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.bz2 openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.zip |
putting most of the braces in the right column is the very least we can do.
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_utl.c')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_utl.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_utl.c b/src/lib/libcrypto/asn1/tasn_utl.c index ab4989b6ce..37c86c6af8 100644 --- a/src/lib/libcrypto/asn1/tasn_utl.c +++ b/src/lib/libcrypto/asn1/tasn_utl.c | |||
@@ -74,23 +74,23 @@ | |||
74 | */ | 74 | */ |
75 | 75 | ||
76 | int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) | 76 | int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it) |
77 | { | 77 | { |
78 | int *sel = offset2ptr(*pval, it->utype); | 78 | int *sel = offset2ptr(*pval, it->utype); |
79 | return *sel; | 79 | return *sel; |
80 | } | 80 | } |
81 | 81 | ||
82 | /* Given an ASN1_ITEM CHOICE type set | 82 | /* Given an ASN1_ITEM CHOICE type set |
83 | * the selector value, return old value. | 83 | * the selector value, return old value. |
84 | */ | 84 | */ |
85 | 85 | ||
86 | int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it) | 86 | int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it) |
87 | { | 87 | { |
88 | int *sel, ret; | 88 | int *sel, ret; |
89 | sel = offset2ptr(*pval, it->utype); | 89 | sel = offset2ptr(*pval, it->utype); |
90 | ret = *sel; | 90 | ret = *sel; |
91 | *sel = value; | 91 | *sel = value; |
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
94 | 94 | ||
95 | /* Do reference counting. The value 'op' decides what to do. | 95 | /* Do reference counting. The value 'op' decides what to do. |
96 | * if it is +1 then the count is incremented. If op is 0 count is | 96 | * if it is +1 then the count is incremented. If op is 0 count is |
@@ -99,7 +99,7 @@ int asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it) | |||
99 | */ | 99 | */ |
100 | 100 | ||
101 | int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) | 101 | int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) |
102 | { | 102 | { |
103 | const ASN1_AUX *aux; | 103 | const ASN1_AUX *aux; |
104 | int *lck, ret; | 104 | int *lck, ret; |
105 | if ((it->itype != ASN1_ITYPE_SEQUENCE) | 105 | if ((it->itype != ASN1_ITYPE_SEQUENCE) |
@@ -110,16 +110,16 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it) | |||
110 | return 0; | 110 | return 0; |
111 | lck = offset2ptr(*pval, aux->ref_offset); | 111 | lck = offset2ptr(*pval, aux->ref_offset); |
112 | if (op == 0) | 112 | if (op == 0) |
113 | { | 113 | { |
114 | *lck = 1; | 114 | *lck = 1; |
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
117 | ret = CRYPTO_add(lck, op, aux->ref_lock); | 117 | ret = CRYPTO_add(lck, op, aux->ref_lock); |
118 | return ret; | 118 | return ret; |
119 | } | 119 | } |
120 | 120 | ||
121 | static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) | 121 | static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) |
122 | { | 122 | { |
123 | const ASN1_AUX *aux; | 123 | const ASN1_AUX *aux; |
124 | if (!pval || !*pval) | 124 | if (!pval || !*pval) |
125 | return NULL; | 125 | return NULL; |
@@ -127,37 +127,37 @@ static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) | |||
127 | if (!aux || !(aux->flags & ASN1_AFLG_ENCODING)) | 127 | if (!aux || !(aux->flags & ASN1_AFLG_ENCODING)) |
128 | return NULL; | 128 | return NULL; |
129 | return offset2ptr(*pval, aux->enc_offset); | 129 | return offset2ptr(*pval, aux->enc_offset); |
130 | } | 130 | } |
131 | 131 | ||
132 | void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) | 132 | void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) |
133 | { | 133 | { |
134 | ASN1_ENCODING *enc; | 134 | ASN1_ENCODING *enc; |
135 | enc = asn1_get_enc_ptr(pval, it); | 135 | enc = asn1_get_enc_ptr(pval, it); |
136 | if (enc) | 136 | if (enc) |
137 | { | 137 | { |
138 | enc->enc = NULL; | 138 | enc->enc = NULL; |
139 | enc->len = 0; | 139 | enc->len = 0; |
140 | enc->modified = 1; | 140 | enc->modified = 1; |
141 | } | ||
142 | } | 141 | } |
142 | } | ||
143 | 143 | ||
144 | void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | 144 | void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) |
145 | { | 145 | { |
146 | ASN1_ENCODING *enc; | 146 | ASN1_ENCODING *enc; |
147 | enc = asn1_get_enc_ptr(pval, it); | 147 | enc = asn1_get_enc_ptr(pval, it); |
148 | if (enc) | 148 | if (enc) |
149 | { | 149 | { |
150 | if (enc->enc) | 150 | if (enc->enc) |
151 | free(enc->enc); | 151 | free(enc->enc); |
152 | enc->enc = NULL; | 152 | enc->enc = NULL; |
153 | enc->len = 0; | 153 | enc->len = 0; |
154 | enc->modified = 1; | 154 | enc->modified = 1; |
155 | } | ||
156 | } | 155 | } |
156 | } | ||
157 | 157 | ||
158 | int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, | 158 | int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, |
159 | const ASN1_ITEM *it) | 159 | const ASN1_ITEM *it) |
160 | { | 160 | { |
161 | ASN1_ENCODING *enc; | 161 | ASN1_ENCODING *enc; |
162 | enc = asn1_get_enc_ptr(pval, it); | 162 | enc = asn1_get_enc_ptr(pval, it); |
163 | if (!enc) | 163 | if (!enc) |
@@ -173,28 +173,28 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, | |||
173 | enc->modified = 0; | 173 | enc->modified = 0; |
174 | 174 | ||
175 | return 1; | 175 | return 1; |
176 | } | 176 | } |
177 | 177 | ||
178 | int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, | 178 | int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, |
179 | const ASN1_ITEM *it) | 179 | const ASN1_ITEM *it) |
180 | { | 180 | { |
181 | ASN1_ENCODING *enc; | 181 | ASN1_ENCODING *enc; |
182 | enc = asn1_get_enc_ptr(pval, it); | 182 | enc = asn1_get_enc_ptr(pval, it); |
183 | if (!enc || enc->modified) | 183 | if (!enc || enc->modified) |
184 | return 0; | 184 | return 0; |
185 | if (out) | 185 | if (out) |
186 | { | 186 | { |
187 | memcpy(*out, enc->enc, enc->len); | 187 | memcpy(*out, enc->enc, enc->len); |
188 | *out += enc->len; | 188 | *out += enc->len; |
189 | } | 189 | } |
190 | if (len) | 190 | if (len) |
191 | *len = enc->len; | 191 | *len = enc->len; |
192 | return 1; | 192 | return 1; |
193 | } | 193 | } |
194 | 194 | ||
195 | /* Given an ASN1_TEMPLATE get a pointer to a field */ | 195 | /* Given an ASN1_TEMPLATE get a pointer to a field */ |
196 | ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | 196 | ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) |
197 | { | 197 | { |
198 | ASN1_VALUE **pvaltmp; | 198 | ASN1_VALUE **pvaltmp; |
199 | if (tt->flags & ASN1_TFLG_COMBINE) | 199 | if (tt->flags & ASN1_TFLG_COMBINE) |
200 | return pval; | 200 | return pval; |
@@ -204,7 +204,7 @@ ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | |||
204 | * (int *). | 204 | * (int *). |
205 | */ | 205 | */ |
206 | return pvaltmp; | 206 | return pvaltmp; |
207 | } | 207 | } |
208 | 208 | ||
209 | /* Handle ANY DEFINED BY template, find the selector, look up | 209 | /* Handle ANY DEFINED BY template, find the selector, look up |
210 | * the relevant ASN1_TEMPLATE in the table and return it. | 210 | * the relevant ASN1_TEMPLATE in the table and return it. |
@@ -212,7 +212,7 @@ ASN1_VALUE ** asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | |||
212 | 212 | ||
213 | const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, | 213 | const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, |
214 | int nullerr) | 214 | int nullerr) |
215 | { | 215 | { |
216 | const ASN1_ADB *adb; | 216 | const ASN1_ADB *adb; |
217 | const ASN1_ADB_TABLE *atbl; | 217 | const ASN1_ADB_TABLE *atbl; |
218 | long selector; | 218 | long selector; |
@@ -229,11 +229,11 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, | |||
229 | 229 | ||
230 | /* Check if NULL */ | 230 | /* Check if NULL */ |
231 | if (!sfld) | 231 | if (!sfld) |
232 | { | 232 | { |
233 | if (!adb->null_tt) | 233 | if (!adb->null_tt) |
234 | goto err; | 234 | goto err; |
235 | return adb->null_tt; | 235 | return adb->null_tt; |
236 | } | 236 | } |
237 | 237 | ||
238 | /* Convert type to a long: | 238 | /* Convert type to a long: |
239 | * NB: don't check for NID_undef here because it | 239 | * NB: don't check for NID_undef here because it |
@@ -269,4 +269,4 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, | |||
269 | ASN1err(ASN1_F_ASN1_DO_ADB, | 269 | ASN1err(ASN1_F_ASN1_DO_ADB, |
270 | ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE); | 270 | ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE); |
271 | return NULL; | 271 | return NULL; |
272 | } | 272 | } |