OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "secder.h" | 5 #include "secder.h" |
6 #include <limits.h> | 6 #include <limits.h> |
7 #include "secerr.h" | 7 #include "secerr.h" |
8 | 8 |
9 int | 9 int |
10 DER_LengthLength(PRUint32 len) | 10 DER_LengthLength(PRUint32 len) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 *buf++ = b[3]; | 69 *buf++ = b[3]; |
70 } | 70 } |
71 return buf; | 71 return buf; |
72 } | 72 } |
73 | 73 |
74 /* | 74 /* |
75 * XXX This should be rewritten, generalized, to take a long instead | 75 * XXX This should be rewritten, generalized, to take a long instead |
76 * of a PRInt32. | 76 * of a PRInt32. |
77 */ | 77 */ |
78 SECStatus | 78 SECStatus |
79 DER_SetInteger(PRArenaPool *arena, SECItem *it, PRInt32 i) | 79 DER_SetInteger(PLArenaPool *arena, SECItem *it, PRInt32 i) |
80 { | 80 { |
81 unsigned char bb[4]; | 81 unsigned char bb[4]; |
82 unsigned len; | 82 unsigned len; |
83 | 83 |
84 bb[0] = (unsigned char) (i >> 24); | 84 bb[0] = (unsigned char) (i >> 24); |
85 bb[1] = (unsigned char) (i >> 16); | 85 bb[1] = (unsigned char) (i >> 16); |
86 bb[2] = (unsigned char) (i >> 8); | 86 bb[2] = (unsigned char) (i >> 8); |
87 bb[3] = (unsigned char) (i); | 87 bb[3] = (unsigned char) (i); |
88 | 88 |
89 /* | 89 /* |
(...skipping 30 matching lines...) Expand all Loading... |
120 it->len = len; | 120 it->len = len; |
121 PORT_Memcpy(it->data, bb + (4 - len), len); | 121 PORT_Memcpy(it->data, bb + (4 - len), len); |
122 return SECSuccess; | 122 return SECSuccess; |
123 } | 123 } |
124 | 124 |
125 /* | 125 /* |
126 * XXX This should be rewritten, generalized, to take an unsigned long instead | 126 * XXX This should be rewritten, generalized, to take an unsigned long instead |
127 * of a PRUint32. | 127 * of a PRUint32. |
128 */ | 128 */ |
129 SECStatus | 129 SECStatus |
130 DER_SetUInteger(PRArenaPool *arena, SECItem *it, PRUint32 ui) | 130 DER_SetUInteger(PLArenaPool *arena, SECItem *it, PRUint32 ui) |
131 { | 131 { |
132 unsigned char bb[5]; | 132 unsigned char bb[5]; |
133 int len; | 133 int len; |
134 | 134 |
135 bb[0] = 0; | 135 bb[0] = 0; |
136 bb[1] = (unsigned char) (ui >> 24); | 136 bb[1] = (unsigned char) (ui >> 24); |
137 bb[2] = (unsigned char) (ui >> 16); | 137 bb[2] = (unsigned char) (ui >> 16); |
138 bb[3] = (unsigned char) (ui >> 8); | 138 bb[3] = (unsigned char) (ui >> 8); |
139 bb[4] = (unsigned char) (ui); | 139 bb[4] = (unsigned char) (ui); |
140 | 140 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 if (ival & overflow) { | 237 if (ival & overflow) { |
238 PORT_SetError(SEC_ERROR_BAD_DER); | 238 PORT_SetError(SEC_ERROR_BAD_DER); |
239 return ULONG_MAX; | 239 return ULONG_MAX; |
240 } | 240 } |
241 ival = ival << 8; | 241 ival = ival << 8; |
242 ival |= *cp++; | 242 ival |= *cp++; |
243 --len; | 243 --len; |
244 } | 244 } |
245 return ival; | 245 return ival; |
246 } | 246 } |
OLD | NEW |