michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ckmk.h" michael@0: michael@0: /* michael@0: * nssmkey/msession.c michael@0: * michael@0: * This file implements the NSSCKMDSession object for the michael@0: * "nssmkey" cryptoki module. michael@0: */ michael@0: michael@0: static NSSCKMDFindObjects * michael@0: ckmk_mdSession_FindObjectsInit michael@0: ( michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: CK_ATTRIBUTE_PTR pTemplate, michael@0: CK_ULONG ulAttributeCount, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: return nss_ckmk_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError); michael@0: } michael@0: michael@0: static NSSCKMDObject * michael@0: ckmk_mdSession_CreateObject michael@0: ( michael@0: NSSCKMDSession *mdSession, michael@0: NSSCKFWSession *fwSession, michael@0: NSSCKMDToken *mdToken, michael@0: NSSCKFWToken *fwToken, michael@0: NSSCKMDInstance *mdInstance, michael@0: NSSCKFWInstance *fwInstance, michael@0: NSSArena *arena, michael@0: CK_ATTRIBUTE_PTR pTemplate, michael@0: CK_ULONG ulAttributeCount, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: return nss_ckmk_CreateObject(fwSession, pTemplate, ulAttributeCount, pError); michael@0: } michael@0: michael@0: NSS_IMPLEMENT NSSCKMDSession * michael@0: nss_ckmk_CreateSession michael@0: ( michael@0: NSSCKFWSession *fwSession, michael@0: CK_RV *pError michael@0: ) michael@0: { michael@0: NSSArena *arena; michael@0: NSSCKMDSession *rv; michael@0: michael@0: arena = NSSCKFWSession_GetArena(fwSession, pError); michael@0: if( (NSSArena *)NULL == arena ) { michael@0: return (NSSCKMDSession *)NULL; michael@0: } michael@0: michael@0: rv = nss_ZNEW(arena, NSSCKMDSession); michael@0: if( (NSSCKMDSession *)NULL == rv ) { michael@0: *pError = CKR_HOST_MEMORY; michael@0: return (NSSCKMDSession *)NULL; michael@0: } michael@0: michael@0: /* michael@0: * rv was zeroed when allocated, so we only michael@0: * need to set the non-zero members. michael@0: */ michael@0: michael@0: rv->etc = (void *)fwSession; michael@0: /* rv->Close */ michael@0: /* rv->GetDeviceError */ michael@0: /* rv->Login */ michael@0: /* rv->Logout */ michael@0: /* rv->InitPIN */ michael@0: /* rv->SetPIN */ michael@0: /* rv->GetOperationStateLen */ michael@0: /* rv->GetOperationState */ michael@0: /* rv->SetOperationState */ michael@0: rv->CreateObject = ckmk_mdSession_CreateObject; michael@0: /* rv->CopyObject */ michael@0: rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit; michael@0: /* rv->SeedRandom */ michael@0: /* rv->GetRandom */ michael@0: /* rv->null */ michael@0: michael@0: return rv; michael@0: }