| OLD | NEW |
| 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 * pkix_pl_x500name.c | 5 * pkix_pl_x500name.c |
| 6 * | 6 * |
| 7 * X500Name Object Functions | 7 * X500Name Object Functions |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "pkix_pl_x500name.h" | 11 #include "pkix_pl_x500name.h" |
| 12 | 12 |
| 13 /* --Private-X500Name-Functions------------------------------------- */ | 13 /* --Private-X500Name-Functions------------------------------------- */ |
| 14 | 14 |
| 15 /* | 15 /* |
| 16 * FUNCTION: pkix_pl_X500Name_ToString_Helper | |
| 17 * DESCRIPTION: | |
| 18 * | |
| 19 * Helper function that creates a string representation of the X500Name | |
| 20 * pointed to by "name" and stores it at "pString". | |
| 21 * | |
| 22 * PARAMETERS | |
| 23 * "name" | |
| 24 * Address of X500Name whose string representation is desired. | |
| 25 * Must be non-NULL. | |
| 26 * "pString" | |
| 27 * Address where object pointer will be stored. Must be non-NULL. | |
| 28 * "plContext" - Platform-specific context pointer. | |
| 29 * THREAD SAFETY: | |
| 30 * Thread Safe (see Thread Safety Definitions in Programmer's Guide) | |
| 31 * RETURNS: | |
| 32 * Returns NULL if the function succeeds. | |
| 33 * Returns a X500Name Error if the function fails in a non-fatal way. | |
| 34 * Returns a Fatal Error if the function fails in an unrecoverable way. | |
| 35 */ | |
| 36 static PKIX_Error * | |
| 37 pkix_pl_X500Name_ToString_Helper( | |
| 38 PKIX_PL_X500Name *name, | |
| 39 PKIX_PL_String **pString, | |
| 40 void *plContext) | |
| 41 { | |
| 42 CERTName *nssDN = NULL; | |
| 43 char *utf8String = NULL; | |
| 44 PKIX_UInt32 utf8Length; | |
| 45 | |
| 46 PKIX_ENTER(X500NAME, "pkix_pl_X500Name_ToString_Helper"); | |
| 47 PKIX_NULLCHECK_TWO(name, pString); | |
| 48 nssDN = &name->nssDN; | |
| 49 | |
| 50 /* this should really be called CERT_NameToUTF8 */ | |
| 51 utf8String = CERT_NameToAsciiInvertible(nssDN, CERT_N2A_INVERTIBLE); | |
| 52 if (!utf8String){ | |
| 53 PKIX_ERROR(PKIX_CERTNAMETOASCIIFAILED); | |
| 54 } | |
| 55 | |
| 56 PKIX_X500NAME_DEBUG("\t\tCalling PL_strlen).\n"); | |
| 57 utf8Length = PL_strlen(utf8String); | |
| 58 | |
| 59 PKIX_CHECK(PKIX_PL_String_Create | |
| 60 (PKIX_UTF8, utf8String, utf8Length, pString, plContext), | |
| 61 PKIX_STRINGCREATEFAILED); | |
| 62 | |
| 63 cleanup: | |
| 64 | |
| 65 PR_Free(utf8String); | |
| 66 | |
| 67 PKIX_RETURN(X500NAME); | |
| 68 } | |
| 69 | |
| 70 /* | |
| 71 * FUNCTION: pkix_pl_X500Name_Destroy | 16 * FUNCTION: pkix_pl_X500Name_Destroy |
| 72 * (see comments for PKIX_PL_DestructorCallback in pkix_pl_system.h) | 17 * (see comments for PKIX_PL_DestructorCallback in pkix_pl_system.h) |
| 73 */ | 18 */ |
| 74 static PKIX_Error * | 19 static PKIX_Error * |
| 75 pkix_pl_X500Name_Destroy( | 20 pkix_pl_X500Name_Destroy( |
| 76 PKIX_PL_Object *object, | 21 PKIX_PL_Object *object, |
| 77 void *plContext) | 22 void *plContext) |
| 78 { | 23 { |
| 79 PKIX_PL_X500Name *name = NULL; | 24 PKIX_PL_X500Name *name = NULL; |
| 80 | 25 |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 unsigned char **pOrgName, | 658 unsigned char **pOrgName, |
| 714 void *plContext) | 659 void *plContext) |
| 715 { | 660 { |
| 716 PKIX_ENTER(X500NAME, "pkix_pl_X500Name_GetOrgName"); | 661 PKIX_ENTER(X500NAME, "pkix_pl_X500Name_GetOrgName"); |
| 717 PKIX_NULLCHECK_TWO(xname, pOrgName); | 662 PKIX_NULLCHECK_TWO(xname, pOrgName); |
| 718 | 663 |
| 719 *pOrgName = (unsigned char*)CERT_GetOrgName(&xname->nssDN); | 664 *pOrgName = (unsigned char*)CERT_GetOrgName(&xname->nssDN); |
| 720 | 665 |
| 721 PKIX_RETURN(X500NAME); | 666 PKIX_RETURN(X500NAME); |
| 722 } | 667 } |
| OLD | NEW |