| 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 * certi.h - private data structures for the certificate library | 5 * certi.h - private data structures for the certificate library |
| 6 */ | 6 */ |
| 7 #ifndef _CERTI_H_ | 7 #ifndef _CERTI_H_ |
| 8 #define _CERTI_H_ | 8 #define _CERTI_H_ |
| 9 | 9 |
| 10 #include "certt.h" | 10 #include "certt.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 PRBool partial; | 31 PRBool partial; |
| 32 PRBool decodingError; | 32 PRBool decodingError; |
| 33 PRBool badEntries; | 33 PRBool badEntries; |
| 34 PRBool badDER; | 34 PRBool badDER; |
| 35 PRBool badExtensions; | 35 PRBool badExtensions; |
| 36 PRBool heapDER; | 36 PRBool heapDER; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 typedef struct PreAllocatorStr PreAllocator; | 39 typedef struct PreAllocatorStr PreAllocator; |
| 40 | 40 |
| 41 struct PreAllocatorStr | 41 struct PreAllocatorStr { |
| 42 { | |
| 43 PRSize len; | 42 PRSize len; |
| 44 void* data; | 43 void* data; |
| 45 PRSize used; | 44 PRSize used; |
| 46 PLArenaPool* arena; | 45 PLArenaPool* arena; |
| 47 PRSize extra; | 46 PRSize extra; |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 /* CRL entry cache. | 49 /* CRL entry cache. |
| 51 This is the same as an entry plus the next/prev pointers for the hash table | 50 This is the same as an entry plus the next/prev pointers for the hash table |
| 52 */ | 51 */ |
| 53 | 52 |
| 54 struct CRLEntryCacheStr { | 53 struct CRLEntryCacheStr { |
| 55 CERTCrlEntry entry; | 54 CERTCrlEntry entry; |
| 56 CRLEntryCache *prev, *next; | 55 CRLEntryCache *prev, *next; |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 #define CRL_CACHE_INVALID_CRLS 0x0001 /* this state will be set | 58 #define CRL_CACHE_INVALID_CRLS 0x0001 /* this state will be set |
| 60 if we have CRL objects with an invalid DER or signature. Can be | 59 if we have CRL objects with an invalid DER or signature. Can be |
| 61 cleared if the invalid objects are deleted from the token */ | 60 cleared if the invalid objects are deleted from the token */ |
| 62 #define CRL_CACHE_LAST_FETCH_FAILED 0x0002 /* this state will be set | 61 #define CRL_CACHE_LAST_FETCH_FAILED 0x0002 /* this state will be set |
| 63 if the last CRL fetch encountered an error. Can be cleared if a | 62 if the last CRL fetch encountered an error. Can be cleared if a |
| 64 new fetch succeeds */ | 63 new fetch succeeds */ |
| 65 | 64 |
| 66 #define CRL_CACHE_OUT_OF_MEMORY 0x0004 /* this state will be set | 65 #define CRL_CACHE_OUT_OF_MEMORY 0x0004 /* this state will be set |
| 67 if we don't have enough memory to build the hash table of entries */ | 66 if we don't have enough memory to build the hash table of entries */ |
| 68 | 67 |
| 69 typedef enum { | 68 typedef enum { |
| 70 CRL_OriginToken = 0, /* CRL came from PKCS#11 token */ | 69 CRL_OriginToken = 0, /* CRL came from PKCS#11 token */ |
| 71 CRL_OriginExplicit = 1 /* CRL was explicitly added to the cache, from RAM *
/ | 70 CRL_OriginExplicit = 1 /* CRL was explicitly added to the cache, from RAM */ |
| 72 } CRLOrigin; | 71 } CRLOrigin; |
| 73 | 72 |
| 74 typedef enum { | 73 typedef enum { |
| 75 dpcacheNoEntry = 0, /* no entry found for this SN */ | 74 dpcacheNoEntry = 0, /* no entry found for this SN */ |
| 76 dpcacheFoundEntry = 1, /* entry found for this SN */ | 75 dpcacheFoundEntry = 1, /* entry found for this SN */ |
| 77 dpcacheCallerError = 2, /* invalid args */ | 76 dpcacheCallerError = 2, /* invalid args */ |
| 78 dpcacheInvalidCacheError = 3, /* CRL in cache may be bad DER */ | 77 dpcacheInvalidCacheError = 3, /* CRL in cache may be bad DER */ |
| 79 /* or unverified */ | 78 /* or unverified */ |
| 80 dpcacheEmpty = 4, /* no CRL in cache */ | 79 dpcacheEmpty = 4, /* no CRL in cache */ |
| 81 dpcacheLookupError = 5 /* internal error */ | 80 dpcacheLookupError = 5 /* internal error */ |
| 82 } dpcacheStatus; | 81 } dpcacheStatus; |
| 83 | 82 |
| 84 | |
| 85 struct CachedCrlStr { | 83 struct CachedCrlStr { |
| 86 CERTSignedCrl* crl; | 84 CERTSignedCrl* crl; |
| 87 CRLOrigin origin; | 85 CRLOrigin origin; |
| 88 /* hash table of entries. We use a PLHashTable and pre-allocate the | 86 /* hash table of entries. We use a PLHashTable and pre-allocate the |
| 89 required amount of memory in one shot, so that our allocator can | 87 required amount of memory in one shot, so that our allocator can |
| 90 simply pass offsets into it when hashing. | 88 simply pass offsets into it when hashing. |
| 91 | 89 |
| 92 This won't work anymore when we support delta CRLs and iCRLs, because | 90 This won't work anymore when we support delta CRLs and iCRLs, because |
| 93 the size of the hash table will vary over time. At that point, the best | 91 the size of the hash table will vary over time. At that point, the best |
| 94 solution will be to allocate large CRLEntry structures by modifying | 92 solution will be to allocate large CRLEntry structures by modifying |
| 95 the DER decoding template. The extra space would be for next/prev | 93 the DER decoding template. The extra space would be for next/prev |
| 96 pointers. This would allow entries from different CRLs to be mixed in | 94 pointers. This would allow entries from different CRLs to be mixed in |
| 97 the same hash table. | 95 the same hash table. |
| 98 */ | 96 */ |
| 99 PLHashTable* entries; | 97 PLHashTable* entries; |
| 100 PreAllocator* prebuffer; /* big pre-allocated buffer mentioned above */ | 98 PreAllocator* prebuffer; /* big pre-allocated buffer mentioned above */ |
| 101 PRBool sigChecked; /* this CRL signature has already been checked */ | 99 PRBool sigChecked; /* this CRL signature has already been checked */ |
| 102 PRBool sigValid; /* signature verification status . | 100 PRBool sigValid; /* signature verification status . |
| 103 Only meaningful if checked is PR_TRUE . */ | 101 Only meaningful if checked is PR_TRUE . */ |
| 104 PRBool unbuildable; /* Avoid using assosiated CRL is it fails | 102 PRBool unbuildable; /* Avoid using assosiated CRL is it fails |
| 105 * a decoding step */ | 103 * a decoding step */ |
| 106 }; | 104 }; |
| 107 | 105 |
| 108 /* CRL distribution point cache object | 106 /* CRL distribution point cache object |
| 109 This is a cache of CRL entries for a given distribution point of an issuer | 107 This is a cache of CRL entries for a given distribution point of an issuer |
| 110 It is built from a collection of one full and 0 or more delta CRLs. | 108 It is built from a collection of one full and 0 or more delta CRLs. |
| 111 */ | 109 */ |
| 112 | 110 |
| 113 struct CRLDPCacheStr { | 111 struct CRLDPCacheStr { |
| 114 #ifdef DPC_RWLOCK | 112 #ifdef DPC_RWLOCK |
| 115 NSSRWLock* lock; | 113 NSSRWLock* lock; |
| 116 #else | 114 #else |
| 117 PRLock* lock; | 115 PRLock* lock; |
| 118 #endif | 116 #endif |
| 119 SECItem *issuerDERCert; /* issuer DER cert. Don't hold a reference | 117 SECItem* issuerDERCert; /* issuer DER cert. Don't hold a reference |
| 120 » » » » to the actual cert so the trust can be | 118 to the actual cert so the trust can be |
| 121 » » » » updated on the cert automatically. | 119 updated on the cert automatically. |
| 122 » » » » XXX there may be multiple issuer certs, | 120 XXX there may be multiple issuer certs, |
| 123 » » » » with different validity dates. Also | 121 with different validity dates. Also |
| 124 » » » » need to deal with SKID/AKID . See | 122 need to deal with SKID/AKID . See |
| 125 » » » » bugzilla 217387, 233118 */ | 123 bugzilla 217387, 233118 */ |
| 126 | 124 |
| 127 CERTCertDBHandle *dbHandle; | 125 CERTCertDBHandle* dbHandle; |
| 128 | 126 |
| 129 SECItem* subject; /* DER of issuer subject */ | 127 SECItem* subject; /* DER of issuer subject */ |
| 130 SECItem* distributionPoint; /* DER of distribution point. This may be | 128 SECItem* distributionPoint; /* DER of distribution point. This may be |
| 131 NULL when distribution points aren't | 129 NULL when distribution points aren't |
| 132 in use (ie. the CA has a single CRL). | 130 in use (ie. the CA has a single CRL). |
| 133 Currently not used. */ | 131 Currently not used. */ |
| 134 | 132 |
| 135 /* array of full CRLs matching this distribution point */ | 133 /* array of full CRLs matching this distribution point */ |
| 136 PRUint32 ncrls; /* total number of CRLs in crls */ | 134 PRUint32 ncrls; /* total number of CRLs in crls */ |
| 137 CachedCrl** crls; /* array of all matching CRLs */ | 135 CachedCrl** crls; /* array of all matching CRLs */ |
| 138 /* XCRL With iCRLs and multiple DPs, the CRL can be shared accross several | 136 /* XCRL With iCRLs and multiple DPs, the CRL can be shared accross several |
| 139 issuers. In the future, we'll need to globally recycle the CRL in a | 137 issuers. In the future, we'll need to globally recycle the CRL in a |
| 140 separate list in order to avoid extra lookups, decodes, and copies */ | 138 separate list in order to avoid extra lookups, decodes, and copies */ |
| 141 | 139 |
| 142 /* pointers to good decoded CRLs used to build the cache */ | 140 /* pointers to good decoded CRLs used to build the cache */ |
| 143 CachedCrl* selected; /* full CRL selected for use in the cache */ | 141 CachedCrl* selected; /* full CRL selected for use in the cache */ |
| 144 #if 0 | 142 #if 0 |
| 145 /* for future use */ | 143 /* for future use */ |
| 146 PRInt32 numdeltas; /* number of delta CRLs used for the cache */ | 144 PRInt32 numdeltas; /* number of delta CRLs used for the cache */ |
| 147 CachedCrl** deltas; /* delta CRLs used for the cache */ | 145 CachedCrl** deltas; /* delta CRLs used for the cache */ |
| 148 #endif | 146 #endif |
| 149 /* cache invalidity bitflag */ | 147 /* cache invalidity bitflag */ |
| 150 PRUint16 invalid; /* this state will be set if either | 148 PRUint16 invalid; /* this state will be set if either |
| 151 CRL_CACHE_INVALID_CRLS or CRL_CACHE_LAST_FETCH_FAILED is set. | 149 CRL_CACHE_INVALID_CRLS or CRL_CACHE_LAST_FETCH_FAILED is set. |
| 152 In those cases, all certs are considered to have unknown status. | 150 In those cases, all certs are considered to have unknown status. |
| 153 The invalid state can only be cleared during an update if all | 151 The invalid state can only be cleared during an update if all |
| 154 error states are cleared */ | 152 error states are cleared */ |
| 155 PRBool refresh; /* manual refresh from tokens has been forced */ | 153 PRBool refresh; /* manual refresh from tokens has been forced */ |
| 156 PRBool mustchoose; /* trigger reselection algorithm, for case when | 154 PRBool mustchoose; /* trigger reselection algorithm, for case when |
| 157 RAM CRL objects are dropped from the cache */ | 155 RAM CRL objects are dropped from the cache */ |
| 158 PRTime lastfetch; /* time a CRL token fetch was last performed */ | 156 PRTime lastfetch; /* time a CRL token fetch was last performed */ |
| 159 PRTime lastcheck; /* time CRL token objects were last checked for | 157 PRTime lastcheck; /* time CRL token objects were last checked for |
| 160 existence */ | 158 existence */ |
| 161 }; | 159 }; |
| 162 | 160 |
| 163 /* CRL issuer cache object | 161 /* CRL issuer cache object |
| 164 This object tracks all the distribution point caches for a given issuer. | 162 This object tracks all the distribution point caches for a given issuer. |
| 165 XCRL once we support multiple issuing distribution points, this object | 163 XCRL once we support multiple issuing distribution points, this object |
| 166 will be a hash table. For now, it just holds the single CRL distribution | 164 will be a hash table. For now, it just holds the single CRL distribution |
| 167 point cache structure. | 165 point cache structure. |
| 168 */ | 166 */ |
| 169 | 167 |
| 170 struct CRLIssuerCacheStr { | 168 struct CRLIssuerCacheStr { |
| 171 SECItem* subject; /* DER of issuer subject */ | 169 SECItem* subject; /* DER of issuer subject */ |
| 172 CRLDPCache* dpp; | 170 CRLDPCache* dpp; |
| 173 }; | 171 }; |
| 174 | 172 |
| 175 /* CRL revocation cache object | 173 /* CRL revocation cache object |
| 176 This object tracks all the issuer caches | 174 This object tracks all the issuer caches |
| 177 */ | 175 */ |
| 178 | 176 |
| 179 struct CRLCacheStr { | 177 struct CRLCacheStr { |
| 180 #ifdef GLOBAL_RWLOCK | 178 #ifdef GLOBAL_RWLOCK |
| 181 NSSRWLock* lock; | 179 NSSRWLock* lock; |
| 182 #else | 180 #else |
| 183 PRLock* lock; | 181 PRLock* lock; |
| 184 #endif | 182 #endif |
| 185 /* hash table of issuer to CRLIssuerCacheStr, | 183 /* hash table of issuer to CRLIssuerCacheStr, |
| 186 indexed by issuer DER subject */ | 184 indexed by issuer DER subject */ |
| 187 PLHashTable* issuers; | 185 PLHashTable* issuers; |
| 188 }; | 186 }; |
| 189 | 187 |
| 190 SECStatus InitCRLCache(void); | 188 SECStatus InitCRLCache(void); |
| 191 SECStatus ShutdownCRLCache(void); | 189 SECStatus ShutdownCRLCache(void); |
| 192 | 190 |
| 193 /* Returns a pointer to an environment-like string, a series of | 191 /* Returns a pointer to an environment-like string, a series of |
| 194 ** null-terminated strings, terminated by a zero-length string. | 192 ** null-terminated strings, terminated by a zero-length string. |
| 195 ** This function is intended to be internal to NSS. | 193 ** This function is intended to be internal to NSS. |
| 196 */ | 194 */ |
| 197 extern char * cert_GetCertificateEmailAddresses(CERTCertificate *cert); | 195 extern char* cert_GetCertificateEmailAddresses(CERTCertificate* cert); |
| 198 | 196 |
| 199 /* | 197 /* |
| 200 * These functions are used to map subjectKeyID extension values to certs | 198 * These functions are used to map subjectKeyID extension values to certs |
| 201 * and to keep track of the checks for user certificates in each slot | 199 * and to keep track of the checks for user certificates in each slot |
| 202 */ | 200 */ |
| 203 SECStatus | 201 SECStatus cert_CreateSubjectKeyIDHashTable(void); |
| 204 cert_CreateSubjectKeyIDHashTable(void); | |
| 205 | 202 |
| 206 SECStatus | 203 SECStatus cert_AddSubjectKeyIDMapping(SECItem* subjKeyID, |
| 207 cert_AddSubjectKeyIDMapping(SECItem *subjKeyID, CERTCertificate *cert); | 204 CERTCertificate* cert); |
| 208 | 205 |
| 209 SECStatus | 206 SECStatus cert_UpdateSubjectKeyIDSlotCheck(SECItem* slotid, int series); |
| 210 cert_UpdateSubjectKeyIDSlotCheck(SECItem *slotid, int series); | |
| 211 | 207 |
| 212 int | 208 int cert_SubjectKeyIDSlotCheckSeries(SECItem* slotid); |
| 213 cert_SubjectKeyIDSlotCheckSeries(SECItem *slotid); | |
| 214 | 209 |
| 215 /* | 210 /* |
| 216 * Call this function to remove an entry from the mapping table. | 211 * Call this function to remove an entry from the mapping table. |
| 217 */ | 212 */ |
| 218 SECStatus | 213 SECStatus cert_RemoveSubjectKeyIDMapping(SECItem* subjKeyID); |
| 219 cert_RemoveSubjectKeyIDMapping(SECItem *subjKeyID); | |
| 220 | 214 |
| 221 SECStatus | 215 SECStatus cert_DestroySubjectKeyIDHashTable(void); |
| 222 cert_DestroySubjectKeyIDHashTable(void); | |
| 223 | 216 |
| 224 SECItem* | 217 SECItem* cert_FindDERCertBySubjectKeyID(SECItem* subjKeyID); |
| 225 cert_FindDERCertBySubjectKeyID(SECItem *subjKeyID); | |
| 226 | 218 |
| 227 /* return maximum length of AVA value based on its type OID tag. */ | 219 /* return maximum length of AVA value based on its type OID tag. */ |
| 228 extern int cert_AVAOidTagToMaxLen(SECOidTag tag); | 220 extern int cert_AVAOidTagToMaxLen(SECOidTag tag); |
| 229 | 221 |
| 230 /* Make an AVA, allocated from pool, from OID and DER encoded value */ | 222 /* Make an AVA, allocated from pool, from OID and DER encoded value */ |
| 231 extern CERTAVA * CERT_CreateAVAFromRaw(PLArenaPool *pool, | 223 extern CERTAVA* CERT_CreateAVAFromRaw(PLArenaPool* pool, const SECItem* OID, |
| 232 const SECItem * OID, const SECItem * value); | 224 const SECItem* value); |
| 233 | 225 |
| 234 /* Make an AVA from binary input specified by SECItem */ | 226 /* Make an AVA from binary input specified by SECItem */ |
| 235 extern CERTAVA * CERT_CreateAVAFromSECItem(PLArenaPool *arena, SECOidTag kind, | 227 extern CERTAVA* CERT_CreateAVAFromSECItem(PLArenaPool* arena, SECOidTag kind, |
| 236 int valueType, SECItem *value); | 228 int valueType, SECItem* value); |
| 237 | 229 |
| 238 /* | 230 /* |
| 239 * get a DPCache object for the given issuer subject and dp | 231 * get a DPCache object for the given issuer subject and dp |
| 240 * Automatically creates the cache object if it doesn't exist yet. | 232 * Automatically creates the cache object if it doesn't exist yet. |
| 241 */ | 233 */ |
| 242 SECStatus AcquireDPCache(CERTCertificate* issuer, const SECItem* subject, | 234 SECStatus AcquireDPCache(CERTCertificate* issuer, const SECItem* subject, |
| 243 const SECItem* dp, PRTime t, void* wincx, | 235 const SECItem* dp, PRTime t, void* wincx, |
| 244 CRLDPCache** dpcache, PRBool* writeLocked); | 236 CRLDPCache** dpcache, PRBool* writeLocked); |
| 245 | 237 |
| 246 /* check if a particular SN is in the CRL cache and return its entry */ | 238 /* check if a particular SN is in the CRL cache and return its entry */ |
| 247 dpcacheStatus DPCache_Lookup(CRLDPCache* cache, const SECItem* sn, | 239 dpcacheStatus DPCache_Lookup(CRLDPCache* cache, const SECItem* sn, |
| 248 CERTCrlEntry** returned); | 240 CERTCrlEntry** returned); |
| 249 | 241 |
| 250 /* release a DPCache object that was previously acquired */ | 242 /* release a DPCache object that was previously acquired */ |
| 251 void ReleaseDPCache(CRLDPCache* dpcache, PRBool writeLocked); | 243 void ReleaseDPCache(CRLDPCache* dpcache, PRBool writeLocked); |
| 252 | 244 |
| 253 /* | 245 /* |
| 254 * map Stan errors into NSS errors | 246 * map Stan errors into NSS errors |
| 255 * This function examines the stan error stack and automatically sets | 247 * This function examines the stan error stack and automatically sets |
| 256 * PORT_SetError(); to the appropriate SEC_ERROR value. | 248 * PORT_SetError(); to the appropriate SEC_ERROR value. |
| 257 */ | 249 */ |
| 258 void CERT_MapStanError(); | 250 void CERT_MapStanError(); |
| 259 | 251 |
| 260 /* Like CERT_VerifyCert, except with an additional argument, flags. The | 252 /* Like CERT_VerifyCert, except with an additional argument, flags. The |
| 261 * flags are defined immediately below. | 253 * flags are defined immediately below. |
| 262 */ | 254 */ |
| 263 SECStatus | 255 SECStatus cert_VerifyCertWithFlags(CERTCertDBHandle* handle, |
| 264 cert_VerifyCertWithFlags(CERTCertDBHandle *handle, CERTCertificate *cert, | 256 CERTCertificate* cert, PRBool checkSig, |
| 265 PRBool checkSig, SECCertUsage certUsage, PRTime t, | 257 SECCertUsage certUsage, PRTime t, |
| 266 PRUint32 flags, void *wincx, CERTVerifyLog *log); | 258 PRUint32 flags, void* wincx, |
| 259 CERTVerifyLog* log); |
| 267 | 260 |
| 268 /* Use the default settings. | 261 /* Use the default settings. |
| 269 * cert_VerifyCertWithFlags(..., CERT_VERIFYCERT_USE_DEFAULTS, ...) is | 262 * cert_VerifyCertWithFlags(..., CERT_VERIFYCERT_USE_DEFAULTS, ...) is |
| 270 * equivalent to CERT_VerifyCert(...); | 263 * equivalent to CERT_VerifyCert(...); |
| 271 */ | 264 */ |
| 272 #define CERT_VERIFYCERT_USE_DEFAULTS 0 | 265 #define CERT_VERIFYCERT_USE_DEFAULTS 0 |
| 273 | 266 |
| 274 /* Skip all the OCSP checks during certificate verification, regardless of | 267 /* Skip all the OCSP checks during certificate verification, regardless of |
| 275 * the global OCSP settings. By default, certificate |cert| will have its | 268 * the global OCSP settings. By default, certificate |cert| will have its |
| 276 * revocation status checked via OCSP according to the global OCSP settings. | 269 * revocation status checked via OCSP according to the global OCSP settings. |
| 277 * | 270 * |
| 278 * OCSP checking is always skipped when certUsage is certUsageStatusResponder. | 271 * OCSP checking is always skipped when certUsage is certUsageStatusResponder. |
| 279 */ | 272 */ |
| 280 #define CERT_VERIFYCERT_SKIP_OCSP 1 | 273 #define CERT_VERIFYCERT_SKIP_OCSP 1 |
| 281 | 274 |
| 282 /* Interface function for libpkix cert validation engine: | 275 /* Interface function for libpkix cert validation engine: |
| 283 * cert_verify wrapper. */ | 276 * cert_verify wrapper. */ |
| 284 SECStatus | 277 SECStatus cert_VerifyCertChainPkix(CERTCertificate* cert, PRBool checkSig, |
| 285 cert_VerifyCertChainPkix(CERTCertificate *cert, | 278 SECCertUsage requiredUsage, PRTime time, |
| 286 PRBool checkSig, | 279 void* wincx, CERTVerifyLog* log, |
| 287 SECCertUsage requiredUsage, | 280 PRBool* sigError, PRBool* revoked); |
| 288 PRTime time, | |
| 289 void *wincx, | |
| 290 CERTVerifyLog *log, | |
| 291 PRBool *sigError, | |
| 292 PRBool *revoked); | |
| 293 | 281 |
| 294 SECStatus cert_InitLocks(void); | 282 SECStatus cert_InitLocks(void); |
| 295 | 283 |
| 296 SECStatus cert_DestroyLocks(void); | 284 SECStatus cert_DestroyLocks(void); |
| 297 | 285 |
| 298 /* | 286 /* |
| 299 * fill in nsCertType field of the cert based on the cert extension | 287 * fill in nsCertType field of the cert based on the cert extension |
| 300 */ | 288 */ |
| 301 extern SECStatus cert_GetCertType(CERTCertificate *cert); | 289 extern SECStatus cert_GetCertType(CERTCertificate* cert); |
| 302 | 290 |
| 303 /* | 291 /* |
| 304 * compute and return the value of nsCertType for cert, but do not | 292 * compute and return the value of nsCertType for cert, but do not |
| 305 * update the CERTCertificate. | 293 * update the CERTCertificate. |
| 306 */ | 294 */ |
| 307 extern PRUint32 cert_ComputeCertType(CERTCertificate *cert); | 295 extern PRUint32 cert_ComputeCertType(CERTCertificate* cert); |
| 308 | 296 |
| 309 void cert_AddToVerifyLog(CERTVerifyLog *log,CERTCertificate *cert, | 297 void cert_AddToVerifyLog(CERTVerifyLog* log, CERTCertificate* cert, |
| 310 long errorCode, unsigned int depth, | 298 long errorCode, unsigned int depth, void* arg); |
| 311 void *arg); | |
| 312 | 299 |
| 313 /* Insert a DER CRL into the CRL cache, and take ownership of it. | 300 /* Insert a DER CRL into the CRL cache, and take ownership of it. |
| 314 * | 301 * |
| 315 * cert_CacheCRLByGeneralName takes ownership of the memory in crl argument | 302 * cert_CacheCRLByGeneralName takes ownership of the memory in crl argument |
| 316 * completely. crl must be freeable by SECITEM_FreeItem. It will be freed | 303 * completely. crl must be freeable by SECITEM_FreeItem. It will be freed |
| 317 * immediately if it is rejected from the CRL cache, or later during cache | 304 * immediately if it is rejected from the CRL cache, or later during cache |
| 318 * updates when a new crl is available, or at shutdown time. | 305 * updates when a new crl is available, or at shutdown time. |
| 319 * | 306 * |
| 320 * canonicalizedName represents the source of the CRL, a GeneralName. | 307 * canonicalizedName represents the source of the CRL, a GeneralName. |
| 321 * The format of the encoding is not restricted, but all callers of | 308 * The format of the encoding is not restricted, but all callers of |
| 322 * cert_CacheCRLByGeneralName and cert_FindCRLByGeneralName must use | 309 * cert_CacheCRLByGeneralName and cert_FindCRLByGeneralName must use |
| 323 * the same encoding. To facilitate X.500 name matching, a canonicalized | 310 * the same encoding. To facilitate X.500 name matching, a canonicalized |
| 324 * encoding of the GeneralName should be used, if available. | 311 * encoding of the GeneralName should be used, if available. |
| 325 */ | 312 */ |
| 326 | 313 |
| 327 SECStatus cert_CacheCRLByGeneralName(CERTCertDBHandle* dbhandle, SECItem* crl, | 314 SECStatus cert_CacheCRLByGeneralName(CERTCertDBHandle* dbhandle, SECItem* crl, |
| 328 const SECItem* canonicalizedName); | 315 const SECItem* canonicalizedName); |
| 329 | 316 |
| 330 struct NamedCRLCacheStr { | 317 struct NamedCRLCacheStr { |
| 331 PRLock* lock; | 318 PRLock* lock; |
| 332 PLHashTable* entries; | 319 PLHashTable* entries; |
| 333 }; | 320 }; |
| 334 | 321 |
| 335 /* NamedCRLCacheEntryStr is filled in by cert_CacheCRLByGeneralName, | 322 /* NamedCRLCacheEntryStr is filled in by cert_CacheCRLByGeneralName, |
| 336 * and read by cert_FindCRLByGeneralName */ | 323 * and read by cert_FindCRLByGeneralName */ |
| 337 struct NamedCRLCacheEntryStr { | 324 struct NamedCRLCacheEntryStr { |
| 338 SECItem* canonicalizedName; | 325 SECItem* canonicalizedName; |
| 339 SECItem* crl; /* DER, kept only if CRL | 326 SECItem* crl; /* DER, kept only if CRL |
| 340 * is successfully cached */ | 327 * is successfully cached */ |
| 341 PRBool inCRLCache; | 328 PRBool inCRLCache; |
| 342 PRTime successfulInsertionTime; /* insertion time */ | 329 PRTime successfulInsertionTime; /* insertion time */ |
| 343 PRTime lastAttemptTime; /* time of last call to | 330 PRTime lastAttemptTime; /* time of last call to |
| 344 cert_CacheCRLByGeneralName with this name */ | 331 cert_CacheCRLByGeneralName with this name */ |
| 345 PRBool badDER; /* ASN.1 error */ | 332 PRBool badDER; /* ASN.1 error */ |
| 346 PRBool dupe; /* matching DER CRL already in CRL cache */ | 333 PRBool dupe; /* matching DER CRL already in CRL cache */ |
| 347 PRBool unsupported; /* IDP, delta, any other reason */ | 334 PRBool unsupported; /* IDP, delta, any other reason */ |
| 348 }; | 335 }; |
| 349 | 336 |
| 350 typedef enum { | 337 typedef enum { |
| 351 certRevocationStatusRevoked = 0, | 338 certRevocationStatusRevoked = 0, |
| 352 certRevocationStatusValid = 1, | 339 certRevocationStatusValid = 1, |
| 353 certRevocationStatusUnknown = 2 | 340 certRevocationStatusUnknown = 2 |
| 354 } CERTRevocationStatus; | 341 } CERTRevocationStatus; |
| 355 | 342 |
| 356 /* Returns detailed status of the cert(revStatus variable). Tells if | 343 /* Returns detailed status of the cert(revStatus variable). Tells if |
| 357 * issuer cache has OriginFetchedWithTimeout crl in it. */ | 344 * issuer cache has OriginFetchedWithTimeout crl in it. */ |
| 358 SECStatus | 345 SECStatus cert_CheckCertRevocationStatus(CERTCertificate* cert, |
| 359 cert_CheckCertRevocationStatus(CERTCertificate* cert, CERTCertificate* issuer, | 346 CERTCertificate* issuer, |
| 360 const SECItem* dp, PRTime t, void *wincx, | 347 const SECItem* dp, PRTime t, |
| 361 CERTRevocationStatus *revStatus, | 348 void* wincx, |
| 362 CERTCRLEntryReasonCode *revReason); | 349 CERTRevocationStatus* revStatus, |
| 363 | 350 CERTCRLEntryReasonCode* revReason); |
| 364 | 351 |
| 365 SECStatus cert_AcquireNamedCRLCache(NamedCRLCache** returned); | 352 SECStatus cert_AcquireNamedCRLCache(NamedCRLCache** returned); |
| 366 | 353 |
| 367 /* cert_FindCRLByGeneralName must be called only while the named cache is | 354 /* cert_FindCRLByGeneralName must be called only while the named cache is |
| 368 * acquired, and the entry is only valid until cache is released. | 355 * acquired, and the entry is only valid until cache is released. |
| 369 */ | 356 */ |
| 370 SECStatus cert_FindCRLByGeneralName(NamedCRLCache* ncc, | 357 SECStatus cert_FindCRLByGeneralName(NamedCRLCache* ncc, |
| 371 const SECItem* canonicalizedName, | 358 const SECItem* canonicalizedName, |
| 372 NamedCRLCacheEntry** retEntry); | 359 NamedCRLCacheEntry** retEntry); |
| 373 | 360 |
| 374 SECStatus cert_ReleaseNamedCRLCache(NamedCRLCache* ncc); | 361 SECStatus cert_ReleaseNamedCRLCache(NamedCRLCache* ncc); |
| 375 | 362 |
| 376 /* This is private for now. Maybe shoule be public. */ | 363 /* This is private for now. Maybe shoule be public. */ |
| 377 CERTGeneralName * | 364 CERTGeneralName* cert_GetSubjectAltNameList(const CERTCertificate* cert, |
| 378 cert_GetSubjectAltNameList(const CERTCertificate *cert, PLArenaPool *arena); | 365 PLArenaPool* arena); |
| 379 | 366 |
| 380 /* Count DNS names and IP addresses in a list of GeneralNames */ | 367 /* Count DNS names and IP addresses in a list of GeneralNames */ |
| 381 PRUint32 | 368 PRUint32 cert_CountDNSPatterns(CERTGeneralName* firstName); |
| 382 cert_CountDNSPatterns(CERTGeneralName *firstName); | |
| 383 | 369 |
| 384 /* | 370 /* |
| 385 * returns the trust status of the leaf certificate based on usage. | 371 * returns the trust status of the leaf certificate based on usage. |
| 386 * If the leaf is explicitly untrusted, this function will fail and | 372 * If the leaf is explicitly untrusted, this function will fail and |
| 387 * failedFlags will be set to the trust bit value that lead to the failure. | 373 * failedFlags will be set to the trust bit value that lead to the failure. |
| 388 * If the leaf is trusted, isTrusted is set to true and the function returns | 374 * If the leaf is trusted, isTrusted is set to true and the function returns |
| 389 * SECSuccess. This function does not check if the cert is fit for a | 375 * SECSuccess. This function does not check if the cert is fit for a |
| 390 * particular usage. | 376 * particular usage. |
| 391 */ | 377 */ |
| 392 SECStatus | 378 SECStatus cert_CheckLeafTrust(CERTCertificate* cert, SECCertUsage usage, |
| 393 cert_CheckLeafTrust(CERTCertificate *cert, | 379 unsigned int* failedFlags, PRBool* isTrusted); |
| 394 SECCertUsage usage, | |
| 395 unsigned int *failedFlags, | |
| 396 PRBool *isTrusted); | |
| 397 | 380 |
| 398 #endif /* _CERTI_H_ */ | 381 #endif /* _CERTI_H_ */ |
| 399 | |
| OLD | NEW |