cinst.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include "ckcapi.h"
  5. /*
  6. * ckcapi/cinstance.c
  7. *
  8. * This file implements the NSSCKMDInstance object for the
  9. * "capi" cryptoki module.
  10. */
  11. /*
  12. * NSSCKMDInstance methods
  13. */
  14. static CK_ULONG
  15. ckcapi_mdInstance_GetNSlots(
  16. NSSCKMDInstance *mdInstance,
  17. NSSCKFWInstance *fwInstance,
  18. CK_RV *pError)
  19. {
  20. return (CK_ULONG)1;
  21. }
  22. static CK_VERSION
  23. ckcapi_mdInstance_GetCryptokiVersion(
  24. NSSCKMDInstance *mdInstance,
  25. NSSCKFWInstance *fwInstance)
  26. {
  27. return nss_ckcapi_CryptokiVersion;
  28. }
  29. static NSSUTF8 *
  30. ckcapi_mdInstance_GetManufacturerID(
  31. NSSCKMDInstance *mdInstance,
  32. NSSCKFWInstance *fwInstance,
  33. CK_RV *pError)
  34. {
  35. return (NSSUTF8 *)nss_ckcapi_ManufacturerID;
  36. }
  37. static NSSUTF8 *
  38. ckcapi_mdInstance_GetLibraryDescription(
  39. NSSCKMDInstance *mdInstance,
  40. NSSCKFWInstance *fwInstance,
  41. CK_RV *pError)
  42. {
  43. return (NSSUTF8 *)nss_ckcapi_LibraryDescription;
  44. }
  45. static CK_VERSION
  46. ckcapi_mdInstance_GetLibraryVersion(
  47. NSSCKMDInstance *mdInstance,
  48. NSSCKFWInstance *fwInstance)
  49. {
  50. return nss_ckcapi_LibraryVersion;
  51. }
  52. static CK_RV
  53. ckcapi_mdInstance_GetSlots(
  54. NSSCKMDInstance *mdInstance,
  55. NSSCKFWInstance *fwInstance,
  56. NSSCKMDSlot *slots[])
  57. {
  58. slots[0] = (NSSCKMDSlot *)&nss_ckcapi_mdSlot;
  59. return CKR_OK;
  60. }
  61. static CK_BBOOL
  62. ckcapi_mdInstance_ModuleHandlesSessionObjects(
  63. NSSCKMDInstance *mdInstance,
  64. NSSCKFWInstance *fwInstance)
  65. {
  66. /* we don't want to allow any session object creation, at least
  67. * until we can investigate whether or not we can use those objects
  68. */
  69. return CK_TRUE;
  70. }
  71. NSS_IMPLEMENT_DATA const NSSCKMDInstance
  72. nss_ckcapi_mdInstance = {
  73. (void *)NULL, /* etc */
  74. NULL, /* Initialize */
  75. NULL, /* Finalize */
  76. ckcapi_mdInstance_GetNSlots,
  77. ckcapi_mdInstance_GetCryptokiVersion,
  78. ckcapi_mdInstance_GetManufacturerID,
  79. ckcapi_mdInstance_GetLibraryDescription,
  80. ckcapi_mdInstance_GetLibraryVersion,
  81. ckcapi_mdInstance_ModuleHandlesSessionObjects,
  82. /*NULL, /* HandleSessionObjects */
  83. ckcapi_mdInstance_GetSlots,
  84. NULL, /* WaitForSlotEvent */
  85. (void *)NULL /* null terminator */
  86. };