nscert.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #ifndef __nscert_h
  7. #define __nscert_h
  8. /*
  9. * Description (nscert.h)
  10. *
  11. * This file describes the interface for accessing and storing
  12. * information in a Netscape client certificate to username
  13. * database. This facility is built on top of the Netscape
  14. * (server) database interface as defined in nsdb.h.
  15. */
  16. #include <libaccess/nserror.h> /* error frame list support */
  17. #include <libaccess/nsautherr.h> /* authentication error codes */
  18. #include <libaccess/nsauth.h>
  19. #include <prtypes.h>
  20. /* Removed for new ns security integration
  21. #include <sec.h>
  22. */
  23. #include <cert.h>
  24. #if defined(CLIENT_AUTH)
  25. /* Certificate to user record attribute tags */
  26. #define CAT_USERNAME 0x61 /* username associated with cert */
  27. #define CAT_CERTID 0x62 /* id assigned to cert */
  28. /* Attribute tags used in certificate key encoding */
  29. #define KAT_ISSUER 0x01 /* issuer DER */
  30. #define KAT_SUBJECT 0x02 /* subject DER */
  31. typedef struct CertObj_s CertObj_t;
  32. struct CertObj_s {
  33. SECItem co_issuer; /* issuing authority */
  34. SECItem co_subject; /* certicate's subject */
  35. char * co_username; /* the local name it mapps to */
  36. USI_t co_certid; /* internal id for this client certificate */
  37. };
  38. typedef int (*CertEnumCallback)(NSErr_t * ferrp, void * authdb,
  39. void * argp, CertObj_t * coptr);
  40. NSPR_BEGIN_EXTERN_C
  41. extern NSAPI_PUBLIC int nsadbCertInitialize(void);
  42. extern NSAPI_PUBLIC int nsadbDecodeCertKey(int keylen, char * keyptr,
  43. SECItem * issuer,
  44. SECItem * subject);
  45. extern NSAPI_PUBLIC int nsadbDecodeCertRec(int reclen, char * recptr,
  46. CertObj_t * coptr);
  47. extern NSAPI_PUBLIC int nsadbEncodeCertKey(SECItem * issuer, SECItem * subject,
  48. int * keylen, char **keyptr);
  49. extern NSAPI_PUBLIC int nsadbEnumerateCerts(NSErr_t * errp, void * authdb,
  50. void * argp,
  51. CertEnumCallback func);
  52. extern NSAPI_PUBLIC void nsadbFreeCertObj(CertObj_t * coptr);
  53. extern NSAPI_PUBLIC int nsadbGetCertById(NSErr_t * errp, void * authdb,
  54. USI_t certid, CertObj_t **coptr);
  55. extern NSAPI_PUBLIC int nsadbGetUserByCert(NSErr_t * errp, void * authdb,
  56. CERTCertificate * cert,
  57. char **username);
  58. extern NSAPI_PUBLIC int nsadbOpenCerts(NSErr_t * errp,
  59. void * authdb, int flags);
  60. extern NSAPI_PUBLIC int nsadbPutUserByCert(NSErr_t * errp, void * authdb,
  61. CERTCertificate * cert,
  62. const char * username);
  63. extern NSAPI_PUBLIC int nsadbRemoveCert(NSErr_t * errp, void * authdb,
  64. void * username, CertObj_t * coptr);
  65. extern NSAPI_PUBLIC int nsadbRemoveUserCert(NSErr_t * errp, void * authdb,
  66. char * username);
  67. extern NSAPI_PUBLIC void nsadbCloseCerts(void * authdb, int flags);
  68. extern NSAPI_PUBLIC void nsadbCloseCertUsers(void * authdb, int flags);
  69. extern NSAPI_PUBLIC int nsadbFindCertUser(NSErr_t * errp, void * authdb,
  70. const char * username, USI_t * id);
  71. NSPR_END_EXTERN_C
  72. #endif /* CLIENT_AUTH */
  73. #endif /* __nscert_h */