security/nss/lib/ckfw/nssmkey/msession.c

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 #include "ckmk.h"
michael@0 6
michael@0 7 /*
michael@0 8 * nssmkey/msession.c
michael@0 9 *
michael@0 10 * This file implements the NSSCKMDSession object for the
michael@0 11 * "nssmkey" cryptoki module.
michael@0 12 */
michael@0 13
michael@0 14 static NSSCKMDFindObjects *
michael@0 15 ckmk_mdSession_FindObjectsInit
michael@0 16 (
michael@0 17 NSSCKMDSession *mdSession,
michael@0 18 NSSCKFWSession *fwSession,
michael@0 19 NSSCKMDToken *mdToken,
michael@0 20 NSSCKFWToken *fwToken,
michael@0 21 NSSCKMDInstance *mdInstance,
michael@0 22 NSSCKFWInstance *fwInstance,
michael@0 23 CK_ATTRIBUTE_PTR pTemplate,
michael@0 24 CK_ULONG ulAttributeCount,
michael@0 25 CK_RV *pError
michael@0 26 )
michael@0 27 {
michael@0 28 return nss_ckmk_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError);
michael@0 29 }
michael@0 30
michael@0 31 static NSSCKMDObject *
michael@0 32 ckmk_mdSession_CreateObject
michael@0 33 (
michael@0 34 NSSCKMDSession *mdSession,
michael@0 35 NSSCKFWSession *fwSession,
michael@0 36 NSSCKMDToken *mdToken,
michael@0 37 NSSCKFWToken *fwToken,
michael@0 38 NSSCKMDInstance *mdInstance,
michael@0 39 NSSCKFWInstance *fwInstance,
michael@0 40 NSSArena *arena,
michael@0 41 CK_ATTRIBUTE_PTR pTemplate,
michael@0 42 CK_ULONG ulAttributeCount,
michael@0 43 CK_RV *pError
michael@0 44 )
michael@0 45 {
michael@0 46 return nss_ckmk_CreateObject(fwSession, pTemplate, ulAttributeCount, pError);
michael@0 47 }
michael@0 48
michael@0 49 NSS_IMPLEMENT NSSCKMDSession *
michael@0 50 nss_ckmk_CreateSession
michael@0 51 (
michael@0 52 NSSCKFWSession *fwSession,
michael@0 53 CK_RV *pError
michael@0 54 )
michael@0 55 {
michael@0 56 NSSArena *arena;
michael@0 57 NSSCKMDSession *rv;
michael@0 58
michael@0 59 arena = NSSCKFWSession_GetArena(fwSession, pError);
michael@0 60 if( (NSSArena *)NULL == arena ) {
michael@0 61 return (NSSCKMDSession *)NULL;
michael@0 62 }
michael@0 63
michael@0 64 rv = nss_ZNEW(arena, NSSCKMDSession);
michael@0 65 if( (NSSCKMDSession *)NULL == rv ) {
michael@0 66 *pError = CKR_HOST_MEMORY;
michael@0 67 return (NSSCKMDSession *)NULL;
michael@0 68 }
michael@0 69
michael@0 70 /*
michael@0 71 * rv was zeroed when allocated, so we only
michael@0 72 * need to set the non-zero members.
michael@0 73 */
michael@0 74
michael@0 75 rv->etc = (void *)fwSession;
michael@0 76 /* rv->Close */
michael@0 77 /* rv->GetDeviceError */
michael@0 78 /* rv->Login */
michael@0 79 /* rv->Logout */
michael@0 80 /* rv->InitPIN */
michael@0 81 /* rv->SetPIN */
michael@0 82 /* rv->GetOperationStateLen */
michael@0 83 /* rv->GetOperationState */
michael@0 84 /* rv->SetOperationState */
michael@0 85 rv->CreateObject = ckmk_mdSession_CreateObject;
michael@0 86 /* rv->CopyObject */
michael@0 87 rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit;
michael@0 88 /* rv->SeedRandom */
michael@0 89 /* rv->GetRandom */
michael@0 90 /* rv->null */
michael@0 91
michael@0 92 return rv;
michael@0 93 }

mercurial