sdb.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. * This file implements PKCS 11 on top of our existing security modules
  6. *
  7. * For more information about PKCS 11 See PKCS 11 Token Inteface Standard.
  8. * This implementation has two slots:
  9. * slot 1 is our generic crypto support. It does not require login.
  10. * It supports Public Key ops, and all they bulk ciphers and hashes.
  11. * It can also support Private Key ops for imported Private keys. It does
  12. * not have any token storage.
  13. * slot 2 is our private key support. It requires a login before use. It
  14. * can store Private Keys and Certs as token objects. Currently only private
  15. * keys and their associated Certificates are saved on the token.
  16. *
  17. * In this implementation, session objects are only visible to the session
  18. * that created or generated them.
  19. */
  20. /*
  21. * the following data structures should be moved to a 'rdb.h'.
  22. */
  23. #ifndef _SDB_H
  24. #define _SDB_H 1
  25. #include "pkcs11t.h"
  26. #include "secitem.h"
  27. #include "sftkdbt.h"
  28. #define STATIC_CMD_SIZE 2048
  29. typedef struct SDBFindStr SDBFind;
  30. typedef struct SDBStr SDB;
  31. struct SDBStr {
  32. void *private;
  33. int version;
  34. int reserved;
  35. int sdb_flags;
  36. void *app_private;
  37. CK_RV(*sdb_FindObjectsInit)
  38. (SDB *sdb, const CK_ATTRIBUTE *template,
  39. CK_ULONG count, SDBFind **find);
  40. CK_RV(*sdb_FindObjects)
  41. (SDB *sdb, SDBFind *find, CK_OBJECT_HANDLE *ids,
  42. CK_ULONG arraySize, CK_ULONG *count);
  43. CK_RV(*sdb_FindObjectsFinal)
  44. (SDB *sdb, SDBFind *find);
  45. CK_RV(*sdb_GetAttributeValue)
  46. (SDB *sdb, CK_OBJECT_HANDLE object,
  47. CK_ATTRIBUTE *template, CK_ULONG count);
  48. CK_RV(*sdb_SetAttributeValue)
  49. (SDB *sdb, CK_OBJECT_HANDLE object,
  50. const CK_ATTRIBUTE *template, CK_ULONG count);
  51. CK_RV(*sdb_CreateObject)
  52. (SDB *sdb, CK_OBJECT_HANDLE *object,
  53. const CK_ATTRIBUTE *template, CK_ULONG count);
  54. CK_RV(*sdb_DestroyObject)
  55. (SDB *sdb, CK_OBJECT_HANDLE object);
  56. CK_RV(*sdb_GetMetaData)
  57. (SDB *sdb, const char *id,
  58. SECItem *item1, SECItem *item2);
  59. CK_RV(*sdb_PutMetaData)
  60. (SDB *sdb, const char *id,
  61. const SECItem *item1, const SECItem *item2);
  62. CK_RV(*sdb_Begin)
  63. (SDB *sdb);
  64. CK_RV(*sdb_Commit)
  65. (SDB *sdb);
  66. CK_RV(*sdb_Abort)
  67. (SDB *sdb);
  68. CK_RV(*sdb_Reset)
  69. (SDB *sdb);
  70. CK_RV(*sdb_Close)
  71. (SDB *sdb);
  72. void (*sdb_SetForkState)(PRBool forked);
  73. CK_RV(*sdb_GetNewObjectID)
  74. (SDB *db, CK_OBJECT_HANDLE *object);
  75. CK_RV(*sdb_DestroyMetaData)
  76. (SDB *db, const char *id);
  77. };
  78. CK_RV s_open(const char *directory, const char *certPrefix,
  79. const char *keyPrefix,
  80. int cert_version, int key_version,
  81. int flags, SDB **certdb, SDB **keydb, int *newInit);
  82. CK_RV s_shutdown();
  83. #if defined(_WIN32)
  84. wchar_t *sdb_UTF8ToWide(const char *buf);
  85. #endif
  86. /* flags */
  87. #define SDB_RDONLY 1
  88. #define SDB_RDWR 2
  89. #define SDB_CREATE 4
  90. #define SDB_HAS_META 8
  91. #define SDB_FIPS 0x10
  92. #endif