extcmap.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef _PUBLIC_CERTMAP_H
  13. #define _PUBLIC_CERTMAP_H
  14. #include <ldap.h>
  15. #ifndef NSAPI_PUBLIC
  16. #define NSAPI_PUBLIC
  17. #endif
  18. #define LDAPU_ATTR_INITFN "InitFn"
  19. #define LDAPU_ATTR_LIBRARY "library"
  20. #define LDAPU_ATTR_DNCOMPS "DNComps"
  21. #define LDAPU_ATTR_FILTERCOMPS "FilterComps"
  22. #define LDAPU_ATTR_VERIFYCERT "VerifyCert"
  23. #define LDAPU_ATTR_CERTMAP_LDAP_ATTR "CmapLdapAttr"
  24. /* Error/Success codes */
  25. #define LDAPU_SUCCESS 0
  26. #define LDAPU_FAILED -1
  27. #define LDAPU_CERT_MAP_FUNCTION_FAILED -2
  28. #define LDAPU_CERT_SEARCH_FUNCTION_FAILED -3
  29. #define LDAPU_CERT_VERIFY_FUNCTION_FAILED -4
  30. #define LDAPU_CERT_MAP_INITFN_FAILED -5
  31. /*
  32. * CertMapFn_t -
  33. * This is a typedef for cert mapping function. The mapping function is
  34. * called by the function ldapu_cert_to_ldap_entry.
  35. * Parameters:
  36. * cert - cert to be mapped. You can pass this to
  37. * functions ldapu_get_cert_XYZ.
  38. * ld - Handle to the connection to the directory server.
  39. * certmap_info - This structure contains information about the
  40. * configuration parameters for the cert's issuer (CA).
  41. * This structure can be passed to the function
  42. * ldapu_certmap_info_attrval to get value for a particular
  43. * configuration attribute (or a property).
  44. * ldapdn - The mapping function should allocate memory for ldapdn
  45. * using malloc and set this variable using the 'cert' and
  46. * 'certmap_info'. This DN will be used for ldap lookup.
  47. * filter - The mapping function should allocate memory for filter
  48. * using malloc and set this variable using the 'cert' and
  49. * 'certmap_info'. This will be used as ldap filter for ldap
  50. * lookup of the ldapdn.
  51. *
  52. * Return Value:
  53. * return LDAPU_SUCCESS upon successful completion (cert is mapped)
  54. * return LDAPU_FAILED there is no unexpected error but cert could not
  55. * mapped (probably because ldap entry doesn't exist).
  56. * otherwise return LDAPU_CERT_MAP_FUNCTION_FAILED.
  57. */
  58. typedef int (*CertMapFn_t)(void *cert, LDAP *ld, void *certmap_info,
  59. char **ldapdn, char **filter);
  60. /*
  61. * CertSearchFn_t -
  62. * This is a typedef for cert search function. The search function is
  63. * called by the function ldapu_cert_to_ldap_entry after calling the mapping
  64. * function. The candidate 'dn' and 'filter' returned by the mapping
  65. * function is passed to this function.
  66. * The default search function works as follows:
  67. * 1. If the 'filter' is NULL, default it to 'objectclass=*'.
  68. * 2. If the 'dn' is non-NULL, do a base level search with the 'dn' and
  69. * 'filter'. If it succeeds, we are done. If there is no serious
  70. * error (LDAP_NO_SUCH_OBJECT is not serious error yet), continue.
  71. * 3. If the 'dn' is NULL, default it to 'basedn'.
  72. * 4. Perform a 'subtree' search in LDAP for the 'dn' and the 'filter'.
  73. * 5. Return the results of the last search.
  74. * Parameters:
  75. * cert - cert to be mapped. You can pass this to
  76. * functions ldapu_get_cert_XYZ.
  77. * ld - Handle to the connection to the directory server.
  78. * certmap_info - This structure contains information about the
  79. * configuration parameters for the cert's issuer (CA).
  80. * This structure can be passed to the function
  81. * ldapu_certmap_info_attrval to get value for a particular
  82. * configuration attribute (or a property).
  83. * suffix - If the ldapdn is empty then use this DN to begin the
  84. * search. This is the DN of the root object in LDAP
  85. * Directory.
  86. * ldapdn - candidate 'dn' returned by the mapping function.
  87. * filter - returned by the mapping function.
  88. * attrs - list of attributes to return from the search. If this is
  89. * NULL, all attributes are returned.
  90. * res - result of the search which is passed to the verify
  91. * function.
  92. *
  93. * Return Value:
  94. * return LDAPU_SUCCESS upon successful completion
  95. * return LDAPU_FAILED there is no unexpected error but entries matching the
  96. * 'dn' and 'filter' doesn't exist.
  97. * otherwise return LDAPU_CERT_SEARCH_FUNCTION_FAILED.
  98. */
  99. typedef int (*CertSearchFn_t)(void *cert, LDAP *ld, void *certmap_info,
  100. const char *suffix, const char *ldapdn,
  101. const char *filter, const char **attrs,
  102. LDAPMessage ***res);
  103. /*
  104. * CertVerifyFn_t -
  105. * This is a typedef for cert verify function. The verify function is
  106. * called by the function ldapu_cert_to_ldap_entry after the cert is
  107. * successfully mapped to ldapdn and filter, and an entry matching that
  108. * exists in the directory server. The verify fn may get called for
  109. * multiple matched entries. This function must go through all the entries
  110. * and check which one is appropriate. The pointer to that entry must be
  111. * passed back in the 'LDAPMessage **entry' parameter.
  112. * Parameters:
  113. * cert - Original cert to be mapped. You can pass this to
  114. * functions ldapu_get_cert_XYZ.
  115. * ld - Handle to the connection to the directory server.
  116. * certmap_info - This structure contains information about the
  117. * configuration parameters for the cert's issuer (CA).
  118. * This structure can be passed to the function
  119. * ldapu_certmap_info_attrval to get value for a particular
  120. * configuration attribute (or a property).
  121. * res - cert is first mapped to ldapdn and filter. 'res' is the
  122. * result of ldap search using the ldapdn and filter.
  123. * 'ld' and 'res' can be used in the calls to ldapsdk API.
  124. * entry - pointer to the entry from 'res' which is the correct match
  125. * according to the verify function.
  126. *
  127. * Return Values:
  128. * return LDAPU_SUCCESS upon successful completion (cert is verified)
  129. * return LDAPU_FAILED there is no unexpected error but cert could not
  130. * verified (probably because it was revoked).
  131. * otherwise return LDAPU_CERT_VERIFY_FUNCTION_FAILED.
  132. */
  133. typedef int (*CertVerifyFn_t)(void *cert, LDAP *ld, void *certmap_info,
  134. LDAPMessage *res, LDAPMessage **entry);
  135. /*
  136. * CertmapInitFn_t -
  137. * This is a typedef for user defined init function. An init function can be
  138. * specified in the config file (<ServerRoot>/userdb/certmap.conf) per issuer
  139. * of a certificate. This init function must from the user's library, also
  140. * loaded from the config file using the 'library' property. The init
  141. * function is specified in the config file using the 'InitFn' property.
  142. * When the config file is loaded, any user defined init functions will be
  143. * called with the certmap_info pertaining to the issuer (CA).
  144. * Parameters:
  145. * certmap_info - This structure contains information about the
  146. * configuration parameters for the cert's issuer (CA).
  147. * This structure can be passed to the function
  148. * ldapu_certmap_info_attrval to get value for a particular
  149. * configuration attribute (or a property).
  150. *
  151. * Return Value:
  152. * return LDAPU_SUCCESS upon successful completion
  153. * otherwise return LDAPU_CERT_MAP_INITFN_FAILED. The server startup will be
  154. * aborted if the return value is not LDAPU_SUCCESS.
  155. */
  156. typedef int (*CertMapInitFn_t)(void *certmap_info, const char *issuerName,
  157. const char *issuerDN, const char *libname);
  158. /*
  159. * Refer to the description of the function ldapu_get_cert_ava_val
  160. */
  161. enum {
  162. LDAPU_SUBJECT_DN,
  163. LDAPU_ISSUER_DN
  164. };
  165. /* ldapu_cert_to_ldap_entry */
  166. typedef int (*t_ldapu_cert_to_ldap_entry)(void *cert, LDAP *ld,
  167. const char *suffix,
  168. LDAPMessage **res);
  169. /* ldapu_set_cert_mapfn */
  170. typedef int (*t_ldapu_set_cert_mapfn)(const char *issuerDN,
  171. CertMapFn_t mapfn);
  172. /* ldapu_get_cert_mapfn */
  173. typedef CertMapFn_t (*t_ldapu_get_cert_mapfn) (const char *issuerDN);
  174. /* ldapu_set_cert_searchfn */
  175. typedef int (*t_ldapu_set_cert_searchfn) (const char *issuerDN,
  176. CertSearchFn_t searchfn);
  177. /* ldapu_get_cert_searchfn */
  178. typedef CertSearchFn_t (*t_ldapu_get_cert_searchfn) (const char *issuerDN);
  179. /* ldapu_set_cert_verifyfn */
  180. typedef int (*t_ldapu_set_cert_verifyfn) (const char *issuerDN,
  181. CertVerifyFn_t verifyFn);
  182. /* ldapu_get_cert_verifyfn */
  183. typedef CertVerifyFn_t (*t_ldapu_get_cert_verifyfn) (const char *issuerDN);
  184. /* ldapu_get_cert_subject_dn */
  185. typedef int (*t_ldapu_get_cert_subject_dn) (void *cert, char **subjectDN);
  186. /* ldapu_get_cert_issuer_dn */
  187. typedef int (*t_ldapu_get_cert_issuer_dn) (void *cert, char **issuerDN);
  188. /* ldapu_get_cert_ava_val */
  189. typedef int (*t_ldapu_get_cert_ava_val) (void *cert, int which_dn,
  190. const char *attr, char ***val);
  191. /* ldapu_free_cert_ava_val */
  192. typedef int (*t_ldapu_free_cert_ava_val) (char **val);
  193. /* ldapu_get_cert_der */
  194. typedef int (*t_ldapu_get_cert_der) (void *cert, unsigned char **derCert,
  195. unsigned int *len);
  196. /* ldapu_issuer_certinfo */
  197. typedef int (*t_ldapu_issuer_certinfo) (const char *issuerDN,
  198. void **certmap_info);
  199. /* ldapu_certmap_info_attrval */
  200. typedef int (*t_ldapu_certmap_info_attrval) (void *certmap_info,
  201. const char *attr, char **val);
  202. /* ldapu_err2string */
  203. typedef char * (*t_ldapu_err2string) (int err);
  204. /* ldapu_free */
  205. typedef void (*t_ldapu_free_old) (char *ptr);
  206. typedef void (*t_ldapu_free) (void *ptr);
  207. /* ldapu_malloc */
  208. typedef void *(*t_ldapu_malloc) (int size);
  209. /* ldapu_strdup */
  210. typedef char *(*t_ldapu_strdup) (const char *ptr);
  211. typedef struct LDAPUDispatchVector LDAPUDispatchVector_t;
  212. struct LDAPUDispatchVector {
  213. t_ldapu_cert_to_ldap_entry f_ldapu_cert_to_ldap_entry;
  214. t_ldapu_set_cert_mapfn f_ldapu_set_cert_mapfn;
  215. t_ldapu_get_cert_mapfn f_ldapu_get_cert_mapfn;
  216. t_ldapu_set_cert_searchfn f_ldapu_set_cert_searchfn;
  217. t_ldapu_get_cert_searchfn f_ldapu_get_cert_searchfn;
  218. t_ldapu_set_cert_verifyfn f_ldapu_set_cert_verifyfn;
  219. t_ldapu_get_cert_verifyfn f_ldapu_get_cert_verifyfn;
  220. t_ldapu_get_cert_subject_dn f_ldapu_get_cert_subject_dn;
  221. t_ldapu_get_cert_issuer_dn f_ldapu_get_cert_issuer_dn;
  222. t_ldapu_get_cert_ava_val f_ldapu_get_cert_ava_val;
  223. t_ldapu_free_cert_ava_val f_ldapu_free_cert_ava_val;
  224. t_ldapu_get_cert_der f_ldapu_get_cert_der;
  225. t_ldapu_issuer_certinfo f_ldapu_issuer_certinfo;
  226. t_ldapu_certmap_info_attrval f_ldapu_certmap_info_attrval;
  227. t_ldapu_err2string f_ldapu_err2string;
  228. t_ldapu_free_old f_ldapu_free_old;
  229. t_ldapu_malloc f_ldapu_malloc;
  230. t_ldapu_strdup f_ldapu_strdup;
  231. t_ldapu_free f_ldapu_free;
  232. };
  233. #ifdef INTLDAPU
  234. NSAPI_PUBLIC extern LDAPUDispatchVector_t *__ldapu_table;
  235. #else
  236. typedef int (*CertMapDLLInitFn_t)(LDAPUDispatchVector_t **table);
  237. NSAPI_PUBLIC extern int CertMapDLLInitFn(LDAPUDispatchVector_t **table);
  238. extern LDAPUDispatchVector_t *__ldapu_table;
  239. #define CertmapDLLInit(rv, libname)
  240. #define CertmapDLLInitFnTbl
  241. #endif /* INTLDAPU */
  242. #ifndef INTLDAPU
  243. /*
  244. * ldapu_cert_to_ldap_entry -
  245. * This function is called to map a cert to an ldap entry. It extracts the
  246. * cert issuer information from the given cert. The mapping function set for
  247. * the issuer (if any) or the default mapping function is called to map the
  248. * subject DN from the cert to a candidate ldap DN and filter for ldap
  249. * search. If the mapped ldap DN is NULL, the 'basedn' passed into this
  250. * function is used as a starting place for the search. If the mapped filter
  251. * is NULL, "objectclass=*" is used as a filter. A base level search is
  252. * performed to see if the candidate DN exists in the LDAP database matching
  253. * the filter. If there is no match, a scoped search (sub-tree search) is
  254. * performed. If at least one entry matched the mapped DN and filter, the
  255. * result is passed to the appropriate verify function. The verify function
  256. * is called only if 'VerifyCert' parameter has been set for the cert issuer
  257. * in the certmap.conf file.
  258. * If the verify function succeeds, it must return the pointer to the matched
  259. * 'entry'. If at the end, there is only one matching entry, the mapping is
  260. * successful.
  261. * Parameters:
  262. * cert - cert to be mapped. You can pass this to
  263. * functions ldapu_get_cert_XYZ.
  264. * ld - Handle to the connection to the directory server.
  265. * suffix - If the subject dn is mapped to empty LDAP DN then use this
  266. * DN to begin the search. This is the DN of the root object
  267. * in LDAP Directory.
  268. * res - cert is first mapped to ldapdn and filter. 'res' is the
  269. * result of ldap search using the ldapdn and filter.
  270. * 'ld' and 'res' can be used in the calls to ldapsdk API.
  271. * When done with 'res', free it using ldap_msgfree(res)
  272. *
  273. * Return Value:
  274. * return LDAPU_SUCCESS upon successful completion
  275. * otherwise returns an error code that can be passed to ldapu_err2string.
  276. */
  277. #define ldapu_cert_to_ldap_entry (*__ldapu_table->f_ldapu_cert_to_ldap_entry)
  278. /*
  279. * ldapu_set_cert_mapfn -
  280. * This function can be used to set the cert mapping function for the given
  281. * issuer (CA). If the mapping information doesn't exist for the given
  282. * issuer then a new one will be created and the mapping function will be
  283. * set. When creating the new mapping information, the default mapping
  284. * information is copied.
  285. * Parameters:
  286. * issuerDN - DN of the cert issuer. This mapping function will be used
  287. * for all certs issued by this issuer. If the issuerDN is
  288. * NULL, the given 'mapfn' becomes the default mapping
  289. * function (which is used when no mapping function has been
  290. * set for the cert's issuer).
  291. * mapfn - the mapping function. Look at the desciption of
  292. * CertMapFn_t to find out more about the mapping functions.
  293. *
  294. * Return Value:
  295. * return LDAPU_SUCCESS upon successful completion
  296. * otherwise returns an error code that can be passed to ldapu_err2string.
  297. */
  298. #define ldapu_set_cert_mapfn (*__ldapu_table->f_ldapu_set_cert_mapfn)
  299. /*
  300. * ldapu_get_cert_mapfn -
  301. * This function can be used to get the cert mapping function for the given
  302. * issuer (CA). This will always return a non-NULL function.
  303. * Parameters:
  304. * issuerDN - DN of the cert issuer for which the mapping function is to
  305. * be retrieved. If this is NULL, default mapping function
  306. * is returned.
  307. *
  308. * Return Value:
  309. * The mapping function set for the issuer is returned. If the issuerDN is
  310. * NULL or if no specific mapping function has been set for the issuer, the
  311. * default mapping function is returned.
  312. */
  313. #define ldapu_get_cert_mapfn (*__ldapu_table->f_ldapu_get_cert_mapfn)
  314. /*
  315. * ldapu_set_cert_searchfn -
  316. * This function can be used to set the cert search function for the given
  317. * issuer (CA).
  318. * Parameters:
  319. * issuerDN - DN of the cert issuer. This search function will be used
  320. * for all certs issued by this issuer. If the issuerDN is
  321. * NULL, the given 'searchfn' becomes the default search
  322. * function (which is used when no search function has been
  323. * set for the cert's issuer).
  324. * searchfn - the search function. Look at the desciption of
  325. * CertSearchFn_t to find out more about the search functions.
  326. *
  327. * Return Value:
  328. * return LDAPU_SUCCESS upon successful completion
  329. * otherwise returns an error code that can be passed to ldapu_err2string.
  330. */
  331. #define ldapu_set_cert_searchfn (*__ldapu_table->f_ldapu_set_cert_searchfn)
  332. /*
  333. * ldapu_get_cert_searchfn -
  334. * This function can be used to get the cert search function for the given
  335. * issuer (CA). This will always return a non-NULL function.
  336. * Parameters:
  337. * issuerDN - DN of the cert issuer for which the search function is to
  338. * be retrieved. If this is NULL, the default search
  339. * function is returned.
  340. *
  341. * Return Value:
  342. * The search function set for the issuer is returned. If the issuerDN is
  343. * NULL or if no specific search function has been set for the issuer, the
  344. * default search function is returned.
  345. */
  346. #define ldapu_get_cert_searchfn (*__ldapu_table->f_ldapu_get_cert_searchfn)
  347. /*
  348. * ldapu_set_cert_verifyfn -
  349. * This function can be used to set the cert verify function for the given
  350. * issuer (CA). If the mapping information doesn't exist for the given
  351. * issuer then a new one will be created and the verify function will be
  352. * set. When creating the new mapping information, the default mapping
  353. * information is copied.
  354. * Parameters:
  355. * issuerDN - DN of the cert issuer. This verify function will be used
  356. * for all certs issued by this issuer. If the issuerDN is
  357. * NULL, the given 'verifyFn' becomes the default verify
  358. * function (which is used when no verify function has been
  359. * set for the cert's issuer).
  360. * verifyFn - the verify function. Look at the desciption of
  361. * CertMapFn_t to find out more about the verify functions.
  362. *
  363. * Return Value:
  364. * return LDAPU_SUCCESS upon successful completion
  365. * otherwise returns an error code that can be passed to ldapu_err2string.
  366. */
  367. #define ldapu_set_cert_verifyfn (*__ldapu_table->f_ldapu_set_cert_verifyfn)
  368. /*
  369. * ldapu_get_cert_verifyfn -
  370. * This function can be used to get the cert verify function for the given
  371. * issuer (CA). This function can return NULL when there is no applicable
  372. * verify function.
  373. * Parameters:
  374. * issuerDN - DN of the cert issuer for which the verify function is to
  375. * be retrieved. If this is NULL, default verify function
  376. * is returned.
  377. *
  378. * Return Value:
  379. * The verify function set for the issuer is returned. If the issuerDN is
  380. * NULL or if no specific verify function has been set for the issuer, the
  381. * default verify function is returned. This function can return NULL when
  382. * there is no applicable verify function.
  383. */
  384. #define ldapu_get_cert_verifyfn (*__ldapu_table->f_ldapu_get_cert_verifyfn)
  385. /*
  386. * ldapu_get_cert_subject_dn -
  387. * This function can be used to get the subject DN from the cert. Free the
  388. * subjectDN using 'free' after you are done using it.
  389. * Parameters:
  390. * cert - cert from which the DN is to be extracted.
  391. * subjectDN - subjectDN extracted from the cert. Free it using 'free'
  392. * after it is no longer required.
  393. *
  394. * Return Value:
  395. * return LDAPU_SUCCESS upon successful completion
  396. * otherwise returns an error code that can be passed to ldapu_err2string.
  397. */
  398. #define ldapu_get_cert_subject_dn (*__ldapu_table->f_ldapu_get_cert_subject_dn)
  399. /*
  400. * ldapu_get_cert_issuer_dn -
  401. * This function can be used to get the issuer DN from the cert. Free the
  402. * issuerDN using 'free' after you are done using it.
  403. * Parameters:
  404. * cert - cert from which the DN is to be extracted.
  405. * issuerDN - issuerDN extracted from the cert. Free it using 'free'
  406. * after it is no longer required.
  407. *
  408. * Return Value:
  409. * return LDAPU_SUCCESS upon successful completion
  410. * otherwise returns an error code that can be passed to ldapu_err2string.
  411. */
  412. #define ldapu_get_cert_issuer_dn (*__ldapu_table->f_ldapu_get_cert_issuer_dn)
  413. /*
  414. * ldapu_get_cert_ava_val -
  415. * This function can be used to get value of the given attribute from either
  416. * the subject DN or the issuer DN from the cert.
  417. * Parameters:
  418. * cert - cert from which the values are to be extracted.
  419. * which_dn - Should be either LDAPU_ISSUER_DN or LDAPU_SUBJECT_DN.
  420. * attr - Should be one of "CN", "OU", "O", "C", "UID", "MAIL",
  421. * "E", "L", and "ST".
  422. * val - An array of attribute values extracted from the cert.
  423. * There could be multiple values. The last entry in the
  424. * array is NULL. You must free this array of strings after
  425. * you are done with it (using the function
  426. * ldapu_free_cert_ava_val). 'val' is initialized to NULL if
  427. * there is an error.
  428. *
  429. * Return Value:
  430. * return LDAPU_SUCCESS upon successful completion
  431. * otherwise returns an error code that can be passed to ldapu_err2string.
  432. */
  433. #define ldapu_get_cert_ava_val (*__ldapu_table->f_ldapu_get_cert_ava_val)
  434. /*
  435. * ldapu_free_cert_ava_val -
  436. * This function can be used to free the array returned by the
  437. * ldapu_get_cert_ava_val function.
  438. * Parameters:
  439. * val - An array of attribute values returned by
  440. * ldapu_get_cert_ava_val.
  441. *
  442. * Return Value:
  443. * return LDAPU_SUCCESS upon successful completion
  444. * otherwise returns an error code that can be passed to ldapu_err2string.
  445. */
  446. #define ldapu_free_cert_ava_val (*__ldapu_table->f_ldapu_free_cert_ava_val)
  447. /*
  448. * ldapu_get_cert_der -
  449. * This function can be used to get the original DER encoded cert for the
  450. * given cert.
  451. * Parameters:
  452. * cert - cert from which the original DER is to be extracted.
  453. * derCert - the original DER encoded cert
  454. * len - length of derCert
  455. *
  456. * Return Value:
  457. * return LDAPU_SUCCESS upon successful completion
  458. * otherwise returns an error code that can be passed to ldapu_err2string.
  459. */
  460. #define ldapu_get_cert_der (*__ldapu_table->f_ldapu_get_cert_der)
  461. /*
  462. * ldapu_issuer_certinfo -
  463. * This function can be used to get the handle on the internal structure for
  464. * the given issuer. This handle can be passed to ldapu_certmap_info_attrval
  465. * to get configuration attribute values for the issuer.
  466. * Parameters:
  467. * issuerDN - DN of the issuer for whom the handle on internal structure
  468. * is requested. If issuerDN is NULL, the handle to the
  469. * default configuration information is returned.
  470. * certmap_info - This structure contains information about the
  471. * configuration parameters for the cert's issuer (CA).
  472. * This structure can be passed to the function
  473. * ldapu_certmap_info_attrval to get value for a particular
  474. * configuration attribute (or a property).
  475. *
  476. * Return Value:
  477. * return LDAPU_SUCCESS upon successful completion
  478. * otherwise returns an error code that can be passed to ldapu_err2string.
  479. * CAUTION: DON'T FREE THE 'certmap_info' STRUCTURE.
  480. */
  481. #define ldapu_issuer_certinfo (*__ldapu_table->f_ldapu_issuer_certinfo)
  482. /*
  483. * ldapu_certmap_info_attrval -
  484. * This function can be used to get values for the given attribute/property
  485. * from the given certmap_info. You can get handle on the certmap_info by
  486. * calling the ldapu_issuer_certinfo function. Free the 'val' using 'free'
  487. * after it is no longer required.
  488. * Parameters:
  489. * certmap_info - This structure contains information about the
  490. * configuration parameters for the cert's issuer (CA).
  491. * attr - name of the attribute/property for which the value is to
  492. * be returned. The attribute can be one of the attributes
  493. * listed above (LDAPU_ATTR_XYZ). User defined attributes
  494. * can also be used.
  495. * val - Value of the 'attr' from the 'certmap_info'.
  496. *
  497. * Return Value:
  498. * return LDAPU_SUCCESS upon successful completion
  499. * otherwise returns an error code that can be passed to ldapu_err2string.
  500. */
  501. #define ldapu_certmap_info_attrval (*__ldapu_table->f_ldapu_certmap_info_attrval)
  502. /*
  503. * ldapu_err2string -
  504. * This function can be used to print any of the ldaputil or LDAP error
  505. * code.
  506. * Parameters:
  507. * err - error code to be converted to printable string.
  508. *
  509. * Return Value:
  510. * Printable representation of the given error code.
  511. */
  512. #define ldapu_err2string (*__ldapu_table->f_ldapu_err2string)
  513. /*
  514. * ldapu_free -
  515. * This function should be used to free the memory allocated by
  516. * ldapu_* functions if the ldapu_* function doesn't have a corresponding
  517. * 'free' function. Use this function for free'ing the memory allocated by
  518. * the following functions:
  519. * ldapu_get_cert_subject_dn
  520. * ldapu_get_cert_issuer_dn
  521. * ldapu_get_cert_der
  522. * ldapu_certmap_info_attrval
  523. * To free memory allocated by ldapu_get_cert_ava_val, use
  524. * ldapu_free_cert_ava_val. Do not free the certmap_info pointer returned by
  525. * ldapu_issuer_certinfo.
  526. * Parameters:
  527. * ptr - pointer returned by ldapu_get_cert_* functions.
  528. */
  529. #define ldapu_free (*__ldapu_table->f_ldapu_free)
  530. /*
  531. * ldapu_malloc -
  532. * This function is a cover function for the 'malloc' system call. On NT, it
  533. * is best to alloc & free the memory in the same DLL.
  534. * Parameters:
  535. * size - size of the memory to be allocated
  536. * Return Value:
  537. * same as 'malloc' -- pointer to the allocated memory or NULL on failure.
  538. */
  539. #define ldapu_malloc (*__ldapu_table->f_ldapu_malloc)
  540. /*
  541. * ldapu_strdup -
  542. * This function is a cover function for the 'strdup' system call. On NT, it
  543. * is best to alloc & free the memory in the same DLL.
  544. * Parameters:
  545. * ptr - Pointer to the string to be copied
  546. * Return Value:
  547. * same as 'strdup' -- pointer to the copied string or NULL on failure.
  548. */
  549. #define ldapu_strdup (*__ldapu_table->f_ldapu_strdup)
  550. #endif /* !INTLDAPU */
  551. #endif /* _PUBLIC_CERTMAP_H */