2001-07-20 00:41:38 +04:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Mozilla Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Netscape security libraries.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* terms of the GNU General Public License Version 2 or later (the
|
|
|
|
* "GPL"), in which case the provisions of the GPL are applicable
|
|
|
|
* instead of those above. If you wish to allow use of your
|
|
|
|
* version of this file only under the terms of the GPL and not to
|
|
|
|
* allow others to use your version of this file under the MPL,
|
|
|
|
* indicate your decision by deleting the provisions above and
|
|
|
|
* replace them with the notice and other provisions required by
|
|
|
|
* the GPL. If you do not delete the provisions above, a recipient
|
|
|
|
* may use your version of this file under either the MPL or the
|
|
|
|
* GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2002-01-23 20:00:39 +03:00
|
|
|
static const char CVS_ID[] = "@(#) $RCSfile: trustdomain.c,v $ $Revision: 1.27 $ $Date: 2002-01-23 17:00:39 $ $Name: $";
|
2001-07-20 00:41:38 +04:00
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
#ifndef NSSPKI_H
|
|
|
|
#include "nsspki.h"
|
|
|
|
#endif /* NSSPKI_H */
|
|
|
|
|
2001-10-11 20:34:49 +04:00
|
|
|
#ifndef PKI_H
|
|
|
|
#include "pki.h"
|
|
|
|
#endif /* PKI_H */
|
|
|
|
|
|
|
|
#ifndef PKIM_H
|
|
|
|
#include "pkim.h"
|
|
|
|
#endif /* PKIM_H */
|
2001-09-14 02:16:22 +04:00
|
|
|
|
|
|
|
#ifndef DEV_H
|
|
|
|
#include "dev.h"
|
|
|
|
#endif /* DEV_H */
|
|
|
|
|
2001-09-20 01:49:52 +04:00
|
|
|
#ifndef CKHELPER_H
|
|
|
|
#include "ckhelper.h"
|
|
|
|
#endif /* CKHELPER_H */
|
|
|
|
|
2001-10-11 22:41:51 +04:00
|
|
|
extern const NSSError NSS_ERROR_NOT_FOUND;
|
|
|
|
|
2001-10-11 20:34:49 +04:00
|
|
|
#define NSSTRUSTDOMAIN_DEFAULT_CACHE_SIZE 32
|
|
|
|
|
|
|
|
NSS_EXTERN PRStatus
|
|
|
|
nssTrustDomain_InitializeCache
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
PRUint32 cacheSize
|
|
|
|
);
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSTrustDomain *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_Create
|
|
|
|
(
|
|
|
|
NSSUTF8 *moduleOpt,
|
|
|
|
NSSUTF8 *uriOpt,
|
|
|
|
NSSUTF8 *opaqueOpt,
|
|
|
|
void *reserved
|
|
|
|
)
|
|
|
|
{
|
2001-09-14 02:16:22 +04:00
|
|
|
NSSArena *arena;
|
|
|
|
NSSTrustDomain *rvTD;
|
|
|
|
arena = NSSArena_Create();
|
|
|
|
if(!arena) {
|
|
|
|
return (NSSTrustDomain *)NULL;
|
|
|
|
}
|
|
|
|
rvTD = nss_ZNEW(arena, NSSTrustDomain);
|
|
|
|
if (!rvTD) {
|
2001-09-21 00:40:03 +04:00
|
|
|
goto loser;
|
|
|
|
}
|
2001-09-14 02:16:22 +04:00
|
|
|
rvTD->arena = arena;
|
2001-09-19 00:55:01 +04:00
|
|
|
rvTD->refCount = 1;
|
2001-10-11 20:34:49 +04:00
|
|
|
nssTrustDomain_InitializeCache(rvTD, NSSTRUSTDOMAIN_DEFAULT_CACHE_SIZE);
|
2002-01-10 03:45:27 +03:00
|
|
|
#ifdef NSS_3_4_CODE
|
|
|
|
rvTD->statusConfig = NULL;
|
|
|
|
#endif
|
2001-09-14 02:16:22 +04:00
|
|
|
return rvTD;
|
2001-09-21 00:40:03 +04:00
|
|
|
loser:
|
|
|
|
nssArena_Destroy(arena);
|
|
|
|
return (NSSTrustDomain *)NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-10-12 21:54:50 +04:00
|
|
|
token_destructor(void *t)
|
2001-09-21 00:40:03 +04:00
|
|
|
{
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSToken *tok = (NSSToken *)t;
|
|
|
|
#ifdef NSS_3_4_CODE
|
|
|
|
/* in 3.4, also destroy the slot (managed separately) */
|
|
|
|
(void)nssSlot_Destroy(tok->slot);
|
|
|
|
#endif
|
|
|
|
(void)nssToken_Destroy(tok);
|
2001-09-21 00:40:03 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_Destroy
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td
|
|
|
|
)
|
|
|
|
{
|
2001-09-19 00:55:01 +04:00
|
|
|
if (--td->refCount == 0) {
|
2001-10-11 20:34:49 +04:00
|
|
|
/* Destroy each token in the list of tokens */
|
|
|
|
if (td->tokens) {
|
2002-01-08 18:37:42 +03:00
|
|
|
nssListIterator_Destroy(td->tokens);
|
2001-11-28 19:23:51 +03:00
|
|
|
nssList_Clear(td->tokenList, token_destructor);
|
|
|
|
nssList_Destroy(td->tokenList);
|
2001-09-21 00:40:03 +04:00
|
|
|
}
|
2001-11-29 22:34:08 +03:00
|
|
|
nssTrustDomain_DestroyCache(td);
|
2001-09-21 00:40:03 +04:00
|
|
|
/* Destroy the trust domain */
|
2001-09-19 00:55:01 +04:00
|
|
|
nssArena_Destroy(td->arena);
|
|
|
|
}
|
|
|
|
return PR_SUCCESS;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_SetDefaultCallback
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSCallback *newCallback,
|
|
|
|
NSSCallback **oldCallbackOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCallback *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_GetDefaultCallback
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
PRStatus *statusOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_LoadModule
|
|
|
|
(
|
2001-09-14 02:16:22 +04:00
|
|
|
NSSTrustDomain *td,
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSUTF8 *moduleOpt,
|
|
|
|
NSSUTF8 *uriOpt,
|
|
|
|
NSSUTF8 *opaqueOpt,
|
|
|
|
void *reserved
|
|
|
|
)
|
|
|
|
{
|
2001-10-11 20:34:49 +04:00
|
|
|
return PR_FAILURE;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_DisableToken
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSToken *token,
|
|
|
|
NSSError why
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_EnableToken
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSToken *token
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_IsTokenEnabled
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSToken *token,
|
|
|
|
NSSError *whyOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSSlot *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindSlotByName
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *slotName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSToken *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindTokenByName
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *tokenName
|
|
|
|
)
|
|
|
|
{
|
2001-10-17 18:40:27 +04:00
|
|
|
PRStatus nssrv;
|
|
|
|
NSSUTF8 *myName;
|
|
|
|
NSSToken *tok = NULL;
|
|
|
|
for (tok = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
tok != (NSSToken *)NULL;
|
|
|
|
tok = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
myName = nssToken_GetName(tok);
|
|
|
|
if (nssUTF8_Equal(tokenName, myName, &nssrv)) break;
|
|
|
|
}
|
|
|
|
nssListIterator_Finish(td->tokens);
|
|
|
|
return tok;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSToken *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindTokenBySlotName
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *slotName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSToken *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindTokenForAlgorithm
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSOID *algorithm
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSToken *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestTokenForAlgorithms
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSOID *algorithms[], /* may be null-terminated */
|
|
|
|
PRUint32 nAlgorithmsOpt /* limits the array if nonzero */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_Login
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_Logout
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportCertificate
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSCertificate *c
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportPKIXCertificate
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
/* declared as a struct until these "data types" are defined */
|
|
|
|
struct NSSPKIXCertificateStr *pc
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportEncodedCertificate
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSBER *ber
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportEncodedCertificateChain
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSBER *ber,
|
|
|
|
NSSCertificate *rvOpt[],
|
|
|
|
PRUint32 maximumOpt, /* 0 for no max */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSPrivateKey *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportEncodedPrivateKey
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSBER *ber,
|
|
|
|
NSSItem *passwordOpt, /* NULL will cause a callback */
|
|
|
|
NSSCallback *uhhOpt,
|
|
|
|
NSSToken *destination
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSPublicKey *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_ImportEncodedPublicKey
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSBER *ber
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-01-03 23:09:30 +03:00
|
|
|
static void cert_destructor(void *el)
|
|
|
|
{
|
|
|
|
NSSCertificate *c = (NSSCertificate *)el;
|
|
|
|
NSSCertificate_Destroy(c);
|
|
|
|
}
|
|
|
|
|
2001-10-11 20:34:49 +04:00
|
|
|
struct collect_arg_str {
|
|
|
|
nssList *list;
|
|
|
|
PRUint32 maximum;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const NSSError NSS_ERROR_MAXIMUM_FOUND;
|
|
|
|
|
|
|
|
static PRStatus
|
|
|
|
collect_certs(NSSCertificate *c, void *arg)
|
|
|
|
{
|
|
|
|
struct collect_arg_str *ca = (struct collect_arg_str *)arg;
|
2002-01-10 00:09:21 +03:00
|
|
|
/* Add the cert to the return list if not present */
|
|
|
|
if (!nssList_Get(ca->list, (void *)c)) {
|
|
|
|
nssCertificate_AddRef(c);
|
|
|
|
nssList_Add(ca->list, (void *)c);
|
|
|
|
}
|
2001-10-11 20:34:49 +04:00
|
|
|
if (ca->maximum > 0 && nssList_Count(ca->list) >= ca->maximum) {
|
|
|
|
/* signal the end of collection) */
|
|
|
|
nss_SetError(NSS_ERROR_MAXIMUM_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
return PR_SUCCESS;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-10-12 21:54:50 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
|
|
|
NSSTrustDomain_FindBestCertificateByNickname
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *name,
|
|
|
|
NSSTime *timeOpt, /* NULL for "now" */
|
|
|
|
NSSUsage *usage,
|
|
|
|
NSSPolicies *policiesOpt /* NULL for none */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
PRStatus nssrv;
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSToken *token;
|
|
|
|
nssTokenCertSearch search;
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificateCB best;
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList *nameList;
|
|
|
|
/* set the criteria for determining the best cert */
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificate_SetArgs(&best, timeOpt, usage, policiesOpt);
|
2001-10-12 21:54:50 +04:00
|
|
|
/* find all matching certs in the cache */
|
|
|
|
nameList = nssList_Create(NULL, PR_FALSE);
|
|
|
|
(void)nssTrustDomain_GetCertsForNicknameFromCache(td, name, nameList);
|
2001-11-28 19:23:51 +03:00
|
|
|
/* set the search criteria */
|
2001-12-14 20:32:23 +03:00
|
|
|
search.callback = nssBestCertificate_Callback;
|
2001-11-28 19:23:51 +03:00
|
|
|
search.cbarg = &best;
|
|
|
|
search.cached = nameList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
nssrv = nssToken_TraverseCertificatesByNickname(token, NULL,
|
|
|
|
name, &search);
|
2001-10-12 21:54:50 +04:00
|
|
|
}
|
2001-11-28 19:23:51 +03:00
|
|
|
nssListIterator_Finish(td->tokens);
|
2002-01-03 23:09:30 +03:00
|
|
|
nssList_Clear(nameList, cert_destructor);
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList_Destroy(nameList);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (best.cert) {
|
|
|
|
nssTrustDomain_AddCertsToCache(td, &best.cert, 1);
|
|
|
|
}
|
|
|
|
return best.cert;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-10-17 18:40:27 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
|
|
|
NSSTrustDomain_FindCertificatesByNickname
|
2001-10-11 20:34:49 +04:00
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
2001-10-17 18:40:27 +04:00
|
|
|
NSSUTF8 *name,
|
|
|
|
NSSCertificate *rvOpt[],
|
|
|
|
PRUint32 maximumOpt, /* 0 for no max */
|
|
|
|
NSSArena *arenaOpt
|
2001-10-11 20:34:49 +04:00
|
|
|
)
|
|
|
|
{
|
2001-10-17 18:40:27 +04:00
|
|
|
NSSCertificate **rvCerts = NULL;
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSToken *token;
|
|
|
|
PRUint32 count;
|
2001-10-17 18:40:27 +04:00
|
|
|
PRStatus nssrv;
|
2001-11-28 19:23:51 +03:00
|
|
|
nssList *nameList;
|
2001-10-17 18:40:27 +04:00
|
|
|
struct collect_arg_str ca;
|
2001-11-28 19:23:51 +03:00
|
|
|
nssTokenCertSearch search;
|
|
|
|
/* set up the collection */
|
|
|
|
nameList = nssList_Create(NULL, PR_FALSE);
|
|
|
|
(void)nssTrustDomain_GetCertsForNicknameFromCache(td, name, nameList);
|
|
|
|
ca.list = nameList;
|
2001-10-17 18:40:27 +04:00
|
|
|
ca.maximum = maximumOpt;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* set the search criteria */
|
|
|
|
search.callback = collect_certs;
|
|
|
|
search.cbarg = &ca;
|
|
|
|
search.cached = nameList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
nssrv = nssToken_TraverseCertificatesByNickname(token, NULL,
|
|
|
|
name, &search);
|
|
|
|
}
|
|
|
|
nssListIterator_Finish(td->tokens);
|
|
|
|
count = nssList_Count(nameList);
|
|
|
|
if (maximumOpt > 0 && count > maximumOpt) count = maximumOpt;
|
|
|
|
if (count > 0) {
|
|
|
|
if (rvOpt) {
|
|
|
|
nssList_GetArray(nameList, (void **)rvOpt, count);
|
|
|
|
rvOpt[count] = NULL;
|
|
|
|
} else {
|
|
|
|
rvCerts = nss_ZNEWARRAY(arenaOpt, NSSCertificate *, count + 1);
|
|
|
|
nssList_GetArray(nameList, (void **)rvCerts, count);
|
|
|
|
}
|
|
|
|
nssTrustDomain_AddCertsToCache(td, rvCerts, count);
|
|
|
|
}
|
|
|
|
nssList_Destroy(nameList);
|
2002-01-10 00:09:21 +03:00
|
|
|
/* The return array assumes the references from the list */
|
2001-10-17 18:40:27 +04:00
|
|
|
return rvCerts;
|
2001-10-11 20:34:49 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificateByIssuerAndSerialNumber
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSDER *issuer,
|
|
|
|
NSSDER *serialNumber
|
|
|
|
)
|
|
|
|
{
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSCertificate *rvCert = NULL;
|
|
|
|
NSSToken *tok;
|
|
|
|
/* Try the cache */
|
|
|
|
rvCert = nssTrustDomain_GetCertForIssuerAndSNFromCache(td,
|
|
|
|
issuer,
|
|
|
|
serialNumber);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (rvCert) {
|
|
|
|
return rvCert;
|
|
|
|
}
|
|
|
|
/* Not cached, look for it on tokens */
|
|
|
|
for (tok = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
tok != (NSSToken *)NULL;
|
|
|
|
tok = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
rvCert = nssToken_FindCertificateByIssuerAndSerialNumber(tok,
|
|
|
|
NULL,
|
|
|
|
issuer,
|
2001-12-11 23:28:38 +03:00
|
|
|
serialNumber,
|
2001-12-14 23:50:59 +03:00
|
|
|
nssTokenSearchType_TokenOnly);
|
2002-01-23 20:00:39 +03:00
|
|
|
#ifdef NSS_3_4_CODE
|
|
|
|
if (!rvCert) {
|
|
|
|
/* Some tokens expect a decoded serial number. For compatibility,
|
|
|
|
* try the search again.
|
|
|
|
*/
|
|
|
|
NSSDER decodedSerial;
|
|
|
|
SECItem ds = { 0 };
|
|
|
|
SECItem sn;
|
|
|
|
SECStatus secrv;
|
|
|
|
sn.data = serialNumber->data;
|
|
|
|
sn.len = serialNumber->size;
|
|
|
|
secrv = SEC_ASN1DecodeItem(NULL, &ds, SEC_IntegerTemplate, &sn);
|
|
|
|
if (secrv == SECSuccess) {
|
|
|
|
decodedSerial.data = ds.data;
|
|
|
|
decodedSerial.size = ds.len;
|
|
|
|
rvCert = nssToken_FindCertificateByIssuerAndSerialNumber(tok,
|
|
|
|
NULL,
|
|
|
|
issuer,
|
|
|
|
&decodedSerial,
|
|
|
|
nssTokenSearchType_TokenOnly);
|
|
|
|
PORT_Free(ds.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2001-11-28 19:23:51 +03:00
|
|
|
if (rvCert) {
|
|
|
|
/* cache it */
|
|
|
|
nssTrustDomain_AddCertsToCache(td, &rvCert, 1);
|
|
|
|
break;
|
2001-10-12 21:54:50 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-28 19:23:51 +03:00
|
|
|
nssListIterator_Finish(td->tokens);
|
2001-10-12 21:54:50 +04:00
|
|
|
return rvCert;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestCertificateBySubject
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSDER *subject,
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTime *timeOpt,
|
|
|
|
NSSUsage *usage,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
2001-11-28 19:23:51 +03:00
|
|
|
PRStatus nssrv;
|
|
|
|
NSSToken *token;
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList *subjectList;
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificateCB best;
|
2001-11-28 19:23:51 +03:00
|
|
|
nssTokenCertSearch search;
|
|
|
|
/* set the criteria for determining the best cert */
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificate_SetArgs(&best, timeOpt, usage, policiesOpt);
|
2001-11-28 19:23:51 +03:00
|
|
|
/* find all matching certs in the cache */
|
2001-10-12 21:54:50 +04:00
|
|
|
subjectList = nssList_Create(NULL, PR_FALSE);
|
|
|
|
(void)nssTrustDomain_GetCertsForSubjectFromCache(td, subject, subjectList);
|
2001-11-28 19:23:51 +03:00
|
|
|
/* set the search criteria */
|
2001-12-14 20:32:23 +03:00
|
|
|
search.callback = nssBestCertificate_Callback;
|
2001-11-28 19:23:51 +03:00
|
|
|
search.cbarg = &best;
|
|
|
|
search.cached = subjectList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
nssrv = nssToken_TraverseCertificatesBySubject(token, NULL,
|
|
|
|
subject, &search);
|
|
|
|
}
|
|
|
|
nssListIterator_Finish(td->tokens);
|
2002-01-03 23:09:30 +03:00
|
|
|
nssList_Clear(subjectList, cert_destructor);
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList_Destroy(subjectList);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (best.cert) {
|
|
|
|
nssTrustDomain_AddCertsToCache(td, &best.cert, 1);
|
|
|
|
}
|
|
|
|
return best.cert;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificatesBySubject
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSDER *subject,
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSCertificate *rvOpt[],
|
|
|
|
PRUint32 maximumOpt, /* 0 for no max */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
2001-11-28 19:23:51 +03:00
|
|
|
PRStatus nssrv;
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSCertificate **rvCerts = NULL;
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSToken *token;
|
|
|
|
PRUint32 count;
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList *subjectList;
|
|
|
|
struct collect_arg_str ca;
|
2001-11-28 19:23:51 +03:00
|
|
|
nssTokenCertSearch search;
|
|
|
|
/* set up the collection */
|
2001-10-12 21:54:50 +04:00
|
|
|
subjectList = nssList_Create(NULL, PR_FALSE);
|
|
|
|
(void)nssTrustDomain_GetCertsForSubjectFromCache(td, subject, subjectList);
|
|
|
|
ca.list = subjectList;
|
|
|
|
ca.maximum = maximumOpt;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* set the search criteria */
|
|
|
|
search.callback = collect_certs;
|
|
|
|
search.cbarg = &ca;
|
|
|
|
search.cached = subjectList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
nssrv = nssToken_TraverseCertificatesBySubject(token, NULL,
|
|
|
|
subject, &search);
|
|
|
|
}
|
|
|
|
nssListIterator_Finish(td->tokens);
|
|
|
|
count = nssList_Count(subjectList);
|
|
|
|
if (maximumOpt > 0 && count > maximumOpt) count = maximumOpt;
|
|
|
|
if (count > 0) {
|
|
|
|
if (rvOpt) {
|
|
|
|
nssList_GetArray(subjectList, (void **)rvOpt, count);
|
|
|
|
rvOpt[count] = NULL;
|
|
|
|
} else {
|
|
|
|
rvCerts = nss_ZNEWARRAY(arenaOpt, NSSCertificate *, count + 1);
|
|
|
|
nssList_GetArray(subjectList, (void **)rvCerts, count);
|
|
|
|
}
|
|
|
|
nssTrustDomain_AddCertsToCache(td, rvCerts, count);
|
|
|
|
}
|
2001-10-12 21:54:50 +04:00
|
|
|
nssList_Destroy(subjectList);
|
2002-01-10 00:09:21 +03:00
|
|
|
/* The return array assumes the references from the list */
|
2001-10-12 21:54:50 +04:00
|
|
|
return rvCerts;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestCertificateByNameComponents
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *nameComponents,
|
|
|
|
NSSTime *timeOpt,
|
|
|
|
NSSUsage *usage,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificatesByNameComponents
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *nameComponents,
|
|
|
|
NSSCertificate *rvOpt[],
|
|
|
|
PRUint32 maximumOpt, /* 0 for no max */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificateByEncodedCertificate
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSBER *encodedCertificate
|
|
|
|
)
|
|
|
|
{
|
2001-10-12 21:54:50 +04:00
|
|
|
NSSCertificate *rvCert = NULL;
|
|
|
|
NSSToken *tok;
|
|
|
|
/* Try the cache */
|
|
|
|
rvCert = nssTrustDomain_GetCertByDERFromCache(td, encodedCertificate);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (rvCert) {
|
|
|
|
return rvCert;
|
|
|
|
}
|
|
|
|
/* Not cached, look for it on tokens */
|
|
|
|
for (tok = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
tok != (NSSToken *)NULL;
|
|
|
|
tok = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
rvCert = nssToken_FindCertificateByEncodedCertificate(tok, NULL,
|
2001-12-11 23:28:38 +03:00
|
|
|
encodedCertificate,
|
2001-12-14 23:50:59 +03:00
|
|
|
nssTokenSearchType_TokenOnly);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (rvCert) {
|
|
|
|
/* cache it */
|
|
|
|
nssTrustDomain_AddCertsToCache(td, &rvCert, 1);
|
|
|
|
break;
|
2001-10-12 21:54:50 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-28 19:23:51 +03:00
|
|
|
nssListIterator_Finish(td->tokens);
|
2001-10-12 21:54:50 +04:00
|
|
|
return rvCert;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificateByEmail
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSASCII7 *email,
|
|
|
|
NSSTime *timeOpt,
|
|
|
|
NSSUsage *usage,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
2001-11-08 08:19:32 +03:00
|
|
|
PRStatus nssrv;
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSToken *token;
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificateCB best;
|
2001-11-28 19:23:51 +03:00
|
|
|
nssTokenCertSearch search;
|
2001-11-08 08:19:32 +03:00
|
|
|
nssList *emailList;
|
|
|
|
/* set the criteria for determining the best cert */
|
2001-12-14 20:32:23 +03:00
|
|
|
nssBestCertificate_SetArgs(&best, timeOpt, usage, policiesOpt);
|
2001-11-08 08:19:32 +03:00
|
|
|
/* find all matching certs in the cache */
|
|
|
|
emailList = nssList_Create(NULL, PR_FALSE);
|
|
|
|
(void)nssTrustDomain_GetCertsForEmailAddressFromCache(td, email, emailList);
|
2001-11-28 19:23:51 +03:00
|
|
|
/* set the search criteria */
|
2001-12-14 20:32:23 +03:00
|
|
|
search.callback = nssBestCertificate_Callback;
|
2001-11-28 19:23:51 +03:00
|
|
|
search.cbarg = &best;
|
|
|
|
search.cached = emailList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
|
|
|
{
|
|
|
|
nssrv = nssToken_TraverseCertificatesByEmail(token, NULL,
|
|
|
|
email, &search);
|
2001-11-08 08:19:32 +03:00
|
|
|
}
|
2001-11-28 19:23:51 +03:00
|
|
|
nssListIterator_Finish(td->tokens);
|
2002-01-03 23:09:30 +03:00
|
|
|
nssList_Clear(emailList, cert_destructor);
|
2001-11-08 08:19:32 +03:00
|
|
|
nssList_Destroy(emailList);
|
2001-11-28 19:23:51 +03:00
|
|
|
if (best.cert) {
|
|
|
|
nssTrustDomain_AddCertsToCache(td, &best.cert, 1);
|
|
|
|
}
|
|
|
|
return best.cert;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificatesByEmail
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSASCII7 *email,
|
|
|
|
NSSCertificate *rvOpt[],
|
|
|
|
PRUint32 maximumOpt, /* 0 for no max */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindCertificateByOCSPHash
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSItem *hash
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestUserCertificate
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSTime *timeOpt,
|
|
|
|
NSSUsage *usage,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindUserCertificates
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSTime *timeOpt,
|
|
|
|
NSSUsage *usageOpt,
|
|
|
|
NSSPolicies *policiesOpt,
|
|
|
|
NSSCertificate **rvOpt,
|
|
|
|
PRUint32 rvLimit, /* zero for no limit */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestUserCertificateForSSLClientAuth
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *sslHostOpt,
|
|
|
|
NSSDER *rootCAsOpt[], /* null pointer for none */
|
|
|
|
PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
|
|
|
|
NSSAlgorithmAndParameters *apOpt,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindUserCertificatesForSSLClientAuth
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSUTF8 *sslHostOpt,
|
|
|
|
NSSDER *rootCAsOpt[], /* null pointer for none */
|
|
|
|
PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
|
|
|
|
NSSAlgorithmAndParameters *apOpt,
|
|
|
|
NSSPolicies *policiesOpt,
|
|
|
|
NSSCertificate **rvOpt,
|
|
|
|
PRUint32 rvLimit, /* zero for no limit */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindBestUserCertificateForEmailSigning
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSASCII7 *signerOpt,
|
|
|
|
NSSASCII7 *recipientOpt,
|
|
|
|
/* anything more here? */
|
|
|
|
NSSAlgorithmAndParameters *apOpt,
|
|
|
|
NSSPolicies *policiesOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCertificate **
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindUserCertificatesForEmailSigning
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSASCII7 *signerOpt,
|
|
|
|
NSSASCII7 *recipientOpt,
|
|
|
|
/* anything more here? */
|
|
|
|
NSSAlgorithmAndParameters *apOpt,
|
|
|
|
NSSPolicies *policiesOpt,
|
|
|
|
NSSCertificate **rvOpt,
|
|
|
|
PRUint32 rvLimit, /* zero for no limit */
|
|
|
|
NSSArena *arenaOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-09-14 02:16:22 +04:00
|
|
|
|
|
|
|
NSS_IMPLEMENT PRStatus *
|
|
|
|
NSSTrustDomain_TraverseCertificates
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
PRStatus (*callback)(NSSCertificate *c, void *arg),
|
|
|
|
void *arg
|
|
|
|
)
|
|
|
|
{
|
2001-11-20 21:28:49 +03:00
|
|
|
PRStatus nssrv;
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSToken *token;
|
|
|
|
nssList *certList;
|
|
|
|
nssTokenCertSearch search;
|
2001-11-30 01:05:32 +03:00
|
|
|
certList = nssList_Create(NULL, PR_FALSE);
|
2001-11-28 19:23:51 +03:00
|
|
|
(void *)nssTrustDomain_GetCertsFromCache(td, certList);
|
|
|
|
/* set the search criteria */
|
|
|
|
search.callback = callback;
|
|
|
|
search.cbarg = arg;
|
|
|
|
search.cached = certList;
|
2001-12-14 23:50:59 +03:00
|
|
|
search.searchType = nssTokenSearchType_TokenOnly;
|
2001-11-28 19:23:51 +03:00
|
|
|
/* traverse the tokens */
|
|
|
|
for (token = (NSSToken *)nssListIterator_Start(td->tokens);
|
|
|
|
token != (NSSToken *)NULL;
|
|
|
|
token = (NSSToken *)nssListIterator_Next(td->tokens))
|
2001-11-20 21:28:49 +03:00
|
|
|
{
|
2001-11-28 19:23:51 +03:00
|
|
|
nssrv = nssToken_TraverseCertificates(token, NULL, &search);
|
2001-11-20 21:28:49 +03:00
|
|
|
}
|
|
|
|
nssListIterator_Finish(td->tokens);
|
2002-01-03 23:09:30 +03:00
|
|
|
nssList_Clear(certList, cert_destructor);
|
2001-11-28 19:23:51 +03:00
|
|
|
nssList_Destroy(certList);
|
|
|
|
return NULL;
|
2001-09-14 02:16:22 +04:00
|
|
|
}
|
2001-07-20 00:41:38 +04:00
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT PRStatus
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_GenerateKeyPair
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSAlgorithmAndParameters *ap,
|
|
|
|
NSSPrivateKey **pvkOpt,
|
|
|
|
NSSPublicKey **pbkOpt,
|
|
|
|
PRBool privateKeyIsSensitive,
|
|
|
|
NSSToken *destination,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return PR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSSymmetricKey *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_GenerateSymmetricKey
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSAlgorithmAndParameters *ap,
|
|
|
|
PRUint32 keysize,
|
|
|
|
NSSToken *destination,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSSymmetricKey *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_GenerateSymmetricKeyFromPassword
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSAlgorithmAndParameters *ap,
|
|
|
|
NSSUTF8 *passwordOpt, /* if null, prompt */
|
|
|
|
NSSToken *destinationOpt,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSSymmetricKey *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_FindSymmetricKeyByAlgorithmAndKeyID
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSOID *algorithm,
|
|
|
|
NSSItem *keyID,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCryptoContext *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_CreateCryptoContext
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSCallback *uhhOpt
|
|
|
|
)
|
|
|
|
{
|
2001-11-28 19:23:51 +03:00
|
|
|
NSSArena *arena;
|
|
|
|
NSSCryptoContext *rvCC;
|
|
|
|
arena = NSSArena_Create();
|
|
|
|
if (!arena) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rvCC = nss_ZNEW(arena, NSSCryptoContext);
|
|
|
|
if (!rvCC) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
rvCC->td = td;
|
2001-11-29 22:34:08 +03:00
|
|
|
rvCC->arena = arena;
|
2001-11-28 19:23:51 +03:00
|
|
|
return rvCC;
|
2001-07-20 00:41:38 +04:00
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCryptoContext *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_CreateCryptoContextForAlgorithm
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSOID *algorithm
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-09-14 02:16:22 +04:00
|
|
|
NSS_IMPLEMENT NSSCryptoContext *
|
2001-07-20 00:41:38 +04:00
|
|
|
NSSTrustDomain_CreateCryptoContextForAlgorithmAndParameters
|
|
|
|
(
|
|
|
|
NSSTrustDomain *td,
|
|
|
|
NSSAlgorithmAndParameters *ap
|
|
|
|
)
|
|
|
|
{
|
|
|
|
nss_SetError(NSS_ERROR_NOT_FOUND);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|