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

Side by Side Diff: nss/lib/util/secasn1e.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/secasn1d.c ('k') | nss/lib/util/secder.h » ('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 ENcoding ASN.1 data based on BER/DER (Basic/Distinguished 6 * Support for ENcoding ASN.1 data based on BER/DER (Basic/Distinguished
7 * Encoding Rules). 7 * Encoding Rules).
8 */ 8 */
9 9
10 #include "secasn1.h" 10 #include "secasn1.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 disallowStreaming; /* disallow streaming in all sub-templates */ 64 disallowStreaming; /* disallow streaming in all sub-templates */
65 } sec_asn1e_state; 65 } sec_asn1e_state;
66 66
67 /* 67 /*
68 * An "outsider" will have an opaque pointer to this, created by calling 68 * An "outsider" will have an opaque pointer to this, created by calling
69 * SEC_ASN1EncoderStart(). It will be passed back in to all subsequent 69 * SEC_ASN1EncoderStart(). It will be passed back in to all subsequent
70 * calls to SEC_ASN1EncoderUpdate() and related routines, and when done 70 * calls to SEC_ASN1EncoderUpdate() and related routines, and when done
71 * it is passed to SEC_ASN1EncoderFinish(). 71 * it is passed to SEC_ASN1EncoderFinish().
72 */ 72 */
73 struct sec_EncoderContext_struct { 73 struct sec_EncoderContext_struct {
74 PRArenaPool *our_pool;» » /* for our internal allocs */ 74 PLArenaPool *our_pool;» » /* for our internal allocs */
75 75
76 sec_asn1e_state *current; 76 sec_asn1e_state *current;
77 sec_asn1e_parse_status status; 77 sec_asn1e_parse_status status;
78 78
79 PRBool streaming; 79 PRBool streaming;
80 PRBool from_buf; 80 PRBool from_buf;
81 81
82 SEC_ASN1NotifyProc notify_proc; /* call before/after handling field */ 82 SEC_ASN1NotifyProc notify_proc; /* call before/after handling field */
83 void *notify_arg; /* argument to notify_proc */ 83 void *notify_arg; /* argument to notify_proc */
84 PRBool during_notify; /* true during call to notify_proc */ 84 PRBool during_notify; /* true during call to notify_proc */
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 */ 1301 */
1302 1302
1303 PORT_FreeArena (cx->our_pool, PR_FALSE); 1303 PORT_FreeArena (cx->our_pool, PR_FALSE);
1304 } 1304 }
1305 1305
1306 1306
1307 SEC_ASN1EncoderContext * 1307 SEC_ASN1EncoderContext *
1308 SEC_ASN1EncoderStart (const void *src, const SEC_ASN1Template *theTemplate, 1308 SEC_ASN1EncoderStart (const void *src, const SEC_ASN1Template *theTemplate,
1309 SEC_ASN1WriteProc output_proc, void *output_arg) 1309 SEC_ASN1WriteProc output_proc, void *output_arg)
1310 { 1310 {
1311 PRArenaPool *our_pool; 1311 PLArenaPool *our_pool;
1312 SEC_ASN1EncoderContext *cx; 1312 SEC_ASN1EncoderContext *cx;
1313 1313
1314 our_pool = PORT_NewArena (SEC_ASN1_DEFAULT_ARENA_SIZE); 1314 our_pool = PORT_NewArena (SEC_ASN1_DEFAULT_ARENA_SIZE);
1315 if (our_pool == NULL) 1315 if (our_pool == NULL)
1316 return NULL; 1316 return NULL;
1317 1317
1318 cx = (SEC_ASN1EncoderContext*)PORT_ArenaZAlloc (our_pool, sizeof(*cx)); 1318 cx = (SEC_ASN1EncoderContext*)PORT_ArenaZAlloc (our_pool, sizeof(*cx));
1319 if (cx == NULL) { 1319 if (cx == NULL) {
1320 PORT_FreeArena (our_pool, PR_FALSE); 1320 PORT_FreeArena (our_pool, PR_FALSE);
1321 return NULL; 1321 return NULL;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 1470
1471 1471
1472 /* 1472 /*
1473 * Allocate an entire SECItem, or just the data part of it, to hold 1473 * Allocate an entire SECItem, or just the data part of it, to hold
1474 * "len" bytes of stuff. Allocate from the given pool, if specified, 1474 * "len" bytes of stuff. Allocate from the given pool, if specified,
1475 * otherwise just do a vanilla PORT_Alloc. 1475 * otherwise just do a vanilla PORT_Alloc.
1476 * 1476 *
1477 * XXX This seems like a reasonable general-purpose function (for SECITEM_)? 1477 * XXX This seems like a reasonable general-purpose function (for SECITEM_)?
1478 */ 1478 */
1479 static SECItem * 1479 static SECItem *
1480 sec_asn1e_allocate_item (PRArenaPool *poolp, SECItem *dest, unsigned long len) 1480 sec_asn1e_allocate_item (PLArenaPool *poolp, SECItem *dest, unsigned long len)
1481 { 1481 {
1482 if (poolp != NULL) { 1482 if (poolp != NULL) {
1483 void *release; 1483 void *release;
1484 1484
1485 release = PORT_ArenaMark (poolp); 1485 release = PORT_ArenaMark (poolp);
1486 if (dest == NULL) 1486 if (dest == NULL)
1487 dest = (SECItem*)PORT_ArenaAlloc (poolp, sizeof(SECItem)); 1487 dest = (SECItem*)PORT_ArenaAlloc (poolp, sizeof(SECItem));
1488 if (dest != NULL) { 1488 if (dest != NULL) {
1489 dest->data = (unsigned char*)PORT_ArenaAlloc (poolp, len); 1489 dest->data = (unsigned char*)PORT_ArenaAlloc (poolp, len);
1490 if (dest->data == NULL) { 1490 if (dest->data == NULL) {
(...skipping 22 matching lines...) Expand all
1513 dest = NULL; 1513 dest = NULL;
1514 } 1514 }
1515 } 1515 }
1516 } 1516 }
1517 1517
1518 return dest; 1518 return dest;
1519 } 1519 }
1520 1520
1521 1521
1522 SECItem * 1522 SECItem *
1523 SEC_ASN1EncodeItem (PRArenaPool *poolp, SECItem *dest, const void *src, 1523 SEC_ASN1EncodeItem (PLArenaPool *poolp, SECItem *dest, const void *src,
1524 const SEC_ASN1Template *theTemplate) 1524 const SEC_ASN1Template *theTemplate)
1525 { 1525 {
1526 unsigned long encoding_length; 1526 unsigned long encoding_length;
1527 SECStatus rv; 1527 SECStatus rv;
1528 1528
1529 PORT_Assert (dest == NULL || dest->data == NULL); 1529 PORT_Assert (dest == NULL || dest->data == NULL);
1530 1530
1531 encoding_length = 0; 1531 encoding_length = 0;
1532 rv = SEC_ASN1Encode (src, theTemplate, 1532 rv = SEC_ASN1Encode (src, theTemplate,
1533 sec_asn1e_encode_item_count, &encoding_length); 1533 sec_asn1e_encode_item_count, &encoding_length);
(...skipping 11 matching lines...) Expand all
1545 1545
1546 dest->len = 0; 1546 dest->len = 0;
1547 (void) SEC_ASN1Encode (src, theTemplate, sec_asn1e_encode_item_store, dest); 1547 (void) SEC_ASN1Encode (src, theTemplate, sec_asn1e_encode_item_store, dest);
1548 1548
1549 PORT_Assert (encoding_length == dest->len); 1549 PORT_Assert (encoding_length == dest->len);
1550 return dest; 1550 return dest;
1551 } 1551 }
1552 1552
1553 1553
1554 static SECItem * 1554 static SECItem *
1555 sec_asn1e_integer(PRArenaPool *poolp, SECItem *dest, unsigned long value, 1555 sec_asn1e_integer(PLArenaPool *poolp, SECItem *dest, unsigned long value,
1556 PRBool is_unsigned) 1556 PRBool is_unsigned)
1557 { 1557 {
1558 unsigned long copy; 1558 unsigned long copy;
1559 unsigned char sign; 1559 unsigned char sign;
1560 int len = 0; 1560 int len = 0;
1561 1561
1562 /* 1562 /*
1563 * Determine the length of the encoded value (minimum of 1). 1563 * Determine the length of the encoded value (minimum of 1).
1564 */ 1564 */
1565 copy = value; 1565 copy = value;
(...skipping 26 matching lines...) Expand all
1592 dest->data[--len] = (unsigned char)value; 1592 dest->data[--len] = (unsigned char)value;
1593 value >>= 8; 1593 value >>= 8;
1594 } 1594 }
1595 PORT_Assert (value == 0); 1595 PORT_Assert (value == 0);
1596 1596
1597 return dest; 1597 return dest;
1598 } 1598 }
1599 1599
1600 1600
1601 SECItem * 1601 SECItem *
1602 SEC_ASN1EncodeInteger(PRArenaPool *poolp, SECItem *dest, long value) 1602 SEC_ASN1EncodeInteger(PLArenaPool *poolp, SECItem *dest, long value)
1603 { 1603 {
1604 return sec_asn1e_integer (poolp, dest, (unsigned long) value, PR_FALSE); 1604 return sec_asn1e_integer (poolp, dest, (unsigned long) value, PR_FALSE);
1605 } 1605 }
1606 1606
1607 1607
1608 SECItem * 1608 SECItem *
1609 SEC_ASN1EncodeUnsignedInteger(PRArenaPool *poolp, 1609 SEC_ASN1EncodeUnsignedInteger(PLArenaPool *poolp,
1610 SECItem *dest, unsigned long value) 1610 SECItem *dest, unsigned long value)
1611 { 1611 {
1612 return sec_asn1e_integer (poolp, dest, value, PR_TRUE); 1612 return sec_asn1e_integer (poolp, dest, value, PR_TRUE);
1613 } 1613 }
OLDNEW
« no previous file with comments | « nss/lib/util/secasn1d.c ('k') | nss/lib/util/secder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698