x509.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. /* $OpenBSD: x509.h,v 1.111 2024/03/02 10:59:41 tb Exp $ */
  2. /* Copyright (C) 1995-1998 Eric Young ([email protected])
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young ([email protected]).
  7. * The implementation was written so as to conform with Netscapes SSL.
  8. *
  9. * This library is free for commercial and non-commercial use as long as
  10. * the following conditions are aheared to. The following conditions
  11. * apply to all code found in this distribution, be it the RC4, RSA,
  12. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  13. * included with this distribution is covered by the same copyright terms
  14. * except that the holder is Tim Hudson ([email protected]).
  15. *
  16. * Copyright remains Eric Young's, and as such any Copyright notices in
  17. * the code are not to be removed.
  18. * If this package is used in a product, Eric Young should be given attribution
  19. * as the author of the parts of the library used.
  20. * This can be in the form of a textual message at program startup or
  21. * in documentation (online or textual) provided with the package.
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions
  25. * are met:
  26. * 1. Redistributions of source code must retain the copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * 2. Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in the
  30. * documentation and/or other materials provided with the distribution.
  31. * 3. All advertising materials mentioning features or use of this software
  32. * must display the following acknowledgement:
  33. * "This product includes cryptographic software written by
  34. * Eric Young ([email protected])"
  35. * The word 'cryptographic' can be left out if the rouines from the library
  36. * being used are not cryptographic related :-).
  37. * 4. If you include any Windows specific code (or a derivative thereof) from
  38. * the apps directory (application code) you must include an acknowledgement:
  39. * "This product includes software written by Tim Hudson ([email protected])"
  40. *
  41. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  42. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  43. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  44. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  45. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  46. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  47. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  49. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  50. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  51. * SUCH DAMAGE.
  52. *
  53. * The licence and distribution terms for any publically available version or
  54. * derivative of this code cannot be changed. i.e. this code cannot simply be
  55. * copied and put under another distribution licence
  56. * [including the GNU Public Licence.]
  57. */
  58. /* ====================================================================
  59. * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  60. * ECDH support in OpenSSL originally developed by
  61. * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
  62. */
  63. #ifndef HEADER_X509_H
  64. #define HEADER_X509_H
  65. #include <openssl/opensslconf.h>
  66. #include <openssl/asn1.h>
  67. #ifndef OPENSSL_NO_BIO
  68. #include <openssl/bio.h>
  69. #endif
  70. #ifndef OPENSSL_NO_BUFFER
  71. #include <openssl/buffer.h>
  72. #endif
  73. #ifndef OPENSSL_NO_DH
  74. #include <openssl/dh.h>
  75. #endif
  76. #ifndef OPENSSL_NO_DSA
  77. #include <openssl/dsa.h>
  78. #endif
  79. #ifndef OPENSSL_NO_EC
  80. #include <openssl/ec.h>
  81. #endif
  82. #ifndef OPENSSL_NO_EVP
  83. #include <openssl/evp.h>
  84. #endif
  85. #ifndef OPENSSL_NO_RSA
  86. #include <openssl/rsa.h>
  87. #endif
  88. #ifndef OPENSSL_NO_SHA
  89. #include <openssl/sha.h>
  90. #endif
  91. #include <openssl/stack.h>
  92. #include <openssl/safestack.h>
  93. #include <openssl/ossl_typ.h>
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif
  97. #if defined(_WIN32) && defined(__WINCRYPT_H__)
  98. #if !defined(LIBRESSL_INTERNAL) && !defined(LIBRESSL_DISABLE_OVERRIDE_WINCRYPT_DEFINES_WARNING)
  99. #ifdef _MSC_VER
  100. #pragma message("Warning, overriding WinCrypt defines")
  101. #else
  102. #warning overriding WinCrypt defines
  103. #endif
  104. #endif
  105. #undef X509_NAME
  106. #undef X509_EXTENSIONS
  107. #endif
  108. #define X509_FILETYPE_PEM 1
  109. #define X509_FILETYPE_ASN1 2
  110. #define X509_FILETYPE_DEFAULT 3
  111. #define X509v3_KU_DIGITAL_SIGNATURE 0x0080
  112. #define X509v3_KU_NON_REPUDIATION 0x0040
  113. #define X509v3_KU_KEY_ENCIPHERMENT 0x0020
  114. #define X509v3_KU_DATA_ENCIPHERMENT 0x0010
  115. #define X509v3_KU_KEY_AGREEMENT 0x0008
  116. #define X509v3_KU_KEY_CERT_SIGN 0x0004
  117. #define X509v3_KU_CRL_SIGN 0x0002
  118. #define X509v3_KU_ENCIPHER_ONLY 0x0001
  119. #define X509v3_KU_DECIPHER_ONLY 0x8000
  120. #define X509v3_KU_UNDEF 0xffff
  121. struct X509_algor_st {
  122. ASN1_OBJECT *algorithm;
  123. ASN1_TYPE *parameter;
  124. } /* X509_ALGOR */;
  125. typedef STACK_OF(X509_ALGOR) X509_ALGORS;
  126. typedef struct X509_val_st {
  127. ASN1_TIME *notBefore;
  128. ASN1_TIME *notAfter;
  129. } X509_VAL;
  130. typedef struct X509_sig_st X509_SIG;
  131. typedef struct X509_name_entry_st X509_NAME_ENTRY;
  132. DECLARE_STACK_OF(X509_NAME_ENTRY)
  133. DECLARE_STACK_OF(X509_NAME)
  134. typedef struct X509_extension_st X509_EXTENSION;
  135. typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
  136. DECLARE_STACK_OF(X509_EXTENSION)
  137. typedef struct x509_attributes_st X509_ATTRIBUTE;
  138. DECLARE_STACK_OF(X509_ATTRIBUTE)
  139. typedef struct X509_req_info_st X509_REQ_INFO;
  140. typedef struct X509_req_st X509_REQ;
  141. typedef struct x509_cinf_st X509_CINF;
  142. DECLARE_STACK_OF(X509)
  143. /* standard trust ids */
  144. /* OpenSSL changed this to 0 */
  145. #define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */
  146. #define X509_TRUST_COMPAT 1
  147. #define X509_TRUST_SSL_CLIENT 2
  148. #define X509_TRUST_SSL_SERVER 3
  149. #define X509_TRUST_EMAIL 4
  150. #define X509_TRUST_OBJECT_SIGN 5
  151. #define X509_TRUST_OCSP_SIGN 6
  152. #define X509_TRUST_OCSP_REQUEST 7
  153. #define X509_TRUST_TSA 8
  154. /* Keep these up to date! */
  155. #define X509_TRUST_MIN 1
  156. #define X509_TRUST_MAX 8
  157. /* trust_flags values */
  158. #define X509_TRUST_DYNAMIC 1
  159. #define X509_TRUST_DYNAMIC_NAME 2
  160. /* check_trust return codes */
  161. #define X509_TRUST_TRUSTED 1
  162. #define X509_TRUST_REJECTED 2
  163. #define X509_TRUST_UNTRUSTED 3
  164. /* Flags for X509_print_ex() */
  165. #define X509_FLAG_COMPAT 0
  166. #define X509_FLAG_NO_HEADER 1L
  167. #define X509_FLAG_NO_VERSION (1L << 1)
  168. #define X509_FLAG_NO_SERIAL (1L << 2)
  169. #define X509_FLAG_NO_SIGNAME (1L << 3)
  170. #define X509_FLAG_NO_ISSUER (1L << 4)
  171. #define X509_FLAG_NO_VALIDITY (1L << 5)
  172. #define X509_FLAG_NO_SUBJECT (1L << 6)
  173. #define X509_FLAG_NO_PUBKEY (1L << 7)
  174. #define X509_FLAG_NO_EXTENSIONS (1L << 8)
  175. #define X509_FLAG_NO_SIGDUMP (1L << 9)
  176. #define X509_FLAG_NO_AUX (1L << 10)
  177. #define X509_FLAG_NO_ATTRIBUTES (1L << 11)
  178. /* Flags specific to X509_NAME_print_ex() */
  179. /* The field separator information */
  180. #define XN_FLAG_SEP_MASK (0xf << 16)
  181. #define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */
  182. #define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */
  183. #define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */
  184. #define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */
  185. #define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */
  186. #define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */
  187. /* How the field name is shown */
  188. #define XN_FLAG_FN_MASK (0x3 << 21)
  189. #define XN_FLAG_FN_SN 0 /* Object short name */
  190. #define XN_FLAG_FN_LN (1 << 21) /* Object long name */
  191. #define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */
  192. #define XN_FLAG_FN_NONE (3 << 21) /* No field names */
  193. #define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */
  194. /* This determines if we dump fields we don't recognise:
  195. * RFC2253 requires this.
  196. */
  197. #define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
  198. #define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */
  199. /* Complete set of RFC2253 flags */
  200. #define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
  201. XN_FLAG_SEP_COMMA_PLUS | \
  202. XN_FLAG_DN_REV | \
  203. XN_FLAG_FN_SN | \
  204. XN_FLAG_DUMP_UNKNOWN_FIELDS)
  205. /* readable oneline form */
  206. #define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
  207. ASN1_STRFLGS_ESC_QUOTE | \
  208. XN_FLAG_SEP_CPLUS_SPC | \
  209. XN_FLAG_SPC_EQ | \
  210. XN_FLAG_FN_SN)
  211. /* readable multiline form */
  212. #define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
  213. ASN1_STRFLGS_ESC_MSB | \
  214. XN_FLAG_SEP_MULTILINE | \
  215. XN_FLAG_SPC_EQ | \
  216. XN_FLAG_FN_LN | \
  217. XN_FLAG_FN_ALIGN)
  218. DECLARE_STACK_OF(X509_REVOKED)
  219. typedef struct X509_crl_info_st X509_CRL_INFO;
  220. DECLARE_STACK_OF(X509_CRL)
  221. typedef struct private_key_st {
  222. int version;
  223. /* The PKCS#8 data types */
  224. X509_ALGOR *enc_algor;
  225. ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
  226. /* When decrypted, the following will not be NULL */
  227. EVP_PKEY *dec_pkey;
  228. /* used to encrypt and decrypt */
  229. int key_length;
  230. char *key_data;
  231. int key_free; /* true if we should auto free key_data */
  232. /* expanded version of 'enc_algor' */
  233. EVP_CIPHER_INFO cipher;
  234. int references;
  235. } X509_PKEY;
  236. #ifndef OPENSSL_NO_EVP
  237. typedef struct X509_info_st {
  238. X509 *x509;
  239. X509_CRL *crl;
  240. X509_PKEY *x_pkey;
  241. EVP_CIPHER_INFO enc_cipher;
  242. int enc_len;
  243. char *enc_data;
  244. int references;
  245. } X509_INFO;
  246. DECLARE_STACK_OF(X509_INFO)
  247. #endif
  248. /* The next 2 structures and their 8 routines were sent to me by
  249. * Pat Richard <[email protected]> and are used to manipulate
  250. * Netscapes spki structures - useful if you are writing a CA web page
  251. */
  252. typedef struct Netscape_spkac_st {
  253. X509_PUBKEY *pubkey;
  254. ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */
  255. } NETSCAPE_SPKAC;
  256. typedef struct Netscape_spki_st {
  257. NETSCAPE_SPKAC *spkac; /* signed public key and challenge */
  258. X509_ALGOR *sig_algor;
  259. ASN1_BIT_STRING *signature;
  260. } NETSCAPE_SPKI;
  261. typedef struct PBEPARAM_st {
  262. ASN1_OCTET_STRING *salt;
  263. ASN1_INTEGER *iter;
  264. } PBEPARAM;
  265. #ifdef __cplusplus
  266. }
  267. #endif
  268. #include <openssl/x509_vfy.h>
  269. #include <openssl/pkcs7.h>
  270. #ifdef __cplusplus
  271. extern "C" {
  272. #endif
  273. #define X509_extract_key(x) X509_get_pubkey(x) /*****/
  274. #define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
  275. #define X509_name_cmp(a,b) X509_NAME_cmp((a),(b))
  276. int X509_CRL_up_ref(X509_CRL *x);
  277. int X509_CRL_get_signature_nid(const X509_CRL *crl);
  278. int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp);
  279. const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl);
  280. long X509_CRL_get_version(const X509_CRL *crl);
  281. const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl);
  282. const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl);
  283. ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl);
  284. ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl);
  285. X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl);
  286. STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl);
  287. void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig,
  288. const X509_ALGOR **palg);
  289. const X509_ALGOR *X509_CRL_get0_tbs_sigalg(const X509_CRL *crl);
  290. int X509_REQ_get_signature_nid(const X509_REQ *req);
  291. void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig,
  292. const X509_ALGOR **palg);
  293. X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x);
  294. const char *X509_verify_cert_error_string(long n);
  295. #ifndef OPENSSL_NO_EVP
  296. int X509_verify(X509 *a, EVP_PKEY *r);
  297. int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
  298. int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
  299. int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
  300. NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
  301. char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
  302. EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
  303. int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
  304. int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
  305. int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent);
  306. int X509_signature_print(BIO *bp, const X509_ALGOR *alg,
  307. const ASN1_STRING *sig);
  308. int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  309. int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx);
  310. int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
  311. int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx);
  312. int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
  313. int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx);
  314. int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
  315. int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
  316. unsigned char *md, unsigned int *len);
  317. int X509_digest(const X509 *data,const EVP_MD *type,
  318. unsigned char *md, unsigned int *len);
  319. int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
  320. unsigned char *md, unsigned int *len);
  321. int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
  322. unsigned char *md, unsigned int *len);
  323. int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
  324. unsigned char *md, unsigned int *len);
  325. #endif
  326. X509 *d2i_X509_fp(FILE *fp, X509 **x509);
  327. int i2d_X509_fp(FILE *fp,X509 *x509);
  328. X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
  329. int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
  330. X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
  331. int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
  332. #ifndef OPENSSL_NO_RSA
  333. RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
  334. int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
  335. RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
  336. int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
  337. RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
  338. int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
  339. #endif
  340. #ifndef OPENSSL_NO_DSA
  341. DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
  342. int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
  343. DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
  344. int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
  345. #endif
  346. #ifndef OPENSSL_NO_EC
  347. EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
  348. int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
  349. EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
  350. int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
  351. #endif
  352. X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
  353. int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
  354. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
  355. PKCS8_PRIV_KEY_INFO **p8inf);
  356. int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
  357. int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
  358. int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
  359. EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
  360. int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
  361. EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
  362. #ifndef OPENSSL_NO_BIO
  363. X509 *d2i_X509_bio(BIO *bp,X509 **x509);
  364. int i2d_X509_bio(BIO *bp,X509 *x509);
  365. X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
  366. int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
  367. X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
  368. int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
  369. #ifndef OPENSSL_NO_RSA
  370. RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
  371. int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
  372. RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
  373. int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
  374. RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
  375. int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
  376. #endif
  377. #ifndef OPENSSL_NO_DSA
  378. DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
  379. int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
  380. DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
  381. int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
  382. #endif
  383. #ifndef OPENSSL_NO_EC
  384. EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
  385. int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
  386. EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
  387. int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
  388. #endif
  389. X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
  390. int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
  391. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
  392. PKCS8_PRIV_KEY_INFO **p8inf);
  393. int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
  394. int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
  395. int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
  396. EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
  397. int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
  398. EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
  399. #endif
  400. X509 *X509_dup(X509 *x509);
  401. X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
  402. X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
  403. X509_CRL *X509_CRL_dup(X509_CRL *crl);
  404. X509_REQ *X509_REQ_dup(X509_REQ *req);
  405. X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
  406. int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
  407. void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, const void **ppval,
  408. const X509_ALGOR *algor);
  409. int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
  410. X509_NAME *X509_NAME_dup(X509_NAME *xn);
  411. int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, size_t *pderlen);
  412. X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
  413. int X509_cmp_time(const ASN1_TIME *s, time_t *t);
  414. int X509_cmp_current_time(const ASN1_TIME *s);
  415. ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
  416. ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s,
  417. int offset_day, long offset_sec, time_t *t);
  418. ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
  419. const char * X509_get_default_cert_area(void );
  420. const char * X509_get_default_cert_dir(void );
  421. const char * X509_get_default_cert_file(void );
  422. const char * X509_get_default_cert_dir_env(void );
  423. const char * X509_get_default_cert_file_env(void );
  424. const char * X509_get_default_private_dir(void );
  425. X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  426. X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
  427. X509_ALGOR *X509_ALGOR_new(void);
  428. void X509_ALGOR_free(X509_ALGOR *a);
  429. X509_ALGOR *d2i_X509_ALGOR(X509_ALGOR **a, const unsigned char **in, long len);
  430. int i2d_X509_ALGOR(X509_ALGOR *a, unsigned char **out);
  431. extern const ASN1_ITEM X509_ALGOR_it;
  432. X509_ALGORS *d2i_X509_ALGORS(X509_ALGORS **a, const unsigned char **in, long len);
  433. int i2d_X509_ALGORS(X509_ALGORS *a, unsigned char **out);
  434. extern const ASN1_ITEM X509_ALGORS_it;
  435. X509_VAL *X509_VAL_new(void);
  436. void X509_VAL_free(X509_VAL *a);
  437. X509_VAL *d2i_X509_VAL(X509_VAL **a, const unsigned char **in, long len);
  438. int i2d_X509_VAL(X509_VAL *a, unsigned char **out);
  439. extern const ASN1_ITEM X509_VAL_it;
  440. X509_PUBKEY *X509_PUBKEY_new(void);
  441. void X509_PUBKEY_free(X509_PUBKEY *a);
  442. X509_PUBKEY *d2i_X509_PUBKEY(X509_PUBKEY **a, const unsigned char **in, long len);
  443. int i2d_X509_PUBKEY(X509_PUBKEY *a, unsigned char **out);
  444. extern const ASN1_ITEM X509_PUBKEY_it;
  445. int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
  446. EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
  447. EVP_PKEY * X509_PUBKEY_get0(X509_PUBKEY *key);
  448. int X509_get_pubkey_parameters(EVP_PKEY *pkey,
  449. STACK_OF(X509) *chain);
  450. int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
  451. EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
  452. long length);
  453. #ifndef OPENSSL_NO_RSA
  454. int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
  455. RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
  456. long length);
  457. #endif
  458. #ifndef OPENSSL_NO_DSA
  459. int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
  460. DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
  461. long length);
  462. #endif
  463. #ifndef OPENSSL_NO_EC
  464. int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
  465. EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
  466. long length);
  467. #endif
  468. X509_SIG *X509_SIG_new(void);
  469. void X509_SIG_free(X509_SIG *a);
  470. X509_SIG *d2i_X509_SIG(X509_SIG **a, const unsigned char **in, long len);
  471. int i2d_X509_SIG(X509_SIG *a, unsigned char **out);
  472. extern const ASN1_ITEM X509_SIG_it;
  473. void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg,
  474. const ASN1_OCTET_STRING **pdigest);
  475. void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg,
  476. ASN1_OCTET_STRING **pdigest);
  477. X509_REQ_INFO *X509_REQ_INFO_new(void);
  478. void X509_REQ_INFO_free(X509_REQ_INFO *a);
  479. X509_REQ_INFO *d2i_X509_REQ_INFO(X509_REQ_INFO **a, const unsigned char **in, long len);
  480. int i2d_X509_REQ_INFO(X509_REQ_INFO *a, unsigned char **out);
  481. extern const ASN1_ITEM X509_REQ_INFO_it;
  482. X509_REQ *X509_REQ_new(void);
  483. void X509_REQ_free(X509_REQ *a);
  484. X509_REQ *d2i_X509_REQ(X509_REQ **a, const unsigned char **in, long len);
  485. int i2d_X509_REQ(X509_REQ *a, unsigned char **out);
  486. extern const ASN1_ITEM X509_REQ_it;
  487. X509_ATTRIBUTE *X509_ATTRIBUTE_new(void);
  488. void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
  489. X509_ATTRIBUTE *d2i_X509_ATTRIBUTE(X509_ATTRIBUTE **a, const unsigned char **in, long len);
  490. int i2d_X509_ATTRIBUTE(X509_ATTRIBUTE *a, unsigned char **out);
  491. extern const ASN1_ITEM X509_ATTRIBUTE_it;
  492. X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
  493. X509_EXTENSION *X509_EXTENSION_new(void);
  494. void X509_EXTENSION_free(X509_EXTENSION *a);
  495. X509_EXTENSION *d2i_X509_EXTENSION(X509_EXTENSION **a, const unsigned char **in, long len);
  496. int i2d_X509_EXTENSION(X509_EXTENSION *a, unsigned char **out);
  497. extern const ASN1_ITEM X509_EXTENSION_it;
  498. X509_EXTENSIONS *d2i_X509_EXTENSIONS(X509_EXTENSIONS **a, const unsigned char **in, long len);
  499. int i2d_X509_EXTENSIONS(X509_EXTENSIONS *a, unsigned char **out);
  500. extern const ASN1_ITEM X509_EXTENSIONS_it;
  501. X509_NAME_ENTRY *X509_NAME_ENTRY_new(void);
  502. void X509_NAME_ENTRY_free(X509_NAME_ENTRY *a);
  503. X509_NAME_ENTRY *d2i_X509_NAME_ENTRY(X509_NAME_ENTRY **a, const unsigned char **in, long len);
  504. int i2d_X509_NAME_ENTRY(X509_NAME_ENTRY *a, unsigned char **out);
  505. extern const ASN1_ITEM X509_NAME_ENTRY_it;
  506. X509_NAME *X509_NAME_new(void);
  507. void X509_NAME_free(X509_NAME *a);
  508. X509_NAME *d2i_X509_NAME(X509_NAME **a, const unsigned char **in, long len);
  509. int i2d_X509_NAME(X509_NAME *a, unsigned char **out);
  510. extern const ASN1_ITEM X509_NAME_it;
  511. int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
  512. X509_CINF *X509_CINF_new(void);
  513. void X509_CINF_free(X509_CINF *a);
  514. X509_CINF *d2i_X509_CINF(X509_CINF **a, const unsigned char **in, long len);
  515. int i2d_X509_CINF(X509_CINF *a, unsigned char **out);
  516. extern const ASN1_ITEM X509_CINF_it;
  517. X509 *X509_new(void);
  518. void X509_free(X509 *a);
  519. X509 *d2i_X509(X509 **a, const unsigned char **in, long len);
  520. int i2d_X509(X509 *a, unsigned char **out);
  521. extern const ASN1_ITEM X509_it;
  522. int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
  523. CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
  524. int X509_set_ex_data(X509 *r, int idx, void *arg);
  525. void *X509_get_ex_data(X509 *r, int idx);
  526. int i2d_X509_AUX(X509 *a,unsigned char **pp);
  527. X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
  528. int i2d_re_X509_tbs(X509 *x, unsigned char **pp);
  529. void X509_get0_signature(const ASN1_BIT_STRING **psig,
  530. const X509_ALGOR **palg, const X509 *x);
  531. int X509_get_signature_nid(const X509 *x);
  532. int X509_alias_set1(X509 *x, const unsigned char *name, int len);
  533. int X509_keyid_set1(X509 *x, const unsigned char *id, int len);
  534. unsigned char *X509_alias_get0(X509 *x, int *len);
  535. unsigned char *X509_keyid_get0(X509 *x, int *len);
  536. int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj);
  537. int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj);
  538. void X509_trust_clear(X509 *x);
  539. void X509_reject_clear(X509 *x);
  540. X509_REVOKED *X509_REVOKED_new(void);
  541. void X509_REVOKED_free(X509_REVOKED *a);
  542. X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *a);
  543. X509_REVOKED *d2i_X509_REVOKED(X509_REVOKED **a, const unsigned char **in, long len);
  544. int i2d_X509_REVOKED(X509_REVOKED *a, unsigned char **out);
  545. extern const ASN1_ITEM X509_REVOKED_it;
  546. X509_CRL_INFO *X509_CRL_INFO_new(void);
  547. void X509_CRL_INFO_free(X509_CRL_INFO *a);
  548. X509_CRL_INFO *d2i_X509_CRL_INFO(X509_CRL_INFO **a, const unsigned char **in, long len);
  549. int i2d_X509_CRL_INFO(X509_CRL_INFO *a, unsigned char **out);
  550. extern const ASN1_ITEM X509_CRL_INFO_it;
  551. X509_CRL *X509_CRL_new(void);
  552. void X509_CRL_free(X509_CRL *a);
  553. X509_CRL *d2i_X509_CRL(X509_CRL **a, const unsigned char **in, long len);
  554. int i2d_X509_CRL(X509_CRL *a, unsigned char **out);
  555. extern const ASN1_ITEM X509_CRL_it;
  556. int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
  557. int X509_CRL_get0_by_serial(X509_CRL *crl,
  558. X509_REVOKED **ret, ASN1_INTEGER *serial);
  559. int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
  560. X509_PKEY * X509_PKEY_new(void );
  561. void X509_PKEY_free(X509_PKEY *a);
  562. NETSCAPE_SPKI *NETSCAPE_SPKI_new(void);
  563. void NETSCAPE_SPKI_free(NETSCAPE_SPKI *a);
  564. NETSCAPE_SPKI *d2i_NETSCAPE_SPKI(NETSCAPE_SPKI **a, const unsigned char **in, long len);
  565. int i2d_NETSCAPE_SPKI(NETSCAPE_SPKI *a, unsigned char **out);
  566. extern const ASN1_ITEM NETSCAPE_SPKI_it;
  567. NETSCAPE_SPKAC *NETSCAPE_SPKAC_new(void);
  568. void NETSCAPE_SPKAC_free(NETSCAPE_SPKAC *a);
  569. NETSCAPE_SPKAC *d2i_NETSCAPE_SPKAC(NETSCAPE_SPKAC **a, const unsigned char **in, long len);
  570. int i2d_NETSCAPE_SPKAC(NETSCAPE_SPKAC *a, unsigned char **out);
  571. extern const ASN1_ITEM NETSCAPE_SPKAC_it;
  572. #ifndef OPENSSL_NO_EVP
  573. X509_INFO * X509_INFO_new(void);
  574. void X509_INFO_free(X509_INFO *a);
  575. char * X509_NAME_oneline(const X509_NAME *a, char *buf, int size);
  576. int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
  577. unsigned char *md,unsigned int *len);
  578. int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
  579. ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
  580. int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
  581. ASN1_BIT_STRING *signature,
  582. void *data, EVP_PKEY *pkey, const EVP_MD *type);
  583. int ASN1_item_sign_ctx(const ASN1_ITEM *it,
  584. X509_ALGOR *algor1, X509_ALGOR *algor2,
  585. ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx);
  586. #endif
  587. const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x);
  588. void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid,
  589. const ASN1_BIT_STRING **psuid);
  590. const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x);
  591. int X509_set_version(X509 *x, long version);
  592. long X509_get_version(const X509 *x);
  593. int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
  594. ASN1_INTEGER * X509_get_serialNumber(X509 *x);
  595. const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x);
  596. int X509_set_issuer_name(X509 *x, X509_NAME *name);
  597. X509_NAME * X509_get_issuer_name(const X509 *a);
  598. int X509_set_subject_name(X509 *x, X509_NAME *name);
  599. X509_NAME * X509_get_subject_name(const X509 *a);
  600. int X509_set_notBefore(X509 *x, const ASN1_TIME *tm);
  601. int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm);
  602. int X509_set_notAfter(X509 *x, const ASN1_TIME *tm);
  603. int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm);
  604. const ASN1_TIME *X509_get0_notBefore(const X509 *x);
  605. ASN1_TIME *X509_getm_notBefore(const X509 *x);
  606. const ASN1_TIME *X509_get0_notAfter(const X509 *x);
  607. ASN1_TIME *X509_getm_notAfter(const X509 *x);
  608. int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
  609. EVP_PKEY * X509_get_pubkey(X509 *x);
  610. EVP_PKEY * X509_get0_pubkey(const X509 *x);
  611. ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x);
  612. int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey);
  613. int X509_get_signature_type(const X509 *x);
  614. #define X509_get_notBefore X509_getm_notBefore
  615. #define X509_get_notAfter X509_getm_notAfter
  616. int X509_REQ_set_version(X509_REQ *x,long version);
  617. long X509_REQ_get_version(const X509_REQ *x);
  618. int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name);
  619. X509_NAME *X509_REQ_get_subject_name(const X509_REQ *x);
  620. int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
  621. EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
  622. int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
  623. EVP_PKEY * X509_REQ_get0_pubkey(X509_REQ *req);
  624. int X509_REQ_extension_nid(int nid);
  625. int * X509_REQ_get_extension_nids(void);
  626. void X509_REQ_set_extension_nids(int *nids);
  627. STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
  628. int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
  629. int nid);
  630. int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
  631. int X509_REQ_get_attr_count(const X509_REQ *req);
  632. int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
  633. int lastpos);
  634. int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj,
  635. int lastpos);
  636. X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
  637. X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
  638. int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
  639. int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
  640. const ASN1_OBJECT *obj, int type,
  641. const unsigned char *bytes, int len);
  642. int X509_REQ_add1_attr_by_NID(X509_REQ *req,
  643. int nid, int type,
  644. const unsigned char *bytes, int len);
  645. int X509_REQ_add1_attr_by_txt(X509_REQ *req,
  646. const char *attrname, int type,
  647. const unsigned char *bytes, int len);
  648. int X509_CRL_set_version(X509_CRL *x, long version);
  649. int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
  650. int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
  651. int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm);
  652. int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
  653. int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm);
  654. int X509_CRL_sort(X509_CRL *crl);
  655. const STACK_OF(X509_EXTENSION) *X509_REVOKED_get0_extensions(const X509_REVOKED *x);
  656. const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x);
  657. const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x);
  658. int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
  659. int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
  660. int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
  661. int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey);
  662. int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
  663. unsigned long X509_issuer_and_serial_hash(X509 *a);
  664. int X509_issuer_name_cmp(const X509 *a, const X509 *b);
  665. unsigned long X509_issuer_name_hash(X509 *a);
  666. int X509_subject_name_cmp(const X509 *a, const X509 *b);
  667. unsigned long X509_subject_name_hash(X509 *x);
  668. #ifndef OPENSSL_NO_MD5
  669. unsigned long X509_issuer_name_hash_old(X509 *a);
  670. unsigned long X509_subject_name_hash_old(X509 *x);
  671. #endif
  672. int X509_cmp(const X509 *a, const X509 *b);
  673. int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
  674. unsigned long X509_NAME_hash(X509_NAME *x);
  675. unsigned long X509_NAME_hash_old(X509_NAME *x);
  676. int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
  677. int X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
  678. int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
  679. int X509_print_fp(FILE *bp,X509 *x);
  680. int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
  681. int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
  682. int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent,
  683. unsigned long flags);
  684. #ifndef OPENSSL_NO_BIO
  685. int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase);
  686. int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent,
  687. unsigned long flags);
  688. int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
  689. int X509_print(BIO *bp,X509 *x);
  690. int X509_ocspid_print(BIO *bp,X509 *x);
  691. int X509_CRL_print(BIO *bp,X509_CRL *x);
  692. int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
  693. int X509_REQ_print(BIO *bp,X509_REQ *req);
  694. #endif
  695. int X509_NAME_entry_count(const X509_NAME *name);
  696. int X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
  697. char *buf,int len);
  698. int X509_NAME_get_text_by_OBJ(X509_NAME *name,
  699. const ASN1_OBJECT *obj, char *buf,int len);
  700. /* NOTE: you should be passing -1, not 0 as lastpos. The functions that use
  701. * lastpos, search after that position on. */
  702. int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid,
  703. int lastpos);
  704. int X509_NAME_get_index_by_OBJ(const X509_NAME *name,
  705. const ASN1_OBJECT *obj, int lastpos);
  706. X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc);
  707. X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
  708. int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne,
  709. int loc, int set);
  710. int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,
  711. int type, const unsigned char *bytes, int len, int loc, int set);
  712. int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
  713. const unsigned char *bytes, int len, int loc, int set);
  714. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
  715. const char *field, int type, const unsigned char *bytes, int len);
  716. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
  717. int type, const unsigned char *bytes, int len);
  718. int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
  719. const unsigned char *bytes, int len, int loc, int set);
  720. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
  721. const ASN1_OBJECT *obj, int type,
  722. const unsigned char *bytes, int len);
  723. int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
  724. const ASN1_OBJECT *obj);
  725. int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
  726. const unsigned char *bytes, int len);
  727. ASN1_OBJECT * X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne);
  728. ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne);
  729. int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne);
  730. int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
  731. int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
  732. int nid, int lastpos);
  733. int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
  734. const ASN1_OBJECT *obj, int lastpos);
  735. int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
  736. int crit, int lastpos);
  737. X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
  738. X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
  739. STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
  740. X509_EXTENSION *ex, int loc);
  741. int X509_get_ext_count(const X509 *x);
  742. int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos);
  743. int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj,
  744. int lastpos);
  745. int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos);
  746. X509_EXTENSION *X509_get_ext(const X509 *x, int loc);
  747. X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
  748. int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
  749. void * X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx);
  750. int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
  751. unsigned long flags);
  752. int X509_CRL_get_ext_count(const X509_CRL *x);
  753. int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid,
  754. int lastpos);
  755. int X509_CRL_get_ext_by_OBJ(const X509_CRL *x,
  756. const ASN1_OBJECT *obj, int lastpos);
  757. int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit,
  758. int lastpos);
  759. X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
  760. X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
  761. int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
  762. void * X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit,
  763. int *idx);
  764. int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value,
  765. int crit, unsigned long flags);
  766. int X509_REVOKED_get_ext_count(const X509_REVOKED *x);
  767. int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid,
  768. int lastpos);
  769. int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x,
  770. const ASN1_OBJECT *obj, int lastpos);
  771. int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x,
  772. int crit, int lastpos);
  773. X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc);
  774. X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
  775. int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex,
  776. int loc);
  777. void * X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid,
  778. int *crit, int *idx);
  779. int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value,
  780. int crit, unsigned long flags);
  781. X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
  782. int nid, int crit, ASN1_OCTET_STRING *data);
  783. X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
  784. const ASN1_OBJECT *obj, int crit, ASN1_OCTET_STRING *data);
  785. int X509_EXTENSION_set_object(X509_EXTENSION *ex,
  786. const ASN1_OBJECT *obj);
  787. int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
  788. int X509_EXTENSION_set_data(X509_EXTENSION *ex,
  789. ASN1_OCTET_STRING *data);
  790. ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
  791. ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
  792. int X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
  793. int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
  794. int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
  795. int lastpos);
  796. int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk,
  797. const ASN1_OBJECT *obj, int lastpos);
  798. X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
  799. X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
  800. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
  801. X509_ATTRIBUTE *attr);
  802. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
  803. const ASN1_OBJECT *obj, int type,
  804. const unsigned char *bytes, int len);
  805. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
  806. int nid, int type,
  807. const unsigned char *bytes, int len);
  808. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
  809. const char *attrname, int type,
  810. const unsigned char *bytes, int len);
  811. void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
  812. const ASN1_OBJECT *obj, int lastpos, int type);
  813. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
  814. int atrtype, const void *data, int len);
  815. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
  816. const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
  817. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
  818. const char *atrname, int type, const unsigned char *bytes, int len);
  819. int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
  820. int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
  821. void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
  822. int atrtype, void *data);
  823. int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr);
  824. ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
  825. ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
  826. int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
  827. int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
  828. int lastpos);
  829. int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
  830. int lastpos);
  831. X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
  832. X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
  833. int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
  834. int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
  835. const ASN1_OBJECT *obj, int type,
  836. const unsigned char *bytes, int len);
  837. int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
  838. int nid, int type,
  839. const unsigned char *bytes, int len);
  840. int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
  841. const char *attrname, int type,
  842. const unsigned char *bytes, int len);
  843. int X509_verify_cert(X509_STORE_CTX *ctx);
  844. /* lookup a cert from a X509 STACK */
  845. X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
  846. ASN1_INTEGER *serial);
  847. X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
  848. extern const ASN1_ITEM PBEPARAM_it;
  849. /* PKCS#8 utilities */
  850. PKCS8_PRIV_KEY_INFO *PKCS8_PRIV_KEY_INFO_new(void);
  851. void PKCS8_PRIV_KEY_INFO_free(PKCS8_PRIV_KEY_INFO *a);
  852. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO **a, const unsigned char **in, long len);
  853. int i2d_PKCS8_PRIV_KEY_INFO(PKCS8_PRIV_KEY_INFO *a, unsigned char **out);
  854. extern const ASN1_ITEM PKCS8_PRIV_KEY_INFO_it;
  855. EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8);
  856. PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
  857. int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, int version,
  858. int ptype, void *pval, unsigned char *penc, int penclen);
  859. int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, const unsigned char **pk,
  860. int *ppklen, const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8);
  861. const STACK_OF(X509_ATTRIBUTE) *PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8);
  862. int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type,
  863. const unsigned char *bytes, int len);
  864. int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, int ptype,
  865. void *pval, unsigned char *penc, int penclen);
  866. int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, const unsigned char **pk,
  867. int *ppklen, X509_ALGOR **pa, X509_PUBKEY *pub);
  868. int X509_check_trust(X509 *x, int id, int flags);
  869. int X509_up_ref(X509 *x);
  870. STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain);
  871. void ERR_load_X509_strings(void);
  872. /* Error codes for the X509 functions. */
  873. /* Function codes. */
  874. #define X509_F_ADD_CERT_DIR 100
  875. #define X509_F_BY_FILE_CTRL 101
  876. #define X509_F_CHECK_POLICY 145
  877. #define X509_F_DIR_CTRL 102
  878. #define X509_F_GET_CERT_BY_SUBJECT 103
  879. #define X509_F_NETSCAPE_SPKI_B64_DECODE 129
  880. #define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
  881. #define X509_F_X509AT_ADD1_ATTR 135
  882. #define X509_F_X509V3_ADD_EXT 104
  883. #define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
  884. #define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
  885. #define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
  886. #define X509_F_X509_ATTRIBUTE_GET0_DATA 139
  887. #define X509_F_X509_ATTRIBUTE_SET1_DATA 138
  888. #define X509_F_X509_CHECK_PRIVATE_KEY 128
  889. #define X509_F_X509_CRL_PRINT_FP 147
  890. #define X509_F_X509_EXTENSION_CREATE_BY_NID 108
  891. #define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
  892. #define X509_F_X509_GET_PUBKEY_PARAMETERS 110
  893. #define X509_F_X509_LOAD_CERT_CRL_FILE 132
  894. #define X509_F_X509_LOAD_CERT_FILE 111
  895. #define X509_F_X509_LOAD_CRL_FILE 112
  896. #define X509_F_X509_NAME_ADD_ENTRY 113
  897. #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
  898. #define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
  899. #define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
  900. #define X509_F_X509_NAME_ONELINE 116
  901. #define X509_F_X509_NAME_PRINT 117
  902. #define X509_F_X509_PRINT_EX_FP 118
  903. #define X509_F_X509_PUBKEY_GET 119
  904. #define X509_F_X509_PUBKEY_SET 120
  905. #define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144
  906. #define X509_F_X509_REQ_PRINT_EX 121
  907. #define X509_F_X509_REQ_PRINT_FP 122
  908. #define X509_F_X509_REQ_TO_X509 123
  909. #define X509_F_X509_STORE_ADD_CERT 124
  910. #define X509_F_X509_STORE_ADD_CRL 125
  911. #define X509_F_X509_STORE_CTX_GET1_ISSUER 146
  912. #define X509_F_X509_STORE_CTX_INIT 143
  913. #define X509_F_X509_STORE_CTX_NEW 142
  914. #define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
  915. #define X509_F_X509_TO_X509_REQ 126
  916. #define X509_F_X509_TRUST_ADD 133
  917. #define X509_F_X509_TRUST_SET 141
  918. #define X509_F_X509_VERIFY_CERT 127
  919. /* Reason codes. */
  920. #define X509_R_BAD_X509_FILETYPE 100
  921. #define X509_R_BASE64_DECODE_ERROR 118
  922. #define X509_R_CANT_CHECK_DH_KEY 114
  923. #define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
  924. #define X509_R_ERR_ASN1_LIB 102
  925. #define X509_R_INVALID_DIRECTORY 113
  926. #define X509_R_INVALID_FIELD_NAME 119
  927. #define X509_R_INVALID_TRUST 123
  928. #define X509_R_INVALID_VERSION 137
  929. #define X509_R_KEY_TYPE_MISMATCH 115
  930. #define X509_R_KEY_VALUES_MISMATCH 116
  931. #define X509_R_LOADING_CERT_DIR 103
  932. #define X509_R_LOADING_DEFAULTS 104
  933. #define X509_R_METHOD_NOT_SUPPORTED 124
  934. #define X509_R_NO_CERTIFICATE_OR_CRL_FOUND 136
  935. #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
  936. #define X509_R_PUBLIC_KEY_DECODE_ERROR 125
  937. #define X509_R_PUBLIC_KEY_ENCODE_ERROR 126
  938. #define X509_R_SHOULD_RETRY 106
  939. #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
  940. #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
  941. #define X509_R_UNKNOWN_KEY_TYPE 117
  942. #define X509_R_UNKNOWN_NID 109
  943. #define X509_R_UNKNOWN_PURPOSE_ID 121
  944. #define X509_R_UNKNOWN_TRUST_ID 120
  945. #define X509_R_UNSUPPORTED_ALGORITHM 111
  946. #define X509_R_WRONG_LOOKUP_TYPE 112
  947. #define X509_R_WRONG_TYPE 122
  948. #ifdef __cplusplus
  949. }
  950. #endif
  951. #endif