utilparst.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 UTILPARS_T_H
  5. #define UTILPARS_T_H 1
  6. #include "pkcs11t.h"
  7. /*
  8. * macros to handle parsing strings of blank sparated arguments.
  9. * Several NSSUTIL_HANDLE_STRING() macros should be places one after another with no intervening
  10. * code. The first ones have precedence over the later ones. The last Macro should be
  11. * NSSUTIL_HANDLE_FINAL_ARG.
  12. *
  13. * param is the input parameters. On exit param will point to the next parameter to parse. If the
  14. * last paramter has been returned, param points to a null byte (*param = '0');
  15. * target is the location to store any data aquired from the parameter. Caller is responsible to free this data.
  16. * value is the string value of the parameter.
  17. * command is any commands you need to run to help process the parameter's data.
  18. */
  19. #define NSSUTIL_HANDLE_STRING_ARG(param, target, value, command) \
  20. if (PORT_Strncasecmp(param, value, sizeof(value) - 1) == 0) { \
  21. param += sizeof(value) - 1; \
  22. if (target) \
  23. PORT_Free(target); \
  24. target = NSSUTIL_ArgFetchValue(param, &next); \
  25. param += next; \
  26. command; \
  27. } else
  28. #define NSSUTIL_HANDLE_FINAL_ARG(param) \
  29. { \
  30. param = NSSUTIL_ArgSkipParameter(param); \
  31. } \
  32. param = NSSUTIL_ArgStrip(param);
  33. #define NSSUTIL_PATH_SEPARATOR "/"
  34. /* default module configuration strings */
  35. #define NSSUTIL_DEFAULT_INTERNAL_INIT1 \
  36. "library= name=\"NSS Internal PKCS #11 Module\" parameters="
  37. #define NSSUTIL_DEFAULT_INTERNAL_INIT2 \
  38. " NSS=\"Flags=internal,critical trustOrder=75 cipherOrder=100 slotParams=(1={"
  39. #define NSSUTIL_DEFAULT_INTERNAL_INIT3 \
  40. " askpw=any timeout=30})\""
  41. #define NSSUTIL_DEFAULT_SFTKN_FLAGS \
  42. "slotFlags=[ECC,RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512]"
  43. #define NSSUTIL_DEFAULT_CIPHER_ORDER 0
  44. #define NSSUTIL_DEFAULT_TRUST_ORDER 50
  45. #define NSSUTIL_ARG_ESCAPE '\\'
  46. /* hold slot default flags until we initialize a slot. This structure is only
  47. * useful between the time we define a module (either by hand or from the
  48. * database) and the time the module is loaded. Not reference counted */
  49. struct NSSUTILPreSlotInfoStr {
  50. CK_SLOT_ID slotID; /* slot these flags are for */
  51. unsigned long defaultFlags; /* bit mask of default implementation this slot
  52. * provides */
  53. int askpw; /* slot specific password bits */
  54. long timeout; /* slot specific timeout value */
  55. char hasRootCerts; /* is this the root cert PKCS #11 module? */
  56. char hasRootTrust; /* is this the root cert PKCS #11 module? */
  57. int reserved0[2];
  58. void *reserved1[2];
  59. };
  60. /*
  61. * private functions for softoken.
  62. */
  63. typedef enum {
  64. NSS_DB_TYPE_NONE = 0,
  65. NSS_DB_TYPE_SQL,
  66. NSS_DB_TYPE_EXTERN,
  67. NSS_DB_TYPE_LEGACY,
  68. NSS_DB_TYPE_MULTIACCESS
  69. } NSSDBType;
  70. #endif /* UTILPARS_T_H */