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

Side by Side Diff: nss/lib/util/secdig.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/secder.h ('k') | nss/lib/util/secitem.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 #include "secdig.h" 4 #include "secdig.h"
5 5
6 #include "secoid.h" 6 #include "secoid.h"
7 #include "secasn1.h" 7 #include "secasn1.h"
8 #include "secerr.h" 8 #include "secerr.h"
9 9
10 /* 10 /*
11 * XXX Want to have a SGN_DecodeDigestInfo, like: 11 * XXX Want to have a SGN_DecodeDigestInfo, like:
12 * SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata); 12 * SGNDigestInfo *SGN_DecodeDigestInfo(SECItem *didata);
13 * that creates a pool and allocates from it and decodes didata into 13 * that creates a pool and allocates from it and decodes didata into
14 * the newly allocated DigestInfo structure. Then fix secvfy.c (it 14 * the newly allocated DigestInfo structure. Then fix secvfy.c (it
15 * will no longer need an arena itself) to call this and then call 15 * will no longer need an arena itself) to call this and then call
16 * DestroyDigestInfo when it is done, then can remove the old template 16 * DestroyDigestInfo when it is done, then can remove the old template
17 * above and keep our new template static and "hidden". 17 * above and keep our new template static and "hidden".
18 */ 18 */
19 19
20 /* 20 /*
21 * XXX It might be nice to combine the following two functions (create 21 * XXX It might be nice to combine the following two functions (create
22 * and encode). I think that is all anybody ever wants to do anyway. 22 * and encode). I think that is all anybody ever wants to do anyway.
23 */ 23 */
24 24
25 SECItem * 25 SECItem *
26 SGN_EncodeDigestInfo(PRArenaPool *poolp, SECItem *dest, SGNDigestInfo *diginfo) 26 SGN_EncodeDigestInfo(PLArenaPool *poolp, SECItem *dest, SGNDigestInfo *diginfo)
27 { 27 {
28 return SEC_ASN1EncodeItem (poolp, dest, diginfo, sgn_DigestInfoTemplate); 28 return SEC_ASN1EncodeItem (poolp, dest, diginfo, sgn_DigestInfoTemplate);
29 } 29 }
30 30
31 SGNDigestInfo * 31 SGNDigestInfo *
32 SGN_CreateDigestInfo(SECOidTag algorithm, unsigned char *sig, unsigned len) 32 SGN_CreateDigestInfo(SECOidTag algorithm, unsigned char *sig, unsigned len)
33 { 33 {
34 SGNDigestInfo *di; 34 SGNDigestInfo *di;
35 SECStatus rv; 35 SECStatus rv;
36 PRArenaPool *arena; 36 PLArenaPool *arena;
37 SECItem *null_param; 37 SECItem *null_param;
38 SECItem dummy_value; 38 SECItem dummy_value;
39 39
40 switch (algorithm) { 40 switch (algorithm) {
41 case SEC_OID_MD2: 41 case SEC_OID_MD2:
42 case SEC_OID_MD5: 42 case SEC_OID_MD5:
43 case SEC_OID_SHA1: 43 case SEC_OID_SHA1:
44 case SEC_OID_SHA224: 44 case SEC_OID_SHA224:
45 case SEC_OID_SHA256: 45 case SEC_OID_SHA256:
46 case SEC_OID_SHA384: 46 case SEC_OID_SHA384:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return di; 94 return di;
95 95
96 loser: 96 loser:
97 SGN_DestroyDigestInfo(di); 97 SGN_DestroyDigestInfo(di);
98 return NULL; 98 return NULL;
99 } 99 }
100 100
101 SGNDigestInfo * 101 SGNDigestInfo *
102 SGN_DecodeDigestInfo(SECItem *didata) 102 SGN_DecodeDigestInfo(SECItem *didata)
103 { 103 {
104 PRArenaPool *arena; 104 PLArenaPool *arena;
105 SGNDigestInfo *di; 105 SGNDigestInfo *di;
106 SECStatus rv = SECFailure; 106 SECStatus rv = SECFailure;
107 SECItem diCopy = {siBuffer, NULL, 0}; 107 SECItem diCopy = {siBuffer, NULL, 0};
108 108
109 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE); 109 arena = PORT_NewArena(SEC_ASN1_DEFAULT_ARENA_SIZE);
110 if(arena == NULL) 110 if(arena == NULL)
111 return NULL; 111 return NULL;
112 112
113 rv = SECITEM_CopyItem(arena, &diCopy, didata); 113 rv = SECITEM_CopyItem(arena, &diCopy, didata);
114 if (rv != SECSuccess) { 114 if (rv != SECSuccess) {
(...skipping 19 matching lines...) Expand all
134 SGN_DestroyDigestInfo(SGNDigestInfo *di) 134 SGN_DestroyDigestInfo(SGNDigestInfo *di)
135 { 135 {
136 if (di && di->arena) { 136 if (di && di->arena) {
137 PORT_FreeArena(di->arena, PR_FALSE); 137 PORT_FreeArena(di->arena, PR_FALSE);
138 } 138 }
139 139
140 return; 140 return;
141 } 141 }
142 142
143 SECStatus 143 SECStatus
144 SGN_CopyDigestInfo(PRArenaPool *poolp, SGNDigestInfo *a, SGNDigestInfo *b) 144 SGN_CopyDigestInfo(PLArenaPool *poolp, SGNDigestInfo *a, SGNDigestInfo *b)
145 { 145 {
146 SECStatus rv; 146 SECStatus rv;
147 void *mark; 147 void *mark;
148 148
149 if((poolp == NULL) || (a == NULL) || (b == NULL)) 149 if((poolp == NULL) || (a == NULL) || (b == NULL))
150 return SECFailure; 150 return SECFailure;
151 151
152 mark = PORT_ArenaMark(poolp); 152 mark = PORT_ArenaMark(poolp);
153 a->arena = poolp; 153 a->arena = poolp;
154 rv = SECOID_CopyAlgorithmID(poolp, &a->digestAlgorithm, 154 rv = SECOID_CopyAlgorithmID(poolp, &a->digestAlgorithm,
(...skipping 16 matching lines...) Expand all
171 SECComparison rv; 171 SECComparison rv;
172 172
173 /* Check signature algorithm's */ 173 /* Check signature algorithm's */
174 rv = SECOID_CompareAlgorithmID(&a->digestAlgorithm, &b->digestAlgorithm); 174 rv = SECOID_CompareAlgorithmID(&a->digestAlgorithm, &b->digestAlgorithm);
175 if (rv) return rv; 175 if (rv) return rv;
176 176
177 /* Compare signature block length's */ 177 /* Compare signature block length's */
178 rv = SECITEM_CompareItem(&a->digest, &b->digest); 178 rv = SECITEM_CompareItem(&a->digest, &b->digest);
179 return rv; 179 return rv;
180 } 180 }
OLDNEW
« no previous file with comments | « nss/lib/util/secder.h ('k') | nss/lib/util/secitem.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698