x509-ext.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (C) 2014 Free Software Foundation, Inc.
  3. *
  4. * Author: Nikos Mavrogiannopoulos
  5. *
  6. * This file is part of GnuTLS.
  7. *
  8. * The GnuTLS is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. /* Prototypes for direct handling of extension data */
  23. #ifndef GNUTLS_X509_EXT_H
  24. #define GNUTLS_X509_EXT_H
  25. #include <gnutls/gnutls.h>
  26. #include <gnutls/x509.h>
  27. /* *INDENT-OFF* */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* *INDENT-ON* */
  32. typedef struct gnutls_subject_alt_names_st *gnutls_subject_alt_names_t;
  33. int gnutls_subject_alt_names_init(gnutls_subject_alt_names_t *);
  34. void gnutls_subject_alt_names_deinit(gnutls_subject_alt_names_t sans);
  35. int gnutls_subject_alt_names_get(gnutls_subject_alt_names_t sans, unsigned int seq,
  36. unsigned int *san_type, gnutls_datum_t * san,
  37. gnutls_datum_t * othername_oid);
  38. int gnutls_subject_alt_names_set(gnutls_subject_alt_names_t sans,
  39. unsigned int san_type,
  40. const gnutls_datum_t * san,
  41. const char* othername_oid);
  42. int gnutls_x509_ext_import_subject_alt_names(const gnutls_datum_t * ext,
  43. gnutls_subject_alt_names_t,
  44. unsigned int flags);
  45. int gnutls_x509_ext_export_subject_alt_names(gnutls_subject_alt_names_t,
  46. gnutls_datum_t * ext);
  47. /* They are exactly the same */
  48. #define gnutls_x509_ext_import_issuer_alt_name gnutls_x509_ext_import_subject_alt_name
  49. #define gnutls_x509_ext_export_issuer_alt_name gnutls_x509_ext_export_subject_alt_name
  50. typedef struct gnutls_x509_crl_dist_points_st *gnutls_x509_crl_dist_points_t;
  51. int gnutls_x509_crl_dist_points_init(gnutls_x509_crl_dist_points_t *);
  52. void gnutls_x509_crl_dist_points_deinit(gnutls_x509_crl_dist_points_t);
  53. int gnutls_x509_crl_dist_points_get(gnutls_x509_crl_dist_points_t, unsigned int seq,
  54. unsigned int *type,
  55. gnutls_datum_t *dist, unsigned int *reason_flags);
  56. int gnutls_x509_crl_dist_points_set(gnutls_x509_crl_dist_points_t,
  57. gnutls_x509_subject_alt_name_t type,
  58. const gnutls_datum_t *dist, unsigned int reason_flags);
  59. int gnutls_x509_ext_import_crl_dist_points(const gnutls_datum_t * ext,
  60. gnutls_x509_crl_dist_points_t dp,
  61. unsigned int flags);
  62. int gnutls_x509_ext_export_crl_dist_points(gnutls_x509_crl_dist_points_t dp,
  63. gnutls_datum_t * ext);
  64. int gnutls_x509_ext_import_name_constraints(const gnutls_datum_t * ext,
  65. gnutls_x509_name_constraints_t nc,
  66. unsigned int flags);
  67. int gnutls_x509_ext_export_name_constraints(gnutls_x509_name_constraints_t nc,
  68. gnutls_datum_t * ext);
  69. typedef struct gnutls_x509_aia_st *gnutls_x509_aia_t;
  70. int gnutls_x509_aia_init(gnutls_x509_aia_t *);
  71. void gnutls_x509_aia_deinit(gnutls_x509_aia_t);
  72. int gnutls_x509_aia_get(gnutls_x509_aia_t aia, unsigned int seq,
  73. gnutls_datum_t *oid,
  74. unsigned *san_type,
  75. gnutls_datum_t *san);
  76. int gnutls_x509_aia_set(gnutls_x509_aia_t aia,
  77. const char *oid,
  78. unsigned san_type,
  79. const gnutls_datum_t * san);
  80. int gnutls_x509_ext_import_aia(const gnutls_datum_t * ext,
  81. gnutls_x509_aia_t,
  82. unsigned int flags);
  83. int gnutls_x509_ext_export_aia(gnutls_x509_aia_t aia,
  84. gnutls_datum_t * ext);
  85. int gnutls_x509_ext_import_subject_key_id(const gnutls_datum_t * ext,
  86. gnutls_datum_t * id);
  87. int gnutls_x509_ext_export_subject_key_id(const gnutls_datum_t * id,
  88. gnutls_datum_t * ext);
  89. typedef struct gnutls_x509_aki_st *gnutls_x509_aki_t;
  90. int gnutls_x509_ext_export_authority_key_id(gnutls_x509_aki_t,
  91. gnutls_datum_t * ext);
  92. int gnutls_x509_ext_import_authority_key_id(const gnutls_datum_t * ext,
  93. gnutls_x509_aki_t,
  94. unsigned int flags);
  95. int gnutls_x509_othername_to_virtual(const char *oid,
  96. const gnutls_datum_t *othername,
  97. unsigned int *virt_type,
  98. gnutls_datum_t *virt);
  99. int gnutls_x509_aki_init(gnutls_x509_aki_t *);
  100. int gnutls_x509_aki_get_id(gnutls_x509_aki_t, gnutls_datum_t *id);
  101. int gnutls_x509_aki_get_cert_issuer(gnutls_x509_aki_t aki, unsigned int seq,
  102. unsigned int *san_type, gnutls_datum_t * san,
  103. gnutls_datum_t *othername_oid,
  104. gnutls_datum_t *serial);
  105. int gnutls_x509_aki_set_id(gnutls_x509_aki_t aki, const gnutls_datum_t *id);
  106. int gnutls_x509_aki_set_cert_issuer(gnutls_x509_aki_t aki,
  107. unsigned int san_type,
  108. const gnutls_datum_t * san,
  109. const char *othername_oid,
  110. const gnutls_datum_t * serial);
  111. void gnutls_x509_aki_deinit(gnutls_x509_aki_t);
  112. int gnutls_x509_ext_import_private_key_usage_period(const gnutls_datum_t * ext,
  113. time_t * activation,
  114. time_t * expiration);
  115. int gnutls_x509_ext_export_private_key_usage_period(time_t activation,
  116. time_t expiration,
  117. gnutls_datum_t * ext);
  118. int gnutls_x509_ext_import_basic_constraints(const gnutls_datum_t * ext,
  119. unsigned int *ca, int *pathlen);
  120. int gnutls_x509_ext_export_basic_constraints(unsigned int ca, int pathlen,
  121. gnutls_datum_t * ext);
  122. typedef struct gnutls_x509_key_purposes_st *gnutls_x509_key_purposes_t;
  123. int gnutls_x509_key_purpose_init(gnutls_x509_key_purposes_t *p);
  124. void gnutls_x509_key_purpose_deinit(gnutls_x509_key_purposes_t p);
  125. int gnutls_x509_key_purpose_set(gnutls_x509_key_purposes_t p, const char *oid);
  126. int gnutls_x509_key_purpose_get(gnutls_x509_key_purposes_t p, unsigned idx, gnutls_datum_t *oid);
  127. int gnutls_x509_ext_import_key_purposes(const gnutls_datum_t * ext,
  128. gnutls_x509_key_purposes_t,
  129. unsigned int flags);
  130. int gnutls_x509_ext_export_key_purposes(gnutls_x509_key_purposes_t,
  131. gnutls_datum_t * ext);
  132. int gnutls_x509_ext_import_key_usage(const gnutls_datum_t * ext,
  133. unsigned int *key_usage);
  134. int gnutls_x509_ext_export_key_usage(unsigned int key_usage,
  135. gnutls_datum_t * ext);
  136. int gnutls_x509_ext_import_inhibit_anypolicy(const gnutls_datum_t * ext,
  137. unsigned int *skipcerts);
  138. int gnutls_x509_ext_export_inhibit_anypolicy(unsigned int skipcerts,
  139. gnutls_datum_t * ext);
  140. int gnutls_x509_ext_import_proxy(const gnutls_datum_t * ext, int *pathlen,
  141. char **policyLanguage, char **policy,
  142. size_t * sizeof_policy);
  143. int gnutls_x509_ext_export_proxy(int pathLenConstraint, const char *policyLanguage,
  144. const char *policy, size_t sizeof_policy,
  145. gnutls_datum_t * ext);
  146. typedef struct gnutls_x509_policies_st *gnutls_x509_policies_t;
  147. int gnutls_x509_policies_init(gnutls_x509_policies_t *);
  148. void gnutls_x509_policies_deinit(gnutls_x509_policies_t);
  149. int gnutls_x509_policies_get(gnutls_x509_policies_t policies, unsigned int seq,
  150. struct gnutls_x509_policy_st *policy);
  151. int gnutls_x509_policies_set(gnutls_x509_policies_t policies,
  152. const struct gnutls_x509_policy_st *policy);
  153. int gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, gnutls_x509_policies_t
  154. policies,
  155. unsigned int flags);
  156. int gnutls_x509_ext_export_policies(gnutls_x509_policies_t policies,
  157. gnutls_datum_t * ext);
  158. int gnutls_x509_ext_import_tlsfeatures(const gnutls_datum_t * ext,
  159. gnutls_x509_tlsfeatures_t,
  160. unsigned int flags);
  161. int gnutls_x509_ext_export_tlsfeatures(gnutls_x509_tlsfeatures_t f,
  162. gnutls_datum_t * ext);
  163. int gnutls_x509_tlsfeatures_add(gnutls_x509_tlsfeatures_t f, unsigned int feature);
  164. /* *INDENT-OFF* */
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. /* *INDENT-ON* */
  169. #endif /* GNUTLS_X509_H */