security/nss/lib/ckfw/capi/csession.c

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "ckcapi.h"
     7 /*
     8  * ckcapi/csession.c
     9  *
    10  * This file implements the NSSCKMDSession object for the 
    11  * "nss to capi" cryptoki module.
    12  */
    14 static NSSCKMDFindObjects *
    15 ckcapi_mdSession_FindObjectsInit
    16 (
    17   NSSCKMDSession *mdSession,
    18   NSSCKFWSession *fwSession,
    19   NSSCKMDToken *mdToken,
    20   NSSCKFWToken *fwToken,
    21   NSSCKMDInstance *mdInstance,
    22   NSSCKFWInstance *fwInstance,
    23   CK_ATTRIBUTE_PTR pTemplate,
    24   CK_ULONG ulAttributeCount,
    25   CK_RV *pError
    26 )
    27 {
    28   return nss_ckcapi_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError);
    29 }
    31 static NSSCKMDObject *
    32 ckcapi_mdSession_CreateObject
    33 (
    34   NSSCKMDSession *mdSession,
    35   NSSCKFWSession *fwSession,
    36   NSSCKMDToken *mdToken,
    37   NSSCKFWToken *fwToken,
    38   NSSCKMDInstance *mdInstance,
    39   NSSCKFWInstance *fwInstance,
    40   NSSArena        *arena,
    41   CK_ATTRIBUTE_PTR pTemplate,
    42   CK_ULONG ulAttributeCount,
    43   CK_RV *pError
    44 )
    45 {
    46   return nss_ckcapi_CreateObject(fwSession, pTemplate, ulAttributeCount, pError);
    47 }
    49 NSS_IMPLEMENT NSSCKMDSession *
    50 nss_ckcapi_CreateSession
    51 (
    52   NSSCKFWSession *fwSession,
    53   CK_RV *pError
    54 )
    55 {
    56   NSSArena *arena;
    57   NSSCKMDSession *rv;
    59   arena = NSSCKFWSession_GetArena(fwSession, pError);
    60   if( (NSSArena *)NULL == arena ) {
    61     return (NSSCKMDSession *)NULL;
    62   }
    64   rv = nss_ZNEW(arena, NSSCKMDSession);
    65   if( (NSSCKMDSession *)NULL == rv ) {
    66     *pError = CKR_HOST_MEMORY;
    67     return (NSSCKMDSession *)NULL;
    68   }
    70   /* 
    71    * rv was zeroed when allocated, so we only 
    72    * need to set the non-zero members.
    73    */
    75   rv->etc = (void *)fwSession;
    76   /* rv->Close */
    77   /* rv->GetDeviceError */
    78   /* rv->Login */
    79   /* rv->Logout */
    80   /* rv->InitPIN */
    81   /* rv->SetPIN */
    82   /* rv->GetOperationStateLen */
    83   /* rv->GetOperationState */
    84   /* rv->SetOperationState */
    85   rv->CreateObject = ckcapi_mdSession_CreateObject;
    86   /* rv->CopyObject */
    87   rv->FindObjectsInit = ckcapi_mdSession_FindObjectsInit;
    88   /* rv->SeedRandom */
    89   /* rv->GetRandom */
    90   /* rv->null */
    92   return rv;
    93 }

mercurial