x509.h 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  1. /* crypto/x509/x509.h */
  2. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  3. * All rights reserved.
  4. *
  5. * This package is an SSL implementation written
  6. * by Eric Young (eay@cryptsoft.com).
  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 (tjh@cryptsoft.com).
  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 (eay@cryptsoft.com)"
  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 (tjh@cryptsoft.com)"
  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/e_os2.h>
  66. #include <openssl/symhacks.h>
  67. #ifndef OPENSSL_NO_BUFFER
  68. #include <openssl/buffer.h>
  69. #endif
  70. #ifndef OPENSSL_NO_EVP
  71. #include <openssl/evp.h>
  72. #endif
  73. #ifndef OPENSSL_NO_BIO
  74. #include <openssl/bio.h>
  75. #endif
  76. #include <openssl/stack.h>
  77. #include <openssl/asn1.h>
  78. #include <openssl/safestack.h>
  79. #ifndef OPENSSL_NO_EC
  80. #include <openssl/ec.h>
  81. #endif
  82. #ifndef OPENSSL_NO_ECDSA
  83. #include <openssl/ecdsa.h>
  84. #endif
  85. #ifndef OPENSSL_NO_ECDH
  86. #include <openssl/ecdh.h>
  87. #endif
  88. #ifndef OPENSSL_NO_DEPRECATED
  89. #ifndef OPENSSL_NO_RSA
  90. #include <openssl/rsa.h>
  91. #endif
  92. #ifndef OPENSSL_NO_DSA
  93. #include <openssl/dsa.h>
  94. #endif
  95. #ifndef OPENSSL_NO_DH
  96. #include <openssl/dh.h>
  97. #endif
  98. #endif
  99. #ifndef OPENSSL_NO_SHA
  100. #include <openssl/sha.h>
  101. #endif
  102. #include <openssl/ossl_typ.h>
  103. #ifdef __cplusplus
  104. extern "C" {
  105. #endif
  106. #ifdef OPENSSL_SYS_WIN32
  107. /* Under Win32 these are defined in wincrypt.h */
  108. #undef X509_NAME
  109. #undef X509_CERT_PAIR
  110. #endif
  111. #define X509_FILETYPE_PEM 1
  112. #define X509_FILETYPE_ASN1 2
  113. #define X509_FILETYPE_DEFAULT 3
  114. #define X509v3_KU_DIGITAL_SIGNATURE 0x0080
  115. #define X509v3_KU_NON_REPUDIATION 0x0040
  116. #define X509v3_KU_KEY_ENCIPHERMENT 0x0020
  117. #define X509v3_KU_DATA_ENCIPHERMENT 0x0010
  118. #define X509v3_KU_KEY_AGREEMENT 0x0008
  119. #define X509v3_KU_KEY_CERT_SIGN 0x0004
  120. #define X509v3_KU_CRL_SIGN 0x0002
  121. #define X509v3_KU_ENCIPHER_ONLY 0x0001
  122. #define X509v3_KU_DECIPHER_ONLY 0x8000
  123. #define X509v3_KU_UNDEF 0xffff
  124. typedef struct X509_objects_st
  125. {
  126. int nid;
  127. int (*a2i)(void);
  128. int (*i2a)(void);
  129. } X509_OBJECTS;
  130. struct X509_algor_st
  131. {
  132. ASN1_OBJECT *algorithm;
  133. ASN1_TYPE *parameter;
  134. } /* X509_ALGOR */;
  135. DECLARE_STACK_OF(X509_ALGOR)
  136. DECLARE_ASN1_SET_OF(X509_ALGOR)
  137. typedef struct X509_val_st
  138. {
  139. ASN1_TIME *notBefore;
  140. ASN1_TIME *notAfter;
  141. } X509_VAL;
  142. struct X509_pubkey_st
  143. {
  144. X509_ALGOR *algor;
  145. ASN1_BIT_STRING *public_key;
  146. EVP_PKEY *pkey;
  147. };
  148. typedef struct X509_sig_st
  149. {
  150. X509_ALGOR *algor;
  151. ASN1_OCTET_STRING *digest;
  152. } X509_SIG;
  153. typedef struct X509_name_entry_st
  154. {
  155. ASN1_OBJECT *object;
  156. ASN1_STRING *value;
  157. int set;
  158. int size; /* temp variable */
  159. } X509_NAME_ENTRY;
  160. DECLARE_STACK_OF(X509_NAME_ENTRY)
  161. DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
  162. /* we always keep X509_NAMEs in 2 forms. */
  163. struct X509_name_st
  164. {
  165. STACK_OF(X509_NAME_ENTRY) *entries;
  166. int modified; /* true if 'bytes' needs to be built */
  167. #ifndef OPENSSL_NO_BUFFER
  168. BUF_MEM *bytes;
  169. #else
  170. char *bytes;
  171. #endif
  172. unsigned long hash; /* Keep the hash around for lookups */
  173. } /* X509_NAME */;
  174. DECLARE_STACK_OF(X509_NAME)
  175. #define X509_EX_V_NETSCAPE_HACK 0x8000
  176. #define X509_EX_V_INIT 0x0001
  177. typedef struct X509_extension_st
  178. {
  179. ASN1_OBJECT *object;
  180. ASN1_BOOLEAN critical;
  181. ASN1_OCTET_STRING *value;
  182. } X509_EXTENSION;
  183. DECLARE_STACK_OF(X509_EXTENSION)
  184. DECLARE_ASN1_SET_OF(X509_EXTENSION)
  185. /* a sequence of these are used */
  186. typedef struct x509_attributes_st
  187. {
  188. ASN1_OBJECT *object;
  189. int single; /* 0 for a set, 1 for a single item (which is wrong) */
  190. union {
  191. char *ptr;
  192. /* 0 */ STACK_OF(ASN1_TYPE) *set;
  193. /* 1 */ ASN1_TYPE *single;
  194. } value;
  195. } X509_ATTRIBUTE;
  196. DECLARE_STACK_OF(X509_ATTRIBUTE)
  197. DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
  198. typedef struct X509_req_info_st
  199. {
  200. ASN1_ENCODING enc;
  201. ASN1_INTEGER *version;
  202. X509_NAME *subject;
  203. X509_PUBKEY *pubkey;
  204. /* d=2 hl=2 l= 0 cons: cont: 00 */
  205. STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
  206. } X509_REQ_INFO;
  207. typedef struct X509_req_st
  208. {
  209. X509_REQ_INFO *req_info;
  210. X509_ALGOR *sig_alg;
  211. ASN1_BIT_STRING *signature;
  212. int references;
  213. } X509_REQ;
  214. typedef struct x509_cinf_st
  215. {
  216. ASN1_INTEGER *version; /* [ 0 ] default of v1 */
  217. ASN1_INTEGER *serialNumber;
  218. X509_ALGOR *signature;
  219. X509_NAME *issuer;
  220. X509_VAL *validity;
  221. X509_NAME *subject;
  222. X509_PUBKEY *key;
  223. ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */
  224. ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */
  225. STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
  226. } X509_CINF;
  227. /* This stuff is certificate "auxiliary info"
  228. * it contains details which are useful in certificate
  229. * stores and databases. When used this is tagged onto
  230. * the end of the certificate itself
  231. */
  232. typedef struct x509_cert_aux_st
  233. {
  234. STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */
  235. STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */
  236. ASN1_UTF8STRING *alias; /* "friendly name" */
  237. ASN1_OCTET_STRING *keyid; /* key id of private key */
  238. STACK_OF(X509_ALGOR) *other; /* other unspecified info */
  239. } X509_CERT_AUX;
  240. struct x509_st
  241. {
  242. X509_CINF *cert_info;
  243. X509_ALGOR *sig_alg;
  244. ASN1_BIT_STRING *signature;
  245. int valid;
  246. int references;
  247. char *name;
  248. CRYPTO_EX_DATA ex_data;
  249. /* These contain copies of various extension values */
  250. long ex_pathlen;
  251. long ex_pcpathlen;
  252. unsigned long ex_flags;
  253. unsigned long ex_kusage;
  254. unsigned long ex_xkusage;
  255. unsigned long ex_nscert;
  256. ASN1_OCTET_STRING *skid;
  257. struct AUTHORITY_KEYID_st *akid;
  258. X509_POLICY_CACHE *policy_cache;
  259. #ifndef OPENSSL_NO_SHA
  260. unsigned char sha1_hash[SHA_DIGEST_LENGTH];
  261. #endif
  262. X509_CERT_AUX *aux;
  263. } /* X509 */;
  264. DECLARE_STACK_OF(X509)
  265. DECLARE_ASN1_SET_OF(X509)
  266. /* This is used for a table of trust checking functions */
  267. typedef struct x509_trust_st {
  268. int trust;
  269. int flags;
  270. int (*check_trust)(struct x509_trust_st *, X509 *, int);
  271. char *name;
  272. int arg1;
  273. void *arg2;
  274. } X509_TRUST;
  275. DECLARE_STACK_OF(X509_TRUST)
  276. typedef struct x509_cert_pair_st {
  277. X509 *forward;
  278. X509 *reverse;
  279. } X509_CERT_PAIR;
  280. /* standard trust ids */
  281. #define X509_TRUST_DEFAULT -1 /* Only valid in purpose settings */
  282. #define X509_TRUST_COMPAT 1
  283. #define X509_TRUST_SSL_CLIENT 2
  284. #define X509_TRUST_SSL_SERVER 3
  285. #define X509_TRUST_EMAIL 4
  286. #define X509_TRUST_OBJECT_SIGN 5
  287. #define X509_TRUST_OCSP_SIGN 6
  288. #define X509_TRUST_OCSP_REQUEST 7
  289. #define X509_TRUST_TSA 8
  290. /* Keep these up to date! */
  291. #define X509_TRUST_MIN 1
  292. #define X509_TRUST_MAX 8
  293. /* trust_flags values */
  294. #define X509_TRUST_DYNAMIC 1
  295. #define X509_TRUST_DYNAMIC_NAME 2
  296. /* check_trust return codes */
  297. #define X509_TRUST_TRUSTED 1
  298. #define X509_TRUST_REJECTED 2
  299. #define X509_TRUST_UNTRUSTED 3
  300. /* Flags for X509_print_ex() */
  301. #define X509_FLAG_COMPAT 0
  302. #define X509_FLAG_NO_HEADER 1L
  303. #define X509_FLAG_NO_VERSION (1L << 1)
  304. #define X509_FLAG_NO_SERIAL (1L << 2)
  305. #define X509_FLAG_NO_SIGNAME (1L << 3)
  306. #define X509_FLAG_NO_ISSUER (1L << 4)
  307. #define X509_FLAG_NO_VALIDITY (1L << 5)
  308. #define X509_FLAG_NO_SUBJECT (1L << 6)
  309. #define X509_FLAG_NO_PUBKEY (1L << 7)
  310. #define X509_FLAG_NO_EXTENSIONS (1L << 8)
  311. #define X509_FLAG_NO_SIGDUMP (1L << 9)
  312. #define X509_FLAG_NO_AUX (1L << 10)
  313. #define X509_FLAG_NO_ATTRIBUTES (1L << 11)
  314. /* Flags specific to X509_NAME_print_ex() */
  315. /* The field separator information */
  316. #define XN_FLAG_SEP_MASK (0xf << 16)
  317. #define XN_FLAG_COMPAT 0 /* Traditional SSLeay: use old X509_NAME_print */
  318. #define XN_FLAG_SEP_COMMA_PLUS (1 << 16) /* RFC2253 ,+ */
  319. #define XN_FLAG_SEP_CPLUS_SPC (2 << 16) /* ,+ spaced: more readable */
  320. #define XN_FLAG_SEP_SPLUS_SPC (3 << 16) /* ;+ spaced */
  321. #define XN_FLAG_SEP_MULTILINE (4 << 16) /* One line per field */
  322. #define XN_FLAG_DN_REV (1 << 20) /* Reverse DN order */
  323. /* How the field name is shown */
  324. #define XN_FLAG_FN_MASK (0x3 << 21)
  325. #define XN_FLAG_FN_SN 0 /* Object short name */
  326. #define XN_FLAG_FN_LN (1 << 21) /* Object long name */
  327. #define XN_FLAG_FN_OID (2 << 21) /* Always use OIDs */
  328. #define XN_FLAG_FN_NONE (3 << 21) /* No field names */
  329. #define XN_FLAG_SPC_EQ (1 << 23) /* Put spaces round '=' */
  330. /* This determines if we dump fields we don't recognise:
  331. * RFC2253 requires this.
  332. */
  333. #define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24)
  334. #define XN_FLAG_FN_ALIGN (1 << 25) /* Align field names to 20 characters */
  335. /* Complete set of RFC2253 flags */
  336. #define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \
  337. XN_FLAG_SEP_COMMA_PLUS | \
  338. XN_FLAG_DN_REV | \
  339. XN_FLAG_FN_SN | \
  340. XN_FLAG_DUMP_UNKNOWN_FIELDS)
  341. /* readable oneline form */
  342. #define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \
  343. ASN1_STRFLGS_ESC_QUOTE | \
  344. XN_FLAG_SEP_CPLUS_SPC | \
  345. XN_FLAG_SPC_EQ | \
  346. XN_FLAG_FN_SN)
  347. /* readable multiline form */
  348. #define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \
  349. ASN1_STRFLGS_ESC_MSB | \
  350. XN_FLAG_SEP_MULTILINE | \
  351. XN_FLAG_SPC_EQ | \
  352. XN_FLAG_FN_LN | \
  353. XN_FLAG_FN_ALIGN)
  354. typedef struct X509_revoked_st
  355. {
  356. ASN1_INTEGER *serialNumber;
  357. ASN1_TIME *revocationDate;
  358. STACK_OF(X509_EXTENSION) /* optional */ *extensions;
  359. int sequence; /* load sequence */
  360. } X509_REVOKED;
  361. DECLARE_STACK_OF(X509_REVOKED)
  362. DECLARE_ASN1_SET_OF(X509_REVOKED)
  363. typedef struct X509_crl_info_st
  364. {
  365. ASN1_INTEGER *version;
  366. X509_ALGOR *sig_alg;
  367. X509_NAME *issuer;
  368. ASN1_TIME *lastUpdate;
  369. ASN1_TIME *nextUpdate;
  370. STACK_OF(X509_REVOKED) *revoked;
  371. STACK_OF(X509_EXTENSION) /* [0] */ *extensions;
  372. ASN1_ENCODING enc;
  373. } X509_CRL_INFO;
  374. struct X509_crl_st
  375. {
  376. /* actual signature */
  377. X509_CRL_INFO *crl;
  378. X509_ALGOR *sig_alg;
  379. ASN1_BIT_STRING *signature;
  380. int references;
  381. } /* X509_CRL */;
  382. DECLARE_STACK_OF(X509_CRL)
  383. DECLARE_ASN1_SET_OF(X509_CRL)
  384. typedef struct private_key_st
  385. {
  386. int version;
  387. /* The PKCS#8 data types */
  388. X509_ALGOR *enc_algor;
  389. ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */
  390. /* When decrypted, the following will not be NULL */
  391. EVP_PKEY *dec_pkey;
  392. /* used to encrypt and decrypt */
  393. int key_length;
  394. char *key_data;
  395. int key_free; /* true if we should auto free key_data */
  396. /* expanded version of 'enc_algor' */
  397. EVP_CIPHER_INFO cipher;
  398. int references;
  399. } X509_PKEY;
  400. #ifndef OPENSSL_NO_EVP
  401. typedef struct X509_info_st
  402. {
  403. X509 *x509;
  404. X509_CRL *crl;
  405. X509_PKEY *x_pkey;
  406. EVP_CIPHER_INFO enc_cipher;
  407. int enc_len;
  408. char *enc_data;
  409. int references;
  410. } X509_INFO;
  411. DECLARE_STACK_OF(X509_INFO)
  412. #endif
  413. /* The next 2 structures and their 8 routines were sent to me by
  414. * Pat Richard <patr@x509.com> and are used to manipulate
  415. * Netscapes spki structures - useful if you are writing a CA web page
  416. */
  417. typedef struct Netscape_spkac_st
  418. {
  419. X509_PUBKEY *pubkey;
  420. ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */
  421. } NETSCAPE_SPKAC;
  422. typedef struct Netscape_spki_st
  423. {
  424. NETSCAPE_SPKAC *spkac; /* signed public key and challenge */
  425. X509_ALGOR *sig_algor;
  426. ASN1_BIT_STRING *signature;
  427. } NETSCAPE_SPKI;
  428. /* Netscape certificate sequence structure */
  429. typedef struct Netscape_certificate_sequence
  430. {
  431. ASN1_OBJECT *type;
  432. STACK_OF(X509) *certs;
  433. } NETSCAPE_CERT_SEQUENCE;
  434. /* Unused (and iv length is wrong)
  435. typedef struct CBCParameter_st
  436. {
  437. unsigned char iv[8];
  438. } CBC_PARAM;
  439. */
  440. /* Password based encryption structure */
  441. typedef struct PBEPARAM_st {
  442. ASN1_OCTET_STRING *salt;
  443. ASN1_INTEGER *iter;
  444. } PBEPARAM;
  445. /* Password based encryption V2 structures */
  446. typedef struct PBE2PARAM_st {
  447. X509_ALGOR *keyfunc;
  448. X509_ALGOR *encryption;
  449. } PBE2PARAM;
  450. typedef struct PBKDF2PARAM_st {
  451. ASN1_TYPE *salt; /* Usually OCTET STRING but could be anything */
  452. ASN1_INTEGER *iter;
  453. ASN1_INTEGER *keylength;
  454. X509_ALGOR *prf;
  455. } PBKDF2PARAM;
  456. /* PKCS#8 private key info structure */
  457. struct pkcs8_priv_key_info_st
  458. {
  459. int broken; /* Flag for various broken formats */
  460. #define PKCS8_OK 0
  461. #define PKCS8_NO_OCTET 1
  462. #define PKCS8_EMBEDDED_PARAM 2
  463. #define PKCS8_NS_DB 3
  464. ASN1_INTEGER *version;
  465. X509_ALGOR *pkeyalg;
  466. ASN1_TYPE *pkey; /* Should be OCTET STRING but some are broken */
  467. STACK_OF(X509_ATTRIBUTE) *attributes;
  468. };
  469. #ifdef __cplusplus
  470. }
  471. #endif
  472. #include <openssl/x509_vfy.h>
  473. #include <openssl/pkcs7.h>
  474. #ifdef __cplusplus
  475. extern "C" {
  476. #endif
  477. #ifdef SSLEAY_MACROS
  478. #define X509_verify(a,r) ASN1_verify((int (*)())i2d_X509_CINF,a->sig_alg,\
  479. a->signature,(char *)a->cert_info,r)
  480. #define X509_REQ_verify(a,r) ASN1_verify((int (*)())i2d_X509_REQ_INFO, \
  481. a->sig_alg,a->signature,(char *)a->req_info,r)
  482. #define X509_CRL_verify(a,r) ASN1_verify((int (*)())i2d_X509_CRL_INFO, \
  483. a->sig_alg, a->signature,(char *)a->crl,r)
  484. #define X509_sign(x,pkey,md) \
  485. ASN1_sign((int (*)())i2d_X509_CINF, x->cert_info->signature, \
  486. x->sig_alg, x->signature, (char *)x->cert_info,pkey,md)
  487. #define X509_REQ_sign(x,pkey,md) \
  488. ASN1_sign((int (*)())i2d_X509_REQ_INFO,x->sig_alg, NULL, \
  489. x->signature, (char *)x->req_info,pkey,md)
  490. #define X509_CRL_sign(x,pkey,md) \
  491. ASN1_sign((int (*)())i2d_X509_CRL_INFO,x->crl->sig_alg,x->sig_alg, \
  492. x->signature, (char *)x->crl,pkey,md)
  493. #define NETSCAPE_SPKI_sign(x,pkey,md) \
  494. ASN1_sign((int (*)())i2d_NETSCAPE_SPKAC, x->sig_algor,NULL, \
  495. x->signature, (char *)x->spkac,pkey,md)
  496. #define X509_dup(x509) (X509 *)ASN1_dup((int (*)())i2d_X509, \
  497. (char *(*)())d2i_X509,(char *)x509)
  498. #define X509_ATTRIBUTE_dup(xa) (X509_ATTRIBUTE *)ASN1_dup(\
  499. (int (*)())i2d_X509_ATTRIBUTE, \
  500. (char *(*)())d2i_X509_ATTRIBUTE,(char *)xa)
  501. #define X509_EXTENSION_dup(ex) (X509_EXTENSION *)ASN1_dup( \
  502. (int (*)())i2d_X509_EXTENSION, \
  503. (char *(*)())d2i_X509_EXTENSION,(char *)ex)
  504. #define d2i_X509_fp(fp,x509) (X509 *)ASN1_d2i_fp((char *(*)())X509_new, \
  505. (char *(*)())d2i_X509, (fp),(unsigned char **)(x509))
  506. #define i2d_X509_fp(fp,x509) ASN1_i2d_fp(i2d_X509,fp,(unsigned char *)x509)
  507. #define d2i_X509_bio(bp,x509) (X509 *)ASN1_d2i_bio((char *(*)())X509_new, \
  508. (char *(*)())d2i_X509, (bp),(unsigned char **)(x509))
  509. #define i2d_X509_bio(bp,x509) ASN1_i2d_bio(i2d_X509,bp,(unsigned char *)x509)
  510. #define X509_CRL_dup(crl) (X509_CRL *)ASN1_dup((int (*)())i2d_X509_CRL, \
  511. (char *(*)())d2i_X509_CRL,(char *)crl)
  512. #define d2i_X509_CRL_fp(fp,crl) (X509_CRL *)ASN1_d2i_fp((char *(*)()) \
  513. X509_CRL_new,(char *(*)())d2i_X509_CRL, (fp),\
  514. (unsigned char **)(crl))
  515. #define i2d_X509_CRL_fp(fp,crl) ASN1_i2d_fp(i2d_X509_CRL,fp,\
  516. (unsigned char *)crl)
  517. #define d2i_X509_CRL_bio(bp,crl) (X509_CRL *)ASN1_d2i_bio((char *(*)()) \
  518. X509_CRL_new,(char *(*)())d2i_X509_CRL, (bp),\
  519. (unsigned char **)(crl))
  520. #define i2d_X509_CRL_bio(bp,crl) ASN1_i2d_bio(i2d_X509_CRL,bp,\
  521. (unsigned char *)crl)
  522. #define PKCS7_dup(p7) (PKCS7 *)ASN1_dup((int (*)())i2d_PKCS7, \
  523. (char *(*)())d2i_PKCS7,(char *)p7)
  524. #define d2i_PKCS7_fp(fp,p7) (PKCS7 *)ASN1_d2i_fp((char *(*)()) \
  525. PKCS7_new,(char *(*)())d2i_PKCS7, (fp),\
  526. (unsigned char **)(p7))
  527. #define i2d_PKCS7_fp(fp,p7) ASN1_i2d_fp(i2d_PKCS7,fp,\
  528. (unsigned char *)p7)
  529. #define d2i_PKCS7_bio(bp,p7) (PKCS7 *)ASN1_d2i_bio((char *(*)()) \
  530. PKCS7_new,(char *(*)())d2i_PKCS7, (bp),\
  531. (unsigned char **)(p7))
  532. #define i2d_PKCS7_bio(bp,p7) ASN1_i2d_bio(i2d_PKCS7,bp,\
  533. (unsigned char *)p7)
  534. #define X509_REQ_dup(req) (X509_REQ *)ASN1_dup((int (*)())i2d_X509_REQ, \
  535. (char *(*)())d2i_X509_REQ,(char *)req)
  536. #define d2i_X509_REQ_fp(fp,req) (X509_REQ *)ASN1_d2i_fp((char *(*)())\
  537. X509_REQ_new, (char *(*)())d2i_X509_REQ, (fp),\
  538. (unsigned char **)(req))
  539. #define i2d_X509_REQ_fp(fp,req) ASN1_i2d_fp(i2d_X509_REQ,fp,\
  540. (unsigned char *)req)
  541. #define d2i_X509_REQ_bio(bp,req) (X509_REQ *)ASN1_d2i_bio((char *(*)())\
  542. X509_REQ_new, (char *(*)())d2i_X509_REQ, (bp),\
  543. (unsigned char **)(req))
  544. #define i2d_X509_REQ_bio(bp,req) ASN1_i2d_bio(i2d_X509_REQ,bp,\
  545. (unsigned char *)req)
  546. #define RSAPublicKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPublicKey, \
  547. (char *(*)())d2i_RSAPublicKey,(char *)rsa)
  548. #define RSAPrivateKey_dup(rsa) (RSA *)ASN1_dup((int (*)())i2d_RSAPrivateKey, \
  549. (char *(*)())d2i_RSAPrivateKey,(char *)rsa)
  550. #define d2i_RSAPrivateKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
  551. RSA_new,(char *(*)())d2i_RSAPrivateKey, (fp), \
  552. (unsigned char **)(rsa))
  553. #define i2d_RSAPrivateKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPrivateKey,fp, \
  554. (unsigned char *)rsa)
  555. #define d2i_RSAPrivateKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
  556. RSA_new,(char *(*)())d2i_RSAPrivateKey, (bp), \
  557. (unsigned char **)(rsa))
  558. #define i2d_RSAPrivateKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPrivateKey,bp, \
  559. (unsigned char *)rsa)
  560. #define d2i_RSAPublicKey_fp(fp,rsa) (RSA *)ASN1_d2i_fp((char *(*)())\
  561. RSA_new,(char *(*)())d2i_RSAPublicKey, (fp), \
  562. (unsigned char **)(rsa))
  563. #define i2d_RSAPublicKey_fp(fp,rsa) ASN1_i2d_fp(i2d_RSAPublicKey,fp, \
  564. (unsigned char *)rsa)
  565. #define d2i_RSAPublicKey_bio(bp,rsa) (RSA *)ASN1_d2i_bio((char *(*)())\
  566. RSA_new,(char *(*)())d2i_RSAPublicKey, (bp), \
  567. (unsigned char **)(rsa))
  568. #define i2d_RSAPublicKey_bio(bp,rsa) ASN1_i2d_bio(i2d_RSAPublicKey,bp, \
  569. (unsigned char *)rsa)
  570. #define d2i_DSAPrivateKey_fp(fp,dsa) (DSA *)ASN1_d2i_fp((char *(*)())\
  571. DSA_new,(char *(*)())d2i_DSAPrivateKey, (fp), \
  572. (unsigned char **)(dsa))
  573. #define i2d_DSAPrivateKey_fp(fp,dsa) ASN1_i2d_fp(i2d_DSAPrivateKey,fp, \
  574. (unsigned char *)dsa)
  575. #define d2i_DSAPrivateKey_bio(bp,dsa) (DSA *)ASN1_d2i_bio((char *(*)())\
  576. DSA_new,(char *(*)())d2i_DSAPrivateKey, (bp), \
  577. (unsigned char **)(dsa))
  578. #define i2d_DSAPrivateKey_bio(bp,dsa) ASN1_i2d_bio(i2d_DSAPrivateKey,bp, \
  579. (unsigned char *)dsa)
  580. #define d2i_ECPrivateKey_fp(fp,ecdsa) (EC_KEY *)ASN1_d2i_fp((char *(*)())\
  581. EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (fp), \
  582. (unsigned char **)(ecdsa))
  583. #define i2d_ECPrivateKey_fp(fp,ecdsa) ASN1_i2d_fp(i2d_ECPrivateKey,fp, \
  584. (unsigned char *)ecdsa)
  585. #define d2i_ECPrivateKey_bio(bp,ecdsa) (EC_KEY *)ASN1_d2i_bio((char *(*)())\
  586. EC_KEY_new,(char *(*)())d2i_ECPrivateKey, (bp), \
  587. (unsigned char **)(ecdsa))
  588. #define i2d_ECPrivateKey_bio(bp,ecdsa) ASN1_i2d_bio(i2d_ECPrivateKey,bp, \
  589. (unsigned char *)ecdsa)
  590. #define X509_ALGOR_dup(xn) (X509_ALGOR *)ASN1_dup((int (*)())i2d_X509_ALGOR,\
  591. (char *(*)())d2i_X509_ALGOR,(char *)xn)
  592. #define X509_NAME_dup(xn) (X509_NAME *)ASN1_dup((int (*)())i2d_X509_NAME, \
  593. (char *(*)())d2i_X509_NAME,(char *)xn)
  594. #define X509_NAME_ENTRY_dup(ne) (X509_NAME_ENTRY *)ASN1_dup( \
  595. (int (*)())i2d_X509_NAME_ENTRY, \
  596. (char *(*)())d2i_X509_NAME_ENTRY,\
  597. (char *)ne)
  598. #define X509_digest(data,type,md,len) \
  599. ASN1_digest((int (*)())i2d_X509,type,(char *)data,md,len)
  600. #define X509_NAME_digest(data,type,md,len) \
  601. ASN1_digest((int (*)())i2d_X509_NAME,type,(char *)data,md,len)
  602. #ifndef PKCS7_ISSUER_AND_SERIAL_digest
  603. #define PKCS7_ISSUER_AND_SERIAL_digest(data,type,md,len) \
  604. ASN1_digest((int (*)())i2d_PKCS7_ISSUER_AND_SERIAL,type,\
  605. (char *)data,md,len)
  606. #endif
  607. #endif
  608. #define X509_EXT_PACK_UNKNOWN 1
  609. #define X509_EXT_PACK_STRING 2
  610. #define X509_get_version(x) ASN1_INTEGER_get((x)->cert_info->version)
  611. /* #define X509_get_serialNumber(x) ((x)->cert_info->serialNumber) */
  612. #define X509_get_notBefore(x) ((x)->cert_info->validity->notBefore)
  613. #define X509_get_notAfter(x) ((x)->cert_info->validity->notAfter)
  614. #define X509_extract_key(x) X509_get_pubkey(x) /*****/
  615. #define X509_REQ_get_version(x) ASN1_INTEGER_get((x)->req_info->version)
  616. #define X509_REQ_get_subject_name(x) ((x)->req_info->subject)
  617. #define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a)
  618. #define X509_name_cmp(a,b) X509_NAME_cmp((a),(b))
  619. #define X509_get_signature_type(x) EVP_PKEY_type(OBJ_obj2nid((x)->sig_alg->algorithm))
  620. #define X509_CRL_get_version(x) ASN1_INTEGER_get((x)->crl->version)
  621. #define X509_CRL_get_lastUpdate(x) ((x)->crl->lastUpdate)
  622. #define X509_CRL_get_nextUpdate(x) ((x)->crl->nextUpdate)
  623. #define X509_CRL_get_issuer(x) ((x)->crl->issuer)
  624. #define X509_CRL_get_REVOKED(x) ((x)->crl->revoked)
  625. /* This one is only used so that a binary form can output, as in
  626. * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) */
  627. #define X509_get_X509_PUBKEY(x) ((x)->cert_info->key)
  628. const char *X509_verify_cert_error_string(long n);
  629. #ifndef SSLEAY_MACROS
  630. #ifndef OPENSSL_NO_EVP
  631. int X509_verify(X509 *a, EVP_PKEY *r);
  632. int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
  633. int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
  634. int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r);
  635. NETSCAPE_SPKI * NETSCAPE_SPKI_b64_decode(const char *str, int len);
  636. char * NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x);
  637. EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x);
  638. int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey);
  639. int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki);
  640. int X509_signature_print(BIO *bp,X509_ALGOR *alg, ASN1_STRING *sig);
  641. int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  642. int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
  643. int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
  644. int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md);
  645. int X509_pubkey_digest(const X509 *data,const EVP_MD *type,
  646. unsigned char *md, unsigned int *len);
  647. int X509_digest(const X509 *data,const EVP_MD *type,
  648. unsigned char *md, unsigned int *len);
  649. int X509_CRL_digest(const X509_CRL *data,const EVP_MD *type,
  650. unsigned char *md, unsigned int *len);
  651. int X509_REQ_digest(const X509_REQ *data,const EVP_MD *type,
  652. unsigned char *md, unsigned int *len);
  653. int X509_NAME_digest(const X509_NAME *data,const EVP_MD *type,
  654. unsigned char *md, unsigned int *len);
  655. #endif
  656. #ifndef OPENSSL_NO_FP_API
  657. X509 *d2i_X509_fp(FILE *fp, X509 **x509);
  658. int i2d_X509_fp(FILE *fp,X509 *x509);
  659. X509_CRL *d2i_X509_CRL_fp(FILE *fp,X509_CRL **crl);
  660. int i2d_X509_CRL_fp(FILE *fp,X509_CRL *crl);
  661. X509_REQ *d2i_X509_REQ_fp(FILE *fp,X509_REQ **req);
  662. int i2d_X509_REQ_fp(FILE *fp,X509_REQ *req);
  663. #ifndef OPENSSL_NO_RSA
  664. RSA *d2i_RSAPrivateKey_fp(FILE *fp,RSA **rsa);
  665. int i2d_RSAPrivateKey_fp(FILE *fp,RSA *rsa);
  666. RSA *d2i_RSAPublicKey_fp(FILE *fp,RSA **rsa);
  667. int i2d_RSAPublicKey_fp(FILE *fp,RSA *rsa);
  668. RSA *d2i_RSA_PUBKEY_fp(FILE *fp,RSA **rsa);
  669. int i2d_RSA_PUBKEY_fp(FILE *fp,RSA *rsa);
  670. #endif
  671. #ifndef OPENSSL_NO_DSA
  672. DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
  673. int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
  674. DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
  675. int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
  676. #endif
  677. #ifndef OPENSSL_NO_EC
  678. EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey);
  679. int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey);
  680. EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey);
  681. int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey);
  682. #endif
  683. X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
  684. int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
  685. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
  686. PKCS8_PRIV_KEY_INFO **p8inf);
  687. int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
  688. int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
  689. int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
  690. EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a);
  691. int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey);
  692. EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a);
  693. #endif
  694. #ifndef OPENSSL_NO_BIO
  695. X509 *d2i_X509_bio(BIO *bp,X509 **x509);
  696. int i2d_X509_bio(BIO *bp,X509 *x509);
  697. X509_CRL *d2i_X509_CRL_bio(BIO *bp,X509_CRL **crl);
  698. int i2d_X509_CRL_bio(BIO *bp,X509_CRL *crl);
  699. X509_REQ *d2i_X509_REQ_bio(BIO *bp,X509_REQ **req);
  700. int i2d_X509_REQ_bio(BIO *bp,X509_REQ *req);
  701. #ifndef OPENSSL_NO_RSA
  702. RSA *d2i_RSAPrivateKey_bio(BIO *bp,RSA **rsa);
  703. int i2d_RSAPrivateKey_bio(BIO *bp,RSA *rsa);
  704. RSA *d2i_RSAPublicKey_bio(BIO *bp,RSA **rsa);
  705. int i2d_RSAPublicKey_bio(BIO *bp,RSA *rsa);
  706. RSA *d2i_RSA_PUBKEY_bio(BIO *bp,RSA **rsa);
  707. int i2d_RSA_PUBKEY_bio(BIO *bp,RSA *rsa);
  708. #endif
  709. #ifndef OPENSSL_NO_DSA
  710. DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa);
  711. int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa);
  712. DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa);
  713. int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa);
  714. #endif
  715. #ifndef OPENSSL_NO_EC
  716. EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey);
  717. int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey);
  718. EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey);
  719. int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey);
  720. #endif
  721. X509_SIG *d2i_PKCS8_bio(BIO *bp,X509_SIG **p8);
  722. int i2d_PKCS8_bio(BIO *bp,X509_SIG *p8);
  723. PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
  724. PKCS8_PRIV_KEY_INFO **p8inf);
  725. int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
  726. int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
  727. int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
  728. EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a);
  729. int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey);
  730. EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a);
  731. #endif
  732. X509 *X509_dup(X509 *x509);
  733. X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa);
  734. X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex);
  735. X509_CRL *X509_CRL_dup(X509_CRL *crl);
  736. X509_REQ *X509_REQ_dup(X509_REQ *req);
  737. X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn);
  738. int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
  739. void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
  740. X509_ALGOR *algor);
  741. X509_NAME *X509_NAME_dup(X509_NAME *xn);
  742. X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
  743. #endif /* !SSLEAY_MACROS */
  744. int X509_cmp_time(ASN1_TIME *s, time_t *t);
  745. int X509_cmp_current_time(ASN1_TIME *s);
  746. ASN1_TIME * X509_time_adj(ASN1_TIME *s, long adj, time_t *t);
  747. ASN1_TIME * X509_gmtime_adj(ASN1_TIME *s, long adj);
  748. const char * X509_get_default_cert_area(void );
  749. const char * X509_get_default_cert_dir(void );
  750. const char * X509_get_default_cert_file(void );
  751. const char * X509_get_default_cert_dir_env(void );
  752. const char * X509_get_default_cert_file_env(void );
  753. const char * X509_get_default_private_dir(void );
  754. X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md);
  755. X509 * X509_REQ_to_X509(X509_REQ *r, int days,EVP_PKEY *pkey);
  756. DECLARE_ASN1_FUNCTIONS(X509_ALGOR)
  757. DECLARE_ASN1_FUNCTIONS(X509_VAL)
  758. DECLARE_ASN1_FUNCTIONS(X509_PUBKEY)
  759. int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey);
  760. EVP_PKEY * X509_PUBKEY_get(X509_PUBKEY *key);
  761. int X509_get_pubkey_parameters(EVP_PKEY *pkey,
  762. STACK_OF(X509) *chain);
  763. int i2d_PUBKEY(EVP_PKEY *a,unsigned char **pp);
  764. EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,const unsigned char **pp,
  765. long length);
  766. #ifndef OPENSSL_NO_RSA
  767. int i2d_RSA_PUBKEY(RSA *a,unsigned char **pp);
  768. RSA * d2i_RSA_PUBKEY(RSA **a,const unsigned char **pp,
  769. long length);
  770. #endif
  771. #ifndef OPENSSL_NO_DSA
  772. int i2d_DSA_PUBKEY(DSA *a,unsigned char **pp);
  773. DSA * d2i_DSA_PUBKEY(DSA **a,const unsigned char **pp,
  774. long length);
  775. #endif
  776. #ifndef OPENSSL_NO_EC
  777. int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp);
  778. EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp,
  779. long length);
  780. #endif
  781. DECLARE_ASN1_FUNCTIONS(X509_SIG)
  782. DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO)
  783. DECLARE_ASN1_FUNCTIONS(X509_REQ)
  784. DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE)
  785. X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value);
  786. DECLARE_ASN1_FUNCTIONS(X509_EXTENSION)
  787. DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY)
  788. DECLARE_ASN1_FUNCTIONS(X509_NAME)
  789. int X509_NAME_set(X509_NAME **xn, X509_NAME *name);
  790. DECLARE_ASN1_FUNCTIONS(X509_CINF)
  791. DECLARE_ASN1_FUNCTIONS(X509)
  792. DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX)
  793. DECLARE_ASN1_FUNCTIONS(X509_CERT_PAIR)
  794. int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
  795. CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
  796. int X509_set_ex_data(X509 *r, int idx, void *arg);
  797. void *X509_get_ex_data(X509 *r, int idx);
  798. int i2d_X509_AUX(X509 *a,unsigned char **pp);
  799. X509 * d2i_X509_AUX(X509 **a,const unsigned char **pp,long length);
  800. int X509_alias_set1(X509 *x, unsigned char *name, int len);
  801. int X509_keyid_set1(X509 *x, unsigned char *id, int len);
  802. unsigned char * X509_alias_get0(X509 *x, int *len);
  803. unsigned char * X509_keyid_get0(X509 *x, int *len);
  804. int (*X509_TRUST_set_default(int (*trust)(int , X509 *, int)))(int, X509 *, int);
  805. int X509_TRUST_set(int *t, int trust);
  806. int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj);
  807. int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj);
  808. void X509_trust_clear(X509 *x);
  809. void X509_reject_clear(X509 *x);
  810. DECLARE_ASN1_FUNCTIONS(X509_REVOKED)
  811. DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO)
  812. DECLARE_ASN1_FUNCTIONS(X509_CRL)
  813. int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
  814. X509_PKEY * X509_PKEY_new(void );
  815. void X509_PKEY_free(X509_PKEY *a);
  816. int i2d_X509_PKEY(X509_PKEY *a,unsigned char **pp);
  817. X509_PKEY * d2i_X509_PKEY(X509_PKEY **a,const unsigned char **pp,long length);
  818. DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI)
  819. DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC)
  820. DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE)
  821. #ifndef OPENSSL_NO_EVP
  822. X509_INFO * X509_INFO_new(void);
  823. void X509_INFO_free(X509_INFO *a);
  824. char * X509_NAME_oneline(X509_NAME *a,char *buf,int size);
  825. int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1,
  826. ASN1_BIT_STRING *signature,char *data,EVP_PKEY *pkey);
  827. int ASN1_digest(i2d_of_void *i2d,const EVP_MD *type,char *data,
  828. unsigned char *md,unsigned int *len);
  829. int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1,
  830. X509_ALGOR *algor2, ASN1_BIT_STRING *signature,
  831. char *data,EVP_PKEY *pkey, const EVP_MD *type);
  832. int ASN1_item_digest(const ASN1_ITEM *it,const EVP_MD *type,void *data,
  833. unsigned char *md,unsigned int *len);
  834. int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1,
  835. ASN1_BIT_STRING *signature,void *data,EVP_PKEY *pkey);
  836. int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
  837. ASN1_BIT_STRING *signature,
  838. void *data, EVP_PKEY *pkey, const EVP_MD *type);
  839. #endif
  840. int X509_set_version(X509 *x,long version);
  841. int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial);
  842. ASN1_INTEGER * X509_get_serialNumber(X509 *x);
  843. int X509_set_issuer_name(X509 *x, X509_NAME *name);
  844. X509_NAME * X509_get_issuer_name(X509 *a);
  845. int X509_set_subject_name(X509 *x, X509_NAME *name);
  846. X509_NAME * X509_get_subject_name(X509 *a);
  847. int X509_set_notBefore(X509 *x, ASN1_TIME *tm);
  848. int X509_set_notAfter(X509 *x, ASN1_TIME *tm);
  849. int X509_set_pubkey(X509 *x, EVP_PKEY *pkey);
  850. EVP_PKEY * X509_get_pubkey(X509 *x);
  851. ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x);
  852. int X509_certificate_type(X509 *x,EVP_PKEY *pubkey /* optional */);
  853. int X509_REQ_set_version(X509_REQ *x,long version);
  854. int X509_REQ_set_subject_name(X509_REQ *req,X509_NAME *name);
  855. int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey);
  856. EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req);
  857. int X509_REQ_extension_nid(int nid);
  858. int * X509_REQ_get_extension_nids(void);
  859. void X509_REQ_set_extension_nids(int *nids);
  860. STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req);
  861. int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts,
  862. int nid);
  863. int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts);
  864. int X509_REQ_get_attr_count(const X509_REQ *req);
  865. int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid,
  866. int lastpos);
  867. int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, ASN1_OBJECT *obj,
  868. int lastpos);
  869. X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc);
  870. X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);
  871. int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr);
  872. int X509_REQ_add1_attr_by_OBJ(X509_REQ *req,
  873. const ASN1_OBJECT *obj, int type,
  874. const unsigned char *bytes, int len);
  875. int X509_REQ_add1_attr_by_NID(X509_REQ *req,
  876. int nid, int type,
  877. const unsigned char *bytes, int len);
  878. int X509_REQ_add1_attr_by_txt(X509_REQ *req,
  879. const char *attrname, int type,
  880. const unsigned char *bytes, int len);
  881. int X509_CRL_set_version(X509_CRL *x, long version);
  882. int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
  883. int X509_CRL_set_lastUpdate(X509_CRL *x, ASN1_TIME *tm);
  884. int X509_CRL_set_nextUpdate(X509_CRL *x, ASN1_TIME *tm);
  885. int X509_CRL_sort(X509_CRL *crl);
  886. int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial);
  887. int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm);
  888. int X509_REQ_check_private_key(X509_REQ *x509,EVP_PKEY *pkey);
  889. int X509_check_private_key(X509 *x509,EVP_PKEY *pkey);
  890. int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
  891. unsigned long X509_issuer_and_serial_hash(X509 *a);
  892. int X509_issuer_name_cmp(const X509 *a, const X509 *b);
  893. unsigned long X509_issuer_name_hash(X509 *a);
  894. int X509_subject_name_cmp(const X509 *a, const X509 *b);
  895. unsigned long X509_subject_name_hash(X509 *x);
  896. int X509_cmp(const X509 *a, const X509 *b);
  897. int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
  898. unsigned long X509_NAME_hash(X509_NAME *x);
  899. int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
  900. #ifndef OPENSSL_NO_FP_API
  901. int X509_print_ex_fp(FILE *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
  902. int X509_print_fp(FILE *bp,X509 *x);
  903. int X509_CRL_print_fp(FILE *bp,X509_CRL *x);
  904. int X509_REQ_print_fp(FILE *bp,X509_REQ *req);
  905. int X509_NAME_print_ex_fp(FILE *fp, X509_NAME *nm, int indent, unsigned long flags);
  906. #endif
  907. #ifndef OPENSSL_NO_BIO
  908. int X509_NAME_print(BIO *bp, X509_NAME *name, int obase);
  909. int X509_NAME_print_ex(BIO *out, X509_NAME *nm, int indent, unsigned long flags);
  910. int X509_print_ex(BIO *bp,X509 *x, unsigned long nmflag, unsigned long cflag);
  911. int X509_print(BIO *bp,X509 *x);
  912. int X509_ocspid_print(BIO *bp,X509 *x);
  913. int X509_CERT_AUX_print(BIO *bp,X509_CERT_AUX *x, int indent);
  914. int X509_CRL_print(BIO *bp,X509_CRL *x);
  915. int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, unsigned long cflag);
  916. int X509_REQ_print(BIO *bp,X509_REQ *req);
  917. #endif
  918. int X509_NAME_entry_count(X509_NAME *name);
  919. int X509_NAME_get_text_by_NID(X509_NAME *name, int nid,
  920. char *buf,int len);
  921. int X509_NAME_get_text_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj,
  922. char *buf,int len);
  923. /* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use
  924. * lastpos, search after that position on. */
  925. int X509_NAME_get_index_by_NID(X509_NAME *name,int nid,int lastpos);
  926. int X509_NAME_get_index_by_OBJ(X509_NAME *name,ASN1_OBJECT *obj,
  927. int lastpos);
  928. X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *name, int loc);
  929. X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc);
  930. int X509_NAME_add_entry(X509_NAME *name,X509_NAME_ENTRY *ne,
  931. int loc, int set);
  932. int X509_NAME_add_entry_by_OBJ(X509_NAME *name, ASN1_OBJECT *obj, int type,
  933. unsigned char *bytes, int len, int loc, int set);
  934. int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
  935. unsigned char *bytes, int len, int loc, int set);
  936. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
  937. const char *field, int type, const unsigned char *bytes, int len);
  938. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid,
  939. int type,unsigned char *bytes, int len);
  940. int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type,
  941. const unsigned char *bytes, int len, int loc, int set);
  942. X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne,
  943. ASN1_OBJECT *obj, int type,const unsigned char *bytes,
  944. int len);
  945. int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne,
  946. ASN1_OBJECT *obj);
  947. int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type,
  948. const unsigned char *bytes, int len);
  949. ASN1_OBJECT * X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *ne);
  950. ASN1_STRING * X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *ne);
  951. int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x);
  952. int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x,
  953. int nid, int lastpos);
  954. int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x,
  955. ASN1_OBJECT *obj,int lastpos);
  956. int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x,
  957. int crit, int lastpos);
  958. X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc);
  959. X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc);
  960. STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
  961. X509_EXTENSION *ex, int loc);
  962. int X509_get_ext_count(X509 *x);
  963. int X509_get_ext_by_NID(X509 *x, int nid, int lastpos);
  964. int X509_get_ext_by_OBJ(X509 *x,ASN1_OBJECT *obj,int lastpos);
  965. int X509_get_ext_by_critical(X509 *x, int crit, int lastpos);
  966. X509_EXTENSION *X509_get_ext(X509 *x, int loc);
  967. X509_EXTENSION *X509_delete_ext(X509 *x, int loc);
  968. int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc);
  969. void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx);
  970. int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit,
  971. unsigned long flags);
  972. int X509_CRL_get_ext_count(X509_CRL *x);
  973. int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos);
  974. int X509_CRL_get_ext_by_OBJ(X509_CRL *x,ASN1_OBJECT *obj,int lastpos);
  975. int X509_CRL_get_ext_by_critical(X509_CRL *x, int crit, int lastpos);
  976. X509_EXTENSION *X509_CRL_get_ext(X509_CRL *x, int loc);
  977. X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc);
  978. int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
  979. void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx);
  980. int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit,
  981. unsigned long flags);
  982. int X509_REVOKED_get_ext_count(X509_REVOKED *x);
  983. int X509_REVOKED_get_ext_by_NID(X509_REVOKED *x, int nid, int lastpos);
  984. int X509_REVOKED_get_ext_by_OBJ(X509_REVOKED *x,ASN1_OBJECT *obj,int lastpos);
  985. int X509_REVOKED_get_ext_by_critical(X509_REVOKED *x, int crit, int lastpos);
  986. X509_EXTENSION *X509_REVOKED_get_ext(X509_REVOKED *x, int loc);
  987. X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc);
  988. int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc);
  989. void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx);
  990. int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit,
  991. unsigned long flags);
  992. X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
  993. int nid, int crit, ASN1_OCTET_STRING *data);
  994. X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
  995. ASN1_OBJECT *obj,int crit,ASN1_OCTET_STRING *data);
  996. int X509_EXTENSION_set_object(X509_EXTENSION *ex,ASN1_OBJECT *obj);
  997. int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
  998. int X509_EXTENSION_set_data(X509_EXTENSION *ex,
  999. ASN1_OCTET_STRING *data);
  1000. ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex);
  1001. ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne);
  1002. int X509_EXTENSION_get_critical(X509_EXTENSION *ex);
  1003. int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x);
  1004. int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
  1005. int lastpos);
  1006. int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, ASN1_OBJECT *obj,
  1007. int lastpos);
  1008. X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc);
  1009. X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc);
  1010. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x,
  1011. X509_ATTRIBUTE *attr);
  1012. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x,
  1013. const ASN1_OBJECT *obj, int type,
  1014. const unsigned char *bytes, int len);
  1015. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x,
  1016. int nid, int type,
  1017. const unsigned char *bytes, int len);
  1018. STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x,
  1019. const char *attrname, int type,
  1020. const unsigned char *bytes, int len);
  1021. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
  1022. int atrtype, const void *data, int len);
  1023. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
  1024. const ASN1_OBJECT *obj, int atrtype, const void *data, int len);
  1025. X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
  1026. const char *atrname, int type, const unsigned char *bytes, int len);
  1027. int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj);
  1028. int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len);
  1029. void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx,
  1030. int atrtype, void *data);
  1031. int X509_ATTRIBUTE_count(X509_ATTRIBUTE *attr);
  1032. ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr);
  1033. ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx);
  1034. int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
  1035. int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid,
  1036. int lastpos);
  1037. int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, ASN1_OBJECT *obj,
  1038. int lastpos);
  1039. X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
  1040. X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
  1041. int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
  1042. int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
  1043. const ASN1_OBJECT *obj, int type,
  1044. const unsigned char *bytes, int len);
  1045. int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
  1046. int nid, int type,
  1047. const unsigned char *bytes, int len);
  1048. int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
  1049. const char *attrname, int type,
  1050. const unsigned char *bytes, int len);
  1051. int X509_verify_cert(X509_STORE_CTX *ctx);
  1052. /* lookup a cert from a X509 STACK */
  1053. X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk,X509_NAME *name,
  1054. ASN1_INTEGER *serial);
  1055. X509 *X509_find_by_subject(STACK_OF(X509) *sk,X509_NAME *name);
  1056. DECLARE_ASN1_FUNCTIONS(PBEPARAM)
  1057. DECLARE_ASN1_FUNCTIONS(PBE2PARAM)
  1058. DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM)
  1059. X509_ALGOR *PKCS5_pbe_set(int alg, int iter, unsigned char *salt, int saltlen);
  1060. X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
  1061. unsigned char *salt, int saltlen);
  1062. X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
  1063. unsigned char *salt, int saltlen,
  1064. unsigned char *aiv, int prf_nid);
  1065. /* PKCS#8 utilities */
  1066. DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO)
  1067. EVP_PKEY *EVP_PKCS82PKEY(PKCS8_PRIV_KEY_INFO *p8);
  1068. PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey);
  1069. PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken);
  1070. PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken);
  1071. int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj,
  1072. int version, int ptype, void *pval,
  1073. unsigned char *penc, int penclen);
  1074. int PKCS8_pkey_get0(ASN1_OBJECT **ppkalg,
  1075. const unsigned char **pk, int *ppklen,
  1076. X509_ALGOR **pa,
  1077. PKCS8_PRIV_KEY_INFO *p8);
  1078. int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj,
  1079. int ptype, void *pval,
  1080. unsigned char *penc, int penclen);
  1081. int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg,
  1082. const unsigned char **pk, int *ppklen,
  1083. X509_ALGOR **pa,
  1084. X509_PUBKEY *pub);
  1085. int X509_check_trust(X509 *x, int id, int flags);
  1086. int X509_TRUST_get_count(void);
  1087. X509_TRUST * X509_TRUST_get0(int idx);
  1088. int X509_TRUST_get_by_id(int id);
  1089. int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int),
  1090. char *name, int arg1, void *arg2);
  1091. void X509_TRUST_cleanup(void);
  1092. int X509_TRUST_get_flags(X509_TRUST *xp);
  1093. char *X509_TRUST_get0_name(X509_TRUST *xp);
  1094. int X509_TRUST_get_trust(X509_TRUST *xp);
  1095. /* BEGIN ERROR CODES */
  1096. /* The following lines are auto generated by the script mkerr.pl. Any changes
  1097. * made after this point may be overwritten when the script is next run.
  1098. */
  1099. void ERR_load_X509_strings(void);
  1100. /* Error codes for the X509 functions. */
  1101. /* Function codes. */
  1102. #define X509_F_ADD_CERT_DIR 100
  1103. #define X509_F_BY_FILE_CTRL 101
  1104. #define X509_F_CHECK_POLICY 145
  1105. #define X509_F_DIR_CTRL 102
  1106. #define X509_F_GET_CERT_BY_SUBJECT 103
  1107. #define X509_F_NETSCAPE_SPKI_B64_DECODE 129
  1108. #define X509_F_NETSCAPE_SPKI_B64_ENCODE 130
  1109. #define X509_F_X509AT_ADD1_ATTR 135
  1110. #define X509_F_X509V3_ADD_EXT 104
  1111. #define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136
  1112. #define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137
  1113. #define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140
  1114. #define X509_F_X509_ATTRIBUTE_GET0_DATA 139
  1115. #define X509_F_X509_ATTRIBUTE_SET1_DATA 138
  1116. #define X509_F_X509_CHECK_PRIVATE_KEY 128
  1117. #define X509_F_X509_CRL_PRINT_FP 147
  1118. #define X509_F_X509_EXTENSION_CREATE_BY_NID 108
  1119. #define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
  1120. #define X509_F_X509_GET_PUBKEY_PARAMETERS 110
  1121. #define X509_F_X509_LOAD_CERT_CRL_FILE 132
  1122. #define X509_F_X509_LOAD_CERT_FILE 111
  1123. #define X509_F_X509_LOAD_CRL_FILE 112
  1124. #define X509_F_X509_NAME_ADD_ENTRY 113
  1125. #define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
  1126. #define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131
  1127. #define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
  1128. #define X509_F_X509_NAME_ONELINE 116
  1129. #define X509_F_X509_NAME_PRINT 117
  1130. #define X509_F_X509_PRINT_EX_FP 118
  1131. #define X509_F_X509_PUBKEY_GET 119
  1132. #define X509_F_X509_PUBKEY_SET 120
  1133. #define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144
  1134. #define X509_F_X509_REQ_PRINT_EX 121
  1135. #define X509_F_X509_REQ_PRINT_FP 122
  1136. #define X509_F_X509_REQ_TO_X509 123
  1137. #define X509_F_X509_STORE_ADD_CERT 124
  1138. #define X509_F_X509_STORE_ADD_CRL 125
  1139. #define X509_F_X509_STORE_CTX_GET1_ISSUER 146
  1140. #define X509_F_X509_STORE_CTX_INIT 143
  1141. #define X509_F_X509_STORE_CTX_NEW 142
  1142. #define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134
  1143. #define X509_F_X509_TO_X509_REQ 126
  1144. #define X509_F_X509_TRUST_ADD 133
  1145. #define X509_F_X509_TRUST_SET 141
  1146. #define X509_F_X509_VERIFY_CERT 127
  1147. /* Reason codes. */
  1148. #define X509_R_BAD_X509_FILETYPE 100
  1149. #define X509_R_BASE64_DECODE_ERROR 118
  1150. #define X509_R_CANT_CHECK_DH_KEY 114
  1151. #define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
  1152. #define X509_R_ERR_ASN1_LIB 102
  1153. #define X509_R_INVALID_DIRECTORY 113
  1154. #define X509_R_INVALID_FIELD_NAME 119
  1155. #define X509_R_INVALID_TRUST 123
  1156. #define X509_R_KEY_TYPE_MISMATCH 115
  1157. #define X509_R_KEY_VALUES_MISMATCH 116
  1158. #define X509_R_LOADING_CERT_DIR 103
  1159. #define X509_R_LOADING_DEFAULTS 104
  1160. #define X509_R_METHOD_NOT_SUPPORTED 124
  1161. #define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
  1162. #define X509_R_PUBLIC_KEY_DECODE_ERROR 125
  1163. #define X509_R_PUBLIC_KEY_ENCODE_ERROR 126
  1164. #define X509_R_SHOULD_RETRY 106
  1165. #define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
  1166. #define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
  1167. #define X509_R_UNKNOWN_KEY_TYPE 117
  1168. #define X509_R_UNKNOWN_NID 109
  1169. #define X509_R_UNKNOWN_PURPOSE_ID 121
  1170. #define X509_R_UNKNOWN_TRUST_ID 120
  1171. #define X509_R_UNSUPPORTED_ALGORITHM 111
  1172. #define X509_R_WRONG_LOOKUP_TYPE 112
  1173. #define X509_R_WRONG_TYPE 122
  1174. #ifdef __cplusplus
  1175. }
  1176. #endif
  1177. #endif