130 if ((rc = flock(fd, LOCK_UN))) { |
140 if ((rc = flock(fd, LOCK_UN))) { |
131 +#endif /* SOLARIS */ |
141 +#endif /* SOLARIS */ |
132 LogDebug("USER PS: failed to unlock file: %s", strerror(errno)); |
142 LogDebug("USER PS: failed to unlock file: %s", strerror(errno)); |
133 rc = -1; |
143 rc = -1; |
134 } |
144 } |
135 @@ -365,6 +410,9 @@ |
145 @@ -365,6 +420,7 @@ |
136 LogDebug("read of %zd bytes: %s", sizeof(UINT32), strerror(errno)); |
146 LogDebug("read of %zd bytes: %s", sizeof(UINT32), strerror(errno)); |
137 return TSPERR(TSS_E_INTERNAL_ERROR); |
147 return TSPERR(TSS_E_INTERNAL_ERROR); |
138 } |
148 } |
139 +#if defined(_BIG_ENDIAN) |
149 + num_keys = LE_32(num_keys); |
140 + num_keys = BSWAP_32(num_keys); |
|
141 +#endif |
|
142 |
150 |
143 if (increment) |
151 if (increment) |
144 num_keys++; |
152 num_keys++; |
145 @@ -377,6 +425,9 @@ |
153 @@ -377,6 +433,7 @@ |
146 return TSPERR(TSS_E_INTERNAL_ERROR); |
154 return TSPERR(TSS_E_INTERNAL_ERROR); |
147 } |
155 } |
148 |
156 |
149 +#if defined(_BIG_ENDIAN) |
157 + num_keys = LE_32(num_keys); |
150 + num_keys = BSWAP_32(num_keys); |
|
151 +#endif |
|
152 if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) { |
158 if ((result = write_data(fd, (void *)&num_keys, sizeof(UINT32)))) { |
153 LogDebug("%s", __FUNCTION__); |
159 LogDebug("%s", __FUNCTION__); |
154 return result; |
160 return result; |
155 @@ -498,16 +549,28 @@ |
161 @@ -498,16 +555,20 @@ |
156 } |
162 } |
157 |
163 |
158 /* [UINT16 pub_data_size0 ] yes */ |
164 /* [UINT16 pub_data_size0 ] yes */ |
159 +#if defined(_BIG_ENDIAN) |
165 + pub_key_size = LE_16(pub_key_size); |
160 + pub_key_size = BSWAP_16(pub_key_size); |
|
161 +#endif |
|
162 if ((result = write_data(fd, &pub_key_size, sizeof(UINT16)))) { |
166 if ((result = write_data(fd, &pub_key_size, sizeof(UINT16)))) { |
163 LogDebug("%s", __FUNCTION__); |
167 LogDebug("%s", __FUNCTION__); |
164 goto done; |
168 goto done; |
165 } |
169 } |
166 +#if defined(_BIG_ENDIAN) |
170 + pub_key_size = LE_16(pub_key_size); |
167 + pub_key_size = BSWAP_16(pub_key_size); |
|
168 +#endif |
|
169 |
171 |
170 /* [UINT16 blob_size0 ] yes */ |
172 /* [UINT16 blob_size0 ] yes */ |
171 +#if defined(_BIG_ENDIAN) |
173 + key_blob_size = LE_16(key_blob_size); |
172 + key_blob_size = BSWAP_16(key_blob_size); |
|
173 +#endif |
|
174 if ((result = write_data(fd, &key_blob_size, sizeof(UINT16)))) { |
174 if ((result = write_data(fd, &key_blob_size, sizeof(UINT16)))) { |
175 LogDebug("%s", __FUNCTION__); |
175 LogDebug("%s", __FUNCTION__); |
176 goto done; |
176 goto done; |
177 } |
177 } |
178 +#if defined(_BIG_ENDIAN) |
178 + key_blob_size = LE_16(key_blob_size); |
179 + key_blob_size = BSWAP_16(key_blob_size); |
|
180 +#endif |
|
181 |
179 |
182 /* [UINT32 vendor_data_size0 ] yes */ |
180 /* [UINT32 vendor_data_size0 ] yes */ |
183 if ((result = write_data(fd, &zero, sizeof(UINT32)))) { |
181 if ((result = write_data(fd, &zero, sizeof(UINT32)))) { |
184 @@ -516,10 +579,16 @@ |
182 @@ -516,10 +577,12 @@ |
185 } |
183 } |
186 |
184 |
187 /* [UINT16 cache_flags0 ] yes */ |
185 /* [UINT16 cache_flags0 ] yes */ |
188 +#if defined(_BIG_ENDIAN) |
186 + cache_flags = LE_16(cache_flags); |
189 + cache_flags = BSWAP_16(cache_flags); |
|
190 +#endif |
|
191 if ((result = write_data(fd, &cache_flags, sizeof(UINT16)))) { |
187 if ((result = write_data(fd, &cache_flags, sizeof(UINT16)))) { |
192 LogDebug("%s", __FUNCTION__); |
188 LogDebug("%s", __FUNCTION__); |
193 goto done; |
189 goto done; |
194 } |
190 } |
195 +#if defined(_BIG_ENDIAN) |
191 + cache_flags = LE_16(cache_flags); |
196 + cache_flags = BSWAP_16(cache_flags); |
|
197 +#endif |
|
198 |
192 |
199 /* [BYTE[] pub_data0 ] no */ |
193 /* [BYTE[] pub_data0 ] no */ |
200 if ((result = write_data(fd, (void *)key.pubKey.key, pub_key_size))) { |
194 if ((result = write_data(fd, (void *)key.pubKey.key, pub_key_size))) { |
201 @@ -685,6 +754,9 @@ |
195 @@ -685,6 +748,7 @@ |
202 LogDebug("%s", __FUNCTION__); |
196 LogDebug("%s", __FUNCTION__); |
203 goto err_exit; |
197 goto err_exit; |
204 } |
198 } |
205 +#if defined(_BIG_ENDIAN) |
199 + tmp[i].pub_data_size = LE_16(tmp[i].pub_data_size); |
206 + tmp[i].pub_data_size = BSWAP_16(tmp[i].pub_data_size); |
|
207 +#endif |
|
208 |
200 |
209 DBG_ASSERT(tmp[i].pub_data_size <= 2048); |
201 DBG_ASSERT(tmp[i].pub_data_size <= 2048); |
210 |
202 |
211 @@ -693,6 +765,9 @@ |
203 @@ -693,6 +757,7 @@ |
212 LogDebug("%s", __FUNCTION__); |
204 LogDebug("%s", __FUNCTION__); |
213 goto err_exit; |
205 goto err_exit; |
214 } |
206 } |
215 +#if defined(_BIG_ENDIAN) |
207 + tmp[i].blob_size = LE_16(tmp[i].blob_size); |
216 + tmp[i].blob_size = BSWAP_16(tmp[i].blob_size); |
|
217 +#endif |
|
218 |
208 |
219 DBG_ASSERT(tmp[i].blob_size <= 4096); |
209 DBG_ASSERT(tmp[i].blob_size <= 4096); |
220 |
210 |
221 @@ -701,6 +776,9 @@ |
211 @@ -701,6 +766,7 @@ |
222 LogDebug("%s", __FUNCTION__); |
212 LogDebug("%s", __FUNCTION__); |
223 goto err_exit; |
213 goto err_exit; |
224 } |
214 } |
225 +#if defined(_BIG_ENDIAN) |
215 + tmp[i].vendor_data_size = LE_32(tmp[i].vendor_data_size); |
226 + tmp[i].vendor_data_size = BSWAP_32(tmp[i].vendor_data_size); |
|
227 +#endif |
|
228 |
216 |
229 /* cache flags */ |
217 /* cache flags */ |
230 if ((result = read_data(fd, &tmp[i].flags, sizeof(UINT16)))) { |
218 if ((result = read_data(fd, &tmp[i].flags, sizeof(UINT16)))) { |
231 @@ -707,6 +785,9 @@ |
219 @@ -707,6 +773,7 @@ |
232 LogDebug("%s", __FUNCTION__); |
220 LogDebug("%s", __FUNCTION__); |
233 goto err_exit; |
221 goto err_exit; |
234 } |
222 } |
235 +#if defined(_BIG_ENDIAN) |
223 + tmp[i].flags = LE_16(tmp[i].flags); |
236 + tmp[i].flags = BSWAP_16(tmp[i].flags); |
|
237 +#endif |
|
238 |
224 |
239 /* fast forward over the pub key */ |
225 /* fast forward over the pub key */ |
240 offset = lseek(fd, tmp[i].pub_data_size, SEEK_CUR); |
226 offset = lseek(fd, tmp[i].pub_data_size, SEEK_CUR); |
241 @@ -1031,6 +1112,10 @@ |
227 @@ -1031,6 +1098,8 @@ |
242 num_keys = 0; |
228 num_keys = 0; |
243 } |
229 } |
244 |
230 |
245 +#if defined(_BIG_ENDIAN) |
|
246 + /* The system PS file is written in little-endian */ |
231 + /* The system PS file is written in little-endian */ |
247 + num_keys = BSWAP_32(num_keys); |
232 + num_keys = LE_32(num_keys); |
248 +#endif |
|
249 return num_keys; |
233 return num_keys; |
250 } |
234 } |
251 |
235 |
252 @@ -1109,7 +1194,9 @@ |
236 @@ -1109,7 +1178,7 @@ |
253 LogDebug("%s", __FUNCTION__); |
237 LogDebug("%s", __FUNCTION__); |
254 return result; |
238 return result; |
255 } |
239 } |
256 - |
240 - |
257 +#if defined(_BIG_ENDIAN) |
241 + c->pub_data_size = LE_16(c->pub_data_size); |
258 + c->pub_data_size = BSWAP_16(c->pub_data_size); |
|
259 +#endif |
|
260 DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0); |
242 DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0); |
261 |
243 |
262 /* blob size */ |
244 /* blob size */ |
263 @@ -1117,7 +1204,9 @@ |
245 @@ -1117,7 +1186,7 @@ |
264 LogDebug("%s", __FUNCTION__); |
246 LogDebug("%s", __FUNCTION__); |
265 return result; |
247 return result; |
266 } |
248 } |
267 - |
249 - |
268 +#if defined(_BIG_ENDIAN) |
250 + c->blob_size = LE_16(c->blob_size); |
269 + c->blob_size = BSWAP_16(c->blob_size); |
|
270 +#endif |
|
271 DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0); |
251 DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0); |
272 |
252 |
273 /* vendor data size */ |
253 /* vendor data size */ |
274 @@ -1125,6 +1214,9 @@ |
254 @@ -1125,6 +1194,7 @@ |
275 LogDebug("%s", __FUNCTION__); |
255 LogDebug("%s", __FUNCTION__); |
276 return result; |
256 return result; |
277 } |
257 } |
278 +#if defined(_BIG_ENDIAN) |
258 + c->vendor_data_size = LE_32(c->vendor_data_size); |
279 + c->vendor_data_size = BSWAP_32(c->vendor_data_size); |
|
280 +#endif |
|
281 |
259 |
282 /* cache flags */ |
260 /* cache flags */ |
283 if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) { |
261 if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) { |
284 @@ -1131,6 +1223,9 @@ |
262 @@ -1131,6 +1201,7 @@ |
285 LogDebug("%s", __FUNCTION__); |
263 LogDebug("%s", __FUNCTION__); |
286 return result; |
264 return result; |
287 } |
265 } |
288 +#if defined(_BIG_ENDIAN) |
266 + c->flags = LE_16(c->flags); |
289 + c->flags = BSWAP_16(c->flags); |
|
290 +#endif |
|
291 |
267 |
292 /* fast forward over the pub key */ |
268 /* fast forward over the pub key */ |
293 offset = lseek(fd, c->pub_data_size, SEEK_CUR); |
269 offset = lseek(fd, c->pub_data_size, SEEK_CUR); |
294 @@ -1198,6 +1293,9 @@ |
270 @@ -1198,6 +1269,7 @@ |
295 return result; |
271 return result; |
296 } |
272 } |
297 |
273 |
298 +#if defined(_BIG_ENDIAN) |
274 + c->pub_data_size = LE_16(c->pub_data_size); |
299 + c->pub_data_size = BSWAP_16(c->pub_data_size); |
|
300 +#endif |
|
301 DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0); |
275 DBG_ASSERT(c->pub_data_size <= 2048 && c->pub_data_size > 0); |
302 |
276 |
303 /* blob size */ |
277 /* blob size */ |
304 @@ -1206,6 +1304,9 @@ |
278 @@ -1206,6 +1278,7 @@ |
305 return result; |
279 return result; |
306 } |
280 } |
307 |
281 |
308 +#if defined(_BIG_ENDIAN) |
282 + c->blob_size = LE_16(c->blob_size); |
309 + c->blob_size = BSWAP_16(c->blob_size); |
|
310 +#endif |
|
311 DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0); |
283 DBG_ASSERT(c->blob_size <= 4096 && c->blob_size > 0); |
312 |
284 |
313 /* vendor data size */ |
285 /* vendor data size */ |
314 @@ -1213,6 +1314,9 @@ |
286 @@ -1213,6 +1286,7 @@ |
315 LogDebug("%s", __FUNCTION__); |
287 LogDebug("%s", __FUNCTION__); |
316 return result; |
288 return result; |
317 } |
289 } |
318 +#if defined(_BIG_ENDIAN) |
290 + c->vendor_data_size = LE_32(c->vendor_data_size); |
319 + c->vendor_data_size = BSWAP_32(c->vendor_data_size); |
|
320 +#endif |
|
321 |
291 |
322 /* cache flags */ |
292 /* cache flags */ |
323 if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) { |
293 if ((result = read_data(fd, &c->flags, sizeof(UINT16)))) { |
324 @@ -1219,6 +1323,9 @@ |
294 @@ -1219,6 +1293,7 @@ |
325 LogDebug("%s", __FUNCTION__); |
295 LogDebug("%s", __FUNCTION__); |
326 return result; |
296 return result; |
327 } |
297 } |
328 +#if defined(_BIG_ENDIAN) |
298 + c->flags = LE_16(c->flags); |
329 + c->flags = BSWAP_16(c->flags); |
|
330 +#endif |
|
331 |
299 |
332 if (c->pub_data_size == pub_size) { |
300 if (c->pub_data_size == pub_size) { |
333 /* read in the pub key */ |
301 /* read in the pub key */ |