tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bsession.c (1809B)


      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/. */
      4 
      5 #include "builtins.h"
      6 
      7 /*
      8 * builtins/session.c
      9 *
     10 * This file implements the NSSCKMDSession object for the
     11 * "builtin objects" cryptoki module.
     12 */
     13 
     14 static NSSCKMDFindObjects *
     15 builtins_mdSession_FindObjectsInit(
     16    NSSCKMDSession *mdSession,
     17    NSSCKFWSession *fwSession,
     18    NSSCKMDToken *mdToken,
     19    NSSCKFWToken *fwToken,
     20    NSSCKMDInstance *mdInstance,
     21    NSSCKFWInstance *fwInstance,
     22    CK_ATTRIBUTE_PTR pTemplate,
     23    CK_ULONG ulAttributeCount,
     24    CK_RV *pError)
     25 {
     26    return nss_builtins_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError);
     27 }
     28 
     29 NSS_IMPLEMENT NSSCKMDSession *
     30 nss_builtins_CreateSession(
     31    NSSCKFWSession *fwSession,
     32    CK_RV *pError)
     33 {
     34    NSSArena *arena;
     35    NSSCKMDSession *rv;
     36 
     37    arena = NSSCKFWSession_GetArena(fwSession, pError);
     38    if ((NSSArena *)NULL == arena) {
     39        return (NSSCKMDSession *)NULL;
     40    }
     41 
     42    rv = nss_ZNEW(arena, NSSCKMDSession);
     43    if ((NSSCKMDSession *)NULL == rv) {
     44        *pError = CKR_HOST_MEMORY;
     45        return (NSSCKMDSession *)NULL;
     46    }
     47 
     48    /*
     49     * rv was zeroed when allocated, so we only
     50     * need to set the non-zero members.
     51     */
     52 
     53    rv->etc = (void *)fwSession;
     54    /* rv->Close */
     55    /* rv->GetDeviceError */
     56    /* rv->Login */
     57    /* rv->Logout */
     58    /* rv->InitPIN */
     59    /* rv->SetPIN */
     60    /* rv->GetOperationStateLen */
     61    /* rv->GetOperationState */
     62    /* rv->SetOperationState */
     63    /* rv->CreateObject */
     64    /* rv->CopyObject */
     65    rv->FindObjectsInit = builtins_mdSession_FindObjectsInit;
     66    /* rv->SeedRandom */
     67    /* rv->GetRandom */
     68    /* rv->null */
     69 
     70    return rv;
     71 }