1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the PKIX-C library.
16
* The Initial Developer of the Original Code is
17
* Sun Microsystems, Inc.
18
* Portions created by the Initial Developer are
19
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
22
* Sun Microsystems, Inc.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
40
* Crl DP Object Functions
44
#include "pkix_pl_crldp.h"
47
pkix_pl_CrlDp_Destroy(
48
PKIX_PL_Object *object,
51
pkix_pl_CrlDp *crldp = NULL;
53
PKIX_ENTER(CRLCHECKER, "pkix_CrlDp_Destroy");
54
PKIX_NULLCHECK_ONE(object);
56
/* Check that this object is a default CRL checker state */
58
pkix_CheckType(object, PKIX_CRLDP_TYPE, plContext),
59
PKIX_OBJECTNOTCRLCHECKER);
61
crldp = (pkix_pl_CrlDp *)object;
62
if (crldp->distPointType == relativeDistinguishedName) {
63
CERT_DestroyName(crldp->name.issuerName);
64
crldp->name.issuerName = NULL;
68
PKIX_RETURN(CRLCHECKER);
72
* FUNCTION: pkix_pl_CrlDp_RegisterSelf
75
* Registers PKIX_CRLDP_TYPE and its related functions
76
* with systemClasses[]
79
* Not Thread Safe (see Thread Safety Definitions in Programmer's Guide)
81
* Since this function is only called by PKIX_PL_Initialize, which should
82
* only be called once, it is acceptable that this function is not
86
pkix_pl_CrlDp_RegisterSelf(void *plContext)
88
extern pkix_ClassTable_Entry systemClasses[PKIX_NUMTYPES];
89
pkix_ClassTable_Entry* entry = &systemClasses[PKIX_CRLDP_TYPE];
91
PKIX_ENTER(CRLCHECKER, "pkix_CrlDp_RegisterSelf");
93
entry->description = "CrlDistPoint";
94
entry->typeObjectSize = sizeof(pkix_pl_CrlDp);
95
entry->destructor = pkix_pl_CrlDp_Destroy;
96
entry->duplicateFunction = pkix_duplicateImmutable;
98
PKIX_RETURN(CRLCHECKER);
104
pkix_pl_CrlDp_Create(
105
const CRLDistributionPoint *dp,
106
const CERTName *certIssuerName,
107
pkix_pl_CrlDp **pPkixDP,
110
PRArenaPool *rdnArena = NULL;
111
CERTName *issuerNameCopy = NULL;
112
pkix_pl_CrlDp *dpl = NULL;
114
/* Need to save the following info to update crl cache:
115
* - reasons if partitioned(but can not return revocation check
116
* success if not all crl are downloaded)
117
* - issuer name if different from issuer of the cert
118
* - url to upload a crl if needed.
120
PKIX_ENTER(CRLDP, "pkix_pl_CrlDp_Create");
121
PKIX_NULLCHECK_ONE(dp);
124
PKIX_PL_Object_Alloc(PKIX_CRLDP_TYPE,
125
sizeof (pkix_pl_CrlDp),
126
(PKIX_PL_Object **)&dpl,
128
PKIX_COULDNOTCREATEOBJECT);
131
dpl->isPartitionedByReasonCode = PKIX_FALSE;
132
if (dp->reasons.data) {
133
dpl->isPartitionedByReasonCode = PKIX_TRUE;
135
if (dp->distPointType == generalName) {
136
dpl->distPointType = generalName;
137
dpl->name.fullName = dp->distPoint.fullName;
140
const CERTName *issuerName = NULL;
141
const CERTRDN *relName = &dp->distPoint.relativeName;
144
if (dp->crlIssuer->l.next) {
145
/* Violate RFC 5280: in this case crlIssuer
146
* should have only one name and should be
147
* a distinguish name. */
148
PKIX_ERROR(PKIX_NOTCONFORMINGCRLDP);
150
issuerName = &dp->crlIssuer->name.directoryName;
152
issuerName = certIssuerName;
154
rdnArena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
156
PKIX_ERROR(PKIX_PORTARENAALLOCFAILED);
158
issuerNameCopy = (CERTName *)PORT_ArenaZNew(rdnArena, CERTName*);
159
if (!issuerNameCopy) {
160
PKIX_ERROR(PKIX_ALLOCERROR);
162
rv = CERT_CopyName(rdnArena, issuerNameCopy, (CERTName*)issuerName);
163
if (rv == SECFailure) {
164
PKIX_ERROR(PKIX_ALLOCERROR);
166
rv = CERT_AddRDN(issuerNameCopy, (CERTRDN*)relName);
167
if (rv == SECFailure) {
168
PKIX_ERROR(PKIX_ALLOCERROR);
170
dpl->distPointType = relativeDistinguishedName;
171
dpl->name.issuerName = issuerNameCopy;
179
PORT_FreeArena(rdnArena, PR_FALSE);