security/nss/lib/softoken/legacydb/pcert.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef _PCERTDB_H_
michael@0 6 #define _PCERTDB_H_
michael@0 7
michael@0 8 #include "plarena.h"
michael@0 9 #include "prlong.h"
michael@0 10 #include "pcertt.h"
michael@0 11
michael@0 12 #include "lowkeyti.h" /* for struct NSSLOWKEYPublicKeyStr */
michael@0 13
michael@0 14 SEC_BEGIN_PROTOS
michael@0 15
michael@0 16 /*
michael@0 17 * initialize any global certificate locks
michael@0 18 */
michael@0 19 SECStatus nsslowcert_InitLocks(void);
michael@0 20
michael@0 21 /*
michael@0 22 ** Add a DER encoded certificate to the permanent database.
michael@0 23 ** "derCert" is the DER encoded certificate.
michael@0 24 ** "nickname" is the nickname to use for the cert
michael@0 25 ** "trust" is the trust parameters for the cert
michael@0 26 */
michael@0 27 SECStatus nsslowcert_AddPermCert(NSSLOWCERTCertDBHandle *handle,
michael@0 28 NSSLOWCERTCertificate *cert,
michael@0 29 char *nickname, NSSLOWCERTCertTrust *trust);
michael@0 30 SECStatus nsslowcert_AddPermNickname(NSSLOWCERTCertDBHandle *dbhandle,
michael@0 31 NSSLOWCERTCertificate *cert, char *nickname);
michael@0 32
michael@0 33 SECStatus nsslowcert_DeletePermCertificate(NSSLOWCERTCertificate *cert);
michael@0 34
michael@0 35 typedef SECStatus (PR_CALLBACK * PermCertCallback)(NSSLOWCERTCertificate *cert,
michael@0 36 SECItem *k, void *pdata);
michael@0 37 /*
michael@0 38 ** Traverse the entire permanent database, and pass the certs off to a
michael@0 39 ** user supplied function.
michael@0 40 ** "certfunc" is the user function to call for each certificate
michael@0 41 ** "udata" is the user's data, which is passed through to "certfunc"
michael@0 42 */
michael@0 43 SECStatus
michael@0 44 nsslowcert_TraversePermCerts(NSSLOWCERTCertDBHandle *handle,
michael@0 45 PermCertCallback certfunc,
michael@0 46 void *udata );
michael@0 47
michael@0 48 PRBool
michael@0 49 nsslowcert_CertDBKeyConflict(SECItem *derCert, NSSLOWCERTCertDBHandle *handle);
michael@0 50
michael@0 51 certDBEntryRevocation *
michael@0 52 nsslowcert_FindCrlByKey(NSSLOWCERTCertDBHandle *handle,
michael@0 53 SECItem *crlKey, PRBool isKRL);
michael@0 54
michael@0 55 SECStatus
michael@0 56 nsslowcert_DeletePermCRL(NSSLOWCERTCertDBHandle *handle,const SECItem *derName,
michael@0 57 PRBool isKRL);
michael@0 58 SECStatus
michael@0 59 nsslowcert_AddCrl(NSSLOWCERTCertDBHandle *handle, SECItem *derCrl ,
michael@0 60 SECItem *derKey, char *url, PRBool isKRL);
michael@0 61
michael@0 62 NSSLOWCERTCertDBHandle *nsslowcert_GetDefaultCertDB();
michael@0 63 NSSLOWKEYPublicKey *nsslowcert_ExtractPublicKey(NSSLOWCERTCertificate *);
michael@0 64
michael@0 65 NSSLOWCERTCertificate *
michael@0 66 nsslowcert_NewTempCertificate(NSSLOWCERTCertDBHandle *handle, SECItem *derCert,
michael@0 67 char *nickname, PRBool isperm, PRBool copyDER);
michael@0 68 NSSLOWCERTCertificate *
michael@0 69 nsslowcert_DupCertificate(NSSLOWCERTCertificate *cert);
michael@0 70 void nsslowcert_DestroyCertificate(NSSLOWCERTCertificate *cert);
michael@0 71 void nsslowcert_DestroyTrust(NSSLOWCERTTrust *Trust);
michael@0 72
michael@0 73 /*
michael@0 74 * Lookup a certificate in the databases without locking
michael@0 75 * "certKey" is the database key to look for
michael@0 76 *
michael@0 77 * XXX - this should be internal, but pkcs 11 needs to call it during a
michael@0 78 * traversal.
michael@0 79 */
michael@0 80 NSSLOWCERTCertificate *
michael@0 81 nsslowcert_FindCertByKey(NSSLOWCERTCertDBHandle *handle, const SECItem *certKey);
michael@0 82
michael@0 83 /*
michael@0 84 * Lookup trust for a certificate in the databases without locking
michael@0 85 * "certKey" is the database key to look for
michael@0 86 *
michael@0 87 * XXX - this should be internal, but pkcs 11 needs to call it during a
michael@0 88 * traversal.
michael@0 89 */
michael@0 90 NSSLOWCERTTrust *
michael@0 91 nsslowcert_FindTrustByKey(NSSLOWCERTCertDBHandle *handle, const SECItem *certKey);
michael@0 92
michael@0 93 /*
michael@0 94 ** Generate a certificate key from the issuer and serialnumber, then look it
michael@0 95 ** up in the database. Return the cert if found.
michael@0 96 ** "issuerAndSN" is the issuer and serial number to look for
michael@0 97 */
michael@0 98 extern NSSLOWCERTCertificate *
michael@0 99 nsslowcert_FindCertByIssuerAndSN (NSSLOWCERTCertDBHandle *handle, NSSLOWCERTIssuerAndSN *issuerAndSN);
michael@0 100
michael@0 101 /*
michael@0 102 ** Generate a certificate key from the issuer and serialnumber, then look it
michael@0 103 ** up in the database. Return the cert if found.
michael@0 104 ** "issuerAndSN" is the issuer and serial number to look for
michael@0 105 */
michael@0 106 extern NSSLOWCERTTrust *
michael@0 107 nsslowcert_FindTrustByIssuerAndSN (NSSLOWCERTCertDBHandle *handle, NSSLOWCERTIssuerAndSN *issuerAndSN);
michael@0 108
michael@0 109 /*
michael@0 110 ** Find a certificate in the database by a DER encoded certificate
michael@0 111 ** "derCert" is the DER encoded certificate
michael@0 112 */
michael@0 113 extern NSSLOWCERTCertificate *
michael@0 114 nsslowcert_FindCertByDERCert(NSSLOWCERTCertDBHandle *handle, SECItem *derCert);
michael@0 115
michael@0 116 /* convert an email address to lower case */
michael@0 117 char *nsslowcert_FixupEmailAddr(char *emailAddr);
michael@0 118
michael@0 119 /*
michael@0 120 ** Decode a DER encoded certificate into an NSSLOWCERTCertificate structure
michael@0 121 ** "derSignedCert" is the DER encoded signed certificate
michael@0 122 ** "copyDER" is true if the DER should be copied, false if the
michael@0 123 ** existing copy should be referenced
michael@0 124 ** "nickname" is the nickname to use in the database. If it is NULL
michael@0 125 ** then a temporary nickname is generated.
michael@0 126 */
michael@0 127 extern NSSLOWCERTCertificate *
michael@0 128 nsslowcert_DecodeDERCertificate (SECItem *derSignedCert, char *nickname);
michael@0 129
michael@0 130 SECStatus
michael@0 131 nsslowcert_KeyFromDERCert(PLArenaPool *arena, SECItem *derCert, SECItem *key);
michael@0 132
michael@0 133 certDBEntrySMime *
michael@0 134 nsslowcert_ReadDBSMimeEntry(NSSLOWCERTCertDBHandle *certHandle,
michael@0 135 char *emailAddr);
michael@0 136 void
michael@0 137 nsslowcert_DestroyDBEntry(certDBEntry *entry);
michael@0 138
michael@0 139 SECStatus
michael@0 140 nsslowcert_OpenCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
michael@0 141 const char *domain, const char *prefix,
michael@0 142 NSSLOWCERTDBNameFunc namecb, void *cbarg, PRBool openVolatile);
michael@0 143
michael@0 144 void
michael@0 145 nsslowcert_ClosePermCertDB(NSSLOWCERTCertDBHandle *handle);
michael@0 146
michael@0 147 /*
michael@0 148 * is certa newer than certb? If one is expired, pick the other one.
michael@0 149 */
michael@0 150 PRBool
michael@0 151 nsslowcert_IsNewer(NSSLOWCERTCertificate *certa, NSSLOWCERTCertificate *certb);
michael@0 152
michael@0 153
michael@0 154 SECStatus
michael@0 155 nsslowcert_TraverseDBEntries(NSSLOWCERTCertDBHandle *handle,
michael@0 156 certDBEntryType type,
michael@0 157 SECStatus (* callback)(SECItem *data, SECItem *key,
michael@0 158 certDBEntryType type, void *pdata),
michael@0 159 void *udata );
michael@0 160 SECStatus
michael@0 161 nsslowcert_TraversePermCertsForSubject(NSSLOWCERTCertDBHandle *handle,
michael@0 162 SECItem *derSubject,
michael@0 163 NSSLOWCERTCertCallback cb, void *cbarg);
michael@0 164 int
michael@0 165 nsslowcert_NumPermCertsForSubject(NSSLOWCERTCertDBHandle *handle,
michael@0 166 SECItem *derSubject);
michael@0 167 SECStatus
michael@0 168 nsslowcert_TraversePermCertsForNickname(NSSLOWCERTCertDBHandle *handle,
michael@0 169 char *nickname, NSSLOWCERTCertCallback cb, void *cbarg);
michael@0 170
michael@0 171 int
michael@0 172 nsslowcert_NumPermCertsForNickname(NSSLOWCERTCertDBHandle *handle,
michael@0 173 char *nickname);
michael@0 174 SECStatus
michael@0 175 nsslowcert_GetCertTrust(NSSLOWCERTCertificate *cert,
michael@0 176 NSSLOWCERTCertTrust *trust);
michael@0 177
michael@0 178 SECStatus
michael@0 179 nsslowcert_SaveSMimeProfile(NSSLOWCERTCertDBHandle *dbhandle, char *emailAddr,
michael@0 180 SECItem *derSubject, SECItem *emailProfile, SECItem *profileTime);
michael@0 181
michael@0 182 /*
michael@0 183 * Change the trust attributes of a certificate and make them permanent
michael@0 184 * in the database.
michael@0 185 */
michael@0 186 SECStatus
michael@0 187 nsslowcert_ChangeCertTrust(NSSLOWCERTCertDBHandle *handle,
michael@0 188 NSSLOWCERTCertificate *cert, NSSLOWCERTCertTrust *trust);
michael@0 189
michael@0 190 PRBool
michael@0 191 nsslowcert_needDBVerify(NSSLOWCERTCertDBHandle *handle);
michael@0 192
michael@0 193 void
michael@0 194 nsslowcert_setDBVerify(NSSLOWCERTCertDBHandle *handle, PRBool value);
michael@0 195
michael@0 196 PRBool
michael@0 197 nsslowcert_hasTrust(NSSLOWCERTCertTrust *trust);
michael@0 198
michael@0 199 void
michael@0 200 nsslowcert_DestroyFreeLists(void);
michael@0 201
michael@0 202 void
michael@0 203 nsslowcert_DestroyGlobalLocks(void);
michael@0 204
michael@0 205 void
michael@0 206 pkcs11_freeNickname(char *nickname, char *space);
michael@0 207
michael@0 208 char *
michael@0 209 pkcs11_copyNickname(char *nickname, char *space, int spaceLen);
michael@0 210
michael@0 211 void
michael@0 212 pkcs11_freeStaticData(unsigned char *data, unsigned char *space);
michael@0 213
michael@0 214 unsigned char *
michael@0 215 pkcs11_allocStaticData(int datalen, unsigned char *space, int spaceLen);
michael@0 216
michael@0 217 unsigned char *
michael@0 218 pkcs11_copyStaticData(unsigned char *data, int datalen, unsigned char *space,
michael@0 219 int spaceLen);
michael@0 220 NSSLOWCERTCertificate *
michael@0 221 nsslowcert_CreateCert(void);
michael@0 222
michael@0 223 certDBEntry *
michael@0 224 nsslowcert_DecodeAnyDBEntry(SECItem *dbData, const SECItem *dbKey,
michael@0 225 certDBEntryType entryType, void *pdata);
michael@0 226
michael@0 227 SEC_END_PROTOS
michael@0 228
michael@0 229 #endif /* _PCERTDB_H_ */

mercurial