Turn audio into a shareable video. forked from nypublicradio/audiogram

ssl.h 109KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439
  1. /*
  2. * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
  4. * Copyright 2005 Nokia. All rights reserved.
  5. *
  6. * Licensed under the OpenSSL license (the "License"). You may not use
  7. * this file except in compliance with the License. You can obtain a copy
  8. * in the file LICENSE in the source distribution or at
  9. * https://www.openssl.org/source/license.html
  10. */
  11. #ifndef HEADER_SSL_H
  12. # define HEADER_SSL_H
  13. # include <openssl/e_os2.h>
  14. # include <openssl/opensslconf.h>
  15. # include <openssl/comp.h>
  16. # include <openssl/bio.h>
  17. # if OPENSSL_API_COMPAT < 0x10100000L
  18. # include <openssl/x509.h>
  19. # include <openssl/crypto.h>
  20. # include <openssl/buffer.h>
  21. # endif
  22. # include <openssl/lhash.h>
  23. # include <openssl/pem.h>
  24. # include <openssl/hmac.h>
  25. # include <openssl/async.h>
  26. # include <openssl/safestack.h>
  27. # include <openssl/symhacks.h>
  28. # include <openssl/ct.h>
  29. # include <openssl/sslerr.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /* OpenSSL version number for ASN.1 encoding of the session information */
  34. /*-
  35. * Version 0 - initial version
  36. * Version 1 - added the optional peer certificate
  37. */
  38. # define SSL_SESSION_ASN1_VERSION 0x0001
  39. # define SSL_MAX_SSL_SESSION_ID_LENGTH 32
  40. # define SSL_MAX_SID_CTX_LENGTH 32
  41. # define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8)
  42. # define SSL_MAX_KEY_ARG_LENGTH 8
  43. # define SSL_MAX_MASTER_KEY_LENGTH 48
  44. /* The maximum number of encrypt/decrypt pipelines we can support */
  45. # define SSL_MAX_PIPELINES 32
  46. /* text strings for the ciphers */
  47. /* These are used to specify which ciphers to use and not to use */
  48. # define SSL_TXT_LOW "LOW"
  49. # define SSL_TXT_MEDIUM "MEDIUM"
  50. # define SSL_TXT_HIGH "HIGH"
  51. # define SSL_TXT_FIPS "FIPS"
  52. # define SSL_TXT_aNULL "aNULL"
  53. # define SSL_TXT_eNULL "eNULL"
  54. # define SSL_TXT_NULL "NULL"
  55. # define SSL_TXT_kRSA "kRSA"
  56. # define SSL_TXT_kDHr "kDHr"/* this cipher class has been removed */
  57. # define SSL_TXT_kDHd "kDHd"/* this cipher class has been removed */
  58. # define SSL_TXT_kDH "kDH"/* this cipher class has been removed */
  59. # define SSL_TXT_kEDH "kEDH"/* alias for kDHE */
  60. # define SSL_TXT_kDHE "kDHE"
  61. # define SSL_TXT_kECDHr "kECDHr"/* this cipher class has been removed */
  62. # define SSL_TXT_kECDHe "kECDHe"/* this cipher class has been removed */
  63. # define SSL_TXT_kECDH "kECDH"/* this cipher class has been removed */
  64. # define SSL_TXT_kEECDH "kEECDH"/* alias for kECDHE */
  65. # define SSL_TXT_kECDHE "kECDHE"
  66. # define SSL_TXT_kPSK "kPSK"
  67. # define SSL_TXT_kRSAPSK "kRSAPSK"
  68. # define SSL_TXT_kECDHEPSK "kECDHEPSK"
  69. # define SSL_TXT_kDHEPSK "kDHEPSK"
  70. # define SSL_TXT_kGOST "kGOST"
  71. # define SSL_TXT_kSRP "kSRP"
  72. # define SSL_TXT_aRSA "aRSA"
  73. # define SSL_TXT_aDSS "aDSS"
  74. # define SSL_TXT_aDH "aDH"/* this cipher class has been removed */
  75. # define SSL_TXT_aECDH "aECDH"/* this cipher class has been removed */
  76. # define SSL_TXT_aECDSA "aECDSA"
  77. # define SSL_TXT_aPSK "aPSK"
  78. # define SSL_TXT_aGOST94 "aGOST94"
  79. # define SSL_TXT_aGOST01 "aGOST01"
  80. # define SSL_TXT_aGOST12 "aGOST12"
  81. # define SSL_TXT_aGOST "aGOST"
  82. # define SSL_TXT_aSRP "aSRP"
  83. # define SSL_TXT_DSS "DSS"
  84. # define SSL_TXT_DH "DH"
  85. # define SSL_TXT_DHE "DHE"/* same as "kDHE:-ADH" */
  86. # define SSL_TXT_EDH "EDH"/* alias for DHE */
  87. # define SSL_TXT_ADH "ADH"
  88. # define SSL_TXT_RSA "RSA"
  89. # define SSL_TXT_ECDH "ECDH"
  90. # define SSL_TXT_EECDH "EECDH"/* alias for ECDHE" */
  91. # define SSL_TXT_ECDHE "ECDHE"/* same as "kECDHE:-AECDH" */
  92. # define SSL_TXT_AECDH "AECDH"
  93. # define SSL_TXT_ECDSA "ECDSA"
  94. # define SSL_TXT_PSK "PSK"
  95. # define SSL_TXT_SRP "SRP"
  96. # define SSL_TXT_DES "DES"
  97. # define SSL_TXT_3DES "3DES"
  98. # define SSL_TXT_RC4 "RC4"
  99. # define SSL_TXT_RC2 "RC2"
  100. # define SSL_TXT_IDEA "IDEA"
  101. # define SSL_TXT_SEED "SEED"
  102. # define SSL_TXT_AES128 "AES128"
  103. # define SSL_TXT_AES256 "AES256"
  104. # define SSL_TXT_AES "AES"
  105. # define SSL_TXT_AES_GCM "AESGCM"
  106. # define SSL_TXT_AES_CCM "AESCCM"
  107. # define SSL_TXT_AES_CCM_8 "AESCCM8"
  108. # define SSL_TXT_CAMELLIA128 "CAMELLIA128"
  109. # define SSL_TXT_CAMELLIA256 "CAMELLIA256"
  110. # define SSL_TXT_CAMELLIA "CAMELLIA"
  111. # define SSL_TXT_CHACHA20 "CHACHA20"
  112. # define SSL_TXT_GOST "GOST89"
  113. # define SSL_TXT_ARIA "ARIA"
  114. # define SSL_TXT_ARIA_GCM "ARIAGCM"
  115. # define SSL_TXT_ARIA128 "ARIA128"
  116. # define SSL_TXT_ARIA256 "ARIA256"
  117. # define SSL_TXT_MD5 "MD5"
  118. # define SSL_TXT_SHA1 "SHA1"
  119. # define SSL_TXT_SHA "SHA"/* same as "SHA1" */
  120. # define SSL_TXT_GOST94 "GOST94"
  121. # define SSL_TXT_GOST89MAC "GOST89MAC"
  122. # define SSL_TXT_GOST12 "GOST12"
  123. # define SSL_TXT_GOST89MAC12 "GOST89MAC12"
  124. # define SSL_TXT_SHA256 "SHA256"
  125. # define SSL_TXT_SHA384 "SHA384"
  126. # define SSL_TXT_SSLV3 "SSLv3"
  127. # define SSL_TXT_TLSV1 "TLSv1"
  128. # define SSL_TXT_TLSV1_1 "TLSv1.1"
  129. # define SSL_TXT_TLSV1_2 "TLSv1.2"
  130. # define SSL_TXT_ALL "ALL"
  131. /*-
  132. * COMPLEMENTOF* definitions. These identifiers are used to (de-select)
  133. * ciphers normally not being used.
  134. * Example: "RC4" will activate all ciphers using RC4 including ciphers
  135. * without authentication, which would normally disabled by DEFAULT (due
  136. * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT"
  137. * will make sure that it is also disabled in the specific selection.
  138. * COMPLEMENTOF* identifiers are portable between version, as adjustments
  139. * to the default cipher setup will also be included here.
  140. *
  141. * COMPLEMENTOFDEFAULT does not experience the same special treatment that
  142. * DEFAULT gets, as only selection is being done and no sorting as needed
  143. * for DEFAULT.
  144. */
  145. # define SSL_TXT_CMPALL "COMPLEMENTOFALL"
  146. # define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT"
  147. /*
  148. * The following cipher list is used by default. It also is substituted when
  149. * an application-defined cipher list string starts with 'DEFAULT'.
  150. * This applies to ciphersuites for TLSv1.2 and below.
  151. */
  152. # define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL"
  153. /* This is the default set of TLSv1.3 ciphersuites */
  154. # if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
  155. # define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \
  156. "TLS_CHACHA20_POLY1305_SHA256:" \
  157. "TLS_AES_128_GCM_SHA256"
  158. # else
  159. # define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \
  160. "TLS_AES_128_GCM_SHA256"
  161. #endif
  162. /*
  163. * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always
  164. * starts with a reasonable order, and all we have to do for DEFAULT is
  165. * throwing out anonymous and unencrypted ciphersuites! (The latter are not
  166. * actually enabled by ALL, but "ALL:RSA" would enable some of them.)
  167. */
  168. /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
  169. # define SSL_SENT_SHUTDOWN 1
  170. # define SSL_RECEIVED_SHUTDOWN 2
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #ifdef __cplusplus
  175. extern "C" {
  176. #endif
  177. # define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1
  178. # define SSL_FILETYPE_PEM X509_FILETYPE_PEM
  179. /*
  180. * This is needed to stop compilers complaining about the 'struct ssl_st *'
  181. * function parameters used to prototype callbacks in SSL_CTX.
  182. */
  183. typedef struct ssl_st *ssl_crock_st;
  184. typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT;
  185. typedef struct ssl_method_st SSL_METHOD;
  186. typedef struct ssl_cipher_st SSL_CIPHER;
  187. typedef struct ssl_session_st SSL_SESSION;
  188. typedef struct tls_sigalgs_st TLS_SIGALGS;
  189. typedef struct ssl_conf_ctx_st SSL_CONF_CTX;
  190. typedef struct ssl_comp_st SSL_COMP;
  191. STACK_OF(SSL_CIPHER);
  192. STACK_OF(SSL_COMP);
  193. /* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/
  194. typedef struct srtp_protection_profile_st {
  195. const char *name;
  196. unsigned long id;
  197. } SRTP_PROTECTION_PROFILE;
  198. DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)
  199. typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data,
  200. int len, void *arg);
  201. typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len,
  202. STACK_OF(SSL_CIPHER) *peer_ciphers,
  203. const SSL_CIPHER **cipher, void *arg);
  204. /* Extension context codes */
  205. /* This extension is only allowed in TLS */
  206. #define SSL_EXT_TLS_ONLY 0x0001
  207. /* This extension is only allowed in DTLS */
  208. #define SSL_EXT_DTLS_ONLY 0x0002
  209. /* Some extensions may be allowed in DTLS but we don't implement them for it */
  210. #define SSL_EXT_TLS_IMPLEMENTATION_ONLY 0x0004
  211. /* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */
  212. #define SSL_EXT_SSL3_ALLOWED 0x0008
  213. /* Extension is only defined for TLS1.2 and below */
  214. #define SSL_EXT_TLS1_2_AND_BELOW_ONLY 0x0010
  215. /* Extension is only defined for TLS1.3 and above */
  216. #define SSL_EXT_TLS1_3_ONLY 0x0020
  217. /* Ignore this extension during parsing if we are resuming */
  218. #define SSL_EXT_IGNORE_ON_RESUMPTION 0x0040
  219. #define SSL_EXT_CLIENT_HELLO 0x0080
  220. /* Really means TLS1.2 or below */
  221. #define SSL_EXT_TLS1_2_SERVER_HELLO 0x0100
  222. #define SSL_EXT_TLS1_3_SERVER_HELLO 0x0200
  223. #define SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS 0x0400
  224. #define SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST 0x0800
  225. #define SSL_EXT_TLS1_3_CERTIFICATE 0x1000
  226. #define SSL_EXT_TLS1_3_NEW_SESSION_TICKET 0x2000
  227. #define SSL_EXT_TLS1_3_CERTIFICATE_REQUEST 0x4000
  228. /* Typedefs for handling custom extensions */
  229. typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type,
  230. const unsigned char **out, size_t *outlen,
  231. int *al, void *add_arg);
  232. typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type,
  233. const unsigned char *out, void *add_arg);
  234. typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type,
  235. const unsigned char *in, size_t inlen,
  236. int *al, void *parse_arg);
  237. typedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type,
  238. unsigned int context,
  239. const unsigned char **out,
  240. size_t *outlen, X509 *x,
  241. size_t chainidx,
  242. int *al, void *add_arg);
  243. typedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type,
  244. unsigned int context,
  245. const unsigned char *out,
  246. void *add_arg);
  247. typedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type,
  248. unsigned int context,
  249. const unsigned char *in,
  250. size_t inlen, X509 *x,
  251. size_t chainidx,
  252. int *al, void *parse_arg);
  253. /* Typedef for verification callback */
  254. typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx);
  255. /*
  256. * Some values are reserved until OpenSSL 1.2.0 because they were previously
  257. * included in SSL_OP_ALL in a 1.1.x release.
  258. *
  259. * Reserved value (until OpenSSL 1.2.0) 0x00000001U
  260. * Reserved value (until OpenSSL 1.2.0) 0x00000002U
  261. */
  262. /* Allow initial connection to servers that don't support RI */
  263. # define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004U
  264. /* Reserved value (until OpenSSL 1.2.0) 0x00000008U */
  265. # define SSL_OP_TLSEXT_PADDING 0x00000010U
  266. /* Reserved value (until OpenSSL 1.2.0) 0x00000020U */
  267. # define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040U
  268. /*
  269. * Reserved value (until OpenSSL 1.2.0) 0x00000080U
  270. * Reserved value (until OpenSSL 1.2.0) 0x00000100U
  271. * Reserved value (until OpenSSL 1.2.0) 0x00000200U
  272. */
  273. /* In TLSv1.3 allow a non-(ec)dhe based kex_mode */
  274. # define SSL_OP_ALLOW_NO_DHE_KEX 0x00000400U
  275. /*
  276. * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in
  277. * OpenSSL 0.9.6d. Usually (depending on the application protocol) the
  278. * workaround is not needed. Unfortunately some broken SSL/TLS
  279. * implementations cannot handle it at all, which is why we include it in
  280. * SSL_OP_ALL. Added in 0.9.6e
  281. */
  282. # define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800U
  283. /* DTLS options */
  284. # define SSL_OP_NO_QUERY_MTU 0x00001000U
  285. /* Turn on Cookie Exchange (on relevant for servers) */
  286. # define SSL_OP_COOKIE_EXCHANGE 0x00002000U
  287. /* Don't use RFC4507 ticket extension */
  288. # define SSL_OP_NO_TICKET 0x00004000U
  289. # ifndef OPENSSL_NO_DTLS1_METHOD
  290. /* Use Cisco's "speshul" version of DTLS_BAD_VER
  291. * (only with deprecated DTLSv1_client_method()) */
  292. # define SSL_OP_CISCO_ANYCONNECT 0x00008000U
  293. # endif
  294. /* As server, disallow session resumption on renegotiation */
  295. # define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000U
  296. /* Don't use compression even if supported */
  297. # define SSL_OP_NO_COMPRESSION 0x00020000U
  298. /* Permit unsafe legacy renegotiation */
  299. # define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000U
  300. /* Disable encrypt-then-mac */
  301. # define SSL_OP_NO_ENCRYPT_THEN_MAC 0x00080000U
  302. /*
  303. * Enable TLSv1.3 Compatibility mode. This is on by default. A future version
  304. * of OpenSSL may have this disabled by default.
  305. */
  306. # define SSL_OP_ENABLE_MIDDLEBOX_COMPAT 0x00100000U
  307. /* Prioritize Chacha20Poly1305 when client does.
  308. * Modifies SSL_OP_CIPHER_SERVER_PREFERENCE */
  309. # define SSL_OP_PRIORITIZE_CHACHA 0x00200000U
  310. /*
  311. * Set on servers to choose the cipher according to the server's preferences
  312. */
  313. # define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000U
  314. /*
  315. * If set, a server will allow a client to issue a SSLv3.0 version number as
  316. * latest version supported in the premaster secret, even when TLSv1.0
  317. * (version 3.1) was announced in the client hello. Normally this is
  318. * forbidden to prevent version rollback attacks.
  319. */
  320. # define SSL_OP_TLS_ROLLBACK_BUG 0x00800000U
  321. /*
  322. * Switches off automatic TLSv1.3 anti-replay protection for early data. This
  323. * is a server-side option only (no effect on the client).
  324. */
  325. # define SSL_OP_NO_ANTI_REPLAY 0x01000000U
  326. # define SSL_OP_NO_SSLv3 0x02000000U
  327. # define SSL_OP_NO_TLSv1 0x04000000U
  328. # define SSL_OP_NO_TLSv1_2 0x08000000U
  329. # define SSL_OP_NO_TLSv1_1 0x10000000U
  330. # define SSL_OP_NO_TLSv1_3 0x20000000U
  331. # define SSL_OP_NO_DTLSv1 0x04000000U
  332. # define SSL_OP_NO_DTLSv1_2 0x08000000U
  333. # define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\
  334. SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2|SSL_OP_NO_TLSv1_3)
  335. # define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2)
  336. /* Disallow all renegotiation */
  337. # define SSL_OP_NO_RENEGOTIATION 0x40000000U
  338. /*
  339. * Make server add server-hello extension from early version of cryptopro
  340. * draft, when GOST ciphersuite is negotiated. Required for interoperability
  341. * with CryptoPro CSP 3.x
  342. */
  343. # define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0x80000000U
  344. /*
  345. * SSL_OP_ALL: various bug workarounds that should be rather harmless.
  346. * This used to be 0x000FFFFFL before 0.9.7.
  347. * This used to be 0x80000BFFU before 1.1.1.
  348. */
  349. # define SSL_OP_ALL (SSL_OP_CRYPTOPRO_TLSEXT_BUG|\
  350. SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS|\
  351. SSL_OP_LEGACY_SERVER_CONNECT|\
  352. SSL_OP_TLSEXT_PADDING|\
  353. SSL_OP_SAFARI_ECDHE_ECDSA_BUG)
  354. /* OBSOLETE OPTIONS: retained for compatibility */
  355. /* Removed from OpenSSL 1.1.0. Was 0x00000001L */
  356. /* Related to removed SSLv2. */
  357. # define SSL_OP_MICROSOFT_SESS_ID_BUG 0x0
  358. /* Removed from OpenSSL 1.1.0. Was 0x00000002L */
  359. /* Related to removed SSLv2. */
  360. # define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x0
  361. /* Removed from OpenSSL 0.9.8q and 1.0.0c. Was 0x00000008L */
  362. /* Dead forever, see CVE-2010-4180 */
  363. # define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0
  364. /* Removed from OpenSSL 1.0.1h and 1.0.2. Was 0x00000010L */
  365. /* Refers to ancient SSLREF and SSLv2. */
  366. # define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0
  367. /* Removed from OpenSSL 1.1.0. Was 0x00000020 */
  368. # define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x0
  369. /* Removed from OpenSSL 0.9.7h and 0.9.8b. Was 0x00000040L */
  370. # define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0
  371. /* Removed from OpenSSL 1.1.0. Was 0x00000080 */
  372. /* Ancient SSLeay version. */
  373. # define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x0
  374. /* Removed from OpenSSL 1.1.0. Was 0x00000100L */
  375. # define SSL_OP_TLS_D5_BUG 0x0
  376. /* Removed from OpenSSL 1.1.0. Was 0x00000200L */
  377. # define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0
  378. /* Removed from OpenSSL 1.1.0. Was 0x00080000L */
  379. # define SSL_OP_SINGLE_ECDH_USE 0x0
  380. /* Removed from OpenSSL 1.1.0. Was 0x00100000L */
  381. # define SSL_OP_SINGLE_DH_USE 0x0
  382. /* Removed from OpenSSL 1.0.1k and 1.0.2. Was 0x00200000L */
  383. # define SSL_OP_EPHEMERAL_RSA 0x0
  384. /* Removed from OpenSSL 1.1.0. Was 0x01000000L */
  385. # define SSL_OP_NO_SSLv2 0x0
  386. /* Removed from OpenSSL 1.0.1. Was 0x08000000L */
  387. # define SSL_OP_PKCS1_CHECK_1 0x0
  388. /* Removed from OpenSSL 1.0.1. Was 0x10000000L */
  389. # define SSL_OP_PKCS1_CHECK_2 0x0
  390. /* Removed from OpenSSL 1.1.0. Was 0x20000000L */
  391. # define SSL_OP_NETSCAPE_CA_DN_BUG 0x0
  392. /* Removed from OpenSSL 1.1.0. Was 0x40000000L */
  393. # define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x0
  394. /*
  395. * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success
  396. * when just a single record has been written):
  397. */
  398. # define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U
  399. /*
  400. * Make it possible to retry SSL_write() with changed buffer location (buffer
  401. * contents must stay the same!); this is not the default to avoid the
  402. * misconception that non-blocking SSL_write() behaves like non-blocking
  403. * write():
  404. */
  405. # define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U
  406. /*
  407. * Never bother the application with retries if the transport is blocking:
  408. */
  409. # define SSL_MODE_AUTO_RETRY 0x00000004U
  410. /* Don't attempt to automatically build certificate chain */
  411. # define SSL_MODE_NO_AUTO_CHAIN 0x00000008U
  412. /*
  413. * Save RAM by releasing read and write buffers when they're empty. (SSL3 and
  414. * TLS only.) Released buffers are freed.
  415. */
  416. # define SSL_MODE_RELEASE_BUFFERS 0x00000010U
  417. /*
  418. * Send the current time in the Random fields of the ClientHello and
  419. * ServerHello records for compatibility with hypothetical implementations
  420. * that require it.
  421. */
  422. # define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U
  423. # define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U
  424. /*
  425. * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications
  426. * that reconnect with a downgraded protocol version; see
  427. * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your
  428. * application attempts a normal handshake. Only use this in explicit
  429. * fallback retries, following the guidance in
  430. * draft-ietf-tls-downgrade-scsv-00.
  431. */
  432. # define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U
  433. /*
  434. * Support Asynchronous operation
  435. */
  436. # define SSL_MODE_ASYNC 0x00000100U
  437. /*
  438. * When using DTLS/SCTP, include the terminating zero in the label
  439. * used for computing the endpoint-pair shared secret. Required for
  440. * interoperability with implementations having this bug like these
  441. * older version of OpenSSL:
  442. * - OpenSSL 1.0.0 series
  443. * - OpenSSL 1.0.1 series
  444. * - OpenSSL 1.0.2 series
  445. * - OpenSSL 1.1.0 series
  446. * - OpenSSL 1.1.1 and 1.1.1a
  447. */
  448. # define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U
  449. /* Cert related flags */
  450. /*
  451. * Many implementations ignore some aspects of the TLS standards such as
  452. * enforcing certificate chain algorithms. When this is set we enforce them.
  453. */
  454. # define SSL_CERT_FLAG_TLS_STRICT 0x00000001U
  455. /* Suite B modes, takes same values as certificate verify flags */
  456. # define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY 0x10000
  457. /* Suite B 192 bit only mode */
  458. # define SSL_CERT_FLAG_SUITEB_192_LOS 0x20000
  459. /* Suite B 128 bit mode allowing 192 bit algorithms */
  460. # define SSL_CERT_FLAG_SUITEB_128_LOS 0x30000
  461. /* Perform all sorts of protocol violations for testing purposes */
  462. # define SSL_CERT_FLAG_BROKEN_PROTOCOL 0x10000000
  463. /* Flags for building certificate chains */
  464. /* Treat any existing certificates as untrusted CAs */
  465. # define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1
  466. /* Don't include root CA in chain */
  467. # define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2
  468. /* Just check certificates already there */
  469. # define SSL_BUILD_CHAIN_FLAG_CHECK 0x4
  470. /* Ignore verification errors */
  471. # define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8
  472. /* Clear verification errors from queue */
  473. # define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10
  474. /* Flags returned by SSL_check_chain */
  475. /* Certificate can be used with this session */
  476. # define CERT_PKEY_VALID 0x1
  477. /* Certificate can also be used for signing */
  478. # define CERT_PKEY_SIGN 0x2
  479. /* EE certificate signing algorithm OK */
  480. # define CERT_PKEY_EE_SIGNATURE 0x10
  481. /* CA signature algorithms OK */
  482. # define CERT_PKEY_CA_SIGNATURE 0x20
  483. /* EE certificate parameters OK */
  484. # define CERT_PKEY_EE_PARAM 0x40
  485. /* CA certificate parameters OK */
  486. # define CERT_PKEY_CA_PARAM 0x80
  487. /* Signing explicitly allowed as opposed to SHA1 fallback */
  488. # define CERT_PKEY_EXPLICIT_SIGN 0x100
  489. /* Client CA issuer names match (always set for server cert) */
  490. # define CERT_PKEY_ISSUER_NAME 0x200
  491. /* Cert type matches client types (always set for server cert) */
  492. # define CERT_PKEY_CERT_TYPE 0x400
  493. /* Cert chain suitable to Suite B */
  494. # define CERT_PKEY_SUITEB 0x800
  495. # define SSL_CONF_FLAG_CMDLINE 0x1
  496. # define SSL_CONF_FLAG_FILE 0x2
  497. # define SSL_CONF_FLAG_CLIENT 0x4
  498. # define SSL_CONF_FLAG_SERVER 0x8
  499. # define SSL_CONF_FLAG_SHOW_ERRORS 0x10
  500. # define SSL_CONF_FLAG_CERTIFICATE 0x20
  501. # define SSL_CONF_FLAG_REQUIRE_PRIVATE 0x40
  502. /* Configuration value types */
  503. # define SSL_CONF_TYPE_UNKNOWN 0x0
  504. # define SSL_CONF_TYPE_STRING 0x1
  505. # define SSL_CONF_TYPE_FILE 0x2
  506. # define SSL_CONF_TYPE_DIR 0x3
  507. # define SSL_CONF_TYPE_NONE 0x4
  508. /* Maximum length of the application-controlled segment of a a TLSv1.3 cookie */
  509. # define SSL_COOKIE_LENGTH 4096
  510. /*
  511. * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they
  512. * cannot be used to clear bits.
  513. */
  514. unsigned long SSL_CTX_get_options(const SSL_CTX *ctx);
  515. unsigned long SSL_get_options(const SSL *s);
  516. unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op);
  517. unsigned long SSL_clear_options(SSL *s, unsigned long op);
  518. unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
  519. unsigned long SSL_set_options(SSL *s, unsigned long op);
  520. # define SSL_CTX_set_mode(ctx,op) \
  521. SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
  522. # define SSL_CTX_clear_mode(ctx,op) \
  523. SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL)
  524. # define SSL_CTX_get_mode(ctx) \
  525. SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL)
  526. # define SSL_clear_mode(ssl,op) \
  527. SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL)
  528. # define SSL_set_mode(ssl,op) \
  529. SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL)
  530. # define SSL_get_mode(ssl) \
  531. SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL)
  532. # define SSL_set_mtu(ssl, mtu) \
  533. SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL)
  534. # define DTLS_set_link_mtu(ssl, mtu) \
  535. SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL)
  536. # define DTLS_get_link_min_mtu(ssl) \
  537. SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL)
  538. # define SSL_get_secure_renegotiation_support(ssl) \
  539. SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL)
  540. # ifndef OPENSSL_NO_HEARTBEATS
  541. # define SSL_heartbeat(ssl) \
  542. SSL_ctrl((ssl),SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT,0,NULL)
  543. # endif
  544. # define SSL_CTX_set_cert_flags(ctx,op) \
  545. SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL)
  546. # define SSL_set_cert_flags(s,op) \
  547. SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL)
  548. # define SSL_CTX_clear_cert_flags(ctx,op) \
  549. SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)
  550. # define SSL_clear_cert_flags(s,op) \
  551. SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL)
  552. void SSL_CTX_set_msg_callback(SSL_CTX *ctx,
  553. void (*cb) (int write_p, int version,
  554. int content_type, const void *buf,
  555. size_t len, SSL *ssl, void *arg));
  556. void SSL_set_msg_callback(SSL *ssl,
  557. void (*cb) (int write_p, int version,
  558. int content_type, const void *buf,
  559. size_t len, SSL *ssl, void *arg));
  560. # define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
  561. # define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg))
  562. # define SSL_get_extms_support(s) \
  563. SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL)
  564. # ifndef OPENSSL_NO_SRP
  565. /* see tls_srp.c */
  566. __owur int SSL_SRP_CTX_init(SSL *s);
  567. __owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx);
  568. int SSL_SRP_CTX_free(SSL *ctx);
  569. int SSL_CTX_SRP_CTX_free(SSL_CTX *ctx);
  570. __owur int SSL_srp_server_param_with_username(SSL *s, int *ad);
  571. __owur int SRP_Calc_A_param(SSL *s);
  572. # endif
  573. /* 100k max cert list */
  574. # define SSL_MAX_CERT_LIST_DEFAULT 1024*100
  575. # define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)
  576. /*
  577. * This callback type is used inside SSL_CTX, SSL, and in the functions that
  578. * set them. It is used to override the generation of SSL/TLS session IDs in
  579. * a server. Return value should be zero on an error, non-zero to proceed.
  580. * Also, callbacks should themselves check if the id they generate is unique
  581. * otherwise the SSL handshake will fail with an error - callbacks can do
  582. * this using the 'ssl' value they're passed by;
  583. * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in
  584. * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32
  585. * bytes. The callback can alter this length to be less if desired. It is
  586. * also an error for the callback to set the size to zero.
  587. */
  588. typedef int (*GEN_SESSION_CB) (SSL *ssl, unsigned char *id,
  589. unsigned int *id_len);
  590. # define SSL_SESS_CACHE_OFF 0x0000
  591. # define SSL_SESS_CACHE_CLIENT 0x0001
  592. # define SSL_SESS_CACHE_SERVER 0x0002
  593. # define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)
  594. # define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080
  595. /* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */
  596. # define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100
  597. # define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200
  598. # define SSL_SESS_CACHE_NO_INTERNAL \
  599. (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE)
  600. LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx);
  601. # define SSL_CTX_sess_number(ctx) \
  602. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL)
  603. # define SSL_CTX_sess_connect(ctx) \
  604. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL)
  605. # define SSL_CTX_sess_connect_good(ctx) \
  606. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL)
  607. # define SSL_CTX_sess_connect_renegotiate(ctx) \
  608. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL)
  609. # define SSL_CTX_sess_accept(ctx) \
  610. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL)
  611. # define SSL_CTX_sess_accept_renegotiate(ctx) \
  612. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL)
  613. # define SSL_CTX_sess_accept_good(ctx) \
  614. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL)
  615. # define SSL_CTX_sess_hits(ctx) \
  616. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL)
  617. # define SSL_CTX_sess_cb_hits(ctx) \
  618. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL)
  619. # define SSL_CTX_sess_misses(ctx) \
  620. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL)
  621. # define SSL_CTX_sess_timeouts(ctx) \
  622. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL)
  623. # define SSL_CTX_sess_cache_full(ctx) \
  624. SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL)
  625. void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,
  626. int (*new_session_cb) (struct ssl_st *ssl,
  627. SSL_SESSION *sess));
  628. int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,
  629. SSL_SESSION *sess);
  630. void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
  631. void (*remove_session_cb) (struct ssl_ctx_st
  632. *ctx,
  633. SSL_SESSION *sess));
  634. void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx,
  635. SSL_SESSION *sess);
  636. void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
  637. SSL_SESSION *(*get_session_cb) (struct ssl_st
  638. *ssl,
  639. const unsigned char
  640. *data, int len,
  641. int *copy));
  642. SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl,
  643. const unsigned char *data,
  644. int len, int *copy);
  645. void SSL_CTX_set_info_callback(SSL_CTX *ctx,
  646. void (*cb) (const SSL *ssl, int type, int val));
  647. void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type,
  648. int val);
  649. void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,
  650. int (*client_cert_cb) (SSL *ssl, X509 **x509,
  651. EVP_PKEY **pkey));
  652. int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,
  653. EVP_PKEY **pkey);
  654. # ifndef OPENSSL_NO_ENGINE
  655. __owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);
  656. # endif
  657. void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx,
  658. int (*app_gen_cookie_cb) (SSL *ssl,
  659. unsigned char
  660. *cookie,
  661. unsigned int
  662. *cookie_len));
  663. void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx,
  664. int (*app_verify_cookie_cb) (SSL *ssl,
  665. const unsigned
  666. char *cookie,
  667. unsigned int
  668. cookie_len));
  669. void SSL_CTX_set_stateless_cookie_generate_cb(
  670. SSL_CTX *ctx,
  671. int (*gen_stateless_cookie_cb) (SSL *ssl,
  672. unsigned char *cookie,
  673. size_t *cookie_len));
  674. void SSL_CTX_set_stateless_cookie_verify_cb(
  675. SSL_CTX *ctx,
  676. int (*verify_stateless_cookie_cb) (SSL *ssl,
  677. const unsigned char *cookie,
  678. size_t cookie_len));
  679. # ifndef OPENSSL_NO_NEXTPROTONEG
  680. typedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl,
  681. const unsigned char **out,
  682. unsigned int *outlen,
  683. void *arg);
  684. void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,
  685. SSL_CTX_npn_advertised_cb_func cb,
  686. void *arg);
  687. # define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb
  688. typedef int (*SSL_CTX_npn_select_cb_func)(SSL *s,
  689. unsigned char **out,
  690. unsigned char *outlen,
  691. const unsigned char *in,
  692. unsigned int inlen,
  693. void *arg);
  694. void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,
  695. SSL_CTX_npn_select_cb_func cb,
  696. void *arg);
  697. # define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb
  698. void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
  699. unsigned *len);
  700. # define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated
  701. # endif
  702. __owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
  703. const unsigned char *in, unsigned int inlen,
  704. const unsigned char *client,
  705. unsigned int client_len);
  706. # define OPENSSL_NPN_UNSUPPORTED 0
  707. # define OPENSSL_NPN_NEGOTIATED 1
  708. # define OPENSSL_NPN_NO_OVERLAP 2
  709. __owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,
  710. unsigned int protos_len);
  711. __owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,
  712. unsigned int protos_len);
  713. typedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl,
  714. const unsigned char **out,
  715. unsigned char *outlen,
  716. const unsigned char *in,
  717. unsigned int inlen,
  718. void *arg);
  719. void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
  720. SSL_CTX_alpn_select_cb_func cb,
  721. void *arg);
  722. void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,
  723. unsigned int *len);
  724. # ifndef OPENSSL_NO_PSK
  725. /*
  726. * the maximum length of the buffer given to callbacks containing the
  727. * resulting identity/psk
  728. */
  729. # define PSK_MAX_IDENTITY_LEN 128
  730. # define PSK_MAX_PSK_LEN 256
  731. typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl,
  732. const char *hint,
  733. char *identity,
  734. unsigned int max_identity_len,
  735. unsigned char *psk,
  736. unsigned int max_psk_len);
  737. void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb);
  738. void SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb);
  739. typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,
  740. const char *identity,
  741. unsigned char *psk,
  742. unsigned int max_psk_len);
  743. void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);
  744. void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);
  745. __owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint);
  746. __owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint);
  747. const char *SSL_get_psk_identity_hint(const SSL *s);
  748. const char *SSL_get_psk_identity(const SSL *s);
  749. # endif
  750. typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,
  751. const unsigned char *identity,
  752. size_t identity_len,
  753. SSL_SESSION **sess);
  754. typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md,
  755. const unsigned char **id,
  756. size_t *idlen,
  757. SSL_SESSION **sess);
  758. void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);
  759. void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,
  760. SSL_psk_find_session_cb_func cb);
  761. void SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb);
  762. void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx,
  763. SSL_psk_use_session_cb_func cb);
  764. /* Register callbacks to handle custom TLS Extensions for client or server. */
  765. __owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx,
  766. unsigned int ext_type);
  767. __owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx,
  768. unsigned int ext_type,
  769. custom_ext_add_cb add_cb,
  770. custom_ext_free_cb free_cb,
  771. void *add_arg,
  772. custom_ext_parse_cb parse_cb,
  773. void *parse_arg);
  774. __owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx,
  775. unsigned int ext_type,
  776. custom_ext_add_cb add_cb,
  777. custom_ext_free_cb free_cb,
  778. void *add_arg,
  779. custom_ext_parse_cb parse_cb,
  780. void *parse_arg);
  781. __owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
  782. unsigned int context,
  783. SSL_custom_ext_add_cb_ex add_cb,
  784. SSL_custom_ext_free_cb_ex free_cb,
  785. void *add_arg,
  786. SSL_custom_ext_parse_cb_ex parse_cb,
  787. void *parse_arg);
  788. __owur int SSL_extension_supported(unsigned int ext_type);
  789. # define SSL_NOTHING 1
  790. # define SSL_WRITING 2
  791. # define SSL_READING 3
  792. # define SSL_X509_LOOKUP 4
  793. # define SSL_ASYNC_PAUSED 5
  794. # define SSL_ASYNC_NO_JOBS 6
  795. # define SSL_CLIENT_HELLO_CB 7
  796. /* These will only be used when doing non-blocking IO */
  797. # define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING)
  798. # define SSL_want_read(s) (SSL_want(s) == SSL_READING)
  799. # define SSL_want_write(s) (SSL_want(s) == SSL_WRITING)
  800. # define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP)
  801. # define SSL_want_async(s) (SSL_want(s) == SSL_ASYNC_PAUSED)
  802. # define SSL_want_async_job(s) (SSL_want(s) == SSL_ASYNC_NO_JOBS)
  803. # define SSL_want_client_hello_cb(s) (SSL_want(s) == SSL_CLIENT_HELLO_CB)
  804. # define SSL_MAC_FLAG_READ_MAC_STREAM 1
  805. # define SSL_MAC_FLAG_WRITE_MAC_STREAM 2
  806. /*
  807. * A callback for logging out TLS key material. This callback should log out
  808. * |line| followed by a newline.
  809. */
  810. typedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line);
  811. /*
  812. * SSL_CTX_set_keylog_callback configures a callback to log key material. This
  813. * is intended for debugging use with tools like Wireshark. The cb function
  814. * should log line followed by a newline.
  815. */
  816. void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb);
  817. /*
  818. * SSL_CTX_get_keylog_callback returns the callback configured by
  819. * SSL_CTX_set_keylog_callback.
  820. */
  821. SSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx);
  822. int SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data);
  823. uint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx);
  824. int SSL_set_max_early_data(SSL *s, uint32_t max_early_data);
  825. uint32_t SSL_get_max_early_data(const SSL *s);
  826. int SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data);
  827. uint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx);
  828. int SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data);
  829. uint32_t SSL_get_recv_max_early_data(const SSL *s);
  830. #ifdef __cplusplus
  831. }
  832. #endif
  833. # include <openssl/ssl2.h>
  834. # include <openssl/ssl3.h>
  835. # include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */
  836. # include <openssl/dtls1.h> /* Datagram TLS */
  837. # include <openssl/srtp.h> /* Support for the use_srtp extension */
  838. #ifdef __cplusplus
  839. extern "C" {
  840. #endif
  841. /*
  842. * These need to be after the above set of includes due to a compiler bug
  843. * in VisualStudio 2015
  844. */
  845. DEFINE_STACK_OF_CONST(SSL_CIPHER)
  846. DEFINE_STACK_OF(SSL_COMP)
  847. /* compatibility */
  848. # define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)(arg)))
  849. # define SSL_get_app_data(s) (SSL_get_ex_data(s,0))
  850. # define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0, \
  851. (char *)(a)))
  852. # define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0))
  853. # define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0))
  854. # define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0, \
  855. (char *)(arg)))
  856. DEPRECATEDIN_1_1_0(void SSL_set_debug(SSL *s, int debug))
  857. /* TLSv1.3 KeyUpdate message types */
  858. /* -1 used so that this is an invalid value for the on-the-wire protocol */
  859. #define SSL_KEY_UPDATE_NONE -1
  860. /* Values as defined for the on-the-wire protocol */
  861. #define SSL_KEY_UPDATE_NOT_REQUESTED 0
  862. #define SSL_KEY_UPDATE_REQUESTED 1
  863. /*
  864. * The valid handshake states (one for each type message sent and one for each
  865. * type of message received). There are also two "special" states:
  866. * TLS = TLS or DTLS state
  867. * DTLS = DTLS specific state
  868. * CR/SR = Client Read/Server Read
  869. * CW/SW = Client Write/Server Write
  870. *
  871. * The "special" states are:
  872. * TLS_ST_BEFORE = No handshake has been initiated yet
  873. * TLS_ST_OK = A handshake has been successfully completed
  874. */
  875. typedef enum {
  876. TLS_ST_BEFORE,
  877. TLS_ST_OK,
  878. DTLS_ST_CR_HELLO_VERIFY_REQUEST,
  879. TLS_ST_CR_SRVR_HELLO,
  880. TLS_ST_CR_CERT,
  881. TLS_ST_CR_CERT_STATUS,
  882. TLS_ST_CR_KEY_EXCH,
  883. TLS_ST_CR_CERT_REQ,
  884. TLS_ST_CR_SRVR_DONE,
  885. TLS_ST_CR_SESSION_TICKET,
  886. TLS_ST_CR_CHANGE,
  887. TLS_ST_CR_FINISHED,
  888. TLS_ST_CW_CLNT_HELLO,
  889. TLS_ST_CW_CERT,
  890. TLS_ST_CW_KEY_EXCH,
  891. TLS_ST_CW_CERT_VRFY,
  892. TLS_ST_CW_CHANGE,
  893. TLS_ST_CW_NEXT_PROTO,
  894. TLS_ST_CW_FINISHED,
  895. TLS_ST_SW_HELLO_REQ,
  896. TLS_ST_SR_CLNT_HELLO,
  897. DTLS_ST_SW_HELLO_VERIFY_REQUEST,
  898. TLS_ST_SW_SRVR_HELLO,
  899. TLS_ST_SW_CERT,
  900. TLS_ST_SW_KEY_EXCH,
  901. TLS_ST_SW_CERT_REQ,
  902. TLS_ST_SW_SRVR_DONE,
  903. TLS_ST_SR_CERT,
  904. TLS_ST_SR_KEY_EXCH,
  905. TLS_ST_SR_CERT_VRFY,
  906. TLS_ST_SR_NEXT_PROTO,
  907. TLS_ST_SR_CHANGE,
  908. TLS_ST_SR_FINISHED,
  909. TLS_ST_SW_SESSION_TICKET,
  910. TLS_ST_SW_CERT_STATUS,
  911. TLS_ST_SW_CHANGE,
  912. TLS_ST_SW_FINISHED,
  913. TLS_ST_SW_ENCRYPTED_EXTENSIONS,
  914. TLS_ST_CR_ENCRYPTED_EXTENSIONS,
  915. TLS_ST_CR_CERT_VRFY,
  916. TLS_ST_SW_CERT_VRFY,
  917. TLS_ST_CR_HELLO_REQ,
  918. TLS_ST_SW_KEY_UPDATE,
  919. TLS_ST_CW_KEY_UPDATE,
  920. TLS_ST_SR_KEY_UPDATE,
  921. TLS_ST_CR_KEY_UPDATE,
  922. TLS_ST_EARLY_DATA,
  923. TLS_ST_PENDING_EARLY_DATA_END,
  924. TLS_ST_CW_END_OF_EARLY_DATA,
  925. TLS_ST_SR_END_OF_EARLY_DATA
  926. } OSSL_HANDSHAKE_STATE;
  927. /*
  928. * Most of the following state values are no longer used and are defined to be
  929. * the closest equivalent value in the current state machine code. Not all
  930. * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT
  931. * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP,
  932. * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT.
  933. */
  934. # define SSL_ST_CONNECT 0x1000
  935. # define SSL_ST_ACCEPT 0x2000
  936. # define SSL_ST_MASK 0x0FFF
  937. # define SSL_CB_LOOP 0x01
  938. # define SSL_CB_EXIT 0x02
  939. # define SSL_CB_READ 0x04
  940. # define SSL_CB_WRITE 0x08
  941. # define SSL_CB_ALERT 0x4000/* used in callback */
  942. # define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)
  943. # define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)
  944. # define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)
  945. # define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)
  946. # define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)
  947. # define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)
  948. # define SSL_CB_HANDSHAKE_START 0x10
  949. # define SSL_CB_HANDSHAKE_DONE 0x20
  950. /* Is the SSL_connection established? */
  951. # define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a))
  952. # define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a))
  953. int SSL_in_init(const SSL *s);
  954. int SSL_in_before(const SSL *s);
  955. int SSL_is_init_finished(const SSL *s);
  956. /*
  957. * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
  958. * should not need these
  959. */
  960. # define SSL_ST_READ_HEADER 0xF0
  961. # define SSL_ST_READ_BODY 0xF1
  962. # define SSL_ST_READ_DONE 0xF2
  963. /*-
  964. * Obtain latest Finished message
  965. * -- that we sent (SSL_get_finished)
  966. * -- that we expected from peer (SSL_get_peer_finished).
  967. * Returns length (0 == no Finished so far), copies up to 'count' bytes.
  968. */
  969. size_t SSL_get_finished(const SSL *s, void *buf, size_t count);
  970. size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);
  971. /*
  972. * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options are
  973. * 'ored' with SSL_VERIFY_PEER if they are desired
  974. */
  975. # define SSL_VERIFY_NONE 0x00
  976. # define SSL_VERIFY_PEER 0x01
  977. # define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
  978. # define SSL_VERIFY_CLIENT_ONCE 0x04
  979. # define SSL_VERIFY_POST_HANDSHAKE 0x08
  980. # if OPENSSL_API_COMPAT < 0x10100000L
  981. # define OpenSSL_add_ssl_algorithms() SSL_library_init()
  982. # define SSLeay_add_ssl_algorithms() SSL_library_init()
  983. # endif
  984. /* More backward compatibility */
  985. # define SSL_get_cipher(s) \
  986. SSL_CIPHER_get_name(SSL_get_current_cipher(s))
  987. # define SSL_get_cipher_bits(s,np) \
  988. SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)
  989. # define SSL_get_cipher_version(s) \
  990. SSL_CIPHER_get_version(SSL_get_current_cipher(s))
  991. # define SSL_get_cipher_name(s) \
  992. SSL_CIPHER_get_name(SSL_get_current_cipher(s))
  993. # define SSL_get_time(a) SSL_SESSION_get_time(a)
  994. # define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b))
  995. # define SSL_get_timeout(a) SSL_SESSION_get_timeout(a)
  996. # define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b))
  997. # define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)
  998. # define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)
  999. DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
  1000. # define SSL_AD_REASON_OFFSET 1000/* offset to get SSL_R_... value
  1001. * from SSL_AD_... */
  1002. /* These alert types are for SSLv3 and TLSv1 */
  1003. # define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY
  1004. /* fatal */
  1005. # define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE
  1006. /* fatal */
  1007. # define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC
  1008. # define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED
  1009. # define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW
  1010. /* fatal */
  1011. # define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE
  1012. /* fatal */
  1013. # define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE
  1014. /* Not for TLS */
  1015. # define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE
  1016. # define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE
  1017. # define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE
  1018. # define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED
  1019. # define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED
  1020. # define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN
  1021. /* fatal */
  1022. # define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER
  1023. /* fatal */
  1024. # define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA
  1025. /* fatal */
  1026. # define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED
  1027. /* fatal */
  1028. # define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR
  1029. # define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR
  1030. /* fatal */
  1031. # define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION
  1032. /* fatal */
  1033. # define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION
  1034. /* fatal */
  1035. # define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY
  1036. /* fatal */
  1037. # define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR
  1038. # define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED
  1039. # define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION
  1040. # define SSL_AD_MISSING_EXTENSION TLS13_AD_MISSING_EXTENSION
  1041. # define SSL_AD_CERTIFICATE_REQUIRED TLS13_AD_CERTIFICATE_REQUIRED
  1042. # define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION
  1043. # define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE
  1044. # define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME
  1045. # define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE
  1046. # define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE
  1047. /* fatal */
  1048. # define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY
  1049. /* fatal */
  1050. # define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK
  1051. # define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL
  1052. # define SSL_ERROR_NONE 0
  1053. # define SSL_ERROR_SSL 1
  1054. # define SSL_ERROR_WANT_READ 2
  1055. # define SSL_ERROR_WANT_WRITE 3
  1056. # define SSL_ERROR_WANT_X509_LOOKUP 4
  1057. # define SSL_ERROR_SYSCALL 5/* look at error stack/return
  1058. * value/errno */
  1059. # define SSL_ERROR_ZERO_RETURN 6
  1060. # define SSL_ERROR_WANT_CONNECT 7
  1061. # define SSL_ERROR_WANT_ACCEPT 8
  1062. # define SSL_ERROR_WANT_ASYNC 9
  1063. # define SSL_ERROR_WANT_ASYNC_JOB 10
  1064. # define SSL_ERROR_WANT_CLIENT_HELLO_CB 11
  1065. # define SSL_CTRL_SET_TMP_DH 3
  1066. # define SSL_CTRL_SET_TMP_ECDH 4
  1067. # define SSL_CTRL_SET_TMP_DH_CB 6
  1068. # define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9
  1069. # define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10
  1070. # define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11
  1071. # define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12
  1072. # define SSL_CTRL_GET_FLAGS 13
  1073. # define SSL_CTRL_EXTRA_CHAIN_CERT 14
  1074. # define SSL_CTRL_SET_MSG_CALLBACK 15
  1075. # define SSL_CTRL_SET_MSG_CALLBACK_ARG 16
  1076. /* only applies to datagram connections */
  1077. # define SSL_CTRL_SET_MTU 17
  1078. /* Stats */
  1079. # define SSL_CTRL_SESS_NUMBER 20
  1080. # define SSL_CTRL_SESS_CONNECT 21
  1081. # define SSL_CTRL_SESS_CONNECT_GOOD 22
  1082. # define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23
  1083. # define SSL_CTRL_SESS_ACCEPT 24
  1084. # define SSL_CTRL_SESS_ACCEPT_GOOD 25
  1085. # define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26
  1086. # define SSL_CTRL_SESS_HIT 27
  1087. # define SSL_CTRL_SESS_CB_HIT 28
  1088. # define SSL_CTRL_SESS_MISSES 29
  1089. # define SSL_CTRL_SESS_TIMEOUTS 30
  1090. # define SSL_CTRL_SESS_CACHE_FULL 31
  1091. # define SSL_CTRL_MODE 33
  1092. # define SSL_CTRL_GET_READ_AHEAD 40
  1093. # define SSL_CTRL_SET_READ_AHEAD 41
  1094. # define SSL_CTRL_SET_SESS_CACHE_SIZE 42
  1095. # define SSL_CTRL_GET_SESS_CACHE_SIZE 43
  1096. # define SSL_CTRL_SET_SESS_CACHE_MODE 44
  1097. # define SSL_CTRL_GET_SESS_CACHE_MODE 45
  1098. # define SSL_CTRL_GET_MAX_CERT_LIST 50
  1099. # define SSL_CTRL_SET_MAX_CERT_LIST 51
  1100. # define SSL_CTRL_SET_MAX_SEND_FRAGMENT 52
  1101. /* see tls1.h for macros based on these */
  1102. # define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53
  1103. # define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54
  1104. # define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
  1105. # define SSL_CTRL_SET_TLSEXT_DEBUG_CB 56
  1106. # define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57
  1107. # define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58
  1108. # define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59
  1109. /*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT 60 */
  1110. /*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */
  1111. /*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */
  1112. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63
  1113. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64
  1114. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65
  1115. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66
  1116. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67
  1117. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68
  1118. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69
  1119. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70
  1120. # define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71
  1121. # define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72
  1122. # define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB 75
  1123. # define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB 76
  1124. # define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB 77
  1125. # define SSL_CTRL_SET_SRP_ARG 78
  1126. # define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME 79
  1127. # define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH 80
  1128. # define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD 81
  1129. # ifndef OPENSSL_NO_HEARTBEATS
  1130. # define SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT 85
  1131. # define SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING 86
  1132. # define SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS 87
  1133. # endif
  1134. # define DTLS_CTRL_GET_TIMEOUT 73
  1135. # define DTLS_CTRL_HANDLE_TIMEOUT 74
  1136. # define SSL_CTRL_GET_RI_SUPPORT 76
  1137. # define SSL_CTRL_CLEAR_MODE 78
  1138. # define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB 79
  1139. # define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82
  1140. # define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83
  1141. # define SSL_CTRL_CHAIN 88
  1142. # define SSL_CTRL_CHAIN_CERT 89
  1143. # define SSL_CTRL_GET_GROUPS 90
  1144. # define SSL_CTRL_SET_GROUPS 91
  1145. # define SSL_CTRL_SET_GROUPS_LIST 92
  1146. # define SSL_CTRL_GET_SHARED_GROUP 93
  1147. # define SSL_CTRL_SET_SIGALGS 97
  1148. # define SSL_CTRL_SET_SIGALGS_LIST 98
  1149. # define SSL_CTRL_CERT_FLAGS 99
  1150. # define SSL_CTRL_CLEAR_CERT_FLAGS 100
  1151. # define SSL_CTRL_SET_CLIENT_SIGALGS 101
  1152. # define SSL_CTRL_SET_CLIENT_SIGALGS_LIST 102
  1153. # define SSL_CTRL_GET_CLIENT_CERT_TYPES 103
  1154. # define SSL_CTRL_SET_CLIENT_CERT_TYPES 104
  1155. # define SSL_CTRL_BUILD_CERT_CHAIN 105
  1156. # define SSL_CTRL_SET_VERIFY_CERT_STORE 106
  1157. # define SSL_CTRL_SET_CHAIN_CERT_STORE 107
  1158. # define SSL_CTRL_GET_PEER_SIGNATURE_NID 108
  1159. # define SSL_CTRL_GET_PEER_TMP_KEY 109
  1160. # define SSL_CTRL_GET_RAW_CIPHERLIST 110
  1161. # define SSL_CTRL_GET_EC_POINT_FORMATS 111
  1162. # define SSL_CTRL_GET_CHAIN_CERTS 115
  1163. # define SSL_CTRL_SELECT_CURRENT_CERT 116
  1164. # define SSL_CTRL_SET_CURRENT_CERT 117
  1165. # define SSL_CTRL_SET_DH_AUTO 118
  1166. # define DTLS_CTRL_SET_LINK_MTU 120
  1167. # define DTLS_CTRL_GET_LINK_MIN_MTU 121
  1168. # define SSL_CTRL_GET_EXTMS_SUPPORT 122
  1169. # define SSL_CTRL_SET_MIN_PROTO_VERSION 123
  1170. # define SSL_CTRL_SET_MAX_PROTO_VERSION 124
  1171. # define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT 125
  1172. # define SSL_CTRL_SET_MAX_PIPELINES 126
  1173. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE 127
  1174. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB 128
  1175. # define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG 129
  1176. # define SSL_CTRL_GET_MIN_PROTO_VERSION 130
  1177. # define SSL_CTRL_GET_MAX_PROTO_VERSION 131
  1178. # define SSL_CTRL_GET_SIGNATURE_NID 132
  1179. # define SSL_CTRL_GET_TMP_KEY 133
  1180. # define SSL_CERT_SET_FIRST 1
  1181. # define SSL_CERT_SET_NEXT 2
  1182. # define SSL_CERT_SET_SERVER 3
  1183. # define DTLSv1_get_timeout(ssl, arg) \
  1184. SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)(arg))
  1185. # define DTLSv1_handle_timeout(ssl) \
  1186. SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL)
  1187. # define SSL_num_renegotiations(ssl) \
  1188. SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)
  1189. # define SSL_clear_num_renegotiations(ssl) \
  1190. SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)
  1191. # define SSL_total_renegotiations(ssl) \
  1192. SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)
  1193. # define SSL_CTX_set_tmp_dh(ctx,dh) \
  1194. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))
  1195. # define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \
  1196. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))
  1197. # define SSL_CTX_set_dh_auto(ctx, onoff) \
  1198. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL)
  1199. # define SSL_set_dh_auto(s, onoff) \
  1200. SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL)
  1201. # define SSL_set_tmp_dh(ssl,dh) \
  1202. SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh))
  1203. # define SSL_set_tmp_ecdh(ssl,ecdh) \
  1204. SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh))
  1205. # define SSL_CTX_add_extra_chain_cert(ctx,x509) \
  1206. SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)(x509))
  1207. # define SSL_CTX_get_extra_chain_certs(ctx,px509) \
  1208. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509)
  1209. # define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \
  1210. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509)
  1211. # define SSL_CTX_clear_extra_chain_certs(ctx) \
  1212. SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL)
  1213. # define SSL_CTX_set0_chain(ctx,sk) \
  1214. SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk))
  1215. # define SSL_CTX_set1_chain(ctx,sk) \
  1216. SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk))
  1217. # define SSL_CTX_add0_chain_cert(ctx,x509) \
  1218. SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))
  1219. # define SSL_CTX_add1_chain_cert(ctx,x509) \
  1220. SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))
  1221. # define SSL_CTX_get0_chain_certs(ctx,px509) \
  1222. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509)
  1223. # define SSL_CTX_clear_chain_certs(ctx) \
  1224. SSL_CTX_set0_chain(ctx,NULL)
  1225. # define SSL_CTX_build_cert_chain(ctx, flags) \
  1226. SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)
  1227. # define SSL_CTX_select_current_cert(ctx,x509) \
  1228. SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))
  1229. # define SSL_CTX_set_current_cert(ctx, op) \
  1230. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL)
  1231. # define SSL_CTX_set0_verify_cert_store(ctx,st) \
  1232. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))
  1233. # define SSL_CTX_set1_verify_cert_store(ctx,st) \
  1234. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))
  1235. # define SSL_CTX_set0_chain_cert_store(ctx,st) \
  1236. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))
  1237. # define SSL_CTX_set1_chain_cert_store(ctx,st) \
  1238. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))
  1239. # define SSL_set0_chain(s,sk) \
  1240. SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk))
  1241. # define SSL_set1_chain(s,sk) \
  1242. SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk))
  1243. # define SSL_add0_chain_cert(s,x509) \
  1244. SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509))
  1245. # define SSL_add1_chain_cert(s,x509) \
  1246. SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509))
  1247. # define SSL_get0_chain_certs(s,px509) \
  1248. SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509)
  1249. # define SSL_clear_chain_certs(s) \
  1250. SSL_set0_chain(s,NULL)
  1251. # define SSL_build_cert_chain(s, flags) \
  1252. SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL)
  1253. # define SSL_select_current_cert(s,x509) \
  1254. SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509))
  1255. # define SSL_set_current_cert(s,op) \
  1256. SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL)
  1257. # define SSL_set0_verify_cert_store(s,st) \
  1258. SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st))
  1259. # define SSL_set1_verify_cert_store(s,st) \
  1260. SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st))
  1261. # define SSL_set0_chain_cert_store(s,st) \
  1262. SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st))
  1263. # define SSL_set1_chain_cert_store(s,st) \
  1264. SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st))
  1265. # define SSL_get1_groups(s, glist) \
  1266. SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist))
  1267. # define SSL_CTX_set1_groups(ctx, glist, glistlen) \
  1268. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist))
  1269. # define SSL_CTX_set1_groups_list(ctx, s) \
  1270. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s))
  1271. # define SSL_set1_groups(s, glist, glistlen) \
  1272. SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist))
  1273. # define SSL_set1_groups_list(s, str) \
  1274. SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str))
  1275. # define SSL_get_shared_group(s, n) \
  1276. SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL)
  1277. # define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \
  1278. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))
  1279. # define SSL_CTX_set1_sigalgs_list(ctx, s) \
  1280. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s))
  1281. # define SSL_set1_sigalgs(s, slist, slistlen) \
  1282. SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist))
  1283. # define SSL_set1_sigalgs_list(s, str) \
  1284. SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str))
  1285. # define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \
  1286. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))
  1287. # define SSL_CTX_set1_client_sigalgs_list(ctx, s) \
  1288. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s))
  1289. # define SSL_set1_client_sigalgs(s, slist, slistlen) \
  1290. SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist))
  1291. # define SSL_set1_client_sigalgs_list(s, str) \
  1292. SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str))
  1293. # define SSL_get0_certificate_types(s, clist) \
  1294. SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist))
  1295. # define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \
  1296. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen, \
  1297. (char *)(clist))
  1298. # define SSL_set1_client_certificate_types(s, clist, clistlen) \
  1299. SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist))
  1300. # define SSL_get_signature_nid(s, pn) \
  1301. SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn)
  1302. # define SSL_get_peer_signature_nid(s, pn) \
  1303. SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn)
  1304. # define SSL_get_peer_tmp_key(s, pk) \
  1305. SSL_ctrl(s,SSL_CTRL_GET_PEER_TMP_KEY,0,pk)
  1306. # define SSL_get_tmp_key(s, pk) \
  1307. SSL_ctrl(s,SSL_CTRL_GET_TMP_KEY,0,pk)
  1308. # define SSL_get0_raw_cipherlist(s, plst) \
  1309. SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst)
  1310. # define SSL_get0_ec_point_formats(s, plst) \
  1311. SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst)
  1312. # define SSL_CTX_set_min_proto_version(ctx, version) \
  1313. SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)
  1314. # define SSL_CTX_set_max_proto_version(ctx, version) \
  1315. SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)
  1316. # define SSL_CTX_get_min_proto_version(ctx) \
  1317. SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)
  1318. # define SSL_CTX_get_max_proto_version(ctx) \
  1319. SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)
  1320. # define SSL_set_min_proto_version(s, version) \
  1321. SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL)
  1322. # define SSL_set_max_proto_version(s, version) \
  1323. SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL)
  1324. # define SSL_get_min_proto_version(s) \
  1325. SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL)
  1326. # define SSL_get_max_proto_version(s) \
  1327. SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL)
  1328. /* Backwards compatibility, original 1.1.0 names */
  1329. # define SSL_CTRL_GET_SERVER_TMP_KEY \
  1330. SSL_CTRL_GET_PEER_TMP_KEY
  1331. # define SSL_get_server_tmp_key(s, pk) \
  1332. SSL_get_peer_tmp_key(s, pk)
  1333. /*
  1334. * The following symbol names are old and obsolete. They are kept
  1335. * for compatibility reasons only and should not be used anymore.
  1336. */
  1337. # define SSL_CTRL_GET_CURVES SSL_CTRL_GET_GROUPS
  1338. # define SSL_CTRL_SET_CURVES SSL_CTRL_SET_GROUPS
  1339. # define SSL_CTRL_SET_CURVES_LIST SSL_CTRL_SET_GROUPS_LIST
  1340. # define SSL_CTRL_GET_SHARED_CURVE SSL_CTRL_GET_SHARED_GROUP
  1341. # define SSL_get1_curves SSL_get1_groups
  1342. # define SSL_CTX_set1_curves SSL_CTX_set1_groups
  1343. # define SSL_CTX_set1_curves_list SSL_CTX_set1_groups_list
  1344. # define SSL_set1_curves SSL_set1_groups
  1345. # define SSL_set1_curves_list SSL_set1_groups_list
  1346. # define SSL_get_shared_curve SSL_get_shared_group
  1347. # if OPENSSL_API_COMPAT < 0x10100000L
  1348. /* Provide some compatibility macros for removed functionality. */
  1349. # define SSL_CTX_need_tmp_RSA(ctx) 0
  1350. # define SSL_CTX_set_tmp_rsa(ctx,rsa) 1
  1351. # define SSL_need_tmp_RSA(ssl) 0
  1352. # define SSL_set_tmp_rsa(ssl,rsa) 1
  1353. # define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0)
  1354. # define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0)
  1355. /*
  1356. * We "pretend" to call the callback to avoid warnings about unused static
  1357. * functions.
  1358. */
  1359. # define SSL_CTX_set_tmp_rsa_callback(ctx, cb) while(0) (cb)(NULL, 0, 0)
  1360. # define SSL_set_tmp_rsa_callback(ssl, cb) while(0) (cb)(NULL, 0, 0)
  1361. # endif
  1362. __owur const BIO_METHOD *BIO_f_ssl(void);
  1363. __owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client);
  1364. __owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx);
  1365. __owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);
  1366. __owur int BIO_ssl_copy_session_id(BIO *to, BIO *from);
  1367. void BIO_ssl_shutdown(BIO *ssl_bio);
  1368. __owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str);
  1369. __owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth);
  1370. int SSL_CTX_up_ref(SSL_CTX *ctx);
  1371. void SSL_CTX_free(SSL_CTX *);
  1372. __owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);
  1373. __owur long SSL_CTX_get_timeout(const SSL_CTX *ctx);
  1374. __owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);
  1375. void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *);
  1376. void SSL_CTX_set1_cert_store(SSL_CTX *, X509_STORE *);
  1377. __owur int SSL_want(const SSL *s);
  1378. __owur int SSL_clear(SSL *s);
  1379. void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
  1380. __owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
  1381. __owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s);
  1382. __owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits);
  1383. __owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c);
  1384. __owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c);
  1385. __owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c);
  1386. __owur const char *OPENSSL_cipher_name(const char *rfc_name);
  1387. __owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c);
  1388. __owur uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c);
  1389. __owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);
  1390. __owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);
  1391. __owur const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);
  1392. __owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c);
  1393. __owur int SSL_get_fd(const SSL *s);
  1394. __owur int SSL_get_rfd(const SSL *s);
  1395. __owur int SSL_get_wfd(const SSL *s);
  1396. __owur const char *SSL_get_cipher_list(const SSL *s, int n);
  1397. __owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size);
  1398. __owur int SSL_get_read_ahead(const SSL *s);
  1399. __owur int SSL_pending(const SSL *s);
  1400. __owur int SSL_has_pending(const SSL *s);
  1401. # ifndef OPENSSL_NO_SOCK
  1402. __owur int SSL_set_fd(SSL *s, int fd);
  1403. __owur int SSL_set_rfd(SSL *s, int fd);
  1404. __owur int SSL_set_wfd(SSL *s, int fd);
  1405. # endif
  1406. void SSL_set0_rbio(SSL *s, BIO *rbio);
  1407. void SSL_set0_wbio(SSL *s, BIO *wbio);
  1408. void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio);
  1409. __owur BIO *SSL_get_rbio(const SSL *s);
  1410. __owur BIO *SSL_get_wbio(const SSL *s);
  1411. __owur int SSL_set_cipher_list(SSL *s, const char *str);
  1412. __owur int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);
  1413. __owur int SSL_set_ciphersuites(SSL *s, const char *str);
  1414. void SSL_set_read_ahead(SSL *s, int yes);
  1415. __owur int SSL_get_verify_mode(const SSL *s);
  1416. __owur int SSL_get_verify_depth(const SSL *s);
  1417. __owur SSL_verify_cb SSL_get_verify_callback(const SSL *s);
  1418. void SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback);
  1419. void SSL_set_verify_depth(SSL *s, int depth);
  1420. void SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg);
  1421. # ifndef OPENSSL_NO_RSA
  1422. __owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
  1423. __owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d,
  1424. long len);
  1425. # endif
  1426. __owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
  1427. __owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d,
  1428. long len);
  1429. __owur int SSL_use_certificate(SSL *ssl, X509 *x);
  1430. __owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);
  1431. __owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey,
  1432. STACK_OF(X509) *chain, int override);
  1433. /* serverinfo file format versions */
  1434. # define SSL_SERVERINFOV1 1
  1435. # define SSL_SERVERINFOV2 2
  1436. /* Set serverinfo data for the current active cert. */
  1437. __owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,
  1438. size_t serverinfo_length);
  1439. __owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version,
  1440. const unsigned char *serverinfo,
  1441. size_t serverinfo_length);
  1442. __owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);
  1443. #ifndef OPENSSL_NO_RSA
  1444. __owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
  1445. #endif
  1446. __owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);
  1447. __owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
  1448. #ifndef OPENSSL_NO_RSA
  1449. __owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file,
  1450. int type);
  1451. #endif
  1452. __owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file,
  1453. int type);
  1454. __owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file,
  1455. int type);
  1456. /* PEM type */
  1457. __owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
  1458. __owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file);
  1459. __owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
  1460. __owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
  1461. const char *file);
  1462. int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
  1463. const char *dir);
  1464. # if OPENSSL_API_COMPAT < 0x10100000L
  1465. # define SSL_load_error_strings() \
  1466. OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \
  1467. | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL)
  1468. # endif
  1469. __owur const char *SSL_state_string(const SSL *s);
  1470. __owur const char *SSL_rstate_string(const SSL *s);
  1471. __owur const char *SSL_state_string_long(const SSL *s);
  1472. __owur const char *SSL_rstate_string_long(const SSL *s);
  1473. __owur long SSL_SESSION_get_time(const SSL_SESSION *s);
  1474. __owur long SSL_SESSION_set_time(SSL_SESSION *s, long t);
  1475. __owur long SSL_SESSION_get_timeout(const SSL_SESSION *s);
  1476. __owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);
  1477. __owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s);
  1478. __owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version);
  1479. __owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);
  1480. __owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);
  1481. void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,
  1482. const unsigned char **alpn,
  1483. size_t *len);
  1484. __owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s,
  1485. const unsigned char *alpn,
  1486. size_t len);
  1487. __owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s);
  1488. __owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher);
  1489. __owur int SSL_SESSION_has_ticket(const SSL_SESSION *s);
  1490. __owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s);
  1491. void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick,
  1492. size_t *len);
  1493. __owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s);
  1494. __owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s,
  1495. uint32_t max_early_data);
  1496. __owur int SSL_copy_session_id(SSL *to, const SSL *from);
  1497. __owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);
  1498. __owur int SSL_SESSION_set1_id_context(SSL_SESSION *s,
  1499. const unsigned char *sid_ctx,
  1500. unsigned int sid_ctx_len);
  1501. __owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,
  1502. unsigned int sid_len);
  1503. __owur int SSL_SESSION_is_resumable(const SSL_SESSION *s);
  1504. __owur SSL_SESSION *SSL_SESSION_new(void);
  1505. __owur SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src);
  1506. const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s,
  1507. unsigned int *len);
  1508. const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s,
  1509. unsigned int *len);
  1510. __owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s);
  1511. # ifndef OPENSSL_NO_STDIO
  1512. int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses);
  1513. # endif
  1514. int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses);
  1515. int SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x);
  1516. int SSL_SESSION_up_ref(SSL_SESSION *ses);
  1517. void SSL_SESSION_free(SSL_SESSION *ses);
  1518. __owur int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);
  1519. __owur int SSL_set_session(SSL *to, SSL_SESSION *session);
  1520. int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session);
  1521. int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session);
  1522. __owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb);
  1523. __owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb);
  1524. __owur int SSL_has_matching_session_id(const SSL *s,
  1525. const unsigned char *id,
  1526. unsigned int id_len);
  1527. SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
  1528. long length);
  1529. # ifdef HEADER_X509_H
  1530. __owur X509 *SSL_get_peer_certificate(const SSL *s);
  1531. # endif
  1532. __owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s);
  1533. __owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx);
  1534. __owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx);
  1535. __owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx);
  1536. void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback);
  1537. void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);
  1538. void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx,
  1539. int (*cb) (X509_STORE_CTX *, void *),
  1540. void *arg);
  1541. void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg),
  1542. void *arg);
  1543. # ifndef OPENSSL_NO_RSA
  1544. __owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
  1545. __owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,
  1546. long len);
  1547. # endif
  1548. __owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
  1549. __owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx,
  1550. const unsigned char *d, long len);
  1551. __owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x);
  1552. __owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,
  1553. const unsigned char *d);
  1554. __owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey,
  1555. STACK_OF(X509) *chain, int override);
  1556. void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
  1557. void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
  1558. pem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx);
  1559. void *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx);
  1560. void SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb);
  1561. void SSL_set_default_passwd_cb_userdata(SSL *s, void *u);
  1562. pem_password_cb *SSL_get_default_passwd_cb(SSL *s);
  1563. void *SSL_get_default_passwd_cb_userdata(SSL *s);
  1564. __owur int SSL_CTX_check_private_key(const SSL_CTX *ctx);
  1565. __owur int SSL_check_private_key(const SSL *ctx);
  1566. __owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx,
  1567. const unsigned char *sid_ctx,
  1568. unsigned int sid_ctx_len);
  1569. SSL *SSL_new(SSL_CTX *ctx);
  1570. int SSL_up_ref(SSL *s);
  1571. int SSL_is_dtls(const SSL *s);
  1572. __owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,
  1573. unsigned int sid_ctx_len);
  1574. __owur int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose);
  1575. __owur int SSL_set_purpose(SSL *ssl, int purpose);
  1576. __owur int SSL_CTX_set_trust(SSL_CTX *ctx, int trust);
  1577. __owur int SSL_set_trust(SSL *ssl, int trust);
  1578. __owur int SSL_set1_host(SSL *s, const char *hostname);
  1579. __owur int SSL_add1_host(SSL *s, const char *hostname);
  1580. __owur const char *SSL_get0_peername(SSL *s);
  1581. void SSL_set_hostflags(SSL *s, unsigned int flags);
  1582. __owur int SSL_CTX_dane_enable(SSL_CTX *ctx);
  1583. __owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md,
  1584. uint8_t mtype, uint8_t ord);
  1585. __owur int SSL_dane_enable(SSL *s, const char *basedomain);
  1586. __owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector,
  1587. uint8_t mtype, unsigned const char *data, size_t dlen);
  1588. __owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki);
  1589. __owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector,
  1590. uint8_t *mtype, unsigned const char **data,
  1591. size_t *dlen);
  1592. /*
  1593. * Bridge opacity barrier between libcrypt and libssl, also needed to support
  1594. * offline testing in test/danetest.c
  1595. */
  1596. SSL_DANE *SSL_get0_dane(SSL *ssl);
  1597. /*
  1598. * DANE flags
  1599. */
  1600. unsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags);
  1601. unsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags);
  1602. unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags);
  1603. unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags);
  1604. __owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);
  1605. __owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);
  1606. __owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);
  1607. __owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);
  1608. # ifndef OPENSSL_NO_SRP
  1609. int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);
  1610. int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);
  1611. int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);
  1612. int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,
  1613. char *(*cb) (SSL *, void *));
  1614. int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,
  1615. int (*cb) (SSL *, void *));
  1616. int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,
  1617. int (*cb) (SSL *, int *, void *));
  1618. int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);
  1619. int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
  1620. BIGNUM *sa, BIGNUM *v, char *info);
  1621. int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,
  1622. const char *grp);
  1623. __owur BIGNUM *SSL_get_srp_g(SSL *s);
  1624. __owur BIGNUM *SSL_get_srp_N(SSL *s);
  1625. __owur char *SSL_get_srp_username(SSL *s);
  1626. __owur char *SSL_get_srp_userinfo(SSL *s);
  1627. # endif
  1628. /*
  1629. * ClientHello callback and helpers.
  1630. */
  1631. # define SSL_CLIENT_HELLO_SUCCESS 1
  1632. # define SSL_CLIENT_HELLO_ERROR 0
  1633. # define SSL_CLIENT_HELLO_RETRY (-1)
  1634. typedef int (*SSL_client_hello_cb_fn) (SSL *s, int *al, void *arg);
  1635. void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb,
  1636. void *arg);
  1637. int SSL_client_hello_isv2(SSL *s);
  1638. unsigned int SSL_client_hello_get0_legacy_version(SSL *s);
  1639. size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out);
  1640. size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out);
  1641. size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out);
  1642. size_t SSL_client_hello_get0_compression_methods(SSL *s,
  1643. const unsigned char **out);
  1644. int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen);
  1645. int SSL_client_hello_get0_ext(SSL *s, unsigned int type,
  1646. const unsigned char **out, size_t *outlen);
  1647. void SSL_certs_clear(SSL *s);
  1648. void SSL_free(SSL *ssl);
  1649. # ifdef OSSL_ASYNC_FD
  1650. /*
  1651. * Windows application developer has to include windows.h to use these.
  1652. */
  1653. __owur int SSL_waiting_for_async(SSL *s);
  1654. __owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds);
  1655. __owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd,
  1656. size_t *numaddfds, OSSL_ASYNC_FD *delfd,
  1657. size_t *numdelfds);
  1658. # endif
  1659. __owur int SSL_accept(SSL *ssl);
  1660. __owur int SSL_stateless(SSL *s);
  1661. __owur int SSL_connect(SSL *ssl);
  1662. __owur int SSL_read(SSL *ssl, void *buf, int num);
  1663. __owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
  1664. # define SSL_READ_EARLY_DATA_ERROR 0
  1665. # define SSL_READ_EARLY_DATA_SUCCESS 1
  1666. # define SSL_READ_EARLY_DATA_FINISH 2
  1667. __owur int SSL_read_early_data(SSL *s, void *buf, size_t num,
  1668. size_t *readbytes);
  1669. __owur int SSL_peek(SSL *ssl, void *buf, int num);
  1670. __owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
  1671. __owur int SSL_write(SSL *ssl, const void *buf, int num);
  1672. __owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written);
  1673. __owur int SSL_write_early_data(SSL *s, const void *buf, size_t num,
  1674. size_t *written);
  1675. long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
  1676. long SSL_callback_ctrl(SSL *, int, void (*)(void));
  1677. long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
  1678. long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void));
  1679. # define SSL_EARLY_DATA_NOT_SENT 0
  1680. # define SSL_EARLY_DATA_REJECTED 1
  1681. # define SSL_EARLY_DATA_ACCEPTED 2
  1682. __owur int SSL_get_early_data_status(const SSL *s);
  1683. __owur int SSL_get_error(const SSL *s, int ret_code);
  1684. __owur const char *SSL_get_version(const SSL *s);
  1685. /* This sets the 'default' SSL version that SSL_new() will create */
  1686. __owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth);
  1687. # ifndef OPENSSL_NO_SSL3_METHOD
  1688. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_method(void)) /* SSLv3 */
  1689. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_server_method(void))
  1690. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_client_method(void))
  1691. # endif
  1692. #define SSLv23_method TLS_method
  1693. #define SSLv23_server_method TLS_server_method
  1694. #define SSLv23_client_method TLS_client_method
  1695. /* Negotiate highest available SSL/TLS version */
  1696. __owur const SSL_METHOD *TLS_method(void);
  1697. __owur const SSL_METHOD *TLS_server_method(void);
  1698. __owur const SSL_METHOD *TLS_client_method(void);
  1699. # ifndef OPENSSL_NO_TLS1_METHOD
  1700. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */
  1701. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void))
  1702. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void))
  1703. # endif
  1704. # ifndef OPENSSL_NO_TLS1_1_METHOD
  1705. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */
  1706. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void))
  1707. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void))
  1708. # endif
  1709. # ifndef OPENSSL_NO_TLS1_2_METHOD
  1710. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */
  1711. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void))
  1712. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void))
  1713. # endif
  1714. # ifndef OPENSSL_NO_DTLS1_METHOD
  1715. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */
  1716. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void))
  1717. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void))
  1718. # endif
  1719. # ifndef OPENSSL_NO_DTLS1_2_METHOD
  1720. /* DTLSv1.2 */
  1721. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void))
  1722. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void))
  1723. DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void))
  1724. # endif
  1725. __owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */
  1726. __owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */
  1727. __owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */
  1728. __owur size_t DTLS_get_data_mtu(const SSL *s);
  1729. __owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);
  1730. __owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
  1731. __owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s);
  1732. __owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s);
  1733. __owur int SSL_do_handshake(SSL *s);
  1734. int SSL_key_update(SSL *s, int updatetype);
  1735. int SSL_get_key_update_type(const SSL *s);
  1736. int SSL_renegotiate(SSL *s);
  1737. int SSL_renegotiate_abbreviated(SSL *s);
  1738. __owur int SSL_renegotiate_pending(const SSL *s);
  1739. int SSL_shutdown(SSL *s);
  1740. __owur int SSL_verify_client_post_handshake(SSL *s);
  1741. void SSL_CTX_set_post_handshake_auth(SSL_CTX *ctx, int val);
  1742. void SSL_set_post_handshake_auth(SSL *s, int val);
  1743. __owur const SSL_METHOD *SSL_CTX_get_ssl_method(const SSL_CTX *ctx);
  1744. __owur const SSL_METHOD *SSL_get_ssl_method(const SSL *s);
  1745. __owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);
  1746. __owur const char *SSL_alert_type_string_long(int value);
  1747. __owur const char *SSL_alert_type_string(int value);
  1748. __owur const char *SSL_alert_desc_string_long(int value);
  1749. __owur const char *SSL_alert_desc_string(int value);
  1750. void SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);
  1751. void SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
  1752. __owur const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s);
  1753. __owur const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx);
  1754. __owur int SSL_add1_to_CA_list(SSL *ssl, const X509 *x);
  1755. __owur int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x);
  1756. __owur const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s);
  1757. void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);
  1758. void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
  1759. __owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);
  1760. __owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s);
  1761. __owur int SSL_add_client_CA(SSL *ssl, X509 *x);
  1762. __owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);
  1763. void SSL_set_connect_state(SSL *s);
  1764. void SSL_set_accept_state(SSL *s);
  1765. __owur long SSL_get_default_timeout(const SSL *s);
  1766. # if OPENSSL_API_COMPAT < 0x10100000L
  1767. # define SSL_library_init() OPENSSL_init_ssl(0, NULL)
  1768. # endif
  1769. __owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size);
  1770. __owur STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk);
  1771. __owur SSL *SSL_dup(SSL *ssl);
  1772. __owur X509 *SSL_get_certificate(const SSL *ssl);
  1773. /*
  1774. * EVP_PKEY
  1775. */
  1776. struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl);
  1777. __owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx);
  1778. __owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx);
  1779. void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode);
  1780. __owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx);
  1781. void SSL_set_quiet_shutdown(SSL *ssl, int mode);
  1782. __owur int SSL_get_quiet_shutdown(const SSL *ssl);
  1783. void SSL_set_shutdown(SSL *ssl, int mode);
  1784. __owur int SSL_get_shutdown(const SSL *ssl);
  1785. __owur int SSL_version(const SSL *ssl);
  1786. __owur int SSL_client_version(const SSL *s);
  1787. __owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx);
  1788. __owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx);
  1789. __owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx);
  1790. __owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
  1791. const char *CApath);
  1792. # define SSL_get0_session SSL_get_session/* just peek at pointer */
  1793. __owur SSL_SESSION *SSL_get_session(const SSL *ssl);
  1794. __owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */
  1795. __owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);
  1796. SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx);
  1797. void SSL_set_info_callback(SSL *ssl,
  1798. void (*cb) (const SSL *ssl, int type, int val));
  1799. void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type,
  1800. int val);
  1801. __owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);
  1802. void SSL_set_verify_result(SSL *ssl, long v);
  1803. __owur long SSL_get_verify_result(const SSL *ssl);
  1804. __owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s);
  1805. __owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out,
  1806. size_t outlen);
  1807. __owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out,
  1808. size_t outlen);
  1809. __owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess,
  1810. unsigned char *out, size_t outlen);
  1811. __owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess,
  1812. const unsigned char *in, size_t len);
  1813. uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess);
  1814. #define SSL_get_ex_new_index(l, p, newf, dupf, freef) \
  1815. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef)
  1816. __owur int SSL_set_ex_data(SSL *ssl, int idx, void *data);
  1817. void *SSL_get_ex_data(const SSL *ssl, int idx);
  1818. #define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \
  1819. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef)
  1820. __owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data);
  1821. void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx);
  1822. #define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \
  1823. CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef)
  1824. __owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data);
  1825. void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx);
  1826. __owur int SSL_get_ex_data_X509_STORE_CTX_idx(void);
  1827. # define SSL_CTX_sess_set_cache_size(ctx,t) \
  1828. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL)
  1829. # define SSL_CTX_sess_get_cache_size(ctx) \
  1830. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL)
  1831. # define SSL_CTX_set_session_cache_mode(ctx,m) \
  1832. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL)
  1833. # define SSL_CTX_get_session_cache_mode(ctx) \
  1834. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL)
  1835. # define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx)
  1836. # define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m)
  1837. # define SSL_CTX_get_read_ahead(ctx) \
  1838. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL)
  1839. # define SSL_CTX_set_read_ahead(ctx,m) \
  1840. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL)
  1841. # define SSL_CTX_get_max_cert_list(ctx) \
  1842. SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
  1843. # define SSL_CTX_set_max_cert_list(ctx,m) \
  1844. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
  1845. # define SSL_get_max_cert_list(ssl) \
  1846. SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL)
  1847. # define SSL_set_max_cert_list(ssl,m) \
  1848. SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL)
  1849. # define SSL_CTX_set_max_send_fragment(ctx,m) \
  1850. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)
  1851. # define SSL_set_max_send_fragment(ssl,m) \
  1852. SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)
  1853. # define SSL_CTX_set_split_send_fragment(ctx,m) \
  1854. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)
  1855. # define SSL_set_split_send_fragment(ssl,m) \
  1856. SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL)
  1857. # define SSL_CTX_set_max_pipelines(ctx,m) \
  1858. SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)
  1859. # define SSL_set_max_pipelines(ssl,m) \
  1860. SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL)
  1861. void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len);
  1862. void SSL_set_default_read_buffer_len(SSL *s, size_t len);
  1863. # ifndef OPENSSL_NO_DH
  1864. /* NB: the |keylength| is only applicable when is_export is true */
  1865. void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
  1866. DH *(*dh) (SSL *ssl, int is_export,
  1867. int keylength));
  1868. void SSL_set_tmp_dh_callback(SSL *ssl,
  1869. DH *(*dh) (SSL *ssl, int is_export,
  1870. int keylength));
  1871. # endif
  1872. __owur const COMP_METHOD *SSL_get_current_compression(const SSL *s);
  1873. __owur const COMP_METHOD *SSL_get_current_expansion(const SSL *s);
  1874. __owur const char *SSL_COMP_get_name(const COMP_METHOD *comp);
  1875. __owur const char *SSL_COMP_get0_name(const SSL_COMP *comp);
  1876. __owur int SSL_COMP_get_id(const SSL_COMP *comp);
  1877. STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void);
  1878. __owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP)
  1879. *meths);
  1880. # if OPENSSL_API_COMPAT < 0x10100000L
  1881. # define SSL_COMP_free_compression_methods() while(0) continue
  1882. # endif
  1883. __owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm);
  1884. const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);
  1885. int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);
  1886. int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);
  1887. int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len,
  1888. int isv2format, STACK_OF(SSL_CIPHER) **sk,
  1889. STACK_OF(SSL_CIPHER) **scsvs);
  1890. /* TLS extensions functions */
  1891. __owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len);
  1892. __owur int SSL_set_session_ticket_ext_cb(SSL *s,
  1893. tls_session_ticket_ext_cb_fn cb,
  1894. void *arg);
  1895. /* Pre-shared secret session resumption functions */
  1896. __owur int SSL_set_session_secret_cb(SSL *s,
  1897. tls_session_secret_cb_fn session_secret_cb,
  1898. void *arg);
  1899. void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx,
  1900. int (*cb) (SSL *ssl,
  1901. int
  1902. is_forward_secure));
  1903. void SSL_set_not_resumable_session_callback(SSL *ssl,
  1904. int (*cb) (SSL *ssl,
  1905. int is_forward_secure));
  1906. void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx,
  1907. size_t (*cb) (SSL *ssl, int type,
  1908. size_t len, void *arg));
  1909. void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg);
  1910. void *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx);
  1911. int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size);
  1912. void SSL_set_record_padding_callback(SSL *ssl,
  1913. size_t (*cb) (SSL *ssl, int type,
  1914. size_t len, void *arg));
  1915. void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg);
  1916. void *SSL_get_record_padding_callback_arg(const SSL *ssl);
  1917. int SSL_set_block_padding(SSL *ssl, size_t block_size);
  1918. int SSL_set_num_tickets(SSL *s, size_t num_tickets);
  1919. size_t SSL_get_num_tickets(const SSL *s);
  1920. int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets);
  1921. size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);
  1922. # if OPENSSL_API_COMPAT < 0x10100000L
  1923. # define SSL_cache_hit(s) SSL_session_reused(s)
  1924. # endif
  1925. __owur int SSL_session_reused(const SSL *s);
  1926. __owur int SSL_is_server(const SSL *s);
  1927. __owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void);
  1928. int SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx);
  1929. void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx);
  1930. unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags);
  1931. __owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx,
  1932. unsigned int flags);
  1933. __owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre);
  1934. void SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl);
  1935. void SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx);
  1936. __owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value);
  1937. __owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv);
  1938. __owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd);
  1939. void SSL_add_ssl_module(void);
  1940. int SSL_config(SSL *s, const char *name);
  1941. int SSL_CTX_config(SSL_CTX *ctx, const char *name);
  1942. # ifndef OPENSSL_NO_SSL_TRACE
  1943. void SSL_trace(int write_p, int version, int content_type,
  1944. const void *buf, size_t len, SSL *ssl, void *arg);
  1945. # endif
  1946. # ifndef OPENSSL_NO_SOCK
  1947. int DTLSv1_listen(SSL *s, BIO_ADDR *client);
  1948. # endif
  1949. # ifndef OPENSSL_NO_CT
  1950. /*
  1951. * A callback for verifying that the received SCTs are sufficient.
  1952. * Expected to return 1 if they are sufficient, otherwise 0.
  1953. * May return a negative integer if an error occurs.
  1954. * A connection should be aborted if the SCTs are deemed insufficient.
  1955. */
  1956. typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx,
  1957. const STACK_OF(SCT) *scts, void *arg);
  1958. /*
  1959. * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate
  1960. * the received SCTs.
  1961. * If the callback returns a non-positive result, the connection is terminated.
  1962. * Call this function before beginning a handshake.
  1963. * If a NULL |callback| is provided, SCT validation is disabled.
  1964. * |arg| is arbitrary userdata that will be passed to the callback whenever it
  1965. * is invoked. Ownership of |arg| remains with the caller.
  1966. *
  1967. * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response
  1968. * will be requested.
  1969. */
  1970. int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback,
  1971. void *arg);
  1972. int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx,
  1973. ssl_ct_validation_cb callback,
  1974. void *arg);
  1975. #define SSL_disable_ct(s) \
  1976. ((void) SSL_set_validation_callback((s), NULL, NULL))
  1977. #define SSL_CTX_disable_ct(ctx) \
  1978. ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL))
  1979. /*
  1980. * The validation type enumerates the available behaviours of the built-in SSL
  1981. * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct().
  1982. * The underlying callback is a static function in libssl.
  1983. */
  1984. enum {
  1985. SSL_CT_VALIDATION_PERMISSIVE = 0,
  1986. SSL_CT_VALIDATION_STRICT
  1987. };
  1988. /*
  1989. * Enable CT by setting up a callback that implements one of the built-in
  1990. * validation variants. The SSL_CT_VALIDATION_PERMISSIVE variant always
  1991. * continues the handshake, the application can make appropriate decisions at
  1992. * handshake completion. The SSL_CT_VALIDATION_STRICT variant requires at
  1993. * least one valid SCT, or else handshake termination will be requested. The
  1994. * handshake may continue anyway if SSL_VERIFY_NONE is in effect.
  1995. */
  1996. int SSL_enable_ct(SSL *s, int validation_mode);
  1997. int SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode);
  1998. /*
  1999. * Report whether a non-NULL callback is enabled.
  2000. */
  2001. int SSL_ct_is_enabled(const SSL *s);
  2002. int SSL_CTX_ct_is_enabled(const SSL_CTX *ctx);
  2003. /* Gets the SCTs received from a connection */
  2004. const STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s);
  2005. /*
  2006. * Loads the CT log list from the default location.
  2007. * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,
  2008. * the log information loaded from this file will be appended to the
  2009. * CTLOG_STORE.
  2010. * Returns 1 on success, 0 otherwise.
  2011. */
  2012. int SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx);
  2013. /*
  2014. * Loads the CT log list from the specified file path.
  2015. * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store,
  2016. * the log information loaded from this file will be appended to the
  2017. * CTLOG_STORE.
  2018. * Returns 1 on success, 0 otherwise.
  2019. */
  2020. int SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
  2021. /*
  2022. * Sets the CT log list used by all SSL connections created from this SSL_CTX.
  2023. * Ownership of the CTLOG_STORE is transferred to the SSL_CTX.
  2024. */
  2025. void SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs);
  2026. /*
  2027. * Gets the CT log list used by all SSL connections created from this SSL_CTX.
  2028. * This will be NULL unless one of the following functions has been called:
  2029. * - SSL_CTX_set_default_ctlog_list_file
  2030. * - SSL_CTX_set_ctlog_list_file
  2031. * - SSL_CTX_set_ctlog_store
  2032. */
  2033. const CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx);
  2034. # endif /* OPENSSL_NO_CT */
  2035. /* What the "other" parameter contains in security callback */
  2036. /* Mask for type */
  2037. # define SSL_SECOP_OTHER_TYPE 0xffff0000
  2038. # define SSL_SECOP_OTHER_NONE 0
  2039. # define SSL_SECOP_OTHER_CIPHER (1 << 16)
  2040. # define SSL_SECOP_OTHER_CURVE (2 << 16)
  2041. # define SSL_SECOP_OTHER_DH (3 << 16)
  2042. # define SSL_SECOP_OTHER_PKEY (4 << 16)
  2043. # define SSL_SECOP_OTHER_SIGALG (5 << 16)
  2044. # define SSL_SECOP_OTHER_CERT (6 << 16)
  2045. /* Indicated operation refers to peer key or certificate */
  2046. # define SSL_SECOP_PEER 0x1000
  2047. /* Values for "op" parameter in security callback */
  2048. /* Called to filter ciphers */
  2049. /* Ciphers client supports */
  2050. # define SSL_SECOP_CIPHER_SUPPORTED (1 | SSL_SECOP_OTHER_CIPHER)
  2051. /* Cipher shared by client/server */
  2052. # define SSL_SECOP_CIPHER_SHARED (2 | SSL_SECOP_OTHER_CIPHER)
  2053. /* Sanity check of cipher server selects */
  2054. # define SSL_SECOP_CIPHER_CHECK (3 | SSL_SECOP_OTHER_CIPHER)
  2055. /* Curves supported by client */
  2056. # define SSL_SECOP_CURVE_SUPPORTED (4 | SSL_SECOP_OTHER_CURVE)
  2057. /* Curves shared by client/server */
  2058. # define SSL_SECOP_CURVE_SHARED (5 | SSL_SECOP_OTHER_CURVE)
  2059. /* Sanity check of curve server selects */
  2060. # define SSL_SECOP_CURVE_CHECK (6 | SSL_SECOP_OTHER_CURVE)
  2061. /* Temporary DH key */
  2062. # define SSL_SECOP_TMP_DH (7 | SSL_SECOP_OTHER_PKEY)
  2063. /* SSL/TLS version */
  2064. # define SSL_SECOP_VERSION (9 | SSL_SECOP_OTHER_NONE)
  2065. /* Session tickets */
  2066. # define SSL_SECOP_TICKET (10 | SSL_SECOP_OTHER_NONE)
  2067. /* Supported signature algorithms sent to peer */
  2068. # define SSL_SECOP_SIGALG_SUPPORTED (11 | SSL_SECOP_OTHER_SIGALG)
  2069. /* Shared signature algorithm */
  2070. # define SSL_SECOP_SIGALG_SHARED (12 | SSL_SECOP_OTHER_SIGALG)
  2071. /* Sanity check signature algorithm allowed */
  2072. # define SSL_SECOP_SIGALG_CHECK (13 | SSL_SECOP_OTHER_SIGALG)
  2073. /* Used to get mask of supported public key signature algorithms */
  2074. # define SSL_SECOP_SIGALG_MASK (14 | SSL_SECOP_OTHER_SIGALG)
  2075. /* Use to see if compression is allowed */
  2076. # define SSL_SECOP_COMPRESSION (15 | SSL_SECOP_OTHER_NONE)
  2077. /* EE key in certificate */
  2078. # define SSL_SECOP_EE_KEY (16 | SSL_SECOP_OTHER_CERT)
  2079. /* CA key in certificate */
  2080. # define SSL_SECOP_CA_KEY (17 | SSL_SECOP_OTHER_CERT)
  2081. /* CA digest algorithm in certificate */
  2082. # define SSL_SECOP_CA_MD (18 | SSL_SECOP_OTHER_CERT)
  2083. /* Peer EE key in certificate */
  2084. # define SSL_SECOP_PEER_EE_KEY (SSL_SECOP_EE_KEY | SSL_SECOP_PEER)
  2085. /* Peer CA key in certificate */
  2086. # define SSL_SECOP_PEER_CA_KEY (SSL_SECOP_CA_KEY | SSL_SECOP_PEER)
  2087. /* Peer CA digest algorithm in certificate */
  2088. # define SSL_SECOP_PEER_CA_MD (SSL_SECOP_CA_MD | SSL_SECOP_PEER)
  2089. void SSL_set_security_level(SSL *s, int level);
  2090. __owur int SSL_get_security_level(const SSL *s);
  2091. void SSL_set_security_callback(SSL *s,
  2092. int (*cb) (const SSL *s, const SSL_CTX *ctx,
  2093. int op, int bits, int nid,
  2094. void *other, void *ex));
  2095. int (*SSL_get_security_callback(const SSL *s)) (const SSL *s,
  2096. const SSL_CTX *ctx, int op,
  2097. int bits, int nid, void *other,
  2098. void *ex);
  2099. void SSL_set0_security_ex_data(SSL *s, void *ex);
  2100. __owur void *SSL_get0_security_ex_data(const SSL *s);
  2101. void SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
  2102. __owur int SSL_CTX_get_security_level(const SSL_CTX *ctx);
  2103. void SSL_CTX_set_security_callback(SSL_CTX *ctx,
  2104. int (*cb) (const SSL *s, const SSL_CTX *ctx,
  2105. int op, int bits, int nid,
  2106. void *other, void *ex));
  2107. int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s,
  2108. const SSL_CTX *ctx,
  2109. int op, int bits,
  2110. int nid,
  2111. void *other,
  2112. void *ex);
  2113. void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex);
  2114. __owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx);
  2115. /* OPENSSL_INIT flag 0x010000 reserved for internal use */
  2116. # define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L
  2117. # define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L
  2118. # define OPENSSL_INIT_SSL_DEFAULT \
  2119. (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS)
  2120. int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
  2121. # ifndef OPENSSL_NO_UNIT_TEST
  2122. __owur const struct openssl_ssl_test_functions *SSL_test_functions(void);
  2123. # endif
  2124. __owur int SSL_free_buffers(SSL *ssl);
  2125. __owur int SSL_alloc_buffers(SSL *ssl);
  2126. /* Status codes passed to the decrypt session ticket callback. Some of these
  2127. * are for internal use only and are never passed to the callback. */
  2128. typedef int SSL_TICKET_STATUS;
  2129. /* Support for ticket appdata */
  2130. /* fatal error, malloc failure */
  2131. # define SSL_TICKET_FATAL_ERR_MALLOC 0
  2132. /* fatal error, either from parsing or decrypting the ticket */
  2133. # define SSL_TICKET_FATAL_ERR_OTHER 1
  2134. /* No ticket present */
  2135. # define SSL_TICKET_NONE 2
  2136. /* Empty ticket present */
  2137. # define SSL_TICKET_EMPTY 3
  2138. /* the ticket couldn't be decrypted */
  2139. # define SSL_TICKET_NO_DECRYPT 4
  2140. /* a ticket was successfully decrypted */
  2141. # define SSL_TICKET_SUCCESS 5
  2142. /* same as above but the ticket needs to be renewed */
  2143. # define SSL_TICKET_SUCCESS_RENEW 6
  2144. /* Return codes for the decrypt session ticket callback */
  2145. typedef int SSL_TICKET_RETURN;
  2146. /* An error occurred */
  2147. #define SSL_TICKET_RETURN_ABORT 0
  2148. /* Do not use the ticket, do not send a renewed ticket to the client */
  2149. #define SSL_TICKET_RETURN_IGNORE 1
  2150. /* Do not use the ticket, send a renewed ticket to the client */
  2151. #define SSL_TICKET_RETURN_IGNORE_RENEW 2
  2152. /* Use the ticket, do not send a renewed ticket to the client */
  2153. #define SSL_TICKET_RETURN_USE 3
  2154. /* Use the ticket, send a renewed ticket to the client */
  2155. #define SSL_TICKET_RETURN_USE_RENEW 4
  2156. typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg);
  2157. typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss,
  2158. const unsigned char *keyname,
  2159. size_t keyname_length,
  2160. SSL_TICKET_STATUS status,
  2161. void *arg);
  2162. int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx,
  2163. SSL_CTX_generate_session_ticket_fn gen_cb,
  2164. SSL_CTX_decrypt_session_ticket_fn dec_cb,
  2165. void *arg);
  2166. int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len);
  2167. int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len);
  2168. extern const char SSL_version_str[];
  2169. typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us);
  2170. void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb);
  2171. typedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg);
  2172. void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx,
  2173. SSL_allow_early_data_cb_fn cb,
  2174. void *arg);
  2175. void SSL_set_allow_early_data_cb(SSL *s,
  2176. SSL_allow_early_data_cb_fn cb,
  2177. void *arg);
  2178. # ifdef __cplusplus
  2179. }
  2180. # endif
  2181. #endif