1 /*
2 * NSS utility functions
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
8 #include "secport.h"
9 #include "secoid.h"
10 #include "secitem.h"
11 #include "secdig.h"
12 #include "secder.h"
13 #include "secasn1.h"
14 #include "base64.h"
15 #include "nssb64.h"
16 #include "nssrwlk.h"
17 #include "cert.h"
18 #include "prerror.h"
19
20 /* wrappers for implementation in libnssutil3 */
21 #undef ATOB_AsciiToData
22 #undef ATOB_ConvertAsciiToItem
23 #undef BTOA_ConvertItemToAscii
24 #undef BTOA_DataToAscii
25 #undef CERT_GenTime2FormattedAscii
26 #undef DER_AsciiToTime
27 #undef DER_DecodeTimeChoice
28 #undef DER_Encode
29 #undef DER_EncodeTimeChoice
30 #undef DER_GeneralizedDayToAscii
31 #undef DER_GeneralizedTimeToTime
32 #undef DER_GetInteger
33 #undef DER_Lengths
34 #undef DER_TimeChoiceDayToAscii
35 #undef DER_TimeToGeneralizedTime
36 #undef DER_TimeToGeneralizedTimeArena
37 #undef DER_TimeToUTCTime
38 #undef DER_UTCDayToAscii
39 #undef DER_UTCTimeToAscii
40 #undef DER_UTCTimeToTime
41 #undef NSS_PutEnv
42 #undef NSSBase64_DecodeBuffer
43 #undef NSSBase64_EncodeItem
44 #undef NSSBase64Decoder_Create
45 #undef NSSBase64Decoder_Destroy
46 #undef NSSBase64Decoder_Update
47 #undef NSSBase64Encoder_Create
48 #undef NSSBase64Encoder_Destroy
49 #undef NSSBase64Encoder_Update
50 #undef NSSRWLock_Destroy
51 #undef NSSRWLock_HaveWriteLock
52 #undef NSSRWLock_LockRead
53 #undef NSSRWLock_LockWrite
54 #undef NSSRWLock_New
55 #undef NSSRWLock_UnlockRead
56 #undef NSSRWLock_UnlockWrite
57 #undef PORT_Alloc
58 #undef PORT_ArenaAlloc
59 #undef PORT_ArenaGrow
60 #undef PORT_ArenaMark
61 #undef PORT_ArenaRelease
62 #undef PORT_ArenaStrdup
63 #undef PORT_ArenaUnmark
64 #undef PORT_ArenaZAlloc
65 #undef PORT_Free
66 #undef PORT_FreeArena
67 #undef PORT_GetError
68 #undef PORT_NewArena
69 #undef PORT_Realloc
70 #undef PORT_SetError
71 #undef PORT_SetUCS2_ASCIIConversionFunction
72 #undef PORT_SetUCS2_UTF8ConversionFunction
73 #undef PORT_SetUCS4_UTF8ConversionFunction
74 #undef PORT_Strdup
75 #undef PORT_UCS2_ASCIIConversion
76 #undef PORT_UCS2_UTF8Conversion
77 #undef PORT_ZAlloc
78 #undef PORT_ZAllocAligned
79 #undef PORT_ZAllocAlignedOffset
80 #undef PORT_ZFree
81 #undef SEC_ASN1Decode
82 #undef SEC_ASN1DecodeInteger
83 #undef SEC_ASN1DecodeItem
84 #undef SEC_ASN1DecoderAbort
85 #undef SEC_ASN1DecoderClearFilterProc
86 #undef SEC_ASN1DecoderClearNotifyProc
87 #undef SEC_ASN1DecoderFinish
88 #undef SEC_ASN1DecoderSetFilterProc
89 #undef SEC_ASN1DecoderSetNotifyProc
90 #undef SEC_ASN1DecoderStart
91 #undef SEC_ASN1DecoderUpdate
92 #undef SEC_ASN1Encode
93 #undef SEC_ASN1EncodeInteger
94 #undef SEC_ASN1EncodeItem
95 #undef SEC_ASN1EncoderAbort
96 #undef SEC_ASN1EncoderClearNotifyProc
97 #undef SEC_ASN1EncoderClearStreaming
98 #undef SEC_ASN1EncoderClearTakeFromBuf
99 #undef SEC_ASN1EncoderFinish
100 #undef SEC_ASN1EncoderSetNotifyProc
101 #undef SEC_ASN1EncoderSetStreaming
102 #undef SEC_ASN1EncoderSetTakeFromBuf
103 #undef SEC_ASN1EncoderStart
104 #undef SEC_ASN1EncoderUpdate
105 #undef SEC_ASN1EncodeUnsignedInteger
106 #undef SEC_ASN1LengthLength
107 #undef SEC_QuickDERDecodeItem
108 #undef SECITEM_AllocItem
109 #undef SECITEM_ArenaDupItem
110 #undef SECITEM_CompareItem
111 #undef SECITEM_CopyItem
112 #undef SECITEM_DupItem
113 #undef SECITEM_FreeItem
114 #undef SECITEM_ItemsAreEqual
115 #undef SECITEM_ZfreeItem
116 #undef SECOID_AddEntry
117 #undef SECOID_CompareAlgorithmID
118 #undef SECOID_CopyAlgorithmID
119 #undef SECOID_DestroyAlgorithmID
120 #undef SECOID_FindOID
121 #undef SECOID_FindOIDByTag
122 #undef SECOID_FindOIDTag
123 #undef SECOID_FindOIDTagDescription
124 #undef SECOID_GetAlgorithmTag
125 #undef SECOID_SetAlgorithmID
126 #undef SGN_CompareDigestInfo
127 #undef SGN_CopyDigestInfo
128 #undef SGN_CreateDigestInfo
129 #undef SGN_DestroyDigestInfo
130
131 void *
PORT_Alloc(size_t bytes)132 PORT_Alloc(size_t bytes)
133 {
134 return PORT_Alloc_Util(bytes);
135 }
136
137 void *
PORT_Realloc(void * oldptr,size_t bytes)138 PORT_Realloc(void *oldptr, size_t bytes)
139 {
140 return PORT_Realloc_Util(oldptr, bytes);
141 }
142
143 void *
PORT_ZAlloc(size_t bytes)144 PORT_ZAlloc(size_t bytes)
145 {
146 return PORT_ZAlloc_Util(bytes);
147 }
148
149 void *
PORT_ZAllocAligned(size_t bytes,size_t alignment,void ** mem)150 PORT_ZAllocAligned(size_t bytes, size_t alignment, void **mem)
151 {
152 return PORT_ZAllocAligned_Util(bytes, alignment, mem);
153 }
154
155 void *
PORT_ZAllocAlignedOffset(size_t bytes,size_t alignment,size_t offset)156 PORT_ZAllocAlignedOffset(size_t bytes, size_t alignment, size_t offset)
157 {
158 return PORT_ZAllocAlignedOffset_Util(bytes, alignment, offset);
159 }
160
161 void
PORT_Free(void * ptr)162 PORT_Free(void *ptr)
163 {
164 PORT_Free_Util(ptr);
165 }
166
167 void
PORT_ZFree(void * ptr,size_t len)168 PORT_ZFree(void *ptr, size_t len)
169 {
170 PORT_ZFree_Util(ptr, len);
171 }
172
173 char *
PORT_Strdup(const char * str)174 PORT_Strdup(const char *str)
175 {
176 return PORT_Strdup_Util(str);
177 }
178
179 void
PORT_SetError(int value)180 PORT_SetError(int value)
181 {
182 PORT_SetError_Util(value);
183 }
184
185 int
PORT_GetError(void)186 PORT_GetError(void)
187 {
188 return PORT_GetError_Util();
189 }
190
191 PLArenaPool *
PORT_NewArena(unsigned long chunksize)192 PORT_NewArena(unsigned long chunksize)
193 {
194 return PORT_NewArena_Util(chunksize);
195 }
196
197 void *
PORT_ArenaAlloc(PLArenaPool * arena,size_t size)198 PORT_ArenaAlloc(PLArenaPool *arena, size_t size)
199 {
200 return PORT_ArenaAlloc_Util(arena, size);
201 }
202
203 void *
PORT_ArenaZAlloc(PLArenaPool * arena,size_t size)204 PORT_ArenaZAlloc(PLArenaPool *arena, size_t size)
205 {
206 return PORT_ArenaZAlloc_Util(arena, size);
207 }
208
209 void
PORT_FreeArena(PLArenaPool * arena,PRBool zero)210 PORT_FreeArena(PLArenaPool *arena, PRBool zero)
211 {
212 PORT_FreeArena_Util(arena, zero);
213 }
214
215 void *
PORT_ArenaGrow(PLArenaPool * arena,void * ptr,size_t oldsize,size_t newsize)216 PORT_ArenaGrow(PLArenaPool *arena, void *ptr, size_t oldsize, size_t newsize)
217 {
218 return PORT_ArenaGrow_Util(arena, ptr, oldsize, newsize);
219 }
220
221 void *
PORT_ArenaMark(PLArenaPool * arena)222 PORT_ArenaMark(PLArenaPool *arena)
223 {
224 return PORT_ArenaMark_Util(arena);
225 }
226
227 void
PORT_ArenaRelease(PLArenaPool * arena,void * mark)228 PORT_ArenaRelease(PLArenaPool *arena, void *mark)
229 {
230 PORT_ArenaRelease_Util(arena, mark);
231 }
232
233 void
PORT_ArenaUnmark(PLArenaPool * arena,void * mark)234 PORT_ArenaUnmark(PLArenaPool *arena, void *mark)
235 {
236 PORT_ArenaUnmark_Util(arena, mark);
237 }
238
239 char *
PORT_ArenaStrdup(PLArenaPool * arena,const char * str)240 PORT_ArenaStrdup(PLArenaPool *arena, const char *str)
241 {
242 return PORT_ArenaStrdup_Util(arena, str);
243 }
244
245 void
PORT_SetUCS4_UTF8ConversionFunction(PORTCharConversionFunc convFunc)246 PORT_SetUCS4_UTF8ConversionFunction(PORTCharConversionFunc convFunc)
247 {
248 PORT_SetUCS4_UTF8ConversionFunction_Util(convFunc);
249 }
250
251 void
PORT_SetUCS2_ASCIIConversionFunction(PORTCharConversionWSwapFunc convFunc)252 PORT_SetUCS2_ASCIIConversionFunction(PORTCharConversionWSwapFunc convFunc)
253 {
254 PORT_SetUCS2_ASCIIConversionFunction_Util(convFunc);
255 }
256
257 void
PORT_SetUCS2_UTF8ConversionFunction(PORTCharConversionFunc convFunc)258 PORT_SetUCS2_UTF8ConversionFunction(PORTCharConversionFunc convFunc)
259 {
260 PORT_SetUCS2_UTF8ConversionFunction_Util(convFunc);
261 }
262
263 PRBool
PORT_UCS2_UTF8Conversion(PRBool toUnicode,unsigned char * inBuf,unsigned int inBufLen,unsigned char * outBuf,unsigned int maxOutBufLen,unsigned int * outBufLen)264 PORT_UCS2_UTF8Conversion(PRBool toUnicode, unsigned char *inBuf,
265 unsigned int inBufLen, unsigned char *outBuf,
266 unsigned int maxOutBufLen, unsigned int *outBufLen)
267 {
268 return PORT_UCS2_UTF8Conversion_Util(toUnicode, inBuf, inBufLen, outBuf,
269 maxOutBufLen, outBufLen);
270 }
271
272 PRBool
PORT_UCS2_ASCIIConversion(PRBool toUnicode,unsigned char * inBuf,unsigned int inBufLen,unsigned char * outBuf,unsigned int maxOutBufLen,unsigned int * outBufLen,PRBool swapBytes)273 PORT_UCS2_ASCIIConversion(PRBool toUnicode, unsigned char *inBuf,
274 unsigned int inBufLen, unsigned char *outBuf,
275 unsigned int maxOutBufLen, unsigned int *outBufLen,
276 PRBool swapBytes)
277 {
278 return PORT_UCS2_ASCIIConversion_Util(toUnicode, inBuf, inBufLen, outBuf,
279 maxOutBufLen, outBufLen, swapBytes);
280 }
281
282 int
NSS_PutEnv(const char * envVarName,const char * envValue)283 NSS_PutEnv(const char *envVarName, const char *envValue)
284 {
285 return NSS_PutEnv_Util(envVarName, envValue);
286 }
287
288 SECOidData *
SECOID_FindOID(const SECItem * oid)289 SECOID_FindOID(const SECItem *oid)
290 {
291 return SECOID_FindOID_Util(oid);
292 }
293
294 SECOidTag
SECOID_FindOIDTag(const SECItem * oid)295 SECOID_FindOIDTag(const SECItem *oid)
296 {
297 return SECOID_FindOIDTag_Util(oid);
298 }
299
300 SECOidData *
SECOID_FindOIDByTag(SECOidTag tagnum)301 SECOID_FindOIDByTag(SECOidTag tagnum)
302 {
303 return SECOID_FindOIDByTag_Util(tagnum);
304 }
305
306 SECStatus
SECOID_SetAlgorithmID(PLArenaPool * arena,SECAlgorithmID * aid,SECOidTag tag,SECItem * params)307 SECOID_SetAlgorithmID(PLArenaPool *arena, SECAlgorithmID *aid,
308 SECOidTag tag, SECItem *params)
309 {
310 return SECOID_SetAlgorithmID_Util(arena, aid, tag, params);
311 }
312
313 SECStatus
SECOID_CopyAlgorithmID(PLArenaPool * arena,SECAlgorithmID * dest,const SECAlgorithmID * src)314 SECOID_CopyAlgorithmID(PLArenaPool *arena, SECAlgorithmID *dest,
315 const SECAlgorithmID *src)
316 {
317 return SECOID_CopyAlgorithmID_Util(arena, dest, src);
318 }
319
320 SECOidTag
SECOID_GetAlgorithmTag(const SECAlgorithmID * aid)321 SECOID_GetAlgorithmTag(const SECAlgorithmID *aid)
322 {
323 return SECOID_GetAlgorithmTag_Util(aid);
324 }
325
326 void
SECOID_DestroyAlgorithmID(SECAlgorithmID * aid,PRBool freeit)327 SECOID_DestroyAlgorithmID(SECAlgorithmID *aid, PRBool freeit)
328 {
329 SECOID_DestroyAlgorithmID_Util(aid, freeit);
330 }
331
332 SECComparison
SECOID_CompareAlgorithmID(SECAlgorithmID * a,SECAlgorithmID * b)333 SECOID_CompareAlgorithmID(SECAlgorithmID *a,
334 SECAlgorithmID *b)
335 {
336 return SECOID_CompareAlgorithmID_Util(a, b);
337 }
338
339 const char *
SECOID_FindOIDTagDescription(SECOidTag tagnum)340 SECOID_FindOIDTagDescription(SECOidTag tagnum)
341 {
342 return SECOID_FindOIDTagDescription_Util(tagnum);
343 }
344
345 SECOidTag
SECOID_AddEntry(const SECOidData * src)346 SECOID_AddEntry(const SECOidData *src)
347 {
348 return SECOID_AddEntry_Util(src);
349 }
350
351 SECItem *
SECITEM_AllocItem(PLArenaPool * arena,SECItem * item,unsigned int len)352 SECITEM_AllocItem(PLArenaPool *arena, SECItem *item,
353 unsigned int len)
354 {
355 return SECITEM_AllocItem_Util(arena, item, len);
356 }
357
358 SECComparison
SECITEM_CompareItem(const SECItem * a,const SECItem * b)359 SECITEM_CompareItem(const SECItem *a, const SECItem *b)
360 {
361 return SECITEM_CompareItem_Util(a, b);
362 }
363
364 PRBool
SECITEM_ItemsAreEqual(const SECItem * a,const SECItem * b)365 SECITEM_ItemsAreEqual(const SECItem *a, const SECItem *b)
366 {
367 return SECITEM_ItemsAreEqual_Util(a, b);
368 }
369
370 SECStatus
SECITEM_CopyItem(PLArenaPool * arena,SECItem * to,const SECItem * from)371 SECITEM_CopyItem(PLArenaPool *arena, SECItem *to,
372 const SECItem *from)
373 {
374 return SECITEM_CopyItem_Util(arena, to, from);
375 }
376
377 SECItem *
SECITEM_DupItem(const SECItem * from)378 SECITEM_DupItem(const SECItem *from)
379 {
380 return SECITEM_DupItem_Util(from);
381 }
382
383 SECItem *
SECITEM_ArenaDupItem(PLArenaPool * arena,const SECItem * from)384 SECITEM_ArenaDupItem(PLArenaPool *arena, const SECItem *from)
385 {
386 return SECITEM_ArenaDupItem_Util(arena, from);
387 }
388
389 void
SECITEM_FreeItem(SECItem * zap,PRBool freeit)390 SECITEM_FreeItem(SECItem *zap, PRBool freeit)
391 {
392 SECITEM_FreeItem_Util(zap, freeit);
393 }
394
395 void
SECITEM_ZfreeItem(SECItem * zap,PRBool freeit)396 SECITEM_ZfreeItem(SECItem *zap, PRBool freeit)
397 {
398 SECITEM_ZfreeItem_Util(zap, freeit);
399 }
400
401 SGNDigestInfo *
SGN_CreateDigestInfo(SECOidTag algorithm,unsigned char * sig,unsigned int sigLen)402 SGN_CreateDigestInfo(SECOidTag algorithm,
403 unsigned char *sig,
404 unsigned int sigLen)
405 {
406 return SGN_CreateDigestInfo_Util(algorithm, sig, sigLen);
407 }
408
409 void
SGN_DestroyDigestInfo(SGNDigestInfo * info)410 SGN_DestroyDigestInfo(SGNDigestInfo *info)
411 {
412 SGN_DestroyDigestInfo_Util(info);
413 }
414
415 SECStatus
SGN_CopyDigestInfo(PLArenaPool * poolp,SGNDigestInfo * a,SGNDigestInfo * b)416 SGN_CopyDigestInfo(PLArenaPool *poolp,
417 SGNDigestInfo *a,
418 SGNDigestInfo *b)
419 {
420 return SGN_CopyDigestInfo_Util(poolp, a, b);
421 }
422
423 SECComparison
SGN_CompareDigestInfo(SGNDigestInfo * a,SGNDigestInfo * b)424 SGN_CompareDigestInfo(SGNDigestInfo *a, SGNDigestInfo *b)
425 {
426 return SGN_CompareDigestInfo_Util(a, b);
427 }
428
429 SECStatus
DER_Encode(PLArenaPool * arena,SECItem * dest,DERTemplate * t,void * src)430 DER_Encode(PLArenaPool *arena, SECItem *dest, DERTemplate *t,
431 void *src)
432 {
433 return DER_Encode_Util(arena, dest, t, src);
434 }
435
436 SECStatus
DER_Lengths(SECItem * item,int * header_len_p,PRUint32 * contents_len_p)437 DER_Lengths(SECItem *item, int *header_len_p,
438 PRUint32 *contents_len_p)
439 {
440 return DER_Lengths_Util(item, header_len_p, contents_len_p);
441 }
442
443 long
DER_GetInteger(const SECItem * src)444 DER_GetInteger(const SECItem *src)
445 {
446 return DER_GetInteger_Util(src);
447 }
448
449 SECStatus
DER_TimeToUTCTime(SECItem * result,PRTime time)450 DER_TimeToUTCTime(SECItem *result, PRTime time)
451 {
452 return DER_TimeToUTCTime_Util(result, time);
453 }
454
455 SECStatus
DER_AsciiToTime(PRTime * result,const char * string)456 DER_AsciiToTime(PRTime *result, const char *string)
457 {
458 return DER_AsciiToTime_Util(result, string);
459 }
460
461 SECStatus
DER_UTCTimeToTime(PRTime * result,const SECItem * time)462 DER_UTCTimeToTime(PRTime *result, const SECItem *time)
463 {
464 return DER_UTCTimeToTime_Util(result, time);
465 }
466
467 char *
DER_UTCTimeToAscii(SECItem * utcTime)468 DER_UTCTimeToAscii(SECItem *utcTime)
469 {
470 return DER_UTCTimeToAscii_Util(utcTime);
471 }
472
473 char *
DER_UTCDayToAscii(SECItem * utctime)474 DER_UTCDayToAscii(SECItem *utctime)
475 {
476 return DER_UTCDayToAscii_Util(utctime);
477 }
478
479 char *
DER_GeneralizedDayToAscii(SECItem * gentime)480 DER_GeneralizedDayToAscii(SECItem *gentime)
481 {
482 return DER_GeneralizedDayToAscii_Util(gentime);
483 }
484
485 char *
DER_TimeChoiceDayToAscii(SECItem * timechoice)486 DER_TimeChoiceDayToAscii(SECItem *timechoice)
487 {
488 return DER_TimeChoiceDayToAscii_Util(timechoice);
489 }
490
491 SECStatus
DER_TimeToGeneralizedTime(SECItem * dst,PRTime gmttime)492 DER_TimeToGeneralizedTime(SECItem *dst, PRTime gmttime)
493 {
494 return DER_TimeToGeneralizedTime_Util(dst, gmttime);
495 }
496
497 SECStatus
DER_TimeToGeneralizedTimeArena(PLArenaPool * arenaOpt,SECItem * dst,PRTime gmttime)498 DER_TimeToGeneralizedTimeArena(PLArenaPool *arenaOpt,
499 SECItem *dst, PRTime gmttime)
500 {
501 return DER_TimeToGeneralizedTimeArena_Util(arenaOpt, dst, gmttime);
502 }
503
504 SECStatus
DER_GeneralizedTimeToTime(PRTime * dst,const SECItem * time)505 DER_GeneralizedTimeToTime(PRTime *dst, const SECItem *time)
506 {
507 return DER_GeneralizedTimeToTime_Util(dst, time);
508 }
509
510 char *
CERT_GenTime2FormattedAscii(PRTime genTime,char * format)511 CERT_GenTime2FormattedAscii(PRTime genTime, char *format)
512 {
513 return CERT_GenTime2FormattedAscii_Util(genTime, format);
514 }
515
516 SECStatus
DER_DecodeTimeChoice(PRTime * output,const SECItem * input)517 DER_DecodeTimeChoice(PRTime *output, const SECItem *input)
518 {
519 return DER_DecodeTimeChoice_Util(output, input);
520 }
521
522 SECStatus
DER_EncodeTimeChoice(PLArenaPool * arena,SECItem * output,PRTime input)523 DER_EncodeTimeChoice(PLArenaPool *arena, SECItem *output,
524 PRTime input)
525 {
526 return DER_EncodeTimeChoice_Util(arena, output, input);
527 }
528
529 SEC_ASN1DecoderContext *
SEC_ASN1DecoderStart(PLArenaPool * pool,void * dest,const SEC_ASN1Template * t)530 SEC_ASN1DecoderStart(PLArenaPool *pool,
531 void *dest,
532 const SEC_ASN1Template *t)
533 {
534 return SEC_ASN1DecoderStart_Util(pool, dest, t);
535 }
536
537 SECStatus
SEC_ASN1DecoderUpdate(SEC_ASN1DecoderContext * cx,const char * buf,unsigned long len)538 SEC_ASN1DecoderUpdate(SEC_ASN1DecoderContext *cx,
539 const char *buf,
540 unsigned long len)
541 {
542 return SEC_ASN1DecoderUpdate_Util(cx, buf, len);
543 }
544
545 SECStatus
SEC_ASN1DecoderFinish(SEC_ASN1DecoderContext * cx)546 SEC_ASN1DecoderFinish(SEC_ASN1DecoderContext *cx)
547 {
548 return SEC_ASN1DecoderFinish_Util(cx);
549 }
550
551 void
SEC_ASN1DecoderAbort(SEC_ASN1DecoderContext * cx,int error)552 SEC_ASN1DecoderAbort(SEC_ASN1DecoderContext *cx, int error)
553 {
554 SEC_ASN1DecoderAbort_Util(cx, error);
555 }
556
557 void
SEC_ASN1DecoderSetFilterProc(SEC_ASN1DecoderContext * cx,SEC_ASN1WriteProc fn,void * arg,PRBool no_store)558 SEC_ASN1DecoderSetFilterProc(SEC_ASN1DecoderContext *cx,
559 SEC_ASN1WriteProc fn,
560 void *arg, PRBool no_store)
561 {
562 SEC_ASN1DecoderSetFilterProc_Util(cx, fn, arg, no_store);
563 }
564
565 void
SEC_ASN1DecoderClearFilterProc(SEC_ASN1DecoderContext * cx)566 SEC_ASN1DecoderClearFilterProc(SEC_ASN1DecoderContext *cx)
567 {
568 SEC_ASN1DecoderClearFilterProc_Util(cx);
569 }
570
571 void
SEC_ASN1DecoderSetNotifyProc(SEC_ASN1DecoderContext * cx,SEC_ASN1NotifyProc fn,void * arg)572 SEC_ASN1DecoderSetNotifyProc(SEC_ASN1DecoderContext *cx,
573 SEC_ASN1NotifyProc fn,
574 void *arg)
575 {
576 SEC_ASN1DecoderSetNotifyProc_Util(cx, fn, arg);
577 }
578
579 void
SEC_ASN1DecoderClearNotifyProc(SEC_ASN1DecoderContext * cx)580 SEC_ASN1DecoderClearNotifyProc(SEC_ASN1DecoderContext *cx)
581 {
582 SEC_ASN1DecoderClearNotifyProc_Util(cx);
583 }
584
585 SECStatus
SEC_ASN1Decode(PLArenaPool * pool,void * dest,const SEC_ASN1Template * t,const char * buf,long len)586 SEC_ASN1Decode(PLArenaPool *pool, void *dest,
587 const SEC_ASN1Template *t,
588 const char *buf, long len)
589 {
590 return SEC_ASN1Decode_Util(pool, dest, t, buf, len);
591 }
592
593 SECStatus
SEC_ASN1DecodeItem(PLArenaPool * pool,void * dest,const SEC_ASN1Template * t,const SECItem * src)594 SEC_ASN1DecodeItem(PLArenaPool *pool, void *dest,
595 const SEC_ASN1Template *t,
596 const SECItem *src)
597 {
598 return SEC_ASN1DecodeItem_Util(pool, dest, t, src);
599 }
600
601 SECStatus
SEC_QuickDERDecodeItem(PLArenaPool * arena,void * dest,const SEC_ASN1Template * templateEntry,const SECItem * src)602 SEC_QuickDERDecodeItem(PLArenaPool *arena, void *dest,
603 const SEC_ASN1Template *templateEntry,
604 const SECItem *src)
605 {
606 return SEC_QuickDERDecodeItem_Util(arena, dest, templateEntry, src);
607 }
608
609 SEC_ASN1EncoderContext *
SEC_ASN1EncoderStart(const void * src,const SEC_ASN1Template * t,SEC_ASN1WriteProc fn,void * output_arg)610 SEC_ASN1EncoderStart(const void *src,
611 const SEC_ASN1Template *t,
612 SEC_ASN1WriteProc fn,
613 void *output_arg)
614 {
615 return SEC_ASN1EncoderStart_Util(src, t, fn, output_arg);
616 }
617
618 SECStatus
SEC_ASN1EncoderUpdate(SEC_ASN1EncoderContext * cx,const char * buf,unsigned long len)619 SEC_ASN1EncoderUpdate(SEC_ASN1EncoderContext *cx,
620 const char *buf,
621 unsigned long len)
622 {
623 return SEC_ASN1EncoderUpdate_Util(cx, buf, len);
624 }
625
626 void
SEC_ASN1EncoderFinish(SEC_ASN1EncoderContext * cx)627 SEC_ASN1EncoderFinish(SEC_ASN1EncoderContext *cx)
628 {
629 SEC_ASN1EncoderFinish_Util(cx);
630 }
631
632 void
SEC_ASN1EncoderAbort(SEC_ASN1EncoderContext * cx,int error)633 SEC_ASN1EncoderAbort(SEC_ASN1EncoderContext *cx, int error)
634 {
635 SEC_ASN1EncoderAbort_Util(cx, error);
636 }
637
638 void
SEC_ASN1EncoderSetNotifyProc(SEC_ASN1EncoderContext * cx,SEC_ASN1NotifyProc fn,void * arg)639 SEC_ASN1EncoderSetNotifyProc(SEC_ASN1EncoderContext *cx,
640 SEC_ASN1NotifyProc fn,
641 void *arg)
642 {
643 SEC_ASN1EncoderSetNotifyProc_Util(cx, fn, arg);
644 }
645
646 void
SEC_ASN1EncoderClearNotifyProc(SEC_ASN1EncoderContext * cx)647 SEC_ASN1EncoderClearNotifyProc(SEC_ASN1EncoderContext *cx)
648 {
649 SEC_ASN1EncoderClearNotifyProc_Util(cx);
650 }
651
652 void
SEC_ASN1EncoderSetStreaming(SEC_ASN1EncoderContext * cx)653 SEC_ASN1EncoderSetStreaming(SEC_ASN1EncoderContext *cx)
654 {
655 SEC_ASN1EncoderSetStreaming_Util(cx);
656 }
657
658 void
SEC_ASN1EncoderClearStreaming(SEC_ASN1EncoderContext * cx)659 SEC_ASN1EncoderClearStreaming(SEC_ASN1EncoderContext *cx)
660 {
661 SEC_ASN1EncoderClearStreaming_Util(cx);
662 }
663
664 void
SEC_ASN1EncoderSetTakeFromBuf(SEC_ASN1EncoderContext * cx)665 SEC_ASN1EncoderSetTakeFromBuf(SEC_ASN1EncoderContext *cx)
666 {
667 SEC_ASN1EncoderSetTakeFromBuf_Util(cx);
668 }
669
670 void
SEC_ASN1EncoderClearTakeFromBuf(SEC_ASN1EncoderContext * cx)671 SEC_ASN1EncoderClearTakeFromBuf(SEC_ASN1EncoderContext *cx)
672 {
673 SEC_ASN1EncoderClearTakeFromBuf_Util(cx);
674 }
675
676 SECStatus
SEC_ASN1Encode(const void * src,const SEC_ASN1Template * t,SEC_ASN1WriteProc output_proc,void * output_arg)677 SEC_ASN1Encode(const void *src, const SEC_ASN1Template *t,
678 SEC_ASN1WriteProc output_proc,
679 void *output_arg)
680 {
681 return SEC_ASN1Encode_Util(src, t, output_proc, output_arg);
682 }
683
684 SECItem *
SEC_ASN1EncodeItem(PLArenaPool * pool,SECItem * dest,const void * src,const SEC_ASN1Template * t)685 SEC_ASN1EncodeItem(PLArenaPool *pool, SECItem *dest,
686 const void *src, const SEC_ASN1Template *t)
687 {
688 return SEC_ASN1EncodeItem_Util(pool, dest, src, t);
689 }
690
691 SECItem *
SEC_ASN1EncodeInteger(PLArenaPool * pool,SECItem * dest,long value)692 SEC_ASN1EncodeInteger(PLArenaPool *pool,
693 SECItem *dest, long value)
694 {
695 return SEC_ASN1EncodeInteger_Util(pool, dest, value);
696 }
697
698 SECItem *
SEC_ASN1EncodeUnsignedInteger(PLArenaPool * pool,SECItem * dest,unsigned long value)699 SEC_ASN1EncodeUnsignedInteger(PLArenaPool *pool,
700 SECItem *dest,
701 unsigned long value)
702 {
703 return SEC_ASN1EncodeUnsignedInteger_Util(pool, dest, value);
704 }
705
706 SECStatus
SEC_ASN1DecodeInteger(SECItem * src,unsigned long * value)707 SEC_ASN1DecodeInteger(SECItem *src,
708 unsigned long *value)
709 {
710 return SEC_ASN1DecodeInteger_Util(src, value);
711 }
712
713 int
SEC_ASN1LengthLength(unsigned long len)714 SEC_ASN1LengthLength(unsigned long len)
715 {
716 return SEC_ASN1LengthLength_Util(len);
717 }
718
719 char *
BTOA_DataToAscii(const unsigned char * data,unsigned int len)720 BTOA_DataToAscii(const unsigned char *data, unsigned int len)
721 {
722 return BTOA_DataToAscii_Util(data, len);
723 }
724
725 unsigned char *
ATOB_AsciiToData(const char * string,unsigned int * lenp)726 ATOB_AsciiToData(const char *string, unsigned int *lenp)
727 {
728 return ATOB_AsciiToData_Util(string, lenp);
729 }
730
731 SECStatus
ATOB_ConvertAsciiToItem(SECItem * binary_item,const char * ascii)732 ATOB_ConvertAsciiToItem(SECItem *binary_item, const char *ascii)
733 {
734 return ATOB_ConvertAsciiToItem_Util(binary_item, ascii);
735 }
736
737 char *
BTOA_ConvertItemToAscii(SECItem * binary_item)738 BTOA_ConvertItemToAscii(SECItem *binary_item)
739 {
740 return BTOA_ConvertItemToAscii_Util(binary_item);
741 }
742
743 NSSBase64Decoder *
NSSBase64Decoder_Create(PRInt32 (* output_fn)(void *,const unsigned char *,PRInt32),void * output_arg)744 NSSBase64Decoder_Create(PRInt32 (*output_fn)(void *, const unsigned char *,
745 PRInt32),
746 void *output_arg)
747 {
748 return NSSBase64Decoder_Create_Util(output_fn, output_arg);
749 }
750
751 NSSBase64Encoder *
NSSBase64Encoder_Create(PRInt32 (* output_fn)(void *,const char *,PRInt32),void * output_arg)752 NSSBase64Encoder_Create(PRInt32 (*output_fn)(void *, const char *, PRInt32),
753 void *output_arg)
754 {
755 return NSSBase64Encoder_Create_Util(output_fn, output_arg);
756 }
757
758 SECStatus
NSSBase64Decoder_Update(NSSBase64Decoder * data,const char * buffer,PRUint32 size)759 NSSBase64Decoder_Update(NSSBase64Decoder *data, const char *buffer,
760 PRUint32 size)
761 {
762 return NSSBase64Decoder_Update_Util(data, buffer, size);
763 }
764
765 SECStatus
NSSBase64Encoder_Update(NSSBase64Encoder * data,const unsigned char * buffer,PRUint32 size)766 NSSBase64Encoder_Update(NSSBase64Encoder *data, const unsigned char *buffer,
767 PRUint32 size)
768 {
769 return NSSBase64Encoder_Update_Util(data, buffer, size);
770 }
771
772 SECStatus
NSSBase64Decoder_Destroy(NSSBase64Decoder * data,PRBool abort_p)773 NSSBase64Decoder_Destroy(NSSBase64Decoder *data, PRBool abort_p)
774 {
775 return NSSBase64Decoder_Destroy_Util(data, abort_p);
776 }
777
778 SECStatus
NSSBase64Encoder_Destroy(NSSBase64Encoder * data,PRBool abort_p)779 NSSBase64Encoder_Destroy(NSSBase64Encoder *data, PRBool abort_p)
780 {
781 return NSSBase64Encoder_Destroy_Util(data, abort_p);
782 }
783
784 SECItem *
NSSBase64_DecodeBuffer(PLArenaPool * arenaOpt,SECItem * outItemOpt,const char * inStr,unsigned int inLen)785 NSSBase64_DecodeBuffer(PLArenaPool *arenaOpt, SECItem *outItemOpt,
786 const char *inStr, unsigned int inLen)
787 {
788 return NSSBase64_DecodeBuffer_Util(arenaOpt, outItemOpt, inStr, inLen);
789 }
790
791 char *
NSSBase64_EncodeItem(PLArenaPool * arenaOpt,char * outStrOpt,unsigned int maxOutLen,SECItem * inItem)792 NSSBase64_EncodeItem(PLArenaPool *arenaOpt, char *outStrOpt,
793 unsigned int maxOutLen, SECItem *inItem)
794 {
795 return NSSBase64_EncodeItem_Util(arenaOpt, outStrOpt, maxOutLen, inItem);
796 }
797
798 NSSRWLock *
NSSRWLock_New(PRUint32 lock_rank,const char * lock_name)799 NSSRWLock_New(PRUint32 lock_rank, const char *lock_name)
800 {
801 return NSSRWLock_New_Util(lock_rank, lock_name);
802 }
803
804 void
NSSRWLock_Destroy(NSSRWLock * lock)805 NSSRWLock_Destroy(NSSRWLock *lock)
806 {
807 NSSRWLock_Destroy_Util(lock);
808 }
809
810 void
NSSRWLock_LockRead(NSSRWLock * lock)811 NSSRWLock_LockRead(NSSRWLock *lock)
812 {
813 NSSRWLock_LockRead_Util(lock);
814 }
815
816 void
NSSRWLock_LockWrite(NSSRWLock * lock)817 NSSRWLock_LockWrite(NSSRWLock *lock)
818 {
819 NSSRWLock_LockWrite_Util(lock);
820 }
821
822 void
NSSRWLock_UnlockRead(NSSRWLock * lock)823 NSSRWLock_UnlockRead(NSSRWLock *lock)
824 {
825 NSSRWLock_UnlockRead_Util(lock);
826 }
827
828 void
NSSRWLock_UnlockWrite(NSSRWLock * lock)829 NSSRWLock_UnlockWrite(NSSRWLock *lock)
830 {
831 NSSRWLock_UnlockWrite_Util(lock);
832 }
833
834 PRBool
NSSRWLock_HaveWriteLock(NSSRWLock * rwlock)835 NSSRWLock_HaveWriteLock(NSSRWLock *rwlock)
836 {
837 return NSSRWLock_HaveWriteLock_Util(rwlock);
838 }
839
840 SECStatus
__nss_InitLock(PZLock ** ppLock,nssILockType ltype)841 __nss_InitLock(PZLock **ppLock, nssILockType ltype)
842 {
843 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR);
844 return SECFailure;
845 }
846
847 /* templates duplicated in libnss3 and libnssutil3 */
848
849 #undef NSS_Get_SEC_AnyTemplate
850 #undef NSS_Get_SEC_BitStringTemplate
851 #undef NSS_Get_SEC_BMPStringTemplate
852 #undef NSS_Get_SEC_BooleanTemplate
853 #undef NSS_Get_SEC_GeneralizedTimeTemplate
854 #undef NSS_Get_SEC_IA5StringTemplate
855 #undef NSS_Get_SEC_IntegerTemplate
856 #undef NSS_Get_SEC_NullTemplate
857 #undef NSS_Get_SEC_ObjectIDTemplate
858 #undef NSS_Get_SEC_OctetStringTemplate
859 #undef NSS_Get_SEC_PointerToAnyTemplate
860 #undef NSS_Get_SEC_PointerToOctetStringTemplate
861 #undef NSS_Get_SEC_SetOfAnyTemplate
862 #undef NSS_Get_SEC_UTCTimeTemplate
863 #undef NSS_Get_SEC_UTF8StringTemplate
864 #undef NSS_Get_SECOID_AlgorithmIDTemplate
865 #undef NSS_Get_sgn_DigestInfoTemplate
866 #undef SEC_AnyTemplate
867 #undef SEC_BitStringTemplate
868 #undef SEC_BMPStringTemplate
869 #undef SEC_BooleanTemplate
870 #undef SEC_GeneralizedTimeTemplate
871 #undef SEC_IA5StringTemplate
872 #undef SEC_IntegerTemplate
873 #undef SEC_NullTemplate
874 #undef SEC_ObjectIDTemplate
875 #undef SEC_OctetStringTemplate
876 #undef SEC_PointerToAnyTemplate
877 #undef SEC_PointerToOctetStringTemplate
878 #undef SEC_SetOfAnyTemplate
879 #undef SEC_UTCTimeTemplate
880 #undef SEC_UTF8StringTemplate
881 #undef SECOID_AlgorithmIDTemplate
882 #undef sgn_DigestInfoTemplate
883
884 #include "templates.c"
885