1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/lib/ckfw/builtins/bsession.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "builtins.h" 1.9 + 1.10 +/* 1.11 + * builtins/session.c 1.12 + * 1.13 + * This file implements the NSSCKMDSession object for the 1.14 + * "builtin objects" cryptoki module. 1.15 + */ 1.16 + 1.17 +static NSSCKMDFindObjects * 1.18 +builtins_mdSession_FindObjectsInit 1.19 +( 1.20 + NSSCKMDSession *mdSession, 1.21 + NSSCKFWSession *fwSession, 1.22 + NSSCKMDToken *mdToken, 1.23 + NSSCKFWToken *fwToken, 1.24 + NSSCKMDInstance *mdInstance, 1.25 + NSSCKFWInstance *fwInstance, 1.26 + CK_ATTRIBUTE_PTR pTemplate, 1.27 + CK_ULONG ulAttributeCount, 1.28 + CK_RV *pError 1.29 +) 1.30 +{ 1.31 + return nss_builtins_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError); 1.32 +} 1.33 + 1.34 +NSS_IMPLEMENT NSSCKMDSession * 1.35 +nss_builtins_CreateSession 1.36 +( 1.37 + NSSCKFWSession *fwSession, 1.38 + CK_RV *pError 1.39 +) 1.40 +{ 1.41 + NSSArena *arena; 1.42 + NSSCKMDSession *rv; 1.43 + 1.44 + arena = NSSCKFWSession_GetArena(fwSession, pError); 1.45 + if( (NSSArena *)NULL == arena ) { 1.46 + return (NSSCKMDSession *)NULL; 1.47 + } 1.48 + 1.49 + rv = nss_ZNEW(arena, NSSCKMDSession); 1.50 + if( (NSSCKMDSession *)NULL == rv ) { 1.51 + *pError = CKR_HOST_MEMORY; 1.52 + return (NSSCKMDSession *)NULL; 1.53 + } 1.54 + 1.55 + /* 1.56 + * rv was zeroed when allocated, so we only 1.57 + * need to set the non-zero members. 1.58 + */ 1.59 + 1.60 + rv->etc = (void *)fwSession; 1.61 + /* rv->Close */ 1.62 + /* rv->GetDeviceError */ 1.63 + /* rv->Login */ 1.64 + /* rv->Logout */ 1.65 + /* rv->InitPIN */ 1.66 + /* rv->SetPIN */ 1.67 + /* rv->GetOperationStateLen */ 1.68 + /* rv->GetOperationState */ 1.69 + /* rv->SetOperationState */ 1.70 + /* rv->CreateObject */ 1.71 + /* rv->CopyObject */ 1.72 + rv->FindObjectsInit = builtins_mdSession_FindObjectsInit; 1.73 + /* rv->SeedRandom */ 1.74 + /* rv->GetRandom */ 1.75 + /* rv->null */ 1.76 + 1.77 + return rv; 1.78 +}