Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: nss/lib/util/secasn1d.c

Issue 16132005: Allow NSS to be built with NO_NSPR_10_SUPPORT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « nss/lib/util/secalgid.c ('k') | nss/lib/util/secasn1e.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /* 5 /*
6 * Support for DEcoding ASN.1 data based on BER/DER (Basic/Distinguished 6 * Support for DEcoding ASN.1 data based on BER/DER (Basic/Distinguished
7 * Encoding Rules). 7 * Encoding Rules).
8 */ 8 */
9 9
10 /* #define DEBUG_ASN1D_STATES 1 */ 10 /* #define DEBUG_ASN1D_STATES 1 */
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 #define HIGH_BITS(field,cnt) ((field) >> ((sizeof(field) * 8) - (cnt))) 265 #define HIGH_BITS(field,cnt) ((field) >> ((sizeof(field) * 8) - (cnt)))
266 266
267 267
268 /* 268 /*
269 * An "outsider" will have an opaque pointer to this, created by calling 269 * An "outsider" will have an opaque pointer to this, created by calling
270 * SEC_ASN1DecoderStart(). It will be passed back in to all subsequent 270 * SEC_ASN1DecoderStart(). It will be passed back in to all subsequent
271 * calls to SEC_ASN1DecoderUpdate(), and when done it is passed to 271 * calls to SEC_ASN1DecoderUpdate(), and when done it is passed to
272 * SEC_ASN1DecoderFinish(). 272 * SEC_ASN1DecoderFinish().
273 */ 273 */
274 struct sec_DecoderContext_struct { 274 struct sec_DecoderContext_struct {
275 PRArenaPool *our_pool;» » /* for our internal allocs */ 275 PLArenaPool *our_pool;» » /* for our internal allocs */
276 PRArenaPool *their_pool;» » /* for destination structure allocs */ 276 PLArenaPool *their_pool;» » /* for destination structure allocs */
277 #ifdef SEC_ASN1D_FREE_ON_ERROR /* 277 #ifdef SEC_ASN1D_FREE_ON_ERROR /*
278 * XXX see comment below (by same 278 * XXX see comment below (by same
279 * ifdef) that explains why this 279 * ifdef) that explains why this
280 * does not work (need more smarts 280 * does not work (need more smarts
281 * in order to free back to mark) 281 * in order to free back to mark)
282 */ 282 */
283 /* 283 /*
284 * XXX how to make their_mark work in the case where they do NOT 284 * XXX how to make their_mark work in the case where they do NOT
285 * give us a pool pointer? 285 * give us a pool pointer?
286 */ 286 */
(...skipping 10 matching lines...) Expand all
297 SEC_ASN1WriteProc filter_proc; /* pass field bytes to this */ 297 SEC_ASN1WriteProc filter_proc; /* pass field bytes to this */
298 void *filter_arg; /* argument to that function */ 298 void *filter_arg; /* argument to that function */
299 PRBool filter_only; /* do not allocate/store fields */ 299 PRBool filter_only; /* do not allocate/store fields */
300 }; 300 };
301 301
302 302
303 /* 303 /*
304 * XXX this is a fairly generic function that may belong elsewhere 304 * XXX this is a fairly generic function that may belong elsewhere
305 */ 305 */
306 static void * 306 static void *
307 sec_asn1d_alloc (PRArenaPool *poolp, unsigned long len) 307 sec_asn1d_alloc (PLArenaPool *poolp, unsigned long len)
308 { 308 {
309 void *thing; 309 void *thing;
310 310
311 if (poolp != NULL) { 311 if (poolp != NULL) {
312 /* 312 /*
313 * Allocate from the pool. 313 * Allocate from the pool.
314 */ 314 */
315 thing = PORT_ArenaAlloc (poolp, len); 315 thing = PORT_ArenaAlloc (poolp, len);
316 } else { 316 } else {
317 /* 317 /*
318 * Allocate generically. 318 * Allocate generically.
319 */ 319 */
320 thing = PORT_Alloc (len); 320 thing = PORT_Alloc (len);
321 } 321 }
322 322
323 return thing; 323 return thing;
324 } 324 }
325 325
326 326
327 /* 327 /*
328 * XXX this is a fairly generic function that may belong elsewhere 328 * XXX this is a fairly generic function that may belong elsewhere
329 */ 329 */
330 static void * 330 static void *
331 sec_asn1d_zalloc (PRArenaPool *poolp, unsigned long len) 331 sec_asn1d_zalloc (PLArenaPool *poolp, unsigned long len)
332 { 332 {
333 void *thing; 333 void *thing;
334 334
335 thing = sec_asn1d_alloc (poolp, len); 335 thing = sec_asn1d_alloc (poolp, len);
336 if (thing != NULL) 336 if (thing != NULL)
337 PORT_Memset (thing, 0, len); 337 PORT_Memset (thing, 0, len);
338 return thing; 338 return thing;
339 } 339 }
340 340
341 341
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 state->place = afterLength; 949 state->place = afterLength;
950 950
951 return count; 951 return count;
952 } 952 }
953 953
954 954
955 static void 955 static void
956 sec_asn1d_prepare_for_contents (sec_asn1d_state *state) 956 sec_asn1d_prepare_for_contents (sec_asn1d_state *state)
957 { 957 {
958 SECItem *item; 958 SECItem *item;
959 PRArenaPool *poolp; 959 PLArenaPool *poolp;
960 unsigned long alloc_len; 960 unsigned long alloc_len;
961 961
962 #ifdef DEBUG_ASN1D_STATES 962 #ifdef DEBUG_ASN1D_STATES
963 { 963 {
964 printf("Found Length %d %s\n", state->contents_length, 964 printf("Found Length %d %s\n", state->contents_length,
965 state->indefinite ? "indefinite" : ""); 965 state->indefinite ? "indefinite" : "");
966 } 966 }
967 #endif 967 #endif
968 968
969 /* 969 /*
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 * XXX anything else that needs to be finished? 2811 * XXX anything else that needs to be finished?
2812 */ 2812 */
2813 2813
2814 PORT_FreeArena (cx->our_pool, PR_TRUE); 2814 PORT_FreeArena (cx->our_pool, PR_TRUE);
2815 2815
2816 return rv; 2816 return rv;
2817 } 2817 }
2818 2818
2819 2819
2820 SEC_ASN1DecoderContext * 2820 SEC_ASN1DecoderContext *
2821 SEC_ASN1DecoderStart (PRArenaPool *their_pool, void *dest, 2821 SEC_ASN1DecoderStart (PLArenaPool *their_pool, void *dest,
2822 const SEC_ASN1Template *theTemplate) 2822 const SEC_ASN1Template *theTemplate)
2823 { 2823 {
2824 PRArenaPool *our_pool; 2824 PLArenaPool *our_pool;
2825 SEC_ASN1DecoderContext *cx; 2825 SEC_ASN1DecoderContext *cx;
2826 2826
2827 our_pool = PORT_NewArena (SEC_ASN1_DEFAULT_ARENA_SIZE); 2827 our_pool = PORT_NewArena (SEC_ASN1_DEFAULT_ARENA_SIZE);
2828 if (our_pool == NULL) 2828 if (our_pool == NULL)
2829 return NULL; 2829 return NULL;
2830 2830
2831 cx = (SEC_ASN1DecoderContext*)PORT_ArenaZAlloc (our_pool, sizeof(*cx)); 2831 cx = (SEC_ASN1DecoderContext*)PORT_ArenaZAlloc (our_pool, sizeof(*cx));
2832 if (cx == NULL) { 2832 if (cx == NULL) {
2833 PORT_FreeArena (our_pool, PR_FALSE); 2833 PORT_FreeArena (our_pool, PR_FALSE);
2834 return NULL; 2834 return NULL;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 void 2903 void
2904 SEC_ASN1DecoderAbort(SEC_ASN1DecoderContext *cx, int error) 2904 SEC_ASN1DecoderAbort(SEC_ASN1DecoderContext *cx, int error)
2905 { 2905 {
2906 PORT_Assert(cx); 2906 PORT_Assert(cx);
2907 PORT_SetError(error); 2907 PORT_SetError(error);
2908 cx->status = decodeError; 2908 cx->status = decodeError;
2909 } 2909 }
2910 2910
2911 2911
2912 SECStatus 2912 SECStatus
2913 SEC_ASN1Decode (PRArenaPool *poolp, void *dest, 2913 SEC_ASN1Decode (PLArenaPool *poolp, void *dest,
2914 const SEC_ASN1Template *theTemplate, 2914 const SEC_ASN1Template *theTemplate,
2915 const char *buf, long len) 2915 const char *buf, long len)
2916 { 2916 {
2917 SEC_ASN1DecoderContext *dcx; 2917 SEC_ASN1DecoderContext *dcx;
2918 SECStatus urv, frv; 2918 SECStatus urv, frv;
2919 2919
2920 dcx = SEC_ASN1DecoderStart (poolp, dest, theTemplate); 2920 dcx = SEC_ASN1DecoderStart (poolp, dest, theTemplate);
2921 if (dcx == NULL) 2921 if (dcx == NULL)
2922 return SECFailure; 2922 return SECFailure;
2923 2923
2924 urv = SEC_ASN1DecoderUpdate (dcx, buf, len); 2924 urv = SEC_ASN1DecoderUpdate (dcx, buf, len);
2925 frv = SEC_ASN1DecoderFinish (dcx); 2925 frv = SEC_ASN1DecoderFinish (dcx);
2926 2926
2927 if (urv != SECSuccess) 2927 if (urv != SECSuccess)
2928 return urv; 2928 return urv;
2929 2929
2930 return frv; 2930 return frv;
2931 } 2931 }
2932 2932
2933 2933
2934 SECStatus 2934 SECStatus
2935 SEC_ASN1DecodeItem (PRArenaPool *poolp, void *dest, 2935 SEC_ASN1DecodeItem (PLArenaPool *poolp, void *dest,
2936 const SEC_ASN1Template *theTemplate, 2936 const SEC_ASN1Template *theTemplate,
2937 const SECItem *src) 2937 const SECItem *src)
2938 { 2938 {
2939 return SEC_ASN1Decode (poolp, dest, theTemplate, 2939 return SEC_ASN1Decode (poolp, dest, theTemplate,
2940 (const char *)src->data, src->len); 2940 (const char *)src->data, src->len);
2941 } 2941 }
2942 2942
2943 #ifdef DEBUG_ASN1D_STATES 2943 #ifdef DEBUG_ASN1D_STATES
2944 void sec_asn1d_Assert(const char *s, const char *file, PRIntn ln) 2944 void sec_asn1d_Assert(const char *s, const char *file, PRIntn ln)
2945 { 2945 {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3226 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_EnumeratedTemplate) 3226 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_EnumeratedTemplate)
3227 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToEnumeratedTemplate) 3227 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToEnumeratedTemplate)
3228 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SequenceOfAnyTemplate) 3228 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SequenceOfAnyTemplate)
3229 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SequenceOfObjectIDTemplate) 3229 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SequenceOfObjectIDTemplate)
3230 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SkipTemplate) 3230 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_SkipTemplate)
3231 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UniversalStringTemplate) 3231 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_UniversalStringTemplate)
3232 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PrintableStringTemplate) 3232 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PrintableStringTemplate)
3233 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_T61StringTemplate) 3233 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_T61StringTemplate)
3234 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToGeneralizedTimeTemplate) 3234 SEC_ASN1_CHOOSER_IMPLEMENT(SEC_PointerToGeneralizedTimeTemplate)
3235 3235
OLDNEW
« no previous file with comments | « nss/lib/util/secalgid.c ('k') | nss/lib/util/secasn1e.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698