Print this page
9643 PKCS#11 tests should not use CRYPTO_INVALID_SESSION
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
          +++ new/usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13   13   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       14 + * Copyright 2018, Joyent, Inc.
  14   15   */
  15   16  
  16   17  #include <stdio.h>
  17   18  #include <cryptoutil.h>
       19 +#include <security/cryptoki.h>
  18   20  
  19   21  #include "cryptotest.h"
  20   22  
  21   23  struct crypto_op {
  22   24          CK_BYTE_PTR in;
  23   25          CK_BYTE_PTR out;
  24   26          CK_BYTE_PTR key;
  25   27          CK_BYTE_PTR param;
  26   28  
  27   29          size_t inlen;
↓ open down ↓ 29 lines elided ↑ open up ↑
  57   59          op->param = (CK_BYTE_PTR)arg->param;
  58   60  
  59   61          op->inlen = arg->inlen;
  60   62          op->outlen = arg->outlen;
  61   63          op->keylen = arg->keylen;
  62   64          op->paramlen = arg->plen;
  63   65          op->updatelen = arg->updatelen;
  64   66  
  65   67          op->mechname = arg->mechname;
  66   68  
  67      -        op->hsession = CRYPTO_INVALID_SESSION;
       69 +        op->hsession = CK_INVALID_HANDLE;
  68   70          op->fg = fg;
  69   71  
  70   72          if (op->out == NULL)
  71   73                  op->outlen = op->inlen;
  72   74          return (op);
  73   75  }
  74   76  
  75   77  int
  76   78  cryptotest_close_session(CK_SESSION_HANDLE hsession)
  77   79  {
↓ open down ↓ 2 lines elided ↑ open up ↑
  80   82          if (rv != CKR_OK)
  81   83                  cryptotest_error("cryptotest_close_session", rv);
  82   84  
  83   85          return (rv);
  84   86  }
  85   87  
  86   88  int
  87   89  cryptotest_close(crypto_op_t *op)
  88   90  {
  89   91          (void) C_DestroyObject(op->hsession, op->keyt);
  90      -        if (op->hsession != CRYPTO_INVALID_SESSION)
       92 +        if (op->hsession != CK_INVALID_HANDLE)
  91   93                  (void) cryptotest_close_session(op->hsession);
  92   94          free(op);
  93   95          return (C_Finalize(NULL));
  94   96  }
  95   97  
  96   98  int
  97   99  get_mech_info(crypto_op_t *op)
  98  100  {
  99  101          CK_RV rv;
 100  102          rv = pkcs11_str2mech(op->mechname, &op->mech);
↓ open down ↓ 301 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX