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 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef _GENAME_H_ 6 #define _GENAME_H_ 7 8 #include "plarena.h" 9 #include "seccomon.h" 10 #include "secoidt.h" 11 #include "secasn1.h" 12 #include "secder.h" 13 #include "certt.h" 14 15 /************************************************************************/ 16 SEC_BEGIN_PROTOS 17 18 extern const SEC_ASN1Template CERT_GeneralNamesTemplate[]; 19 20 extern SECItem **cert_EncodeGeneralNames(PLArenaPool *arena, 21 CERTGeneralName *names); 22 23 extern CERTGeneralName *cert_DecodeGeneralNames(PLArenaPool *arena, 24 SECItem **encodedGenName); 25 26 extern SECStatus cert_DestroyGeneralNames(CERTGeneralName *name); 27 28 extern SECStatus cert_EncodeNameConstraints(CERTNameConstraints *constraints, 29 PLArenaPool *arena, SECItem *dest); 30 31 extern CERTNameConstraints *cert_DecodeNameConstraints( 32 PLArenaPool *arena, const SECItem *encodedConstraints); 33 34 extern CERTGeneralName *cert_CombineNamesLists(CERTGeneralName *list1, 35 CERTGeneralName *list2); 36 37 extern CERTNameConstraint *cert_CombineConstraintsLists( 38 CERTNameConstraint *list1, CERTNameConstraint *list2); 39 40 /*********************************************************************/ 41 /* A thread safe implementation of General Names */ 42 /*********************************************************************/ 43 44 /* Destroy a Single CERTGeneralName */ 45 void CERT_DestroyGeneralName(CERTGeneralName *name); 46 47 SECStatus CERT_CompareGeneralName(CERTGeneralName *a, CERTGeneralName *b); 48 49 SECStatus CERT_CopyGeneralName(PLArenaPool *arena, CERTGeneralName *dest, 50 CERTGeneralName *src); 51 52 /* General Name Lists are a thread safe, reference counting layer to 53 * general names */ 54 55 /* Destroys a CERTGeneralNameList */ 56 void CERT_DestroyGeneralNameList(CERTGeneralNameList *list); 57 58 /* Creates a CERTGeneralNameList */ 59 CERTGeneralNameList *CERT_CreateGeneralNameList(CERTGeneralName *name); 60 61 /* Compares two CERTGeneralNameList */ 62 SECStatus CERT_CompareGeneralNameLists(CERTGeneralNameList *a, 63 CERTGeneralNameList *b); 64 65 /* returns a copy of the first name of the type requested */ 66 void *CERT_GetGeneralNameFromListByType(CERTGeneralNameList *list, 67 CERTGeneralNameType type, 68 PLArenaPool *arena); 69 70 /* Adds a name to the tail of the list */ 71 void CERT_AddGeneralNameToList(CERTGeneralNameList *list, 72 CERTGeneralNameType type, void *data, 73 SECItem *oid); 74 75 /* returns a duplicate of the CERTGeneralNameList */ 76 CERTGeneralNameList *CERT_DupGeneralNameList(CERTGeneralNameList *list); 77 78 /* returns the number of CERTGeneralName objects in the doubly linked 79 ** list of which *names is a member. 80 */ 81 extern int CERT_GetNamesLength(CERTGeneralName *names); 82 83 /************************************************************************/ 84 85 SECStatus CERT_CompareNameSpace(CERTCertificate *cert, 86 CERTGeneralName *namesList, 87 CERTCertificate **certsList, 88 PLArenaPool *reqArena, 89 CERTCertificate **pBadCert); 90 91 SEC_END_PROTOS 92 93 #endif 94