x509v3.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  2. * project 1999. */
  3. /* ====================================================================
  4. * Copyright (c) 1999-2004 The OpenSSL Project. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * 3. All advertising materials mentioning features or use of this
  19. * software must display the following acknowledgment:
  20. * "This product includes software developed by the OpenSSL Project
  21. * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
  22. *
  23. * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
  24. * endorse or promote products derived from this software without
  25. * prior written permission. For written permission, please contact
  26. * licensing@OpenSSL.org.
  27. *
  28. * 5. Products derived from this software may not be called "OpenSSL"
  29. * nor may "OpenSSL" appear in their names without prior written
  30. * permission of the OpenSSL Project.
  31. *
  32. * 6. Redistributions of any form whatsoever must retain the following
  33. * acknowledgment:
  34. * "This product includes software developed by the OpenSSL Project
  35. * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
  36. *
  37. * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
  38. * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  39. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  40. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
  41. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  43. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  44. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  45. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  46. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  47. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  48. * OF THE POSSIBILITY OF SUCH DAMAGE.
  49. * ====================================================================
  50. *
  51. * This product includes cryptographic software written by Eric Young
  52. * (eay@cryptsoft.com). This product includes software written by Tim
  53. * Hudson (tjh@cryptsoft.com). */
  54. #ifndef HEADER_X509V3_H
  55. #define HEADER_X509V3_H
  56. #include <openssl/bio.h>
  57. #include <openssl/conf.h>
  58. #include <openssl/lhash.h>
  59. #include <openssl/x509.h>
  60. #if defined(__cplusplus)
  61. extern "C" {
  62. #endif
  63. // Legacy X.509 library.
  64. //
  65. // This header is part of OpenSSL's X.509 implementation. It is retained for
  66. // compatibility but otherwise underdocumented and not actively maintained. In
  67. // the future, a replacement library will be available. Meanwhile, minimize
  68. // dependencies on this header where possible.
  69. // Forward reference
  70. struct v3_ext_method;
  71. struct v3_ext_ctx;
  72. // Useful typedefs
  73. typedef void *(*X509V3_EXT_NEW)(void);
  74. typedef void (*X509V3_EXT_FREE)(void *);
  75. typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long);
  76. typedef int (*X509V3_EXT_I2D)(void *, unsigned char **);
  77. typedef STACK_OF(CONF_VALUE) *(*X509V3_EXT_I2V)(
  78. const struct v3_ext_method *method, void *ext,
  79. STACK_OF(CONF_VALUE) *extlist);
  80. typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method,
  81. struct v3_ext_ctx *ctx,
  82. STACK_OF(CONF_VALUE) *values);
  83. typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, void *ext);
  84. typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method,
  85. struct v3_ext_ctx *ctx, const char *str);
  86. typedef int (*X509V3_EXT_I2R)(const struct v3_ext_method *method, void *ext,
  87. BIO *out, int indent);
  88. typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method,
  89. struct v3_ext_ctx *ctx, const char *str);
  90. // V3 extension structure
  91. struct v3_ext_method {
  92. int ext_nid;
  93. int ext_flags;
  94. // If this is set the following four fields are ignored
  95. ASN1_ITEM_EXP *it;
  96. // Old style ASN1 calls
  97. X509V3_EXT_NEW ext_new;
  98. X509V3_EXT_FREE ext_free;
  99. X509V3_EXT_D2I d2i;
  100. X509V3_EXT_I2D i2d;
  101. // The following pair is used for string extensions
  102. X509V3_EXT_I2S i2s;
  103. X509V3_EXT_S2I s2i;
  104. // The following pair is used for multi-valued extensions
  105. X509V3_EXT_I2V i2v;
  106. X509V3_EXT_V2I v2i;
  107. // The following are used for raw extensions
  108. X509V3_EXT_I2R i2r;
  109. X509V3_EXT_R2I r2i;
  110. void *usr_data; // Any extension specific data
  111. };
  112. typedef struct X509V3_CONF_METHOD_st {
  113. char *(*get_string)(void *db, const char *section, const char *value);
  114. STACK_OF(CONF_VALUE) *(*get_section)(void *db, const char *section);
  115. void (*free_string)(void *db, char *string);
  116. void (*free_section)(void *db, STACK_OF(CONF_VALUE) *section);
  117. } X509V3_CONF_METHOD;
  118. // Context specific info
  119. struct v3_ext_ctx {
  120. #define CTX_TEST 0x1
  121. int flags;
  122. X509 *issuer_cert;
  123. X509 *subject_cert;
  124. X509_REQ *subject_req;
  125. X509_CRL *crl;
  126. const X509V3_CONF_METHOD *db_meth;
  127. void *db;
  128. // Maybe more here
  129. };
  130. typedef struct v3_ext_method X509V3_EXT_METHOD;
  131. DEFINE_STACK_OF(X509V3_EXT_METHOD)
  132. // ext_flags values
  133. #define X509V3_EXT_DYNAMIC 0x1
  134. #define X509V3_EXT_CTX_DEP 0x2
  135. #define X509V3_EXT_MULTILINE 0x4
  136. struct BASIC_CONSTRAINTS_st {
  137. int ca;
  138. ASN1_INTEGER *pathlen;
  139. };
  140. typedef struct otherName_st {
  141. ASN1_OBJECT *type_id;
  142. ASN1_TYPE *value;
  143. } OTHERNAME;
  144. typedef struct EDIPartyName_st {
  145. ASN1_STRING *nameAssigner;
  146. ASN1_STRING *partyName;
  147. } EDIPARTYNAME;
  148. typedef struct GENERAL_NAME_st {
  149. #define GEN_OTHERNAME 0
  150. #define GEN_EMAIL 1
  151. #define GEN_DNS 2
  152. #define GEN_X400 3
  153. #define GEN_DIRNAME 4
  154. #define GEN_EDIPARTY 5
  155. #define GEN_URI 6
  156. #define GEN_IPADD 7
  157. #define GEN_RID 8
  158. int type;
  159. union {
  160. char *ptr;
  161. OTHERNAME *otherName; // otherName
  162. ASN1_IA5STRING *rfc822Name;
  163. ASN1_IA5STRING *dNSName;
  164. ASN1_TYPE *x400Address;
  165. X509_NAME *directoryName;
  166. EDIPARTYNAME *ediPartyName;
  167. ASN1_IA5STRING *uniformResourceIdentifier;
  168. ASN1_OCTET_STRING *iPAddress;
  169. ASN1_OBJECT *registeredID;
  170. // Old names
  171. ASN1_OCTET_STRING *ip; // iPAddress
  172. X509_NAME *dirn; // dirn
  173. ASN1_IA5STRING *ia5; // rfc822Name, dNSName, uniformResourceIdentifier
  174. ASN1_OBJECT *rid; // registeredID
  175. ASN1_TYPE *other; // x400Address
  176. } d;
  177. } GENERAL_NAME;
  178. DEFINE_STACK_OF(GENERAL_NAME)
  179. typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES;
  180. DEFINE_STACK_OF(GENERAL_NAMES)
  181. typedef struct ACCESS_DESCRIPTION_st {
  182. ASN1_OBJECT *method;
  183. GENERAL_NAME *location;
  184. } ACCESS_DESCRIPTION;
  185. DEFINE_STACK_OF(ACCESS_DESCRIPTION)
  186. typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS;
  187. typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE;
  188. typedef struct DIST_POINT_NAME_st {
  189. int type;
  190. union {
  191. GENERAL_NAMES *fullname;
  192. STACK_OF(X509_NAME_ENTRY) *relativename;
  193. } name;
  194. // If relativename then this contains the full distribution point name
  195. X509_NAME *dpname;
  196. } DIST_POINT_NAME;
  197. // All existing reasons
  198. #define CRLDP_ALL_REASONS 0x807f
  199. #define CRL_REASON_NONE (-1)
  200. #define CRL_REASON_UNSPECIFIED 0
  201. #define CRL_REASON_KEY_COMPROMISE 1
  202. #define CRL_REASON_CA_COMPROMISE 2
  203. #define CRL_REASON_AFFILIATION_CHANGED 3
  204. #define CRL_REASON_SUPERSEDED 4
  205. #define CRL_REASON_CESSATION_OF_OPERATION 5
  206. #define CRL_REASON_CERTIFICATE_HOLD 6
  207. #define CRL_REASON_REMOVE_FROM_CRL 8
  208. #define CRL_REASON_PRIVILEGE_WITHDRAWN 9
  209. #define CRL_REASON_AA_COMPROMISE 10
  210. struct DIST_POINT_st {
  211. DIST_POINT_NAME *distpoint;
  212. ASN1_BIT_STRING *reasons;
  213. GENERAL_NAMES *CRLissuer;
  214. int dp_reasons;
  215. };
  216. typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS;
  217. DEFINE_STACK_OF(DIST_POINT)
  218. struct AUTHORITY_KEYID_st {
  219. ASN1_OCTET_STRING *keyid;
  220. GENERAL_NAMES *issuer;
  221. ASN1_INTEGER *serial;
  222. };
  223. typedef struct NOTICEREF_st {
  224. ASN1_STRING *organization;
  225. STACK_OF(ASN1_INTEGER) *noticenos;
  226. } NOTICEREF;
  227. typedef struct USERNOTICE_st {
  228. NOTICEREF *noticeref;
  229. ASN1_STRING *exptext;
  230. } USERNOTICE;
  231. typedef struct POLICYQUALINFO_st {
  232. ASN1_OBJECT *pqualid;
  233. union {
  234. ASN1_IA5STRING *cpsuri;
  235. USERNOTICE *usernotice;
  236. ASN1_TYPE *other;
  237. } d;
  238. } POLICYQUALINFO;
  239. DEFINE_STACK_OF(POLICYQUALINFO)
  240. typedef struct POLICYINFO_st {
  241. ASN1_OBJECT *policyid;
  242. STACK_OF(POLICYQUALINFO) *qualifiers;
  243. } POLICYINFO;
  244. typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES;
  245. DEFINE_STACK_OF(POLICYINFO)
  246. typedef struct POLICY_MAPPING_st {
  247. ASN1_OBJECT *issuerDomainPolicy;
  248. ASN1_OBJECT *subjectDomainPolicy;
  249. } POLICY_MAPPING;
  250. DEFINE_STACK_OF(POLICY_MAPPING)
  251. typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS;
  252. typedef struct GENERAL_SUBTREE_st {
  253. GENERAL_NAME *base;
  254. ASN1_INTEGER *minimum;
  255. ASN1_INTEGER *maximum;
  256. } GENERAL_SUBTREE;
  257. DEFINE_STACK_OF(GENERAL_SUBTREE)
  258. struct NAME_CONSTRAINTS_st {
  259. STACK_OF(GENERAL_SUBTREE) *permittedSubtrees;
  260. STACK_OF(GENERAL_SUBTREE) *excludedSubtrees;
  261. };
  262. typedef struct POLICY_CONSTRAINTS_st {
  263. ASN1_INTEGER *requireExplicitPolicy;
  264. ASN1_INTEGER *inhibitPolicyMapping;
  265. } POLICY_CONSTRAINTS;
  266. // Proxy certificate structures, see RFC 3820
  267. typedef struct PROXY_POLICY_st {
  268. ASN1_OBJECT *policyLanguage;
  269. ASN1_OCTET_STRING *policy;
  270. } PROXY_POLICY;
  271. typedef struct PROXY_CERT_INFO_EXTENSION_st {
  272. ASN1_INTEGER *pcPathLengthConstraint;
  273. PROXY_POLICY *proxyPolicy;
  274. } PROXY_CERT_INFO_EXTENSION;
  275. DECLARE_ASN1_FUNCTIONS(PROXY_POLICY)
  276. DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
  277. struct ISSUING_DIST_POINT_st {
  278. DIST_POINT_NAME *distpoint;
  279. int onlyuser;
  280. int onlyCA;
  281. ASN1_BIT_STRING *onlysomereasons;
  282. int indirectCRL;
  283. int onlyattr;
  284. };
  285. // Values in idp_flags field
  286. // IDP present
  287. #define IDP_PRESENT 0x1
  288. // IDP values inconsistent
  289. #define IDP_INVALID 0x2
  290. // onlyuser true
  291. #define IDP_ONLYUSER 0x4
  292. // onlyCA true
  293. #define IDP_ONLYCA 0x8
  294. // onlyattr true
  295. #define IDP_ONLYATTR 0x10
  296. // indirectCRL true
  297. #define IDP_INDIRECT 0x20
  298. // onlysomereasons present
  299. #define IDP_REASONS 0x40
  300. #define X509V3_conf_err(val) \
  301. ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, \
  302. ",value:", (val)->value);
  303. #define X509V3_set_ctx_test(ctx) \
  304. X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST)
  305. #define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL;
  306. #define EXT_BITSTRING(nid, table) \
  307. { \
  308. nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), 0, 0, 0, 0, 0, 0, \
  309. (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \
  310. (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, NULL, NULL, (void *)(table) \
  311. }
  312. #define EXT_IA5STRING(nid) \
  313. { \
  314. nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), 0, 0, 0, 0, \
  315. (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \
  316. (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, 0, 0, 0, 0, NULL \
  317. }
  318. #define EXT_END \
  319. { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
  320. // X509_PURPOSE stuff
  321. #define EXFLAG_BCONS 0x1
  322. #define EXFLAG_KUSAGE 0x2
  323. #define EXFLAG_XKUSAGE 0x4
  324. #define EXFLAG_NSCERT 0x8
  325. #define EXFLAG_CA 0x10
  326. // Really self issued not necessarily self signed
  327. #define EXFLAG_SI 0x20
  328. #define EXFLAG_V1 0x40
  329. #define EXFLAG_INVALID 0x80
  330. #define EXFLAG_SET 0x100
  331. #define EXFLAG_CRITICAL 0x200
  332. #define EXFLAG_PROXY 0x400
  333. #define EXFLAG_INVALID_POLICY 0x800
  334. #define EXFLAG_FRESHEST 0x1000
  335. // Self signed
  336. #define EXFLAG_SS 0x2000
  337. #define KU_DIGITAL_SIGNATURE 0x0080
  338. #define KU_NON_REPUDIATION 0x0040
  339. #define KU_KEY_ENCIPHERMENT 0x0020
  340. #define KU_DATA_ENCIPHERMENT 0x0010
  341. #define KU_KEY_AGREEMENT 0x0008
  342. #define KU_KEY_CERT_SIGN 0x0004
  343. #define KU_CRL_SIGN 0x0002
  344. #define KU_ENCIPHER_ONLY 0x0001
  345. #define KU_DECIPHER_ONLY 0x8000
  346. #define NS_SSL_CLIENT 0x80
  347. #define NS_SSL_SERVER 0x40
  348. #define NS_SMIME 0x20
  349. #define NS_OBJSIGN 0x10
  350. #define NS_SSL_CA 0x04
  351. #define NS_SMIME_CA 0x02
  352. #define NS_OBJSIGN_CA 0x01
  353. #define NS_ANY_CA (NS_SSL_CA | NS_SMIME_CA | NS_OBJSIGN_CA)
  354. #define XKU_SSL_SERVER 0x1
  355. #define XKU_SSL_CLIENT 0x2
  356. #define XKU_SMIME 0x4
  357. #define XKU_CODE_SIGN 0x8
  358. #define XKU_SGC 0x10
  359. #define XKU_OCSP_SIGN 0x20
  360. #define XKU_TIMESTAMP 0x40
  361. #define XKU_DVCS 0x80
  362. #define XKU_ANYEKU 0x100
  363. #define X509_PURPOSE_DYNAMIC 0x1
  364. #define X509_PURPOSE_DYNAMIC_NAME 0x2
  365. typedef struct x509_purpose_st {
  366. int purpose;
  367. int trust; // Default trust ID
  368. int flags;
  369. int (*check_purpose)(const struct x509_purpose_st *, const X509 *, int);
  370. char *name;
  371. char *sname;
  372. void *usr_data;
  373. } X509_PURPOSE;
  374. #define X509_PURPOSE_SSL_CLIENT 1
  375. #define X509_PURPOSE_SSL_SERVER 2
  376. #define X509_PURPOSE_NS_SSL_SERVER 3
  377. #define X509_PURPOSE_SMIME_SIGN 4
  378. #define X509_PURPOSE_SMIME_ENCRYPT 5
  379. #define X509_PURPOSE_CRL_SIGN 6
  380. #define X509_PURPOSE_ANY 7
  381. #define X509_PURPOSE_OCSP_HELPER 8
  382. #define X509_PURPOSE_TIMESTAMP_SIGN 9
  383. #define X509_PURPOSE_MIN 1
  384. #define X509_PURPOSE_MAX 9
  385. DEFINE_STACK_OF(X509_PURPOSE)
  386. DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS)
  387. DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID)
  388. DECLARE_ASN1_FUNCTIONS(GENERAL_NAME)
  389. OPENSSL_EXPORT GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a);
  390. // GENERAL_NAME_cmp returns zero if |a| and |b| are equal and a non-zero
  391. // value otherwise. Note this function does not provide a comparison suitable
  392. // for sorting.
  393. OPENSSL_EXPORT int GENERAL_NAME_cmp(const GENERAL_NAME *a,
  394. const GENERAL_NAME *b);
  395. OPENSSL_EXPORT ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
  396. X509V3_CTX *ctx,
  397. STACK_OF(CONF_VALUE) *nval);
  398. OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(
  399. X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits,
  400. STACK_OF(CONF_VALUE) *extlist);
  401. // i2v_GENERAL_NAME serializes |gen| as a |CONF_VALUE|. If |ret| is non-NULL, it
  402. // appends the value to |ret| and returns |ret| on success or NULL on error. If
  403. // it returns NULL, the caller is still responsible for freeing |ret|. If |ret|
  404. // is NULL, it returns a newly-allocated |STACK_OF(CONF_VALUE)| containing the
  405. // result. |method| is ignored.
  406. //
  407. // Do not use this function. This is an internal implementation detail of the
  408. // human-readable print functions. If extracting a SAN list from a certificate,
  409. // look at |gen| directly.
  410. OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(
  411. X509V3_EXT_METHOD *method, GENERAL_NAME *gen, STACK_OF(CONF_VALUE) *ret);
  412. OPENSSL_EXPORT int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen);
  413. DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES)
  414. // i2v_GENERAL_NAMES serializes |gen| as a list of |CONF_VALUE|s. If |ret| is
  415. // non-NULL, it appends the values to |ret| and returns |ret| on success or NULL
  416. // on error. If it returns NULL, the caller is still responsible for freeing
  417. // |ret|. If |ret| is NULL, it returns a newly-allocated |STACK_OF(CONF_VALUE)|
  418. // containing the results. |method| is ignored.
  419. //
  420. // Do not use this function. This is an internal implementation detail of the
  421. // human-readable print functions. If extracting a SAN list from a certificate,
  422. // look at |gen| directly.
  423. OPENSSL_EXPORT STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(
  424. X509V3_EXT_METHOD *method, GENERAL_NAMES *gen,
  425. STACK_OF(CONF_VALUE) *extlist);
  426. OPENSSL_EXPORT GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method,
  427. X509V3_CTX *ctx,
  428. STACK_OF(CONF_VALUE) *nval);
  429. DECLARE_ASN1_FUNCTIONS(OTHERNAME)
  430. DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME)
  431. OPENSSL_EXPORT int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b);
  432. OPENSSL_EXPORT void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type,
  433. void *value);
  434. OPENSSL_EXPORT void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype);
  435. OPENSSL_EXPORT int GENERAL_NAME_set0_othername(GENERAL_NAME *gen,
  436. ASN1_OBJECT *oid,
  437. ASN1_TYPE *value);
  438. OPENSSL_EXPORT int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen,
  439. ASN1_OBJECT **poid,
  440. ASN1_TYPE **pvalue);
  441. OPENSSL_EXPORT char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
  442. const ASN1_OCTET_STRING *ia5);
  443. OPENSSL_EXPORT ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(
  444. X509V3_EXT_METHOD *method, X509V3_CTX *ctx, const char *str);
  445. DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE)
  446. OPENSSL_EXPORT int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a);
  447. DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES)
  448. DECLARE_ASN1_FUNCTIONS(POLICYINFO)
  449. DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO)
  450. DECLARE_ASN1_FUNCTIONS(USERNOTICE)
  451. DECLARE_ASN1_FUNCTIONS(NOTICEREF)
  452. DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS)
  453. DECLARE_ASN1_FUNCTIONS(DIST_POINT)
  454. DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME)
  455. DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
  456. OPENSSL_EXPORT int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn,
  457. X509_NAME *iname);
  458. OPENSSL_EXPORT int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc);
  459. DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
  460. DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
  461. DECLARE_ASN1_ITEM(POLICY_MAPPING)
  462. DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING)
  463. DECLARE_ASN1_ITEM(POLICY_MAPPINGS)
  464. DECLARE_ASN1_ITEM(GENERAL_SUBTREE)
  465. DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE)
  466. DECLARE_ASN1_ITEM(NAME_CONSTRAINTS)
  467. DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS)
  468. DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS)
  469. DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS)
  470. OPENSSL_EXPORT GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
  471. const X509V3_EXT_METHOD *method,
  472. X509V3_CTX *ctx, int gen_type,
  473. const char *value, int is_nc);
  474. OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method,
  475. X509V3_CTX *ctx, CONF_VALUE *cnf);
  476. OPENSSL_EXPORT GENERAL_NAME *v2i_GENERAL_NAME_ex(
  477. GENERAL_NAME *out, const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
  478. CONF_VALUE *cnf, int is_nc);
  479. OPENSSL_EXPORT void X509V3_conf_free(CONF_VALUE *val);
  480. // X509V3_EXT_conf_nid contains the only exposed instance of an LHASH in our
  481. // public headers. The |conf| pointer must be NULL but cryptography.io wraps
  482. // this function so we cannot, yet, replace the type with a dummy struct.
  483. OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf,
  484. X509V3_CTX *ctx, int ext_nid,
  485. const char *value);
  486. OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx,
  487. int ext_nid,
  488. const char *value);
  489. OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx,
  490. const char *name,
  491. const char *value);
  492. OPENSSL_EXPORT int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx,
  493. const char *section,
  494. STACK_OF(X509_EXTENSION) **sk);
  495. OPENSSL_EXPORT int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx,
  496. const char *section, X509 *cert);
  497. OPENSSL_EXPORT int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx,
  498. const char *section, X509_REQ *req);
  499. OPENSSL_EXPORT int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx,
  500. const char *section, X509_CRL *crl);
  501. OPENSSL_EXPORT int X509V3_add_value_bool_nf(const char *name, int asn1_bool,
  502. STACK_OF(CONF_VALUE) **extlist);
  503. OPENSSL_EXPORT int X509V3_get_value_bool(const CONF_VALUE *value,
  504. int *asn1_bool);
  505. OPENSSL_EXPORT int X509V3_get_value_int(const CONF_VALUE *value,
  506. ASN1_INTEGER **aint);
  507. OPENSSL_EXPORT void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf);
  508. OPENSSL_EXPORT char *X509V3_get_string(X509V3_CTX *ctx, const char *name,
  509. const char *section);
  510. OPENSSL_EXPORT STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx,
  511. const char *section);
  512. OPENSSL_EXPORT void X509V3_string_free(X509V3_CTX *ctx, char *str);
  513. OPENSSL_EXPORT void X509V3_section_free(X509V3_CTX *ctx,
  514. STACK_OF(CONF_VALUE) *section);
  515. OPENSSL_EXPORT void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject,
  516. X509_REQ *req, X509_CRL *crl, int flags);
  517. // X509V3_add_value appends a |CONF_VALUE| containing |name| and |value| to
  518. // |*extlist|. It returns one on success and zero on error. If |*extlist| is
  519. // NULL, it sets |*extlist| to a newly-allocated |STACK_OF(CONF_VALUE)|
  520. // containing the result. Either |name| or |value| may be NULL to omit the
  521. // field.
  522. //
  523. // On failure, if |*extlist| was NULL, |*extlist| will remain NULL when the
  524. // function returns.
  525. OPENSSL_EXPORT int X509V3_add_value(const char *name, const char *value,
  526. STACK_OF(CONF_VALUE) **extlist);
  527. // X509V3_add_value_uchar behaves like |X509V3_add_value| but takes an
  528. // |unsigned char| pointer.
  529. OPENSSL_EXPORT int X509V3_add_value_uchar(const char *name,
  530. const unsigned char *value,
  531. STACK_OF(CONF_VALUE) **extlist);
  532. // X509V3_add_value_bool behaves like |X509V3_add_value| but stores the value
  533. // "TRUE" if |asn1_bool| is non-zero and "FALSE" otherwise.
  534. OPENSSL_EXPORT int X509V3_add_value_bool(const char *name, int asn1_bool,
  535. STACK_OF(CONF_VALUE) **extlist);
  536. // X509V3_add_value_bool behaves like |X509V3_add_value| but stores a string
  537. // representation of |aint|. Note this string representation may be decimal or
  538. // hexadecimal, depending on the size of |aint|.
  539. OPENSSL_EXPORT int X509V3_add_value_int(const char *name,
  540. const ASN1_INTEGER *aint,
  541. STACK_OF(CONF_VALUE) **extlist);
  542. OPENSSL_EXPORT char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth,
  543. const ASN1_INTEGER *aint);
  544. OPENSSL_EXPORT ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth,
  545. const char *value);
  546. OPENSSL_EXPORT char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth,
  547. const ASN1_ENUMERATED *aint);
  548. OPENSSL_EXPORT char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth,
  549. const ASN1_ENUMERATED *aint);
  550. OPENSSL_EXPORT int X509V3_EXT_add(X509V3_EXT_METHOD *ext);
  551. OPENSSL_EXPORT int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist);
  552. OPENSSL_EXPORT int X509V3_EXT_add_alias(int nid_to, int nid_from);
  553. OPENSSL_EXPORT void X509V3_EXT_cleanup(void);
  554. OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get(
  555. const X509_EXTENSION *ext);
  556. OPENSSL_EXPORT const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid);
  557. OPENSSL_EXPORT int X509V3_add_standard_extensions(void);
  558. OPENSSL_EXPORT STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line);
  559. // X509V3_EXT_d2i decodes |ext| and returns a pointer to a newly-allocated
  560. // structure, with type dependent on the type of the extension. It returns NULL
  561. // if |ext| is an unsupported extension or if there was a syntax error in the
  562. // extension. The caller should cast the return value to the expected type and
  563. // free the structure when done.
  564. //
  565. // WARNING: Casting the return value to the wrong type is a potentially
  566. // exploitable memory error, so callers must not use this function before
  567. // checking |ext| is of a known type.
  568. OPENSSL_EXPORT void *X509V3_EXT_d2i(const X509_EXTENSION *ext);
  569. // X509V3_get_d2i finds and decodes the extension in |extensions| of type |nid|.
  570. // If found, it decodes it and returns a newly-allocated structure, with type
  571. // dependent on |nid|. If the extension is not found or on error, it returns
  572. // NULL. The caller may distinguish these cases using the |out_critical| value.
  573. //
  574. // If |out_critical| is not NULL, this function sets |*out_critical| to one if
  575. // the extension is found and critical, zero if it is found and not critical, -1
  576. // if it is not found, and -2 if there is an invalid duplicate extension. Note
  577. // this function may set |*out_critical| to one or zero and still return NULL if
  578. // the extension is found but has a syntax error.
  579. //
  580. // If |out_idx| is not NULL, this function looks for the first occurrence of the
  581. // extension after |*out_idx|. It then sets |*out_idx| to the index of the
  582. // extension, or -1 if not found. If |out_idx| is non-NULL, duplicate extensions
  583. // are not treated as an error. Callers, however, should not rely on this
  584. // behavior as it may be removed in the future. Duplicate extensions are
  585. // forbidden in RFC 5280.
  586. //
  587. // WARNING: This function is difficult to use correctly. Callers should pass a
  588. // non-NULL |out_critical| and check both the return value and |*out_critical|
  589. // to handle errors. If the return value is NULL and |*out_critical| is not -1,
  590. // there was an error. Otherwise, the function succeeded and but may return NULL
  591. // for a missing extension. Callers should pass NULL to |out_idx| so that
  592. // duplicate extensions are handled correctly.
  593. //
  594. // Additionally, casting the return value to the wrong type is a potentially
  595. // exploitable memory error, so callers must ensure the cast and |nid| match.
  596. OPENSSL_EXPORT void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *extensions,
  597. int nid, int *out_critical, int *out_idx);
  598. // X509V3_EXT_free casts |ext_data| into the type that corresponds to |nid| and
  599. // releases memory associated with it. It returns one on success and zero if
  600. // |nid| is not a known extension.
  601. //
  602. // WARNING: Casting |ext_data| to the wrong type is a potentially exploitable
  603. // memory error, so callers must ensure |ext_data|'s type matches |nid|.
  604. //
  605. // TODO(davidben): OpenSSL upstream no longer exposes this function. Remove it?
  606. OPENSSL_EXPORT int X509V3_EXT_free(int nid, void *ext_data);
  607. // X509V3_EXT_i2d casts |ext_struc| into the type that corresponds to
  608. // |ext_nid|, serializes it, and returns a newly-allocated |X509_EXTENSION|
  609. // object containing the serialization, or NULL on error. The |X509_EXTENSION|
  610. // has OID |ext_nid| and is critical if |crit| is one.
  611. //
  612. // WARNING: Casting |ext_struc| to the wrong type is a potentially exploitable
  613. // memory error, so callers must ensure |ext_struct|'s type matches |ext_nid|.
  614. OPENSSL_EXPORT X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit,
  615. void *ext_struc);
  616. // The following constants control the behavior of |X509V3_add1_i2d| and related
  617. // functions.
  618. // X509V3_ADD_OP_MASK can be ANDed with the flags to determine how duplicate
  619. // extensions are processed.
  620. #define X509V3_ADD_OP_MASK 0xfL
  621. // X509V3_ADD_DEFAULT causes the function to fail if the extension was already
  622. // present.
  623. #define X509V3_ADD_DEFAULT 0L
  624. // X509V3_ADD_APPEND causes the function to unconditionally appended the new
  625. // extension to to the extensions list, even if there is a duplicate.
  626. #define X509V3_ADD_APPEND 1L
  627. // X509V3_ADD_REPLACE causes the function to replace the existing extension, or
  628. // append if it is not present.
  629. #define X509V3_ADD_REPLACE 2L
  630. // X509V3_ADD_REPLACE causes the function to replace the existing extension and
  631. // fail if it is not present.
  632. #define X509V3_ADD_REPLACE_EXISTING 3L
  633. // X509V3_ADD_KEEP_EXISTING causes the function to succeed without replacing the
  634. // extension if already present.
  635. #define X509V3_ADD_KEEP_EXISTING 4L
  636. // X509V3_ADD_DELETE causes the function to remove the matching extension. No
  637. // new extension is added. If there is no matching extension, the function
  638. // fails. The |value| parameter is ignored in this mode.
  639. #define X509V3_ADD_DELETE 5L
  640. // X509V3_ADD_SILENT may be ORed into one of the values above to indicate the
  641. // function should not add to the error queue on duplicate or missing extension.
  642. // The function will continue to return zero in those cases, and it will
  643. // continue to return -1 and add to the error queue on other errors.
  644. #define X509V3_ADD_SILENT 0x10
  645. // X509V3_add1_i2d casts |value| to the type that corresponds to |nid|,
  646. // serializes it, and appends it to the extension list in |*x|. If |*x| is NULL,
  647. // it will set |*x| to a newly-allocated |STACK_OF(X509_EXTENSION)| as needed.
  648. // The |crit| parameter determines whether the new extension is critical.
  649. // |flags| may be some combination of the |X509V3_ADD_*| constants to control
  650. // the function's behavior on duplicate extension.
  651. //
  652. // This function returns one on success, zero if the operation failed due to a
  653. // missing or duplicate extension, and -1 on other errors.
  654. //
  655. // WARNING: Casting |value| to the wrong type is a potentially exploitable
  656. // memory error, so callers must ensure |value|'s type matches |nid|.
  657. OPENSSL_EXPORT int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid,
  658. void *value, int crit, unsigned long flags);
  659. #define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)
  660. // X509V3_EXT_DEFAULT causes unknown extensions or syntax errors to return
  661. // failure.
  662. #define X509V3_EXT_DEFAULT 0
  663. // X509V3_EXT_ERROR_UNKNOWN causes unknown extensions or syntax errors to print
  664. // as "<Not Supported>" or "<Parse Error>", respectively.
  665. #define X509V3_EXT_ERROR_UNKNOWN (1L << 16)
  666. // X509V3_EXT_PARSE_UNKNOWN is deprecated and behaves like
  667. // |X509V3_EXT_DUMP_UNKNOWN|.
  668. #define X509V3_EXT_PARSE_UNKNOWN (2L << 16)
  669. // X509V3_EXT_DUMP_UNKNOWN causes unknown extensions to be displayed as a
  670. // hexdump.
  671. #define X509V3_EXT_DUMP_UNKNOWN (3L << 16)
  672. OPENSSL_EXPORT void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val,
  673. int indent, int ml);
  674. OPENSSL_EXPORT int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext,
  675. unsigned long flag, int indent);
  676. OPENSSL_EXPORT int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag,
  677. int indent);
  678. // X509V3_extensions_print prints |title|, followed by a human-readable
  679. // representation of |exts| to |out|. It returns one on success and zero on
  680. // error. The output is indented by |indent| spaces. |flag| is one of the
  681. // |X509V3_EXT_*| constants and controls printing of unknown extensions and
  682. // syntax errors.
  683. OPENSSL_EXPORT int X509V3_extensions_print(BIO *out, const char *title,
  684. const STACK_OF(X509_EXTENSION) *exts,
  685. unsigned long flag, int indent);
  686. OPENSSL_EXPORT int X509_check_ca(X509 *x);
  687. OPENSSL_EXPORT int X509_check_purpose(X509 *x, int id, int ca);
  688. OPENSSL_EXPORT int X509_supported_extension(X509_EXTENSION *ex);
  689. OPENSSL_EXPORT int X509_PURPOSE_set(int *p, int purpose);
  690. OPENSSL_EXPORT int X509_check_issued(X509 *issuer, X509 *subject);
  691. OPENSSL_EXPORT int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid);
  692. OPENSSL_EXPORT uint32_t X509_get_extension_flags(X509 *x);
  693. OPENSSL_EXPORT uint32_t X509_get_key_usage(X509 *x);
  694. OPENSSL_EXPORT uint32_t X509_get_extended_key_usage(X509 *x);
  695. // X509_get0_subject_key_id returns |x509|'s subject key identifier, if present.
  696. // (See RFC 5280, section 4.2.1.2.) It returns NULL if the extension is not
  697. // present or if some extension in |x509| was invalid.
  698. //
  699. // Note that decoding an |X509| object will not check for invalid extensions. To
  700. // detect the error case, call |X509_get_extensions_flags| and check the
  701. // |EXFLAG_INVALID| bit.
  702. OPENSSL_EXPORT const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x509);
  703. // X509_get0_authority_key_id returns keyIdentifier of |x509|'s authority key
  704. // identifier, if the extension and field are present. (See RFC 5280,
  705. // section 4.2.1.1.) It returns NULL if the extension is not present, if it is
  706. // present but lacks a keyIdentifier field, or if some extension in |x509| was
  707. // invalid.
  708. //
  709. // Note that decoding an |X509| object will not check for invalid extensions. To
  710. // detect the error case, call |X509_get_extensions_flags| and check the
  711. // |EXFLAG_INVALID| bit.
  712. OPENSSL_EXPORT const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x509);
  713. // X509_get0_authority_issuer returns the authorityCertIssuer of |x509|'s
  714. // authority key identifier, if the extension and field are present. (See
  715. // RFC 5280, section 4.2.1.1.) It returns NULL if the extension is not present,
  716. // if it is present but lacks a authorityCertIssuer field, or if some extension
  717. // in |x509| was invalid.
  718. //
  719. // Note that decoding an |X509| object will not check for invalid extensions. To
  720. // detect the error case, call |X509_get_extensions_flags| and check the
  721. // |EXFLAG_INVALID| bit.
  722. OPENSSL_EXPORT const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x509);
  723. // X509_get0_authority_serial returns the authorityCertSerialNumber of |x509|'s
  724. // authority key identifier, if the extension and field are present. (See
  725. // RFC 5280, section 4.2.1.1.) It returns NULL if the extension is not present,
  726. // if it is present but lacks a authorityCertSerialNumber field, or if some
  727. // extension in |x509| was invalid.
  728. //
  729. // Note that decoding an |X509| object will not check for invalid extensions. To
  730. // detect the error case, call |X509_get_extensions_flags| and check the
  731. // |EXFLAG_INVALID| bit.
  732. OPENSSL_EXPORT const ASN1_INTEGER *X509_get0_authority_serial(X509 *x509);
  733. OPENSSL_EXPORT int X509_PURPOSE_get_count(void);
  734. OPENSSL_EXPORT X509_PURPOSE *X509_PURPOSE_get0(int idx);
  735. OPENSSL_EXPORT int X509_PURPOSE_get_by_sname(char *sname);
  736. OPENSSL_EXPORT int X509_PURPOSE_get_by_id(int id);
  737. OPENSSL_EXPORT int X509_PURPOSE_add(int id, int trust, int flags,
  738. int (*ck)(const X509_PURPOSE *,
  739. const X509 *, int),
  740. char *name, char *sname, void *arg);
  741. OPENSSL_EXPORT char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp);
  742. OPENSSL_EXPORT char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp);
  743. OPENSSL_EXPORT int X509_PURPOSE_get_trust(const X509_PURPOSE *xp);
  744. OPENSSL_EXPORT void X509_PURPOSE_cleanup(void);
  745. OPENSSL_EXPORT int X509_PURPOSE_get_id(const X509_PURPOSE *);
  746. OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x);
  747. OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x);
  748. OPENSSL_EXPORT void X509_email_free(STACK_OF(OPENSSL_STRING) *sk);
  749. OPENSSL_EXPORT STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x);
  750. // Flags for X509_check_* functions
  751. // Deprecated: this flag does nothing
  752. #define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0
  753. // Disable wildcard matching for dnsName fields and common name.
  754. #define X509_CHECK_FLAG_NO_WILDCARDS 0x2
  755. // X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS does nothing, but is necessary in
  756. // OpenSSL to enable standard wildcard matching. In BoringSSL, this behavior is
  757. // always enabled.
  758. #define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0
  759. // Deprecated: this flag does nothing
  760. #define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0
  761. // Deprecated: this flag does nothing
  762. #define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0
  763. // Skip the subject common name fallback if subjectAltNames is missing.
  764. #define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20
  765. OPENSSL_EXPORT int X509_check_host(X509 *x, const char *chk, size_t chklen,
  766. unsigned int flags, char **peername);
  767. OPENSSL_EXPORT int X509_check_email(X509 *x, const char *chk, size_t chklen,
  768. unsigned int flags);
  769. OPENSSL_EXPORT int X509_check_ip(X509 *x, const unsigned char *chk,
  770. size_t chklen, unsigned int flags);
  771. OPENSSL_EXPORT int X509_check_ip_asc(X509 *x, const char *ipasc,
  772. unsigned int flags);
  773. OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc);
  774. OPENSSL_EXPORT ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc);
  775. OPENSSL_EXPORT int X509V3_NAME_from_section(X509_NAME *nm,
  776. STACK_OF(CONF_VALUE) *dn_sk,
  777. unsigned long chtype);
  778. OPENSSL_EXPORT void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node,
  779. int indent);
  780. DEFINE_STACK_OF(X509_POLICY_NODE)
  781. // BEGIN ERROR CODES
  782. // The following lines are auto generated by the script mkerr.pl. Any changes
  783. // made after this point may be overwritten when the script is next run.
  784. #if defined(__cplusplus)
  785. } // extern C
  786. extern "C++" {
  787. BSSL_NAMESPACE_BEGIN
  788. BORINGSSL_MAKE_DELETER(ACCESS_DESCRIPTION, ACCESS_DESCRIPTION_free)
  789. BORINGSSL_MAKE_DELETER(AUTHORITY_KEYID, AUTHORITY_KEYID_free)
  790. BORINGSSL_MAKE_DELETER(BASIC_CONSTRAINTS, BASIC_CONSTRAINTS_free)
  791. // TODO(davidben): Move this to conf.h and rename to CONF_VALUE_free.
  792. BORINGSSL_MAKE_DELETER(CONF_VALUE, X509V3_conf_free)
  793. BORINGSSL_MAKE_DELETER(DIST_POINT, DIST_POINT_free)
  794. BORINGSSL_MAKE_DELETER(GENERAL_NAME, GENERAL_NAME_free)
  795. BORINGSSL_MAKE_DELETER(GENERAL_SUBTREE, GENERAL_SUBTREE_free)
  796. BORINGSSL_MAKE_DELETER(NAME_CONSTRAINTS, NAME_CONSTRAINTS_free)
  797. BORINGSSL_MAKE_DELETER(POLICY_MAPPING, POLICY_MAPPING_free)
  798. BORINGSSL_MAKE_DELETER(POLICYINFO, POLICYINFO_free)
  799. BSSL_NAMESPACE_END
  800. } // extern C++
  801. #endif
  802. #define X509V3_R_BAD_IP_ADDRESS 100
  803. #define X509V3_R_BAD_OBJECT 101
  804. #define X509V3_R_BN_DEC2BN_ERROR 102
  805. #define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 103
  806. #define X509V3_R_CANNOT_FIND_FREE_FUNCTION 104
  807. #define X509V3_R_DIRNAME_ERROR 105
  808. #define X509V3_R_DISTPOINT_ALREADY_SET 106
  809. #define X509V3_R_DUPLICATE_ZONE_ID 107
  810. #define X509V3_R_ERROR_CONVERTING_ZONE 108
  811. #define X509V3_R_ERROR_CREATING_EXTENSION 109
  812. #define X509V3_R_ERROR_IN_EXTENSION 110
  813. #define X509V3_R_EXPECTED_A_SECTION_NAME 111
  814. #define X509V3_R_EXTENSION_EXISTS 112
  815. #define X509V3_R_EXTENSION_NAME_ERROR 113
  816. #define X509V3_R_EXTENSION_NOT_FOUND 114
  817. #define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 115
  818. #define X509V3_R_EXTENSION_VALUE_ERROR 116
  819. #define X509V3_R_ILLEGAL_EMPTY_EXTENSION 117
  820. #define X509V3_R_ILLEGAL_HEX_DIGIT 118
  821. #define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 119
  822. #define X509V3_R_INVALID_BOOLEAN_STRING 120
  823. #define X509V3_R_INVALID_EXTENSION_STRING 121
  824. #define X509V3_R_INVALID_MULTIPLE_RDNS 122
  825. #define X509V3_R_INVALID_NAME 123
  826. #define X509V3_R_INVALID_NULL_ARGUMENT 124
  827. #define X509V3_R_INVALID_NULL_NAME 125
  828. #define X509V3_R_INVALID_NULL_VALUE 126
  829. #define X509V3_R_INVALID_NUMBER 127
  830. #define X509V3_R_INVALID_NUMBERS 128
  831. #define X509V3_R_INVALID_OBJECT_IDENTIFIER 129
  832. #define X509V3_R_INVALID_OPTION 130
  833. #define X509V3_R_INVALID_POLICY_IDENTIFIER 131
  834. #define X509V3_R_INVALID_PROXY_POLICY_SETTING 132
  835. #define X509V3_R_INVALID_PURPOSE 133
  836. #define X509V3_R_INVALID_SECTION 134
  837. #define X509V3_R_INVALID_SYNTAX 135
  838. #define X509V3_R_ISSUER_DECODE_ERROR 136
  839. #define X509V3_R_MISSING_VALUE 137
  840. #define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 138
  841. #define X509V3_R_NO_CONFIG_DATABASE 139
  842. #define X509V3_R_NO_ISSUER_CERTIFICATE 140
  843. #define X509V3_R_NO_ISSUER_DETAILS 141
  844. #define X509V3_R_NO_POLICY_IDENTIFIER 142
  845. #define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 143
  846. #define X509V3_R_NO_PUBLIC_KEY 144
  847. #define X509V3_R_NO_SUBJECT_DETAILS 145
  848. #define X509V3_R_ODD_NUMBER_OF_DIGITS 146
  849. #define X509V3_R_OPERATION_NOT_DEFINED 147
  850. #define X509V3_R_OTHERNAME_ERROR 148
  851. #define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 149
  852. #define X509V3_R_POLICY_PATH_LENGTH 150
  853. #define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 151
  854. #define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 152
  855. #define X509V3_R_SECTION_NOT_FOUND 153
  856. #define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 154
  857. #define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 155
  858. #define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 156
  859. #define X509V3_R_UNKNOWN_EXTENSION 157
  860. #define X509V3_R_UNKNOWN_EXTENSION_NAME 158
  861. #define X509V3_R_UNKNOWN_OPTION 159
  862. #define X509V3_R_UNSUPPORTED_OPTION 160
  863. #define X509V3_R_UNSUPPORTED_TYPE 161
  864. #define X509V3_R_USER_TOO_LONG 162
  865. #define X509V3_R_INVALID_VALUE 163
  866. #define X509V3_R_TRAILING_DATA_IN_EXTENSION 164
  867. #endif