x509.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. /*
  2. * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. */
  10. #ifndef OPENSSL_X509_H
  11. # define OPENSSL_X509_H
  12. # pragma once
  13. # include <openssl/macros.h>
  14. # ifndef OPENSSL_NO_DEPRECATED_3_0
  15. # define HEADER_X509_H
  16. # endif
  17. # include <openssl/e_os2.h>
  18. # include <openssl/types.h>
  19. # include <openssl/symhacks.h>
  20. # include <openssl/buffer.h>
  21. # include <openssl/evp.h>
  22. # include <openssl/bio.h>
  23. # include <openssl/asn1.h>
  24. # include <openssl/safestack.h>
  25. # include <openssl/ec.h>
  26. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  27. # include <openssl/rsa.h>
  28. # include <openssl/dsa.h>
  29. # include <openssl/dh.h>
  30. # endif
  31. # include <openssl/sha.h>
  32. # include <openssl/x509err.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Flags for X509_get_signature_info() */
  37. /* Signature info is valid */
  38. # define X509_SIG_INFO_VALID 0x1
  39. /* Signature is suitable for TLS use */
  40. # define X509_SIG_INFO_TLS 0x2
  41. # define X509_FILETYPE_PEM 1
  42. # define X509_FILETYPE_ASN1 2
  43. # define X509_FILETYPE_DEFAULT 3
  44. # define X509v3_KU_DIGITAL_SIGNATURE 0x0080
  45. # define X509v3_KU_NON_REPUDIATION 0x0040
  46. # define X509v3_KU_KEY_ENCIPHERMENT 0x0020
  47. # define X509v3_KU_DATA_ENCIPHERMENT 0x0010
  48. # define X509v3_KU_KEY_AGREEMENT 0x0008
  49. # define X509v3_KU_KEY_CERT_SIGN 0x0004
  50. # define X509v3_KU_CRL_SIGN 0x0002
  51. # define X509v3_KU_ENCIPHER_ONLY 0x0001
  52. # define X509v3_KU_DECIPHER_ONLY 0x8000
  53. # define X509v3_KU_UNDEF 0xffff
  54. struct X509_algor_st {
  55. ASN1_OBJECT *algorithm;
  56. ASN1_TYPE *parameter;
  57. } /* X509_ALGOR */ ;
  58. typedef STACK_OF(X509_ALGOR) X509_ALGORS;
  59. typedef struct X509_val_st {
  60. ASN1_TIME *notBefore;
  61. ASN1_TIME *notAfter;
  62. } X509_VAL;
  63. typedef struct X509_sig_st X509_SIG;
  64. typedef struct X509_name_entry_st X509_NAME_ENTRY;
  65. DEFINE_STACK_OF(X509_NAME_ENTRY)
  66. DEFINE_STACK_OF(X509_NAME)
  67. # define X509_EX_V_NETSCAPE_HACK 0x8000
  68. # define X509_EX_V_INIT 0x0001
  69. typedef struct X509_extension_st X509_EXTENSION;
  70. typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
  71. DEFINE_STACK_OF(X509_EXTENSION)
  72. typedef struct x509_attributes_st X509_ATTRIBUTE;
  73. DEFINE_STACK_OF(X509_ATTRIBUTE)
  74. typedef struct X509_req_info_st X509_REQ_INFO;
  75. typedef struct X509_req_st X509_REQ;
  76. typedef struct x509_cert_aux_st X509_CERT_AUX;
  77. typedef struct x509_cinf_st X509_CINF;
  78. DEFINE_STACK_OF(X509)
  79. /* This is used for a table of trust checking functions */
  80. typedef struct x509_trust_st {
  81. int trust;
  82. int flags;
  83. int (*check_trust) (struct x509_trust_st *, X509 *, int);
  84. char *name;
  85. int arg1;
  86. void *arg2;
  87. } X509_TRUST;
  88. DEFINE_STACK_OF(X509_TRUST)
  89. /* standard trust ids */
  90. # define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */
  91. # define X509_TRUST_COMPAT 1
  92. # define X509_TRUST_SSL_CLIENT 2
  93. # define X509_TRUST_SSL_SERVER 3
  94. # define X509_TRUST_EMAIL 4
  95. # define X509_TRUST_OBJECT_SIGN 5
  96. # define X509_TRUST_OCSP_SIGN 6
  97. # define X509_TRUST_OCSP_REQUEST 7
  98. # define X509_TRUST_TSA 8
  99. /* Keep these up to date! */
  100. # define X509_TRUST_MIN 1
  101. # define X509_TRUST_MAX 8
  102. /* trust_flags values */
  103. # define X509_TRUST_DYNAMIC (1U << 0)
  104. # define X509_TRUST_DYNAMIC_NAME (1U << 1)
  105. /* No compat trust if self-signed, preempts "DO_SS" */
  106. # define X509_TRUST_NO_SS_COMPAT (1U << 2)
  107. /* Compat trust if no explicit accepted trust EKUs */
  108. # define X509_TRUST_DO_SS_COMPAT (1U << 3)
  109. /* Accept "anyEKU" as a wildcard trust OID */
  110. # define X509_TRUST_OK_ANY_EKU (1U << 4)
  111. /* check_trust return codes */
  112. # define X509_TRUST_TRUSTED 1
  113. # define X509_TRUST_REJECTED 2
  114. # define X509_TRUST_UNTRUSTED 3
  115. /* Flags for X509_print_ex() */
  116. # define X509_FLAG_COMPAT 0
  117. # define X509_FLAG_NO_HEADER 1L
  118. # define X509_FLAG_NO_VERSION (1L << 1)
  119. # define X509_FLAG_NO_SERIAL (1L << 2)
  120. # define X509_FLAG_NO_SIGNAME (1L << 3)
  121. # define X509_FLAG_NO_ISSUER (1L << 4)
  122. # define X509_FLAG_NO_VALIDITY (1L << 5)
  123. # define X509_FLAG_NO_SUBJECT (1L << 6)
  124. # define X509_FLAG_NO_PUBKEY (1L << 7)
  125. # define X509_FLAG_NO_EXTENSIONS (1L << 8)
  126. # define X509_FLAG_NO_SIGDUMP (1L << 9)
  127. # define X509_FLAG_NO_AUX (1L << 10)
  128. # define X509_FLAG_NO_ATTRIBUTES (1L << 11)
  129. # define X509_FLAG_NO_IDS (1L << 12)
  130. /* Flags specific to X509_NAME_print_ex() */
  131. /* The field separator information */
  132. # define XN_FLAG_SEP_MASK (0xf << 16)
  133. # define XN_FLAG_COMPAT 0/* Traditional; use old X509_NAME_print */
  134. # define XN_FLAG_SEP_COMMA_PLUS (1 << 16)/* RFC2253 ,+ */
  135. # define XN_FLAG_SEP_CPLUS_SPC (2 << 16)/* ,+ spaced: more readable */
  136. # define XN_FLAG_SEP_SPLUS_SPC (3 << 16)/* ;+ spaced */
  137. # define XN_FLAG_SEP_MULTILINE (4 << 16)/* One line per field */
  138. # define XN_FLAG_DN_REV (1 << 20)/* Reverse DN order */
  139. /* How the field name is shown */
  140. # define XN_FLAG_FN_MASK (0x3 << 21)
  141. # define XN_FLAG_FN_SN 0/* Object short name */
  142. # define XN_FLAG_FN_LN (1 << 21)/* Object long name */
  143. # define XN_FLAG_FN_OID (2 << 21)/* Always use OIDs */
  144. # define XN_FLAG_FN_NONE (3 << 21)/* No field names */
  145. # define XN_FLAG_SPC_EQ (1 << 23)/* Put spaces round '=' */
  146. /*
  147. * This determines if we dump fields we don't recognise: RFC2253 requires
  148. * this.
  149. */
  150. # define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
  151. # define XN_FLAG_FN_ALIGN (1 << 25)/* Align field names to 20
  152. * characters */
  153. /* Complete set of RFC2253 flags */
  154. # define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
  155. XN_FLAG_SEP_COMMA_PLUS | \
  156. XN_FLAG_DN_REV | \
  157. XN_FLAG_FN_SN | \
  158. XN_FLAG_DUMP_UNKNOWN_FIELDS)
  159. /* readable oneline form */
  160. # define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
  161. ASN1_STRFLGS_ESC_QUOTE | \
  162. XN_FLAG_SEP_CPLUS_SPC | \
  163. XN_FLAG_SPC_EQ | \
  164. XN_FLAG_FN_SN)
  165. /* readable multiline form */
  166. # define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
  167. ASN1_STRFLGS_ESC_MSB | \
  168. XN_FLAG_SEP_MULTILINE | \
  169. XN_FLAG_SPC_EQ | \
  170. XN_FLAG_FN_LN | \
  171. XN_FLAG_FN_ALIGN)
  172. DEFINE_STACK_OF(X509_REVOKED)
  173. typedef struct X509_crl_info_st X509_CRL_INFO;
  174. DEFINE_STACK_OF(X509_CRL)
  175. typedef struct private_key_st {
  176. int version;
  177. /* The PKCS#8 data types */
  178. X509_ALGOR *enc_algor;
  179. ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
  180. /* When decrypted, the following will not be NULL */
  181. EVP_PKEY *dec_pkey;
  182. /* used to encrypt and decrypt */
  183. int key_length;
  184. char *key_data;
  185. int key_free; /* true if we should auto free key_data */
  186. /* expanded version of 'enc_algor' */
  187. EVP_CIPHER_INFO cipher;
  188. } X509_PKEY;
  189. typedef struct X509_info_st {
  190. X509 *x509;
  191. X509_CRL *crl;
  192. X509_PKEY *x_pkey;
  193. EVP_CIPHER_INFO enc_cipher;
  194. int enc_len;
  195. char *enc_data;
  196. } X509_INFO;
  197. DEFINE_STACK_OF(X509_INFO)
  198. /*
  199. * The next 2 structures and their 8 routines are used to manipulate Netscape's
  200. * spki structures - useful if you are writing a CA web page
  201. */
  202. typedef struct Netscape_spkac_st {
  203. X509_PUBKEY *pubkey;
  204. ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */
  205. } NETSCAPE_SPKAC;
  206. typedef struct Netscape_spki_st {
  207. NETSCAPE_SPKAC *spkac; /* signed public key and challenge */
  208. X509_ALGOR sig_algor;
  209. ASN1_BIT_STRING *signature;
  210. } NETSCAPE_SPKI;
  211. /* Netscape certificate sequence structure */
  212. typedef struct Netscape_certificate_sequence {
  213. ASN1_OBJECT *type;
  214. STACK_OF(X509) *certs;
  215. } NETSCAPE_CERT_SEQUENCE;
  216. /*- Unused (and iv length is wrong)
  217. typedef struct CBCParameter_st
  218. {
  219. unsigned char iv[8];
  220. } CBC_PARAM;
  221. */
  222. /* Password based encryption structure */
  223. typedef struct PBEPARAM_st {
  224. ASN1_OCTET_STRING *salt;
  225. ASN1_INTEGER *iter;
  226. } PBEPARAM;
  227. /* Password based encryption V2 structures */
  228. typedef struct PBE2PARAM_st {
  229. X509_ALGOR *keyfunc;
  230. X509_ALGOR *encryption;
  231. } PBE2PARAM;
  232. typedef struct PBKDF2PARAM_st {
  233. /* Usually OCTET STRING but could be anything */
  234. ASN1_TYPE *salt;
  235. ASN1_INTEGER *iter;
  236. ASN1_INTEGER *keylength;
  237. X509_ALGOR *prf;
  238. } PBKDF2PARAM;
  239. #ifndef OPENSSL_NO_SCRYPT
  240. typedef struct SCRYPT_PARAMS_st {
  241. ASN1_OCTET_STRING *salt;
  242. ASN1_INTEGER *costParameter;
  243. ASN1_INTEGER *blockSize;
  244. ASN1_INTEGER *parallelizationParameter;
  245. ASN1_INTEGER *keyLength;
  246. } SCRYPT_PARAMS;
  247. #endif
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. # include <openssl/x509_vfy.h>
  252. # include <openssl/pkcs7.h>
  253. #ifdef __cplusplus
  254. extern "C" {
  255. #endif
  256. # define X509_EXT_PACK_UNKNOWN 1
  257. # define X509_EXT_PACK_STRING 2
  258. # define X509_extract_key(x) X509_get_pubkey(x)/*****/
  259. # define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
  260. # define X509_name_cmp(a,b) X509_NAME_cmp((a),(b))
  261. void X509_CRL_set_default_method(const X509_CRL_METHOD *meth);
  262. X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
  263. int (*crl_free) (X509_CRL *crl),
  264. int (*crl_lookup) (X509_CRL *crl,
  265. X509_REVOKED **ret,
  266. ASN1_INTEGER *ser,
  267. X509_NAME *issuer),
  268. int (*crl_verify) (X509_CRL *crl,
  269. EVP_PKEY *pk));
  270. void X509_CRL_METHOD_free(X509_CRL_METHOD *m);
  271. void X509_CRL_set_meth_data(X509_CRL *crl, void *dat);
  272. void *X509_CRL_get_meth_data(X509_CRL *crl);
  273. const char *X509_verify_cert_error_string(long n);
  274. int X509_verify(X509 *a, EVP_PKEY *r);
  275. int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
  276. int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
  277. int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
  278. NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len);
  279. char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
  280. EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
  281. int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
  282. int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
  283. int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
  284. int X509_signature_print(BIO *bp, const X509_ALGOR *alg,
  285. const ASN1_STRING *sig);
  286. int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  287. int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
  288. # ifndef OPENSSL_NO_OCSP
  289. int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert);
  290. # endif
  291. int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
  292. int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
  293. int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
  294. int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
  295. # ifndef OPENSSL_NO_OCSP
  296. int X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl);
  297. # endif
  298. int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
  299. int X509_pubkey_digest(const X509 *data, const EVP_MD *type,
  300. unsigned char *md, unsigned int *len);
  301. int X509_digest(const X509 *data, const EVP_MD *type,
  302. unsigned char *md, unsigned int *len);
  303. int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
  304. unsigned char *md, unsigned int *len);
  305. int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,
  306. unsigned char *md, unsigned int *len);
  307. int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,
  308. unsigned char *md, unsigned int *len);
  309. # ifndef OPENSSL_NO_STDIO
  310. X509 *d2i_X509_fp(FILE *fp, X509 **x509);
  311. int i2d_X509_fp(FILE *fp, const X509 *x509);
  312. X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl);
  313. int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl);
  314. X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req);
  315. int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req);
  316. # ifndef OPENSSL_NO_RSA
  317. RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa);
  318. int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa);
  319. RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa);
  320. int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa);
  321. RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa);
  322. int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa);
  323. # endif
  324. # ifndef OPENSSL_NO_DSA
  325. DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
  326. int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa);
  327. DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
  328. int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa);
  329. # endif
  330. # ifndef OPENSSL_NO_EC
  331. EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
  332. int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey);
  333. EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
  334. int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey);
  335. # endif
  336. X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8);
  337. int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8);
  338. X509_PUBKEY *d2i_X509_PUBKEY_fp(FILE *fp, X509_PUBKEY **xpk);
  339. int i2d_X509_PUBKEY_fp(FILE *fp, const X509_PUBKEY *xpk);
  340. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
  341. PKCS8_PRIV_KEY_INFO **p8inf);
  342. int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf);
  343. int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key);
  344. int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey);
  345. EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
  346. int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey);
  347. EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
  348. # endif
  349. X509 *d2i_X509_bio(BIO *bp, X509 **x509);
  350. int i2d_X509_bio(BIO *bp, const X509 *x509);
  351. X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl);
  352. int i2d_X509_CRL_bio(BIO *bp, const X509_CRL *crl);
  353. X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req);
  354. int i2d_X509_REQ_bio(BIO *bp, const X509_REQ *req);
  355. # ifndef OPENSSL_NO_RSA
  356. RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa);
  357. int i2d_RSAPrivateKey_bio(BIO *bp, const RSA *rsa);
  358. RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa);
  359. int i2d_RSAPublicKey_bio(BIO *bp, const RSA *rsa);
  360. RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa);
  361. int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa);
  362. # endif
  363. # ifndef OPENSSL_NO_DSA
  364. DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
  365. int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa);
  366. DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
  367. int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa);
  368. # endif
  369. # ifndef OPENSSL_NO_EC
  370. EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
  371. int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *eckey);
  372. EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
  373. int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey);
  374. # endif
  375. X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8);
  376. int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8);
  377. X509_PUBKEY *d2i_X509_PUBKEY_bio(BIO *bp, X509_PUBKEY **xpk);
  378. int i2d_X509_PUBKEY_bio(BIO *bp, const X509_PUBKEY *xpk);
  379. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
  380. PKCS8_PRIV_KEY_INFO **p8inf);
  381. int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf);
  382. int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key);
  383. int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey);
  384. EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
  385. int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey);
  386. EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
  387. DECLARE_ASN1_DUP_FUNCTION(X509)
  388. DECLARE_ASN1_DUP_FUNCTION(X509_ALGOR)
  389. DECLARE_ASN1_DUP_FUNCTION(X509_ATTRIBUTE)
  390. DECLARE_ASN1_DUP_FUNCTION(X509_CRL)
  391. DECLARE_ASN1_DUP_FUNCTION(X509_EXTENSION)
  392. DECLARE_ASN1_DUP_FUNCTION(X509_PUBKEY)
  393. DECLARE_ASN1_DUP_FUNCTION(X509_REQ)
  394. DECLARE_ASN1_DUP_FUNCTION(X509_REVOKED)
  395. int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype,
  396. void *pval);
  397. void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype,
  398. const void **ppval, const X509_ALGOR *algor);
  399. void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
  400. int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
  401. DECLARE_ASN1_DUP_FUNCTION(X509_NAME)
  402. DECLARE_ASN1_DUP_FUNCTION(X509_NAME_ENTRY)
  403. int X509_cmp_time(const ASN1_TIME *s, time_t *t);
  404. int X509_cmp_current_time(const ASN1_TIME *s);
  405. int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm,
  406. const ASN1_TIME *start, const ASN1_TIME *end);
  407. ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
  408. ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s,
  409. int offset_day, long offset_sec, time_t *t);
  410. ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj);
  411. const char *X509_get_default_cert_area(void);
  412. const char *X509_get_default_cert_dir(void);
  413. const char *X509_get_default_cert_file(void);
  414. const char *X509_get_default_cert_dir_env(void);
  415. const char *X509_get_default_cert_file_env(void);
  416. const char *X509_get_default_private_dir(void);
  417. X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  418. X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey);
  419. DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
  420. DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS)
  421. DECLARE_ASN1_FUNCTIONS(X509_VAL)
  422. DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
  423. int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
  424. EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key);
  425. EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key);
  426. int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain);
  427. long X509_get_pathlen(X509 *x);
  428. DECLARE_ASN1_ENCODE_FUNCTIONS_only(EVP_PKEY, PUBKEY)
  429. # ifndef OPENSSL_NO_RSA
  430. DECLARE_ASN1_ENCODE_FUNCTIONS_only(RSA, RSA_PUBKEY)
  431. # endif
  432. # ifndef OPENSSL_NO_DSA
  433. DECLARE_ASN1_ENCODE_FUNCTIONS_only(DSA, DSA_PUBKEY)
  434. # endif
  435. # ifndef OPENSSL_NO_EC
  436. DECLARE_ASN1_ENCODE_FUNCTIONS_only(EC_KEY, EC_PUBKEY)
  437. # endif
  438. DECLARE_ASN1_FUNCTIONS(X509_SIG)
  439. void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,
  440. const ASN1_OCTET_STRING **pdigest);
  441. void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,
  442. ASN1_OCTET_STRING **pdigest);
  443. DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
  444. DECLARE_ASN1_FUNCTIONS(X509_REQ)
  445. DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
  446. X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
  447. DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
  448. DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS)
  449. DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
  450. DECLARE_ASN1_FUNCTIONS(X509_NAME)
  451. int X509_NAME_set(X509_NAME **xn, const X509_NAME *name);
  452. DECLARE_ASN1_FUNCTIONS(X509_CINF)
  453. DECLARE_ASN1_FUNCTIONS(X509)
  454. DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
  455. #define X509_get_ex_new_index(l, p, newf, dupf, freef) \
  456. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef)
  457. int X509_set_ex_data(X509 *r, int idx, void *arg);
  458. void *X509_get_ex_data(X509 *r, int idx);
  459. DECLARE_ASN1_ENCODE_FUNCTIONS_only(X509,X509_AUX)
  460. int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
  461. int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid,
  462. int *secbits, uint32_t *flags);
  463. void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid,
  464. int secbits, uint32_t flags);
  465. int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits,
  466. uint32_t *flags);
  467. void X509_get0_signature(const ASN1_BIT_STRING **psig,
  468. const X509_ALGOR **palg, const X509 *x);
  469. int X509_get_signature_nid(const X509 *x);
  470. # ifndef OPENSSL_NO_SM2
  471. void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id);
  472. ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x);
  473. void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id);
  474. ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x);
  475. # endif
  476. int X509_trusted(const X509 *x);
  477. int X509_alias_set1(X509 *x, const unsigned char *name, int len);
  478. int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
  479. unsigned char *X509_alias_get0(X509 *x, int *len);
  480. unsigned char *X509_keyid_get0(X509 *x, int *len);
  481. int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *,
  482. int);
  483. int X509_TRUST_set(int *t, int trust);
  484. int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
  485. int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);
  486. void X509_trust_clear(X509 *x);
  487. void X509_reject_clear(X509 *x);
  488. STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x);
  489. STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x);
  490. DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
  491. DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
  492. DECLARE_ASN1_FUNCTIONS(X509_CRL)
  493. int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
  494. int X509_CRL_get0_by_serial(X509_CRL *crl,
  495. X509_REVOKED **ret, ASN1_INTEGER *serial);
  496. int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
  497. X509_PKEY *X509_PKEY_new(void);
  498. void X509_PKEY_free(X509_PKEY *a);
  499. DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
  500. DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
  501. DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
  502. X509_INFO *X509_INFO_new(void);
  503. void X509_INFO_free(X509_INFO *a);
  504. char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size);
  505. int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
  506. ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey);
  507. int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data,
  508. unsigned char *md, unsigned int *len);
  509. int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
  510. X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
  511. char *data, EVP_PKEY *pkey, const EVP_MD *type);
  512. int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data,
  513. unsigned char *md, unsigned int *len);
  514. int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
  515. ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey);
  516. int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1,
  517. X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data,
  518. EVP_PKEY *pkey, const EVP_MD *type);
  519. int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1,
  520. X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
  521. void *asn, EVP_MD_CTX *ctx);
  522. long X509_get_version(const X509 *x);
  523. int X509_set_version(X509 *x, long version);
  524. int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
  525. ASN1_INTEGER *X509_get_serialNumber(X509 *x);
  526. const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);
  527. int X509_set_issuer_name(X509 *x, X509_NAME *name);
  528. X509_NAME *X509_get_issuer_name(const X509 *a);
  529. int X509_set_subject_name(X509 *x, X509_NAME *name);
  530. X509_NAME *X509_get_subject_name(const X509 *a);
  531. const ASN1_TIME * X509_get0_notBefore(const X509 *x);
  532. ASN1_TIME *X509_getm_notBefore(const X509 *x);
  533. int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);
  534. const ASN1_TIME *X509_get0_notAfter(const X509 *x);
  535. ASN1_TIME *X509_getm_notAfter(const X509 *x);
  536. int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);
  537. int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
  538. int X509_up_ref(X509 *x);
  539. int X509_get_signature_type(const X509 *x);
  540. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  541. # define X509_get_notBefore X509_getm_notBefore
  542. # define X509_get_notAfter X509_getm_notAfter
  543. # define X509_set_notBefore X509_set1_notBefore
  544. # define X509_set_notAfter X509_set1_notAfter
  545. #endif
  546. /*
  547. * This one is only used so that a binary form can output, as in
  548. * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf)
  549. */
  550. X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
  551. const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
  552. void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,
  553. const ASN1_BIT_STRING **psuid);
  554. const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
  555. EVP_PKEY *X509_get0_pubkey(const X509 *x);
  556. EVP_PKEY *X509_get_pubkey(X509 *x);
  557. ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
  558. int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey);
  559. long X509_REQ_get_version(const X509_REQ *req);
  560. int X509_REQ_set_version(X509_REQ *x, long version);
  561. X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req);
  562. int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
  563. void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
  564. const X509_ALGOR **palg);
  565. int X509_REQ_get_signature_nid(const X509_REQ *req);
  566. int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
  567. int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
  568. EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req);
  569. EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req);
  570. X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req);
  571. int X509_REQ_extension_nid(int nid);
  572. int *X509_REQ_get_extension_nids(void);
  573. void X509_REQ_set_extension_nids(int *nids);
  574. STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
  575. int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
  576. int nid);
  577. int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
  578. int X509_REQ_get_attr_count(const X509_REQ *req);
  579. int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
  580. int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
  581. int lastpos);
  582. X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
  583. X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
  584. int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
  585. int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
  586. const ASN1_OBJECT *obj, int type,
  587. const unsigned char *bytes, int len);
  588. int X509_REQ_add1_attr_by_NID(X509_REQ *req,
  589. int nid, int type,
  590. const unsigned char *bytes, int len);
  591. int X509_REQ_add1_attr_by_txt(X509_REQ *req,
  592. const char *attrname, int type,
  593. const unsigned char *bytes, int len);
  594. int X509_CRL_set_version(X509_CRL *x, long version);
  595. int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
  596. int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
  597. int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
  598. int X509_CRL_sort(X509_CRL *crl);
  599. int X509_CRL_up_ref(X509_CRL *crl);
  600. # ifndef OPENSSL_NO_DEPRECATED_1_1_0
  601. # define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate
  602. # define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate
  603. #endif
  604. long X509_CRL_get_version(const X509_CRL *crl);
  605. const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);
  606. const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);
  607. DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl))
  608. DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl))
  609. X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
  610. const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
  611. STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
  612. void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
  613. const X509_ALGOR **palg);
  614. int X509_CRL_get_signature_nid(const X509_CRL *crl);
  615. int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
  616. const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);
  617. int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
  618. const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);
  619. int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
  620. const STACK_OF(X509_EXTENSION) *
  621. X509_REVOKED_get0_extensions(const X509_REVOKED *r);
  622. X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer,
  623. EVP_PKEY *skey, const EVP_MD *md, unsigned int flags);
  624. int X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey);
  625. int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);
  626. int X509_chain_check_suiteb(int *perror_depth,
  627. X509 *x, STACK_OF(X509) *chain,
  628. unsigned long flags);
  629. int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags);
  630. STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
  631. int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
  632. unsigned long X509_issuer_and_serial_hash(X509 *a);
  633. int X509_issuer_name_cmp(const X509 *a, const X509 *b);
  634. unsigned long X509_issuer_name_hash(X509 *a);
  635. int X509_subject_name_cmp(const X509 *a, const X509 *b);
  636. unsigned long X509_subject_name_hash(X509 *x);
  637. # ifndef OPENSSL_NO_MD5
  638. unsigned long X509_issuer_name_hash_old(X509 *a);
  639. unsigned long X509_subject_name_hash_old(X509 *x);
  640. # endif
  641. int X509_cmp(const X509 *a, const X509 *b);
  642. int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
  643. unsigned long X509_NAME_hash(X509_NAME *x);
  644. unsigned long X509_NAME_hash_old(X509_NAME *x);
  645. int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
  646. int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
  647. int X509_aux_print(BIO *out, X509 *x, int indent);
  648. # ifndef OPENSSL_NO_STDIO
  649. int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag,
  650. unsigned long cflag);
  651. int X509_print_fp(FILE *bp, X509 *x);
  652. int X509_CRL_print_fp(FILE *bp, X509_CRL *x);
  653. int X509_REQ_print_fp(FILE *bp, X509_REQ *req);
  654. int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,
  655. unsigned long flags);
  656. # endif
  657. int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);
  658. int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,
  659. unsigned long flags);
  660. int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag,
  661. unsigned long cflag);
  662. int X509_print(BIO *bp, X509 *x);
  663. int X509_ocspid_print(BIO *bp, X509 *x);
  664. int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag);
  665. int X509_CRL_print(BIO *bp, X509_CRL *x);
  666. int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag,
  667. unsigned long cflag);
  668. int X509_REQ_print(BIO *bp, X509_REQ *req);
  669. int X509_NAME_entry_count(const X509_NAME *name);
  670. int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len);
  671. int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,
  672. char *buf, int len);
  673. /*
  674. * NOTE: you should be passing -1, not 0 as lastpos. The functions that use
  675. * lastpos, search after that position on.
  676. */
  677. int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos);
  678. int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,
  679. int lastpos);
  680. X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
  681. X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
  682. int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,
  683. int loc, int set);
  684. int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type,
  685. const unsigned char *bytes, int len, int loc,
  686. int set);
  687. int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
  688. const unsigned char *bytes, int len, int loc,
  689. int set);
  690. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
  691. const char *field, int type,
  692. const unsigned char *bytes,
  693. int len);
  694. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
  695. int type,
  696. const unsigned char *bytes,
  697. int len);
  698. int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
  699. const unsigned char *bytes, int len, int loc,
  700. int set);
  701. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
  702. const ASN1_OBJECT *obj, int type,
  703. const unsigned char *bytes,
  704. int len);
  705. int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj);
  706. int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
  707. const unsigned char *bytes, int len);
  708. ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);
  709. ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);
  710. int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
  711. int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,
  712. size_t *pderlen);
  713. int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
  714. int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
  715. int nid, int lastpos);
  716. int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
  717. const ASN1_OBJECT *obj, int lastpos);
  718. int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
  719. int crit, int lastpos);
  720. X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
  721. X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
  722. STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
  723. X509_EXTENSION *ex, int loc);
  724. int X509_get_ext_count(const X509 *x);
  725. int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);
  726. int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos);
  727. int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);
  728. X509_EXTENSION *X509_get_ext(const X509 *x, int loc);
  729. X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
  730. int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
  731. void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
  732. int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
  733. unsigned long flags);
  734. int X509_CRL_get_ext_count(const X509_CRL *x);
  735. int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);
  736. int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj,
  737. int lastpos);
  738. int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos);
  739. X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
  740. X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
  741. int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
  742. void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);
  743. int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
  744. unsigned long flags);
  745. int X509_REVOKED_get_ext_count(const X509_REVOKED *x);
  746. int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos);
  747. int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj,
  748. int lastpos);
  749. int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit,
  750. int lastpos);
  751. X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);
  752. X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
  753. int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
  754. void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit,
  755. int *idx);
  756. int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
  757. unsigned long flags);
  758. X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
  759. int nid, int crit,
  760. ASN1_OCTET_STRING *data);
  761. X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
  762. const ASN1_OBJECT *obj, int crit,
  763. ASN1_OCTET_STRING *data);
  764. int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);
  765. int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
  766. int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data);
  767. ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex);
  768. ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
  769. int X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
  770. int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
  771. int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
  772. int lastpos);
  773. int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
  774. const ASN1_OBJECT *obj, int lastpos);
  775. X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
  776. X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
  777. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
  778. X509_ATTRIBUTE *attr);
  779. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE)
  780. **x, const ASN1_OBJECT *obj,
  781. int type,
  782. const unsigned char *bytes,
  783. int len);
  784. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE)
  785. **x, int nid, int type,
  786. const unsigned char *bytes,
  787. int len);
  788. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE)
  789. **x, const char *attrname,
  790. int type,
  791. const unsigned char *bytes,
  792. int len);
  793. void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
  794. const ASN1_OBJECT *obj, int lastpos, int type);
  795. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
  796. int atrtype, const void *data,
  797. int len);
  798. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
  799. const ASN1_OBJECT *obj,
  800. int atrtype, const void *data,
  801. int len);
  802. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
  803. const char *atrname, int type,
  804. const unsigned char *bytes,
  805. int len);
  806. int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
  807. int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype,
  808. const void *data, int len);
  809. void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype,
  810. void *data);
  811. int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
  812. ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
  813. ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
  814. int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
  815. int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
  816. int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
  817. int lastpos);
  818. X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
  819. X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
  820. int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
  821. int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
  822. const ASN1_OBJECT *obj, int type,
  823. const unsigned char *bytes, int len);
  824. int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
  825. int nid, int type,
  826. const unsigned char *bytes, int len);
  827. int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
  828. const char *attrname, int type,
  829. const unsigned char *bytes, int len);
  830. int X509_verify_cert(X509_STORE_CTX *ctx);
  831. /* lookup a cert from a X509 STACK */
  832. X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
  833. ASN1_INTEGER *serial);
  834. X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name);
  835. DECLARE_ASN1_FUNCTIONS(PBEPARAM)
  836. DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
  837. DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
  838. #ifndef OPENSSL_NO_SCRYPT
  839. DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS)
  840. #endif
  841. int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
  842. const unsigned char *salt, int saltlen);
  843. X509_ALGOR *PKCS5_pbe_set(int alg, int iter,
  844. const unsigned char *salt, int saltlen);
  845. X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
  846. unsigned char *salt, int saltlen);
  847. X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
  848. unsigned char *salt, int saltlen,
  849. unsigned char *aiv, int prf_nid);
  850. #ifndef OPENSSL_NO_SCRYPT
  851. X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher,
  852. const unsigned char *salt, int saltlen,
  853. unsigned char *aiv, uint64_t N, uint64_t r,
  854. uint64_t p);
  855. #endif
  856. X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
  857. int prf_nid, int keylen);
  858. /* PKCS#8 utilities */
  859. DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
  860. EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);
  861. PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey);
  862. int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
  863. int version, int ptype, void *pval,
  864. unsigned char *penc, int penclen);
  865. int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg,
  866. const unsigned char **pk, int *ppklen,
  867. const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);
  868. const STACK_OF(X509_ATTRIBUTE) *
  869. PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);
  870. int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,
  871. const unsigned char *bytes, int len);
  872. int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
  873. int ptype, void *pval,
  874. unsigned char *penc, int penclen);
  875. int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
  876. const unsigned char **pk, int *ppklen,
  877. X509_ALGOR **pa, X509_PUBKEY *pub);
  878. int X509_check_trust(X509 *x, int id, int flags);
  879. int X509_TRUST_get_count(void);
  880. X509_TRUST *X509_TRUST_get0(int idx);
  881. int X509_TRUST_get_by_id(int id);
  882. int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int),
  883. const char *name, int arg1, void *arg2);
  884. void X509_TRUST_cleanup(void);
  885. int X509_TRUST_get_flags(const X509_TRUST *xp);
  886. char *X509_TRUST_get0_name(const X509_TRUST *xp);
  887. int X509_TRUST_get_trust(const X509_TRUST *xp);
  888. # ifdef __cplusplus
  889. }
  890. # endif
  891. #endif