Back to index

lightning-sunbird  0.9+nobinonly
pkistore.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef PKISTORE_H
00038 #define PKISTORE_H
00039 
00040 #ifdef DEBUG
00041 static const char PKISTORE_CVS_ID[] = "@(#) $RCSfile: pkistore.h,v $ $Revision: 1.7.28.2 $ $Date: 2006/08/22 17:12:04 $";
00042 #endif /* DEBUG */
00043 
00044 #ifndef NSSPKIT_H
00045 #include "nsspkit.h"
00046 #endif /* NSSPKIT_H */
00047 
00048 #ifndef BASE_H
00049 #include "base.h"
00050 #endif /* BASE_H */
00051 
00052 PR_BEGIN_EXTERN_C
00053 
00054 /* 
00055  * PKI Stores
00056  *
00057  * This is a set of routines for managing local stores of PKI objects.
00058  * Currently, the only application is in crypto contexts, where the
00059  * certificate store is used.  In the future, methods should be added
00060  * here for storing local references to keys.
00061  */
00062 
00063 /* 
00064  * nssCertificateStore
00065  *
00066  * Manages local store of certificate, trust, and S/MIME profile objects.
00067  * Within a crypto context, mappings of cert to trust and cert to S/MIME
00068  * profile are always 1-1.  Therefore, it is reasonable to store all objects
00069  * in a single collection, indexed by the certificate.
00070  */
00071 
00072 NSS_EXTERN nssCertificateStore *
00073 nssCertificateStore_Create
00074 (
00075   NSSArena *arenaOpt
00076 );
00077 
00078 NSS_EXTERN PRStatus
00079 nssCertificateStore_Destroy
00080 (
00081   nssCertificateStore *store
00082 );
00083 
00084 /* Atomic Find cert in store, or add this cert to the store.
00085 ** Ref counts properly maintained.
00086 */
00087 NSS_EXTERN NSSCertificate *
00088 nssCertificateStore_FindOrAdd 
00089 (
00090   nssCertificateStore *store,
00091   NSSCertificate *c
00092 );
00093 
00094 NSS_EXTERN void
00095 nssCertificateStore_RemoveCertLOCKED
00096 (
00097   nssCertificateStore *store,
00098   NSSCertificate *cert
00099 );
00100 
00101 struct nssCertificateStoreTraceStr {
00102     nssCertificateStore* store;
00103     PZLock* lock;
00104     PRBool locked;
00105     PRBool unlocked;
00106 };
00107 
00108 typedef struct nssCertificateStoreTraceStr nssCertificateStoreTrace;
00109 
00110 static void nssCertificateStore_Check(nssCertificateStoreTrace* a,
00111                                   nssCertificateStoreTrace* b) {
00112     PORT_Assert(a->locked);
00113     PORT_Assert(b->unlocked);
00114 
00115     PORT_Assert(!a->unlocked);
00116     PORT_Assert(!b->locked);
00117 
00118     PORT_Assert(a->lock == b->lock);
00119     PORT_Assert(a->store == b->store);
00120 };
00121 
00122 NSS_EXTERN void
00123 nssCertificateStore_Lock (
00124   nssCertificateStore *store, nssCertificateStoreTrace* out
00125 );
00126 
00127 NSS_EXTERN void
00128 nssCertificateStore_Unlock (
00129   nssCertificateStore *store, nssCertificateStoreTrace* in,
00130   nssCertificateStoreTrace* out
00131 );
00132 
00133 NSS_EXTERN NSSCertificate **
00134 nssCertificateStore_FindCertificatesBySubject
00135 (
00136   nssCertificateStore *store,
00137   NSSDER *subject,
00138   NSSCertificate *rvOpt[],
00139   PRUint32 maximumOpt,
00140   NSSArena *arenaOpt
00141 );
00142 
00143 NSS_EXTERN NSSCertificate **
00144 nssCertificateStore_FindCertificatesByNickname
00145 (
00146   nssCertificateStore *store,
00147   NSSUTF8 *nickname,
00148   NSSCertificate *rvOpt[],
00149   PRUint32 maximumOpt,
00150   NSSArena *arenaOpt
00151 );
00152 
00153 NSS_EXTERN NSSCertificate **
00154 nssCertificateStore_FindCertificatesByEmail
00155 (
00156   nssCertificateStore *store,
00157   NSSASCII7 *email,
00158   NSSCertificate *rvOpt[],
00159   PRUint32 maximumOpt,
00160   NSSArena *arenaOpt
00161 );
00162 
00163 NSS_EXTERN NSSCertificate *
00164 nssCertificateStore_FindCertificateByIssuerAndSerialNumber
00165 (
00166   nssCertificateStore *store,
00167   NSSDER *issuer,
00168   NSSDER *serial
00169 );
00170 
00171 NSS_EXTERN NSSCertificate *
00172 nssCertificateStore_FindCertificateByEncodedCertificate
00173 (
00174   nssCertificateStore *store,
00175   NSSDER *encoding
00176 );
00177 
00178 NSS_EXTERN PRStatus
00179 nssCertificateStore_AddTrust
00180 (
00181   nssCertificateStore *store,
00182   NSSTrust *trust
00183 );
00184 
00185 NSS_EXTERN NSSTrust *
00186 nssCertificateStore_FindTrustForCertificate
00187 (
00188   nssCertificateStore *store,
00189   NSSCertificate *cert
00190 );
00191 
00192 NSS_EXTERN PRStatus
00193 nssCertificateStore_AddSMIMEProfile
00194 (
00195   nssCertificateStore *store,
00196   nssSMIMEProfile *profile
00197 );
00198 
00199 NSS_EXTERN nssSMIMEProfile *
00200 nssCertificateStore_FindSMIMEProfileForCertificate
00201 (
00202   nssCertificateStore *store,
00203   NSSCertificate *cert
00204 );
00205 
00206 NSS_EXTERN void
00207 nssCertificateStore_DumpStoreInfo
00208 (
00209   nssCertificateStore *store,
00210   void (* cert_dump_iter)(const void *, void *, void *),
00211   void *arg
00212 );
00213 
00214 PR_END_EXTERN_C
00215 
00216 #endif /* PKISTORE_H */