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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/ckfw/nssmkey/msession.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     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 "ckmk.h"
     1.9 +
    1.10 +/*
    1.11 + * nssmkey/msession.c
    1.12 + *
    1.13 + * This file implements the NSSCKMDSession object for the 
    1.14 + * "nssmkey" cryptoki module.
    1.15 + */
    1.16 +
    1.17 +static NSSCKMDFindObjects *
    1.18 +ckmk_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_ckmk_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError);
    1.32 +}
    1.33 +
    1.34 +static NSSCKMDObject *
    1.35 +ckmk_mdSession_CreateObject
    1.36 +(
    1.37 +  NSSCKMDSession *mdSession,
    1.38 +  NSSCKFWSession *fwSession,
    1.39 +  NSSCKMDToken *mdToken,
    1.40 +  NSSCKFWToken *fwToken,
    1.41 +  NSSCKMDInstance *mdInstance,
    1.42 +  NSSCKFWInstance *fwInstance,
    1.43 +  NSSArena        *arena,
    1.44 +  CK_ATTRIBUTE_PTR pTemplate,
    1.45 +  CK_ULONG ulAttributeCount,
    1.46 +  CK_RV *pError
    1.47 +)
    1.48 +{
    1.49 +  return nss_ckmk_CreateObject(fwSession, pTemplate, ulAttributeCount, pError);
    1.50 +}
    1.51 +
    1.52 +NSS_IMPLEMENT NSSCKMDSession *
    1.53 +nss_ckmk_CreateSession
    1.54 +(
    1.55 +  NSSCKFWSession *fwSession,
    1.56 +  CK_RV *pError
    1.57 +)
    1.58 +{
    1.59 +  NSSArena *arena;
    1.60 +  NSSCKMDSession *rv;
    1.61 +
    1.62 +  arena = NSSCKFWSession_GetArena(fwSession, pError);
    1.63 +  if( (NSSArena *)NULL == arena ) {
    1.64 +    return (NSSCKMDSession *)NULL;
    1.65 +  }
    1.66 +
    1.67 +  rv = nss_ZNEW(arena, NSSCKMDSession);
    1.68 +  if( (NSSCKMDSession *)NULL == rv ) {
    1.69 +    *pError = CKR_HOST_MEMORY;
    1.70 +    return (NSSCKMDSession *)NULL;
    1.71 +  }
    1.72 +
    1.73 +  /* 
    1.74 +   * rv was zeroed when allocated, so we only 
    1.75 +   * need to set the non-zero members.
    1.76 +   */
    1.77 +
    1.78 +  rv->etc = (void *)fwSession;
    1.79 +  /* rv->Close */
    1.80 +  /* rv->GetDeviceError */
    1.81 +  /* rv->Login */
    1.82 +  /* rv->Logout */
    1.83 +  /* rv->InitPIN */
    1.84 +  /* rv->SetPIN */
    1.85 +  /* rv->GetOperationStateLen */
    1.86 +  /* rv->GetOperationState */
    1.87 +  /* rv->SetOperationState */
    1.88 +  rv->CreateObject = ckmk_mdSession_CreateObject;
    1.89 +  /* rv->CopyObject */
    1.90 +  rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit;
    1.91 +  /* rv->SeedRandom */
    1.92 +  /* rv->GetRandom */
    1.93 +  /* rv->null */
    1.94 +
    1.95 +  return rv;
    1.96 +}

mercurial