sftkdbti.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifndef SFTKDBTI_H
  5. #define SFTKDBTI_H 1
  6. /*
  7. * private defines
  8. */
  9. struct SFTKDBHandleStr {
  10. SDB *db;
  11. PRInt32 ref;
  12. CK_OBJECT_HANDLE type;
  13. SECItem passwordKey;
  14. int defaultIterationCount;
  15. SECItem *newKey;
  16. int newDefaultIterationCount;
  17. SECItem *oldKey;
  18. SECItem *updatePasswordKey;
  19. PZLock *passwordLock;
  20. SFTKDBHandle *peerDB;
  21. SDB *update;
  22. char *updateID;
  23. PRBool updateDBIsInit;
  24. PRBool usesLegacyStorage;
  25. };
  26. #define SFTK_KEYDB_TYPE 0x40000000
  27. #define SFTK_CERTDB_TYPE 0x00000000
  28. #define SFTK_OBJ_TYPE_MASK 0xc0000000
  29. #define SFTK_OBJ_ID_MASK (~SFTK_OBJ_TYPE_MASK)
  30. #define SFTK_TOKEN_TYPE 0x80000000
  31. /* the following is the number of id's to handle on the stack at a time,
  32. * it's not an upper limit of IDS that can be stored in the database */
  33. #define SFTK_MAX_IDS 10
  34. #define SFTK_GET_SDB(handle) \
  35. ((handle)->update ? (handle)->update : (handle)->db)
  36. SECStatus sftkdb_DecryptAttribute(SFTKDBHandle *handle,
  37. SECItem *passKey,
  38. CK_OBJECT_HANDLE id,
  39. CK_ATTRIBUTE_TYPE attrType,
  40. SECItem *cipherText, SECItem **plainText);
  41. SECStatus sftkdb_EncryptAttribute(PLArenaPool *arena,
  42. SFTKDBHandle *handle, SDB *db,
  43. SECItem *passKey,
  44. int iterationCount,
  45. CK_OBJECT_HANDLE id,
  46. CK_ATTRIBUTE_TYPE attrType,
  47. SECItem *plainText, SECItem **cipherText);
  48. SECStatus sftkdb_SignAttribute(PLArenaPool *arena,
  49. SFTKDBHandle *handle, SDB *db,
  50. SECItem *passKey,
  51. int iterationCount, CK_OBJECT_HANDLE objectID,
  52. CK_ATTRIBUTE_TYPE attrType,
  53. SECItem *plainText, SECItem **sigText);
  54. SECStatus sftkdb_VerifyAttribute(SFTKDBHandle *handle,
  55. SECItem *passKey,
  56. CK_OBJECT_HANDLE objectID,
  57. CK_ATTRIBUTE_TYPE attrType,
  58. SECItem *plainText, SECItem *sigText);
  59. PRBool sftkdb_isULONGAttribute(CK_ATTRIBUTE_TYPE type);
  60. void sftk_ULong2SDBULong(unsigned char *data, CK_ULONG value);
  61. CK_RV sftkdb_Update(SFTKDBHandle *handle, SECItem *key);
  62. CK_RV sftkdb_PutAttributeSignature(SFTKDBHandle *handle,
  63. SDB *keyTarget, CK_OBJECT_HANDLE objectID,
  64. CK_ATTRIBUTE_TYPE type, SECItem *signText);
  65. CK_RV sftkdb_GetAttributeSignature(SFTKDBHandle *handle,
  66. SFTKDBHandle *keyHandle,
  67. CK_OBJECT_HANDLE objectID,
  68. CK_ATTRIBUTE_TYPE type,
  69. SECItem *signText);
  70. CK_RV
  71. sftkdb_DestroyAttributeSignature(SFTKDBHandle *handle, SDB *db,
  72. CK_OBJECT_HANDLE objectID,
  73. CK_ATTRIBUTE_TYPE type);
  74. #endif