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