gnutls.h 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965
  1. /* -*- c -*-
  2. * Copyright (C) 2000-2016 Free Software Foundation, Inc.
  3. * Copyright (C) 2015-2017 Red Hat, Inc.
  4. *
  5. * Author: Nikos Mavrogiannopoulos
  6. *
  7. * This file is part of GnuTLS.
  8. *
  9. * The GnuTLS is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public License
  11. * as published by the Free Software Foundation; either version 2.1 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. /* This file contains the types and prototypes for all the
  24. * high level functionality of the gnutls main library.
  25. *
  26. * If the optional C++ binding was built, it is available in
  27. * gnutls/gnutlsxx.h.
  28. *
  29. * The openssl compatibility layer (which is under the GNU GPL
  30. * license) is in gnutls/openssl.h.
  31. *
  32. * The low level cipher functionality is in gnutls/crypto.h.
  33. */
  34. #ifndef GNUTLS_H
  35. #define GNUTLS_H
  36. /* Get size_t. */
  37. #include <stddef.h>
  38. /* Get ssize_t. */
  39. #ifndef HAVE_SSIZE_T
  40. #define HAVE_SSIZE_T
  41. /* *INDENT-OFF* */
  42. #include <sys/types.h>
  43. /* *INDENT-ON* */
  44. #endif
  45. /* Get time_t. */
  46. #include <time.h>
  47. /* *INDENT-OFF* */
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. /* *INDENT-ON* */
  52. #define GNUTLS_VERSION "3.6.0"
  53. #define GNUTLS_VERSION_MAJOR 3
  54. #define GNUTLS_VERSION_MINOR 6
  55. #define GNUTLS_VERSION_PATCH 0
  56. #define GNUTLS_VERSION_NUMBER 0x030600
  57. #define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC
  58. #define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC
  59. #define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC
  60. #define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128
  61. #if !defined(GNUTLS_INTERNAL_BUILD) && defined(_WIN32)
  62. # define _SYM_EXPORT __declspec(dllimport)
  63. #else
  64. # define _SYM_EXPORT
  65. #endif
  66. #ifdef __GNUC__
  67. # define __GNUTLS_CONST__ __attribute__((const))
  68. # define __GNUTLS_PURE__ __attribute__((pure))
  69. #else
  70. # define __GNUTLS_CONST__
  71. # define __GNUTLS_PURE__
  72. #endif
  73. /* Use the following definition globally in your program to disable
  74. * implicit initialization of gnutls. */
  75. #define GNUTLS_SKIP_GLOBAL_INIT int _gnutls_global_init_skip(void); \
  76. int _gnutls_global_init_skip(void) {return 1;}
  77. /**
  78. * gnutls_cipher_algorithm_t:
  79. * @GNUTLS_CIPHER_UNKNOWN: Value to identify an unknown/unsupported algorithm.
  80. * @GNUTLS_CIPHER_NULL: The NULL (identity) encryption algorithm.
  81. * @GNUTLS_CIPHER_ARCFOUR_128: ARCFOUR stream cipher with 128-bit keys.
  82. * @GNUTLS_CIPHER_3DES_CBC: 3DES in CBC mode.
  83. * @GNUTLS_CIPHER_AES_128_CBC: AES in CBC mode with 128-bit keys.
  84. * @GNUTLS_CIPHER_AES_192_CBC: AES in CBC mode with 192-bit keys.
  85. * @GNUTLS_CIPHER_AES_256_CBC: AES in CBC mode with 256-bit keys.
  86. * @GNUTLS_CIPHER_ARCFOUR_40: ARCFOUR stream cipher with 40-bit keys.
  87. * @GNUTLS_CIPHER_CAMELLIA_128_CBC: Camellia in CBC mode with 128-bit keys.
  88. * @GNUTLS_CIPHER_CAMELLIA_192_CBC: Camellia in CBC mode with 192-bit keys.
  89. * @GNUTLS_CIPHER_CAMELLIA_256_CBC: Camellia in CBC mode with 256-bit keys.
  90. * @GNUTLS_CIPHER_RC2_40_CBC: RC2 in CBC mode with 40-bit keys.
  91. * @GNUTLS_CIPHER_DES_CBC: DES in CBC mode (56-bit keys).
  92. * @GNUTLS_CIPHER_AES_128_GCM: AES in GCM mode with 128-bit keys.
  93. * @GNUTLS_CIPHER_AES_256_GCM: AES in GCM mode with 256-bit keys.
  94. * @GNUTLS_CIPHER_AES_128_CCM: AES in CCM mode with 128-bit keys.
  95. * @GNUTLS_CIPHER_AES_256_CCM: AES in CCM mode with 256-bit keys.
  96. * @GNUTLS_CIPHER_AES_128_CCM_8: AES in CCM mode with 64-bit tag and 128-bit keys.
  97. * @GNUTLS_CIPHER_AES_256_CCM_8: AES in CCM mode with 64-bit tag and 256-bit keys.
  98. * @GNUTLS_CIPHER_CAMELLIA_128_GCM: CAMELLIA in GCM mode with 128-bit keys.
  99. * @GNUTLS_CIPHER_CAMELLIA_256_GCM: CAMELLIA in GCM mode with 256-bit keys.
  100. * @GNUTLS_CIPHER_SALSA20_256: Salsa20 with 256-bit keys.
  101. * @GNUTLS_CIPHER_ESTREAM_SALSA20_256: Estream's Salsa20 variant with 256-bit keys.
  102. * @GNUTLS_CIPHER_CHACHA20_POLY1305: The Chacha20 cipher with the Poly1305 authenticator (AEAD).
  103. * @GNUTLS_CIPHER_IDEA_PGP_CFB: IDEA in CFB mode (placeholder - unsupported).
  104. * @GNUTLS_CIPHER_3DES_PGP_CFB: 3DES in CFB mode (placeholder - unsupported).
  105. * @GNUTLS_CIPHER_CAST5_PGP_CFB: CAST5 in CFB mode (placeholder - unsupported).
  106. * @GNUTLS_CIPHER_BLOWFISH_PGP_CFB: Blowfish in CFB mode (placeholder - unsupported).
  107. * @GNUTLS_CIPHER_SAFER_SK128_PGP_CFB: Safer-SK in CFB mode with 128-bit keys (placeholder - unsupported).
  108. * @GNUTLS_CIPHER_AES128_PGP_CFB: AES in CFB mode with 128-bit keys (placeholder - unsupported).
  109. * @GNUTLS_CIPHER_AES192_PGP_CFB: AES in CFB mode with 192-bit keys (placeholder - unsupported).
  110. * @GNUTLS_CIPHER_AES256_PGP_CFB: AES in CFB mode with 256-bit keys (placeholder - unsupported).
  111. * @GNUTLS_CIPHER_TWOFISH_PGP_CFB: Twofish in CFB mode (placeholder - unsupported).
  112. *
  113. * Enumeration of different symmetric encryption algorithms.
  114. */
  115. typedef enum gnutls_cipher_algorithm {
  116. GNUTLS_CIPHER_UNKNOWN = 0,
  117. GNUTLS_CIPHER_NULL = 1,
  118. GNUTLS_CIPHER_ARCFOUR_128 = 2,
  119. GNUTLS_CIPHER_3DES_CBC = 3,
  120. GNUTLS_CIPHER_AES_128_CBC = 4,
  121. GNUTLS_CIPHER_AES_256_CBC = 5,
  122. GNUTLS_CIPHER_ARCFOUR_40 = 6,
  123. GNUTLS_CIPHER_CAMELLIA_128_CBC = 7,
  124. GNUTLS_CIPHER_CAMELLIA_256_CBC = 8,
  125. GNUTLS_CIPHER_AES_192_CBC = 9,
  126. GNUTLS_CIPHER_AES_128_GCM = 10,
  127. GNUTLS_CIPHER_AES_256_GCM = 11,
  128. GNUTLS_CIPHER_CAMELLIA_192_CBC = 12,
  129. GNUTLS_CIPHER_SALSA20_256 = 13,
  130. GNUTLS_CIPHER_ESTREAM_SALSA20_256 = 14,
  131. GNUTLS_CIPHER_CAMELLIA_128_GCM = 15,
  132. GNUTLS_CIPHER_CAMELLIA_256_GCM = 16,
  133. GNUTLS_CIPHER_RC2_40_CBC = 17,
  134. GNUTLS_CIPHER_DES_CBC = 18,
  135. GNUTLS_CIPHER_AES_128_CCM = 19,
  136. GNUTLS_CIPHER_AES_256_CCM = 20,
  137. GNUTLS_CIPHER_AES_128_CCM_8 = 21,
  138. GNUTLS_CIPHER_AES_256_CCM_8 = 22,
  139. GNUTLS_CIPHER_CHACHA20_POLY1305 = 23,
  140. /* used only for PGP internals. Ignored in TLS/SSL
  141. */
  142. GNUTLS_CIPHER_IDEA_PGP_CFB = 200,
  143. GNUTLS_CIPHER_3DES_PGP_CFB = 201,
  144. GNUTLS_CIPHER_CAST5_PGP_CFB = 202,
  145. GNUTLS_CIPHER_BLOWFISH_PGP_CFB = 203,
  146. GNUTLS_CIPHER_SAFER_SK128_PGP_CFB = 204,
  147. GNUTLS_CIPHER_AES128_PGP_CFB = 205,
  148. GNUTLS_CIPHER_AES192_PGP_CFB = 206,
  149. GNUTLS_CIPHER_AES256_PGP_CFB = 207,
  150. GNUTLS_CIPHER_TWOFISH_PGP_CFB = 208
  151. } gnutls_cipher_algorithm_t;
  152. /**
  153. * gnutls_kx_algorithm_t:
  154. * @GNUTLS_KX_UNKNOWN: Unknown key-exchange algorithm.
  155. * @GNUTLS_KX_RSA: RSA key-exchange algorithm.
  156. * @GNUTLS_KX_DHE_DSS: DHE-DSS key-exchange algorithm.
  157. * @GNUTLS_KX_DHE_RSA: DHE-RSA key-exchange algorithm.
  158. * @GNUTLS_KX_ECDHE_RSA: ECDHE-RSA key-exchange algorithm.
  159. * @GNUTLS_KX_ECDHE_ECDSA: ECDHE-ECDSA key-exchange algorithm.
  160. * @GNUTLS_KX_ANON_DH: Anon-DH key-exchange algorithm.
  161. * @GNUTLS_KX_ANON_ECDH: Anon-ECDH key-exchange algorithm.
  162. * @GNUTLS_KX_SRP: SRP key-exchange algorithm.
  163. * @GNUTLS_KX_RSA_EXPORT: RSA-EXPORT key-exchange algorithm (defunc).
  164. * @GNUTLS_KX_SRP_RSA: SRP-RSA key-exchange algorithm.
  165. * @GNUTLS_KX_SRP_DSS: SRP-DSS key-exchange algorithm.
  166. * @GNUTLS_KX_PSK: PSK key-exchange algorithm.
  167. * @GNUTLS_KX_DHE_PSK: DHE-PSK key-exchange algorithm.
  168. * @GNUTLS_KX_ECDHE_PSK: ECDHE-PSK key-exchange algorithm.
  169. * @GNUTLS_KX_RSA_PSK: RSA-PSK key-exchange algorithm.
  170. *
  171. * Enumeration of different key exchange algorithms.
  172. */
  173. typedef enum {
  174. GNUTLS_KX_UNKNOWN = 0,
  175. GNUTLS_KX_RSA = 1,
  176. GNUTLS_KX_DHE_DSS = 2,
  177. GNUTLS_KX_DHE_RSA = 3,
  178. GNUTLS_KX_ANON_DH = 4,
  179. GNUTLS_KX_SRP = 5,
  180. GNUTLS_KX_RSA_EXPORT = 6,
  181. GNUTLS_KX_SRP_RSA = 7,
  182. GNUTLS_KX_SRP_DSS = 8,
  183. GNUTLS_KX_PSK = 9,
  184. GNUTLS_KX_DHE_PSK = 10,
  185. GNUTLS_KX_ANON_ECDH = 11,
  186. GNUTLS_KX_ECDHE_RSA = 12,
  187. GNUTLS_KX_ECDHE_ECDSA = 13,
  188. GNUTLS_KX_ECDHE_PSK = 14,
  189. GNUTLS_KX_RSA_PSK = 15
  190. } gnutls_kx_algorithm_t;
  191. /**
  192. * gnutls_params_type_t:
  193. * @GNUTLS_PARAMS_RSA_EXPORT: Session RSA-EXPORT parameters (defunc).
  194. * @GNUTLS_PARAMS_DH: Session Diffie-Hellman parameters.
  195. * @GNUTLS_PARAMS_ECDH: Session Elliptic-Curve Diffie-Hellman parameters.
  196. *
  197. * Enumeration of different TLS session parameter types.
  198. */
  199. typedef enum {
  200. GNUTLS_PARAMS_RSA_EXPORT = 1,
  201. GNUTLS_PARAMS_DH = 2,
  202. GNUTLS_PARAMS_ECDH = 3
  203. } gnutls_params_type_t;
  204. /**
  205. * gnutls_credentials_type_t:
  206. * @GNUTLS_CRD_CERTIFICATE: Certificate credential.
  207. * @GNUTLS_CRD_ANON: Anonymous credential.
  208. * @GNUTLS_CRD_SRP: SRP credential.
  209. * @GNUTLS_CRD_PSK: PSK credential.
  210. * @GNUTLS_CRD_IA: IA credential.
  211. *
  212. * Enumeration of different credential types.
  213. */
  214. typedef enum {
  215. GNUTLS_CRD_CERTIFICATE = 1,
  216. GNUTLS_CRD_ANON,
  217. GNUTLS_CRD_SRP,
  218. GNUTLS_CRD_PSK,
  219. GNUTLS_CRD_IA
  220. } gnutls_credentials_type_t;
  221. #define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1
  222. #define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1
  223. /**
  224. * gnutls_mac_algorithm_t:
  225. * @GNUTLS_MAC_UNKNOWN: Unknown MAC algorithm.
  226. * @GNUTLS_MAC_NULL: NULL MAC algorithm (empty output).
  227. * @GNUTLS_MAC_MD5: HMAC-MD5 algorithm.
  228. * @GNUTLS_MAC_SHA1: HMAC-SHA-1 algorithm.
  229. * @GNUTLS_MAC_RMD160: HMAC-RMD160 algorithm.
  230. * @GNUTLS_MAC_MD2: HMAC-MD2 algorithm.
  231. * @GNUTLS_MAC_SHA256: HMAC-SHA-256 algorithm.
  232. * @GNUTLS_MAC_SHA384: HMAC-SHA-384 algorithm.
  233. * @GNUTLS_MAC_SHA512: HMAC-SHA-512 algorithm.
  234. * @GNUTLS_MAC_SHA224: HMAC-SHA-224 algorithm.
  235. * @GNUTLS_MAC_MD5_SHA1: Combined MD5+SHA1 MAC placeholder.
  236. * @GNUTLS_MAC_AEAD: MAC implicit through AEAD cipher.
  237. * @GNUTLS_MAC_UMAC_96: The UMAC-96 MAC algorithm.
  238. * @GNUTLS_MAC_UMAC_128: The UMAC-128 MAC algorithm.
  239. *
  240. * Enumeration of different Message Authentication Code (MAC)
  241. * algorithms.
  242. */
  243. typedef enum {
  244. GNUTLS_MAC_UNKNOWN = 0,
  245. GNUTLS_MAC_NULL = 1,
  246. GNUTLS_MAC_MD5 = 2,
  247. GNUTLS_MAC_SHA1 = 3,
  248. GNUTLS_MAC_RMD160 = 4,
  249. GNUTLS_MAC_MD2 = 5,
  250. GNUTLS_MAC_SHA256 = 6,
  251. GNUTLS_MAC_SHA384 = 7,
  252. GNUTLS_MAC_SHA512 = 8,
  253. GNUTLS_MAC_SHA224 = 9,
  254. GNUTLS_MAC_SHA3_224 = 10, /* reserved: no implementation */
  255. GNUTLS_MAC_SHA3_256 = 11, /* reserved: no implementation */
  256. GNUTLS_MAC_SHA3_384 = 12, /* reserved: no implementation */
  257. GNUTLS_MAC_SHA3_512 = 13, /* reserved: no implementation */
  258. GNUTLS_MAC_MD5_SHA1 = 14, /* reserved: no implementation */
  259. /* If you add anything here, make sure you align with
  260. gnutls_digest_algorithm_t. */
  261. GNUTLS_MAC_AEAD = 200, /* indicates that MAC is on the cipher */
  262. GNUTLS_MAC_UMAC_96 = 201,
  263. GNUTLS_MAC_UMAC_128 = 202
  264. } gnutls_mac_algorithm_t;
  265. /**
  266. * gnutls_digest_algorithm_t:
  267. * @GNUTLS_DIG_UNKNOWN: Unknown hash algorithm.
  268. * @GNUTLS_DIG_NULL: NULL hash algorithm (empty output).
  269. * @GNUTLS_DIG_MD5: MD5 algorithm.
  270. * @GNUTLS_DIG_SHA1: SHA-1 algorithm.
  271. * @GNUTLS_DIG_RMD160: RMD160 algorithm.
  272. * @GNUTLS_DIG_MD2: MD2 algorithm.
  273. * @GNUTLS_DIG_SHA256: SHA-256 algorithm.
  274. * @GNUTLS_DIG_SHA384: SHA-384 algorithm.
  275. * @GNUTLS_DIG_SHA512: SHA-512 algorithm.
  276. * @GNUTLS_DIG_SHA224: SHA-224 algorithm.
  277. * @GNUTLS_DIG_SHA3_224: SHA3-224 algorithm.
  278. * @GNUTLS_DIG_SHA3_256: SHA3-256 algorithm.
  279. * @GNUTLS_DIG_SHA3_384: SHA3-384 algorithm.
  280. * @GNUTLS_DIG_SHA3_512: SHA3-512 algorithm.
  281. * @GNUTLS_DIG_MD5_SHA1: Combined MD5+SHA1 algorithm.
  282. *
  283. * Enumeration of different digest (hash) algorithms.
  284. */
  285. typedef enum {
  286. GNUTLS_DIG_UNKNOWN = GNUTLS_MAC_UNKNOWN,
  287. GNUTLS_DIG_NULL = GNUTLS_MAC_NULL,
  288. GNUTLS_DIG_MD5 = GNUTLS_MAC_MD5,
  289. GNUTLS_DIG_SHA1 = GNUTLS_MAC_SHA1,
  290. GNUTLS_DIG_RMD160 = GNUTLS_MAC_RMD160,
  291. GNUTLS_DIG_MD2 = GNUTLS_MAC_MD2,
  292. GNUTLS_DIG_SHA256 = GNUTLS_MAC_SHA256,
  293. GNUTLS_DIG_SHA384 = GNUTLS_MAC_SHA384,
  294. GNUTLS_DIG_SHA512 = GNUTLS_MAC_SHA512,
  295. GNUTLS_DIG_SHA224 = GNUTLS_MAC_SHA224,
  296. GNUTLS_DIG_SHA3_224 = GNUTLS_MAC_SHA3_224,
  297. GNUTLS_DIG_SHA3_256 = GNUTLS_MAC_SHA3_256,
  298. GNUTLS_DIG_SHA3_384 = GNUTLS_MAC_SHA3_384,
  299. GNUTLS_DIG_SHA3_512 = GNUTLS_MAC_SHA3_512,
  300. GNUTLS_DIG_MD5_SHA1 = GNUTLS_MAC_MD5_SHA1
  301. /* If you add anything here, make sure you align with
  302. gnutls_mac_algorithm_t. */
  303. } gnutls_digest_algorithm_t;
  304. /* exported for other gnutls headers. This is the maximum number of
  305. * algorithms (ciphers, kx or macs).
  306. */
  307. #define GNUTLS_MAX_ALGORITHM_NUM 64
  308. #define GNUTLS_MAX_SESSION_ID_SIZE 32
  309. /**
  310. * gnutls_compression_method_t:
  311. * @GNUTLS_COMP_UNKNOWN: Unknown compression method.
  312. * @GNUTLS_COMP_NULL: The NULL compression method (no compression).
  313. * @GNUTLS_COMP_DEFLATE: The DEFLATE compression method from zlib.
  314. * @GNUTLS_COMP_ZLIB: Same as %GNUTLS_COMP_DEFLATE.
  315. *
  316. * Enumeration of different TLS compression methods.
  317. */
  318. typedef enum {
  319. GNUTLS_COMP_UNKNOWN = 0,
  320. GNUTLS_COMP_NULL = 1,
  321. GNUTLS_COMP_DEFLATE = 2,
  322. GNUTLS_COMP_ZLIB = GNUTLS_COMP_DEFLATE
  323. } gnutls_compression_method_t;
  324. /**
  325. * gnutls_init_flags_t:
  326. *
  327. * @GNUTLS_SERVER: Connection end is a server.
  328. * @GNUTLS_CLIENT: Connection end is a client.
  329. * @GNUTLS_DATAGRAM: Connection is datagram oriented (DTLS). Since 3.0.0.
  330. * @GNUTLS_NONBLOCK: Connection should not block. Since 3.0.0.
  331. * @GNUTLS_NO_SIGNAL: In systems where SIGPIPE is delivered on send, it will be disabled. That flag has effect in systems which support the MSG_NOSIGNAL sockets flag (since 3.4.2).
  332. * @GNUTLS_NO_EXTENSIONS: Do not enable any TLS extensions by default (since 3.1.2).
  333. * @GNUTLS_NO_REPLAY_PROTECTION: Disable any replay protection in DTLS. This must only be used if replay protection is achieved using other means. Since 3.2.2.
  334. * @GNUTLS_ALLOW_ID_CHANGE: Allow the peer to replace its certificate, or change its ID during a rehandshake. This change is often used in attacks and thus prohibited by default. Since 3.5.0.
  335. * @GNUTLS_ENABLE_FALSE_START: Enable the TLS false start on client side if the negotiated ciphersuites allow it. This will enable sending data prior to the handshake being complete, and may introduce a risk of crypto failure when combined with certain key exchanged; for that GnuTLS may not enable that option in ciphersuites that are known to be not safe for false start. Since 3.5.0.
  336. * @GNUTLS_FORCE_CLIENT_CERT: When in client side and only a single cert is specified, send that certificate irrespective of the issuers expected by the server. Since 3.5.0.
  337. * @GNUTLS_NO_TICKETS: Flag to indicate that the session should not use resumption with session tickets.
  338. *
  339. * Enumeration of different flags for gnutls_init() function. All the flags
  340. * can be combined except @GNUTLS_SERVER and @GNUTLS_CLIENT which are mutually
  341. * exclusive.
  342. */
  343. typedef enum {
  344. GNUTLS_SERVER = 1,
  345. GNUTLS_CLIENT = (1<<1),
  346. GNUTLS_DATAGRAM = (1<<2),
  347. GNUTLS_NONBLOCK = (1<<3),
  348. GNUTLS_NO_EXTENSIONS = (1<<4),
  349. GNUTLS_NO_REPLAY_PROTECTION = (1<<5),
  350. GNUTLS_NO_SIGNAL = (1<<6),
  351. GNUTLS_ALLOW_ID_CHANGE = (1<<7),
  352. GNUTLS_ENABLE_FALSE_START = (1<<8),
  353. GNUTLS_FORCE_CLIENT_CERT = (1<<9),
  354. GNUTLS_NO_TICKETS = (1<<10)
  355. } gnutls_init_flags_t;
  356. /* compatibility defines (previous versions of gnutls
  357. * used defines instead of enumerated values). */
  358. #define GNUTLS_SERVER (1)
  359. #define GNUTLS_CLIENT (1<<1)
  360. #define GNUTLS_DATAGRAM (1<<2)
  361. #define GNUTLS_NONBLOCK (1<<3)
  362. #define GNUTLS_NO_EXTENSIONS (1<<4)
  363. #define GNUTLS_NO_REPLAY_PROTECTION (1<<5)
  364. #define GNUTLS_NO_SIGNAL (1<<6)
  365. #define GNUTLS_ALLOW_ID_CHANGE (1<<7)
  366. #define GNUTLS_ENABLE_FALSE_START (1<<8)
  367. #define GNUTLS_FORCE_CLIENT_CERT (1<<9)
  368. #define GNUTLS_NO_TICKETS (1<<10)
  369. /**
  370. * gnutls_alert_level_t:
  371. * @GNUTLS_AL_WARNING: Alert of warning severity.
  372. * @GNUTLS_AL_FATAL: Alert of fatal severity.
  373. *
  374. * Enumeration of different TLS alert severities.
  375. */
  376. typedef enum {
  377. GNUTLS_AL_WARNING = 1,
  378. GNUTLS_AL_FATAL
  379. } gnutls_alert_level_t;
  380. /**
  381. * gnutls_alert_description_t:
  382. * @GNUTLS_A_CLOSE_NOTIFY: Close notify.
  383. * @GNUTLS_A_UNEXPECTED_MESSAGE: Unexpected message.
  384. * @GNUTLS_A_BAD_RECORD_MAC: Bad record MAC.
  385. * @GNUTLS_A_DECRYPTION_FAILED: Decryption failed.
  386. * @GNUTLS_A_RECORD_OVERFLOW: Record overflow.
  387. * @GNUTLS_A_DECOMPRESSION_FAILURE: Decompression failed.
  388. * @GNUTLS_A_HANDSHAKE_FAILURE: Handshake failed.
  389. * @GNUTLS_A_SSL3_NO_CERTIFICATE: No certificate.
  390. * @GNUTLS_A_BAD_CERTIFICATE: Certificate is bad.
  391. * @GNUTLS_A_UNSUPPORTED_CERTIFICATE: Certificate is not supported.
  392. * @GNUTLS_A_CERTIFICATE_REVOKED: Certificate was revoked.
  393. * @GNUTLS_A_CERTIFICATE_EXPIRED: Certificate is expired.
  394. * @GNUTLS_A_CERTIFICATE_UNKNOWN: Unknown certificate.
  395. * @GNUTLS_A_ILLEGAL_PARAMETER: Illegal parameter.
  396. * @GNUTLS_A_UNKNOWN_CA: CA is unknown.
  397. * @GNUTLS_A_ACCESS_DENIED: Access was denied.
  398. * @GNUTLS_A_DECODE_ERROR: Decode error.
  399. * @GNUTLS_A_DECRYPT_ERROR: Decrypt error.
  400. * @GNUTLS_A_EXPORT_RESTRICTION: Export restriction.
  401. * @GNUTLS_A_PROTOCOL_VERSION: Error in protocol version.
  402. * @GNUTLS_A_INSUFFICIENT_SECURITY: Insufficient security.
  403. * @GNUTLS_A_USER_CANCELED: User canceled.
  404. * @GNUTLS_A_INTERNAL_ERROR: Internal error.
  405. * @GNUTLS_A_INAPPROPRIATE_FALLBACK: Inappropriate fallback,
  406. * @GNUTLS_A_NO_RENEGOTIATION: No renegotiation is allowed.
  407. * @GNUTLS_A_CERTIFICATE_UNOBTAINABLE: Could not retrieve the
  408. * specified certificate.
  409. * @GNUTLS_A_UNSUPPORTED_EXTENSION: An unsupported extension was
  410. * sent.
  411. * @GNUTLS_A_UNRECOGNIZED_NAME: The server name sent was not
  412. * recognized.
  413. * @GNUTLS_A_UNKNOWN_PSK_IDENTITY: The SRP/PSK username is missing
  414. * or not known.
  415. * @GNUTLS_A_NO_APPLICATION_PROTOCOL: The ALPN protocol requested is
  416. * not supported by the peer.
  417. *
  418. * Enumeration of different TLS alerts.
  419. */
  420. typedef enum {
  421. GNUTLS_A_CLOSE_NOTIFY,
  422. GNUTLS_A_UNEXPECTED_MESSAGE = 10,
  423. GNUTLS_A_BAD_RECORD_MAC = 20,
  424. GNUTLS_A_DECRYPTION_FAILED,
  425. GNUTLS_A_RECORD_OVERFLOW,
  426. GNUTLS_A_DECOMPRESSION_FAILURE = 30,
  427. GNUTLS_A_HANDSHAKE_FAILURE = 40,
  428. GNUTLS_A_SSL3_NO_CERTIFICATE = 41,
  429. GNUTLS_A_BAD_CERTIFICATE = 42,
  430. GNUTLS_A_UNSUPPORTED_CERTIFICATE,
  431. GNUTLS_A_CERTIFICATE_REVOKED,
  432. GNUTLS_A_CERTIFICATE_EXPIRED,
  433. GNUTLS_A_CERTIFICATE_UNKNOWN,
  434. GNUTLS_A_ILLEGAL_PARAMETER,
  435. GNUTLS_A_UNKNOWN_CA,
  436. GNUTLS_A_ACCESS_DENIED,
  437. GNUTLS_A_DECODE_ERROR = 50,
  438. GNUTLS_A_DECRYPT_ERROR,
  439. GNUTLS_A_EXPORT_RESTRICTION = 60,
  440. GNUTLS_A_PROTOCOL_VERSION = 70,
  441. GNUTLS_A_INSUFFICIENT_SECURITY,
  442. GNUTLS_A_INTERNAL_ERROR = 80,
  443. GNUTLS_A_INAPPROPRIATE_FALLBACK = 86,
  444. GNUTLS_A_USER_CANCELED = 90,
  445. GNUTLS_A_NO_RENEGOTIATION = 100,
  446. GNUTLS_A_UNSUPPORTED_EXTENSION = 110,
  447. GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,
  448. GNUTLS_A_UNRECOGNIZED_NAME = 112,
  449. GNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,
  450. GNUTLS_A_NO_APPLICATION_PROTOCOL = 120,
  451. GNUTLS_A_MAX = GNUTLS_A_NO_APPLICATION_PROTOCOL
  452. } gnutls_alert_description_t;
  453. /**
  454. * gnutls_handshake_description_t:
  455. * @GNUTLS_HANDSHAKE_HELLO_REQUEST: Hello request.
  456. * @GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: DTLS Hello verify request.
  457. * @GNUTLS_HANDSHAKE_CLIENT_HELLO: Client hello.
  458. * @GNUTLS_HANDSHAKE_SERVER_HELLO: Server hello.
  459. * @GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: New session ticket.
  460. * @GNUTLS_HANDSHAKE_CERTIFICATE_PKT: Certificate packet.
  461. * @GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: Server key exchange.
  462. * @GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: Certificate request.
  463. * @GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: Server hello done.
  464. * @GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: Certificate verify.
  465. * @GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: Client key exchange.
  466. * @GNUTLS_HANDSHAKE_FINISHED: Finished.
  467. * @GNUTLS_HANDSHAKE_CERTIFICATE_STATUS: Certificate status (OCSP).
  468. * @GNUTLS_HANDSHAKE_SUPPLEMENTAL: Supplemental.
  469. * @GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: Change Cipher Spec.
  470. * @GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: SSLv2 Client Hello.
  471. *
  472. * Enumeration of different TLS handshake packets.
  473. */
  474. typedef enum {
  475. GNUTLS_HANDSHAKE_HELLO_REQUEST = 0,
  476. GNUTLS_HANDSHAKE_CLIENT_HELLO = 1,
  477. GNUTLS_HANDSHAKE_SERVER_HELLO = 2,
  478. GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST = 3,
  479. GNUTLS_HANDSHAKE_NEW_SESSION_TICKET = 4,
  480. GNUTLS_HANDSHAKE_CERTIFICATE_PKT = 11,
  481. GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE = 12,
  482. GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST = 13,
  483. GNUTLS_HANDSHAKE_SERVER_HELLO_DONE = 14,
  484. GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY = 15,
  485. GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,
  486. GNUTLS_HANDSHAKE_FINISHED = 20,
  487. GNUTLS_HANDSHAKE_CERTIFICATE_STATUS = 22,
  488. GNUTLS_HANDSHAKE_SUPPLEMENTAL = 23,
  489. GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC = 254,
  490. GNUTLS_HANDSHAKE_CLIENT_HELLO_V2 = 1024
  491. } gnutls_handshake_description_t;
  492. #define GNUTLS_HANDSHAKE_ANY ((unsigned int)-1)
  493. const char
  494. *gnutls_handshake_description_get_name(gnutls_handshake_description_t
  495. type);
  496. /**
  497. * gnutls_certificate_status_t:
  498. * @GNUTLS_CERT_INVALID: The certificate is not signed by one of the
  499. * known authorities or the signature is invalid (deprecated by the flags
  500. * %GNUTLS_CERT_SIGNATURE_FAILURE and %GNUTLS_CERT_SIGNER_NOT_FOUND).
  501. * @GNUTLS_CERT_SIGNATURE_FAILURE: The signature verification failed.
  502. * @GNUTLS_CERT_REVOKED: Certificate is revoked by its authority. In X.509 this will be
  503. * set only if CRLs are checked.
  504. * @GNUTLS_CERT_SIGNER_NOT_FOUND: The certificate's issuer is not known.
  505. * This is the case if the issuer is not included in the trusted certificate list.
  506. * @GNUTLS_CERT_SIGNER_NOT_CA: The certificate's signer was not a CA. This
  507. * may happen if this was a version 1 certificate, which is common with
  508. * some CAs, or a version 3 certificate without the basic constrains extension.
  509. * @GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE: The certificate's signer constraints were
  510. * violated.
  511. * @GNUTLS_CERT_INSECURE_ALGORITHM: The certificate was signed using an insecure
  512. * algorithm such as MD2 or MD5. These algorithms have been broken and
  513. * should not be trusted.
  514. * @GNUTLS_CERT_NOT_ACTIVATED: The certificate is not yet activated.
  515. * @GNUTLS_CERT_EXPIRED: The certificate has expired.
  516. * @GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED: The revocation data are old and have been superseded.
  517. * @GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE: The revocation data have a future issue date.
  518. * @GNUTLS_CERT_UNEXPECTED_OWNER: The owner is not the expected one.
  519. * @GNUTLS_CERT_MISMATCH: The certificate presented isn't the expected one (TOFU)
  520. * @GNUTLS_CERT_PURPOSE_MISMATCH: The certificate or an intermediate does not match the intended purpose (extended key usage).
  521. * @GNUTLS_CERT_MISSING_OCSP_STATUS: The certificate requires the server to send the certifiate status, but no status was received.
  522. * @GNUTLS_CERT_INVALID_OCSP_STATUS: The received OCSP status response is invalid.
  523. * @GNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS: The certificate has extensions marked as critical which are not supported.
  524. *
  525. * Enumeration of certificate status codes. Note that the status
  526. * bits may have different meanings in OpenPGP keys and X.509
  527. * certificate verification.
  528. */
  529. typedef enum {
  530. GNUTLS_CERT_INVALID = 1 << 1,
  531. GNUTLS_CERT_REVOKED = 1 << 5,
  532. GNUTLS_CERT_SIGNER_NOT_FOUND = 1 << 6,
  533. GNUTLS_CERT_SIGNER_NOT_CA = 1 << 7,
  534. GNUTLS_CERT_INSECURE_ALGORITHM = 1 << 8,
  535. GNUTLS_CERT_NOT_ACTIVATED = 1 << 9,
  536. GNUTLS_CERT_EXPIRED = 1 << 10,
  537. GNUTLS_CERT_SIGNATURE_FAILURE = 1 << 11,
  538. GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED = 1 << 12,
  539. GNUTLS_CERT_UNEXPECTED_OWNER = 1 << 14,
  540. GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE = 1 << 15,
  541. GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE = 1 << 16,
  542. GNUTLS_CERT_MISMATCH = 1 << 17,
  543. GNUTLS_CERT_PURPOSE_MISMATCH = 1 << 18,
  544. GNUTLS_CERT_MISSING_OCSP_STATUS = 1 << 19,
  545. GNUTLS_CERT_INVALID_OCSP_STATUS = 1 << 20,
  546. GNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS = 1 << 21
  547. } gnutls_certificate_status_t;
  548. /**
  549. * gnutls_certificate_request_t:
  550. * @GNUTLS_CERT_IGNORE: Ignore certificate.
  551. * @GNUTLS_CERT_REQUEST: Request certificate.
  552. * @GNUTLS_CERT_REQUIRE: Require certificate.
  553. *
  554. * Enumeration of certificate request types.
  555. */
  556. typedef enum {
  557. GNUTLS_CERT_IGNORE = 0,
  558. GNUTLS_CERT_REQUEST = 1,
  559. GNUTLS_CERT_REQUIRE = 2
  560. } gnutls_certificate_request_t;
  561. /**
  562. * gnutls_openpgp_crt_status_t:
  563. * @GNUTLS_OPENPGP_CERT: Send entire certificate.
  564. * @GNUTLS_OPENPGP_CERT_FINGERPRINT: Send only certificate fingerprint.
  565. *
  566. * Enumeration of ways to send OpenPGP certificate.
  567. */
  568. typedef enum {
  569. GNUTLS_OPENPGP_CERT = 0,
  570. GNUTLS_OPENPGP_CERT_FINGERPRINT = 1
  571. } gnutls_openpgp_crt_status_t;
  572. /**
  573. * gnutls_close_request_t:
  574. * @GNUTLS_SHUT_RDWR: Disallow further receives/sends.
  575. * @GNUTLS_SHUT_WR: Disallow further sends.
  576. *
  577. * Enumeration of how TLS session should be terminated. See gnutls_bye().
  578. */
  579. typedef enum {
  580. GNUTLS_SHUT_RDWR = 0,
  581. GNUTLS_SHUT_WR = 1
  582. } gnutls_close_request_t;
  583. /**
  584. * gnutls_protocol_t:
  585. * @GNUTLS_SSL3: SSL version 3.0.
  586. * @GNUTLS_TLS1_0: TLS version 1.0.
  587. * @GNUTLS_TLS1: Same as %GNUTLS_TLS1_0.
  588. * @GNUTLS_TLS1_1: TLS version 1.1.
  589. * @GNUTLS_TLS1_2: TLS version 1.2.
  590. * @GNUTLS_DTLS1_0: DTLS version 1.0.
  591. * @GNUTLS_DTLS1_2: DTLS version 1.2.
  592. * @GNUTLS_DTLS0_9: DTLS version 0.9 (Cisco AnyConnect / OpenSSL 0.9.8e).
  593. * @GNUTLS_VERSION_MAX: Maps to the highest supported TLS version.
  594. * @GNUTLS_VERSION_UNKNOWN: Unknown SSL/TLS version.
  595. *
  596. * Enumeration of different SSL/TLS protocol versions.
  597. */
  598. typedef enum {
  599. GNUTLS_SSL3 = 1,
  600. GNUTLS_TLS1_0 = 2,
  601. GNUTLS_TLS1 = GNUTLS_TLS1_0,
  602. GNUTLS_TLS1_1 = 3,
  603. GNUTLS_TLS1_2 = 4,
  604. GNUTLS_DTLS0_9 = 200,
  605. GNUTLS_DTLS1_0 = 201, /* 201 */
  606. GNUTLS_DTLS1_2 = 202,
  607. GNUTLS_DTLS_VERSION_MIN = GNUTLS_DTLS0_9,
  608. GNUTLS_DTLS_VERSION_MAX = GNUTLS_DTLS1_2,
  609. GNUTLS_TLS_VERSION_MAX = GNUTLS_TLS1_2,
  610. GNUTLS_VERSION_UNKNOWN = 0xff /* change it to 0xffff */
  611. } gnutls_protocol_t;
  612. /**
  613. * gnutls_certificate_type_t:
  614. * @GNUTLS_CRT_UNKNOWN: Unknown certificate type.
  615. * @GNUTLS_CRT_X509: X.509 Certificate.
  616. * @GNUTLS_CRT_OPENPGP: OpenPGP certificate.
  617. * @GNUTLS_CRT_RAW: Raw public key (SubjectPublicKey)
  618. *
  619. * Enumeration of different certificate types.
  620. */
  621. typedef enum {
  622. GNUTLS_CRT_UNKNOWN = 0,
  623. GNUTLS_CRT_X509 = 1,
  624. GNUTLS_CRT_OPENPGP = 2,
  625. GNUTLS_CRT_RAW = 3
  626. } gnutls_certificate_type_t;
  627. /**
  628. * gnutls_x509_crt_fmt_t:
  629. * @GNUTLS_X509_FMT_DER: X.509 certificate in DER format (binary).
  630. * @GNUTLS_X509_FMT_PEM: X.509 certificate in PEM format (text).
  631. *
  632. * Enumeration of different certificate encoding formats.
  633. */
  634. typedef enum {
  635. GNUTLS_X509_FMT_DER = 0,
  636. GNUTLS_X509_FMT_PEM = 1
  637. } gnutls_x509_crt_fmt_t;
  638. /**
  639. * gnutls_certificate_print_formats_t:
  640. * @GNUTLS_CRT_PRINT_FULL: Full information about certificate.
  641. * @GNUTLS_CRT_PRINT_FULL_NUMBERS: Full information about certificate and include easy to parse public key parameters.
  642. * @GNUTLS_CRT_PRINT_COMPACT: Information about certificate name in one line, plus identification of the public key.
  643. * @GNUTLS_CRT_PRINT_ONELINE: Information about certificate in one line.
  644. * @GNUTLS_CRT_PRINT_UNSIGNED_FULL: All info for an unsigned certificate.
  645. *
  646. * Enumeration of different certificate printing variants.
  647. */
  648. typedef enum gnutls_certificate_print_formats {
  649. GNUTLS_CRT_PRINT_FULL = 0,
  650. GNUTLS_CRT_PRINT_ONELINE = 1,
  651. GNUTLS_CRT_PRINT_UNSIGNED_FULL = 2,
  652. GNUTLS_CRT_PRINT_COMPACT = 3,
  653. GNUTLS_CRT_PRINT_FULL_NUMBERS = 4
  654. } gnutls_certificate_print_formats_t;
  655. #define GNUTLS_PK_ECC GNUTLS_PK_ECDSA
  656. #define GNUTLS_PK_EC GNUTLS_PK_ECDSA
  657. #define GNUTLS_PK_ECDHX GNUTLS_PK_ECDH_X25519
  658. /**
  659. * gnutls_pk_algorithm_t:
  660. * @GNUTLS_PK_UNKNOWN: Unknown public-key algorithm.
  661. * @GNUTLS_PK_RSA: RSA public-key algorithm.
  662. * @GNUTLS_PK_RSA_PSS: RSA public-key algorithm, with PSS padding.
  663. * @GNUTLS_PK_DSA: DSA public-key algorithm.
  664. * @GNUTLS_PK_DH: Diffie-Hellman algorithm. Used to generate parameters.
  665. * @GNUTLS_PK_ECDSA: Elliptic curve algorithm. These parameters are compatible with the ECDSA and ECDH algorithm.
  666. * @GNUTLS_PK_ECDH_X25519: Elliptic curve algorithm, restricted to ECDH as per rfc7748.
  667. * @GNUTLS_PK_EDDSA_ED25519: Edwards curve Digital signature algorithm. Used with SHA512 on signatures.
  668. *
  669. * Enumeration of different public-key algorithms.
  670. */
  671. typedef enum {
  672. GNUTLS_PK_UNKNOWN = 0,
  673. GNUTLS_PK_RSA = 1,
  674. GNUTLS_PK_DSA = 2,
  675. GNUTLS_PK_DH = 3,
  676. GNUTLS_PK_ECDSA = 4,
  677. GNUTLS_PK_ECDH_X25519 = 5,
  678. GNUTLS_PK_RSA_PSS = 6,
  679. GNUTLS_PK_EDDSA_ED25519 = 7,
  680. GNUTLS_PK_MAX = GNUTLS_PK_EDDSA_ED25519
  681. } gnutls_pk_algorithm_t;
  682. const char *gnutls_pk_algorithm_get_name(gnutls_pk_algorithm_t algorithm);
  683. /**
  684. * gnutls_sign_algorithm_t:
  685. * @GNUTLS_SIGN_UNKNOWN: Unknown signature algorithm.
  686. * @GNUTLS_SIGN_RSA_RAW: Digital signature algorithm RSA with DigestInfo formatted data
  687. * @GNUTLS_SIGN_RSA_SHA1: Digital signature algorithm RSA with SHA-1
  688. * @GNUTLS_SIGN_RSA_SHA: Same as %GNUTLS_SIGN_RSA_SHA1.
  689. * @GNUTLS_SIGN_DSA_SHA1: Digital signature algorithm DSA with SHA-1
  690. * @GNUTLS_SIGN_DSA_SHA224: Digital signature algorithm DSA with SHA-224
  691. * @GNUTLS_SIGN_DSA_SHA256: Digital signature algorithm DSA with SHA-256
  692. * @GNUTLS_SIGN_DSA_SHA384: Digital signature algorithm DSA with SHA-384
  693. * @GNUTLS_SIGN_DSA_SHA512: Digital signature algorithm DSA with SHA-512
  694. * @GNUTLS_SIGN_DSA_SHA: Same as %GNUTLS_SIGN_DSA_SHA1.
  695. * @GNUTLS_SIGN_RSA_MD5: Digital signature algorithm RSA with MD5.
  696. * @GNUTLS_SIGN_RSA_MD2: Digital signature algorithm RSA with MD2.
  697. * @GNUTLS_SIGN_RSA_RMD160: Digital signature algorithm RSA with RMD-160.
  698. * @GNUTLS_SIGN_RSA_SHA256: Digital signature algorithm RSA with SHA-256.
  699. * @GNUTLS_SIGN_RSA_SHA384: Digital signature algorithm RSA with SHA-384.
  700. * @GNUTLS_SIGN_RSA_SHA512: Digital signature algorithm RSA with SHA-512.
  701. * @GNUTLS_SIGN_RSA_SHA224: Digital signature algorithm RSA with SHA-224.
  702. * @GNUTLS_SIGN_ECDSA_SHA1: ECDSA with SHA1.
  703. * @GNUTLS_SIGN_ECDSA_SHA224: Digital signature algorithm ECDSA with SHA-224.
  704. * @GNUTLS_SIGN_ECDSA_SHA256: Digital signature algorithm ECDSA with SHA-256.
  705. * @GNUTLS_SIGN_ECDSA_SHA384: Digital signature algorithm ECDSA with SHA-384.
  706. * @GNUTLS_SIGN_ECDSA_SHA512: Digital signature algorithm ECDSA with SHA-512.
  707. * @GNUTLS_SIGN_ECDSA_SHA3_224: Digital signature algorithm ECDSA with SHA3-224.
  708. * @GNUTLS_SIGN_ECDSA_SHA3_256: Digital signature algorithm ECDSA with SHA3-256.
  709. * @GNUTLS_SIGN_ECDSA_SHA3_384: Digital signature algorithm ECDSA with SHA3-384.
  710. * @GNUTLS_SIGN_ECDSA_SHA3_512: Digital signature algorithm ECDSA with SHA3-512.
  711. * @GNUTLS_SIGN_DSA_SHA3_224: Digital signature algorithm DSA with SHA3-224.
  712. * @GNUTLS_SIGN_DSA_SHA3_256: Digital signature algorithm DSA with SHA3-256.
  713. * @GNUTLS_SIGN_DSA_SHA3_384: Digital signature algorithm DSA with SHA3-384.
  714. * @GNUTLS_SIGN_DSA_SHA3_512: Digital signature algorithm DSA with SHA3-512.
  715. * @GNUTLS_SIGN_RSA_SHA3_224: Digital signature algorithm RSA with SHA3-224.
  716. * @GNUTLS_SIGN_RSA_SHA3_256: Digital signature algorithm RSA with SHA3-256.
  717. * @GNUTLS_SIGN_RSA_SHA3_384: Digital signature algorithm RSA with SHA3-384.
  718. * @GNUTLS_SIGN_RSA_SHA3_512: Digital signature algorithm RSA with SHA3-512.
  719. * @GNUTLS_SIGN_RSA_PSS_SHA256: Digital signature algorithm RSA with SHA-256, with PSS padding.
  720. * @GNUTLS_SIGN_RSA_PSS_SHA384: Digital signature algorithm RSA with SHA-384, with PSS padding.
  721. * @GNUTLS_SIGN_RSA_PSS_SHA512: Digital signature algorithm RSA with SHA-512, with PSS padding.
  722. * @GNUTLS_SIGN_EDDSA_ED25519: Digital signature algorithm EdDSA with Ed25519 curve.
  723. *
  724. * Enumeration of different digital signature algorithms.
  725. */
  726. typedef enum {
  727. GNUTLS_SIGN_UNKNOWN = 0,
  728. GNUTLS_SIGN_RSA_SHA1 = 1,
  729. GNUTLS_SIGN_RSA_SHA = GNUTLS_SIGN_RSA_SHA1,
  730. GNUTLS_SIGN_DSA_SHA1 = 2,
  731. GNUTLS_SIGN_DSA_SHA = GNUTLS_SIGN_DSA_SHA1,
  732. GNUTLS_SIGN_RSA_MD5 = 3,
  733. GNUTLS_SIGN_RSA_MD2 = 4,
  734. GNUTLS_SIGN_RSA_RMD160 = 5,
  735. GNUTLS_SIGN_RSA_SHA256 = 6,
  736. GNUTLS_SIGN_RSA_SHA384 = 7,
  737. GNUTLS_SIGN_RSA_SHA512 = 8,
  738. GNUTLS_SIGN_RSA_SHA224 = 9,
  739. GNUTLS_SIGN_DSA_SHA224 = 10,
  740. GNUTLS_SIGN_DSA_SHA256 = 11,
  741. GNUTLS_SIGN_ECDSA_SHA1 = 12,
  742. GNUTLS_SIGN_ECDSA_SHA224 = 13,
  743. GNUTLS_SIGN_ECDSA_SHA256 = 14,
  744. GNUTLS_SIGN_ECDSA_SHA384 = 15,
  745. GNUTLS_SIGN_ECDSA_SHA512 = 16,
  746. GNUTLS_SIGN_DSA_SHA384 = 17,
  747. GNUTLS_SIGN_DSA_SHA512 = 18,
  748. GNUTLS_SIGN_ECDSA_SHA3_224 = 20,
  749. GNUTLS_SIGN_ECDSA_SHA3_256 = 21,
  750. GNUTLS_SIGN_ECDSA_SHA3_384 = 22,
  751. GNUTLS_SIGN_ECDSA_SHA3_512 = 23,
  752. GNUTLS_SIGN_DSA_SHA3_224 = 24,
  753. GNUTLS_SIGN_DSA_SHA3_256 = 25,
  754. GNUTLS_SIGN_DSA_SHA3_384 = 26,
  755. GNUTLS_SIGN_DSA_SHA3_512 = 27,
  756. GNUTLS_SIGN_RSA_SHA3_224 = 28,
  757. GNUTLS_SIGN_RSA_SHA3_256 = 29,
  758. GNUTLS_SIGN_RSA_SHA3_384 = 30,
  759. GNUTLS_SIGN_RSA_SHA3_512 = 31,
  760. GNUTLS_SIGN_RSA_PSS_SHA256 = 32,
  761. GNUTLS_SIGN_RSA_PSS_SHA384 = 33,
  762. GNUTLS_SIGN_RSA_PSS_SHA512 = 34,
  763. GNUTLS_SIGN_EDDSA_ED25519 = 35,
  764. GNUTLS_SIGN_RSA_RAW = 36,
  765. GNUTLS_SIGN_MAX = GNUTLS_SIGN_RSA_RAW
  766. } gnutls_sign_algorithm_t;
  767. /**
  768. * gnutls_ecc_curve_t:
  769. * @GNUTLS_ECC_CURVE_INVALID: Cannot be known
  770. * @GNUTLS_ECC_CURVE_SECP192R1: the SECP192R1 curve
  771. * @GNUTLS_ECC_CURVE_SECP224R1: the SECP224R1 curve
  772. * @GNUTLS_ECC_CURVE_SECP256R1: the SECP256R1 curve
  773. * @GNUTLS_ECC_CURVE_SECP384R1: the SECP384R1 curve
  774. * @GNUTLS_ECC_CURVE_SECP521R1: the SECP521R1 curve
  775. * @GNUTLS_ECC_CURVE_X25519: the X25519 curve (ECDH only)
  776. * @GNUTLS_ECC_CURVE_ED25519: the Ed25519 curve
  777. *
  778. * Enumeration of ECC curves.
  779. */
  780. typedef enum {
  781. GNUTLS_ECC_CURVE_INVALID = 0,
  782. GNUTLS_ECC_CURVE_SECP224R1,
  783. GNUTLS_ECC_CURVE_SECP256R1,
  784. GNUTLS_ECC_CURVE_SECP384R1,
  785. GNUTLS_ECC_CURVE_SECP521R1,
  786. GNUTLS_ECC_CURVE_SECP192R1,
  787. GNUTLS_ECC_CURVE_X25519,
  788. GNUTLS_ECC_CURVE_ED25519,
  789. GNUTLS_ECC_CURVE_MAX = GNUTLS_ECC_CURVE_ED25519
  790. } gnutls_ecc_curve_t;
  791. /**
  792. * gnutls_group_t:
  793. * @GNUTLS_GROUP_INVALID: Indicates unknown/invalid group
  794. * @GNUTLS_GROUP_SECP192R1: the SECP192R1 curve group (legacy, only for TLS 1.2 compatibility)
  795. * @GNUTLS_GROUP_SECP224R1: the SECP224R1 curve group (legacy, only for TLS 1.2 compatibility)
  796. * @GNUTLS_GROUP_SECP256R1: the SECP256R1 curve group
  797. * @GNUTLS_GROUP_SECP384R1: the SECP384R1 curve group
  798. * @GNUTLS_GROUP_SECP521R1: the SECP521R1 curve group
  799. * @GNUTLS_GROUP_X25519: the X25519 curve group
  800. * @GNUTLS_GROUP_FFDHE2048: the FFDHE2048 group
  801. * @GNUTLS_GROUP_FFDHE3072: the FFDHE3072 group
  802. * @GNUTLS_GROUP_FFDHE4096: the FFDHE4096 group
  803. * @GNUTLS_GROUP_FFDHE8192: the FFDHE8192 group
  804. *
  805. * Enumeration of supported groups. It is intended to be backwards
  806. * compatible with the enumerations in %gnutls_ecc_curve_t for the groups
  807. * which are valid elliptic curves.
  808. */
  809. typedef enum {
  810. GNUTLS_GROUP_INVALID = 0,
  811. GNUTLS_GROUP_SECP192R1 = GNUTLS_ECC_CURVE_SECP192R1,
  812. GNUTLS_GROUP_SECP224R1 = GNUTLS_ECC_CURVE_SECP224R1,
  813. GNUTLS_GROUP_SECP256R1 = GNUTLS_ECC_CURVE_SECP256R1,
  814. GNUTLS_GROUP_SECP384R1 = GNUTLS_ECC_CURVE_SECP384R1,
  815. GNUTLS_GROUP_SECP521R1 = GNUTLS_ECC_CURVE_SECP521R1,
  816. GNUTLS_GROUP_X25519 = GNUTLS_ECC_CURVE_X25519,
  817. GNUTLS_GROUP_FFDHE2048 = 256,
  818. GNUTLS_GROUP_FFDHE3072,
  819. GNUTLS_GROUP_FFDHE4096,
  820. GNUTLS_GROUP_FFDHE8192,
  821. GNUTLS_GROUP_MAX = GNUTLS_GROUP_FFDHE8192,
  822. } gnutls_group_t;
  823. /* macros to allow specifying a specific curve in gnutls_privkey_generate()
  824. * and gnutls_x509_privkey_generate() */
  825. #define GNUTLS_CURVE_TO_BITS(curve) (unsigned int)(((unsigned int)1<<31)|((unsigned int)(curve)))
  826. #define GNUTLS_BITS_TO_CURVE(bits) (((unsigned int)(bits)) & 0x7FFFFFFF)
  827. #define GNUTLS_BITS_ARE_CURVE(bits) (((unsigned int)(bits)) & 0x80000000)
  828. /**
  829. * gnutls_sec_param_t:
  830. * @GNUTLS_SEC_PARAM_UNKNOWN: Cannot be known
  831. * @GNUTLS_SEC_PARAM_INSECURE: Less than 42 bits of security
  832. * @GNUTLS_SEC_PARAM_EXPORT: 42 bits of security
  833. * @GNUTLS_SEC_PARAM_VERY_WEAK: 64 bits of security
  834. * @GNUTLS_SEC_PARAM_WEAK: 72 bits of security
  835. * @GNUTLS_SEC_PARAM_LOW: 80 bits of security
  836. * @GNUTLS_SEC_PARAM_LEGACY: 96 bits of security
  837. * @GNUTLS_SEC_PARAM_MEDIUM: 112 bits of security (used to be %GNUTLS_SEC_PARAM_NORMAL)
  838. * @GNUTLS_SEC_PARAM_HIGH: 128 bits of security
  839. * @GNUTLS_SEC_PARAM_ULTRA: 192 bits of security
  840. * @GNUTLS_SEC_PARAM_FUTURE: 256 bits of security
  841. *
  842. * Enumeration of security parameters for passive attacks.
  843. */
  844. typedef enum {
  845. GNUTLS_SEC_PARAM_UNKNOWN = 0,
  846. GNUTLS_SEC_PARAM_INSECURE = 5,
  847. GNUTLS_SEC_PARAM_EXPORT = 10,
  848. GNUTLS_SEC_PARAM_VERY_WEAK = 15,
  849. GNUTLS_SEC_PARAM_WEAK = 20,
  850. GNUTLS_SEC_PARAM_LOW = 25,
  851. GNUTLS_SEC_PARAM_LEGACY = 30,
  852. GNUTLS_SEC_PARAM_MEDIUM = 35,
  853. GNUTLS_SEC_PARAM_HIGH = 40,
  854. GNUTLS_SEC_PARAM_ULTRA = 45,
  855. GNUTLS_SEC_PARAM_FUTURE = 50,
  856. GNUTLS_SEC_PARAM_MAX = GNUTLS_SEC_PARAM_FUTURE
  857. } gnutls_sec_param_t;
  858. /* old name */
  859. #define GNUTLS_SEC_PARAM_NORMAL GNUTLS_SEC_PARAM_MEDIUM
  860. /**
  861. * gnutls_channel_binding_t:
  862. * @GNUTLS_CB_TLS_UNIQUE: "tls-unique" (RFC 5929) channel binding
  863. *
  864. * Enumeration of support channel binding types.
  865. */
  866. typedef enum {
  867. GNUTLS_CB_TLS_UNIQUE
  868. } gnutls_channel_binding_t;
  869. /* If you want to change this, then also change the define in
  870. * gnutls_int.h, and recompile.
  871. */
  872. typedef void *gnutls_transport_ptr_t;
  873. struct gnutls_session_int;
  874. typedef struct gnutls_session_int *gnutls_session_t;
  875. struct gnutls_dh_params_int;
  876. typedef struct gnutls_dh_params_int *gnutls_dh_params_t;
  877. /* XXX ugly. */
  878. struct gnutls_x509_privkey_int;
  879. typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;
  880. struct gnutls_priority_st;
  881. typedef struct gnutls_priority_st *gnutls_priority_t;
  882. typedef struct {
  883. unsigned char *data;
  884. unsigned int size;
  885. } gnutls_datum_t;
  886. typedef struct gnutls_params_st {
  887. gnutls_params_type_t type;
  888. union params {
  889. gnutls_dh_params_t dh;
  890. gnutls_rsa_params_t rsa_export;
  891. } params;
  892. int deinit;
  893. } gnutls_params_st;
  894. typedef int gnutls_params_function(gnutls_session_t, gnutls_params_type_t,
  895. gnutls_params_st *);
  896. /* internal functions */
  897. int gnutls_init(gnutls_session_t * session, unsigned int flags);
  898. void gnutls_deinit(gnutls_session_t session);
  899. #define _gnutls_deinit(x) gnutls_deinit(x)
  900. int gnutls_bye(gnutls_session_t session, gnutls_close_request_t how);
  901. int gnutls_handshake(gnutls_session_t session);
  902. #define GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT ((unsigned int)-1)
  903. #define GNUTLS_INDEFINITE_TIMEOUT ((unsigned int)-2)
  904. void gnutls_handshake_set_timeout(gnutls_session_t session,
  905. unsigned int ms);
  906. int gnutls_rehandshake(gnutls_session_t session);
  907. gnutls_alert_description_t gnutls_alert_get(gnutls_session_t session);
  908. int gnutls_alert_send(gnutls_session_t session,
  909. gnutls_alert_level_t level,
  910. gnutls_alert_description_t desc);
  911. int gnutls_alert_send_appropriate(gnutls_session_t session, int err);
  912. const char *gnutls_alert_get_name(gnutls_alert_description_t alert);
  913. const char *gnutls_alert_get_strname(gnutls_alert_description_t alert);
  914. gnutls_sec_param_t gnutls_pk_bits_to_sec_param(gnutls_pk_algorithm_t algo,
  915. unsigned int bits);
  916. const char *gnutls_sec_param_get_name(gnutls_sec_param_t param);
  917. unsigned int gnutls_sec_param_to_pk_bits(gnutls_pk_algorithm_t algo,
  918. gnutls_sec_param_t param);
  919. unsigned int
  920. gnutls_sec_param_to_symmetric_bits(gnutls_sec_param_t param) __GNUTLS_CONST__;
  921. /* Elliptic curves */
  922. const char *
  923. gnutls_ecc_curve_get_name(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;
  924. const char *
  925. gnutls_ecc_curve_get_oid(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;
  926. const char *
  927. gnutls_group_get_name(gnutls_group_t group) __GNUTLS_CONST__;
  928. int
  929. gnutls_ecc_curve_get_size(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;
  930. gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
  931. gnutls_group_t gnutls_group_get(gnutls_session_t session);
  932. /* get information on the current session */
  933. gnutls_cipher_algorithm_t gnutls_cipher_get(gnutls_session_t session);
  934. gnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session);
  935. gnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session);
  936. gnutls_certificate_type_t
  937. gnutls_certificate_type_get(gnutls_session_t session);
  938. int gnutls_sign_algorithm_get(gnutls_session_t session);
  939. int gnutls_sign_algorithm_get_client(gnutls_session_t session);
  940. int gnutls_sign_algorithm_get_requested(gnutls_session_t session,
  941. size_t indx,
  942. gnutls_sign_algorithm_t * algo);
  943. /* the name of the specified algorithms */
  944. const char *
  945. gnutls_cipher_get_name(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;
  946. const char *
  947. gnutls_mac_get_name(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;
  948. const char *
  949. gnutls_digest_get_name(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;
  950. const char *
  951. gnutls_digest_get_oid(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;
  952. const char *
  953. gnutls_kx_get_name(gnutls_kx_algorithm_t algorithm) __GNUTLS_CONST__;
  954. const char *
  955. gnutls_certificate_type_get_name(gnutls_certificate_type_t
  956. type) __GNUTLS_CONST__;
  957. const char *
  958. gnutls_pk_get_name(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;
  959. const char *
  960. gnutls_pk_get_oid(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;
  961. const char *
  962. gnutls_sign_get_name(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;
  963. const char *gnutls_sign_get_oid(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;
  964. size_t
  965. gnutls_cipher_get_key_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;
  966. size_t
  967. gnutls_mac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;
  968. unsigned gnutls_sign_is_secure(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;
  969. /* It is possible that a signature algorithm is ok to use for short-lived
  970. * data (e.g., to sign a TLS session), but not for data that are long-lived
  971. * like certificates. This flag is about checking the security of the algorithm
  972. * for long-lived data. */
  973. #define GNUTLS_SIGN_FLAG_SECURE_FOR_CERTS 1
  974. unsigned gnutls_sign_is_secure2(gnutls_sign_algorithm_t algorithm, unsigned int flags) __GNUTLS_CONST__;
  975. gnutls_digest_algorithm_t
  976. gnutls_sign_get_hash_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;
  977. gnutls_pk_algorithm_t
  978. gnutls_sign_get_pk_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;
  979. gnutls_sign_algorithm_t
  980. gnutls_pk_to_sign(gnutls_pk_algorithm_t pk,
  981. gnutls_digest_algorithm_t hash) __GNUTLS_CONST__;
  982. unsigned
  983. gnutls_sign_supports_pk_algorithm(gnutls_sign_algorithm_t sign, gnutls_pk_algorithm_t pk) __GNUTLS_CONST__;
  984. #define gnutls_sign_algorithm_get_name gnutls_sign_get_name
  985. gnutls_mac_algorithm_t gnutls_mac_get_id(const char *name) __GNUTLS_CONST__;
  986. gnutls_digest_algorithm_t gnutls_digest_get_id(const char *name) __GNUTLS_CONST__;
  987. gnutls_cipher_algorithm_t
  988. gnutls_cipher_get_id(const char *name) __GNUTLS_CONST__;
  989. gnutls_kx_algorithm_t
  990. gnutls_kx_get_id(const char *name) __GNUTLS_CONST__;
  991. gnutls_protocol_t
  992. gnutls_protocol_get_id(const char *name) __GNUTLS_CONST__;
  993. gnutls_certificate_type_t
  994. gnutls_certificate_type_get_id(const char *name) __GNUTLS_CONST__;
  995. gnutls_pk_algorithm_t
  996. gnutls_pk_get_id(const char *name) __GNUTLS_CONST__;
  997. gnutls_sign_algorithm_t
  998. gnutls_sign_get_id(const char *name) __GNUTLS_CONST__;
  999. gnutls_ecc_curve_t gnutls_ecc_curve_get_id(const char *name) __GNUTLS_CONST__;
  1000. gnutls_pk_algorithm_t gnutls_ecc_curve_get_pk(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;
  1001. gnutls_group_t gnutls_group_get_id(const char *name);
  1002. gnutls_digest_algorithm_t
  1003. gnutls_oid_to_digest(const char *oid) __GNUTLS_CONST__;
  1004. gnutls_mac_algorithm_t
  1005. gnutls_oid_to_mac(const char *oid) __GNUTLS_CONST__;
  1006. gnutls_pk_algorithm_t
  1007. gnutls_oid_to_pk(const char *oid) __GNUTLS_CONST__;
  1008. gnutls_sign_algorithm_t
  1009. gnutls_oid_to_sign(const char *oid) __GNUTLS_CONST__;
  1010. gnutls_ecc_curve_t
  1011. gnutls_oid_to_ecc_curve(const char *oid) __GNUTLS_CONST__;
  1012. /* list supported algorithms */
  1013. const gnutls_ecc_curve_t *
  1014. gnutls_ecc_curve_list(void) __GNUTLS_PURE__;
  1015. const gnutls_group_t *
  1016. gnutls_group_list(void) __GNUTLS_PURE__;
  1017. const gnutls_cipher_algorithm_t *
  1018. gnutls_cipher_list(void) __GNUTLS_PURE__;
  1019. const gnutls_mac_algorithm_t *
  1020. gnutls_mac_list(void) __GNUTLS_PURE__;
  1021. const gnutls_digest_algorithm_t *
  1022. gnutls_digest_list(void) __GNUTLS_PURE__;
  1023. const gnutls_protocol_t *
  1024. gnutls_protocol_list(void) __GNUTLS_PURE__;
  1025. const gnutls_certificate_type_t *
  1026. gnutls_certificate_type_list(void) __GNUTLS_PURE__;
  1027. const gnutls_kx_algorithm_t *
  1028. gnutls_kx_list(void) __GNUTLS_PURE__;
  1029. const gnutls_pk_algorithm_t *
  1030. gnutls_pk_list(void) __GNUTLS_PURE__;
  1031. const gnutls_sign_algorithm_t *
  1032. gnutls_sign_list(void) __GNUTLS_PURE__;
  1033. const char *
  1034. gnutls_cipher_suite_info(size_t idx,
  1035. unsigned char *cs_id,
  1036. gnutls_kx_algorithm_t * kx,
  1037. gnutls_cipher_algorithm_t * cipher,
  1038. gnutls_mac_algorithm_t * mac,
  1039. gnutls_protocol_t * min_version);
  1040. /* error functions */
  1041. int gnutls_error_is_fatal(int error) __GNUTLS_CONST__;
  1042. int gnutls_error_to_alert(int err, int *level);
  1043. void gnutls_perror(int error);
  1044. const char * gnutls_strerror(int error) __GNUTLS_CONST__;
  1045. const char * gnutls_strerror_name(int error) __GNUTLS_CONST__;
  1046. /* Semi-internal functions.
  1047. */
  1048. void gnutls_handshake_set_private_extensions(gnutls_session_t session,
  1049. int allow);
  1050. int gnutls_handshake_set_random(gnutls_session_t session,
  1051. const gnutls_datum_t * random);
  1052. gnutls_handshake_description_t
  1053. gnutls_handshake_get_last_out(gnutls_session_t session);
  1054. gnutls_handshake_description_t
  1055. gnutls_handshake_get_last_in(gnutls_session_t session);
  1056. /* Record layer functions.
  1057. */
  1058. #define GNUTLS_HEARTBEAT_WAIT 1
  1059. int gnutls_heartbeat_ping(gnutls_session_t session, size_t data_size,
  1060. unsigned int max_tries, unsigned int flags);
  1061. int gnutls_heartbeat_pong(gnutls_session_t session, unsigned int flags);
  1062. void gnutls_record_set_timeout(gnutls_session_t session, unsigned int ms);
  1063. void gnutls_record_disable_padding(gnutls_session_t session);
  1064. void gnutls_record_cork(gnutls_session_t session);
  1065. #define GNUTLS_RECORD_WAIT 1
  1066. int gnutls_record_uncork(gnutls_session_t session, unsigned int flags);
  1067. size_t gnutls_record_discard_queued(gnutls_session_t session);
  1068. int
  1069. gnutls_record_get_state(gnutls_session_t session,
  1070. unsigned read,
  1071. gnutls_datum_t *mac_key,
  1072. gnutls_datum_t *IV,
  1073. gnutls_datum_t *cipher_key,
  1074. unsigned char seq_number[8]);
  1075. int
  1076. gnutls_record_set_state(gnutls_session_t session,
  1077. unsigned read,
  1078. unsigned char seq_number[8]);
  1079. typedef struct {
  1080. size_t low;
  1081. size_t high;
  1082. } gnutls_range_st;
  1083. int gnutls_range_split(gnutls_session_t session,
  1084. const gnutls_range_st * orig,
  1085. gnutls_range_st * small_range,
  1086. gnutls_range_st * rem_range);
  1087. ssize_t gnutls_record_send(gnutls_session_t session, const void *data,
  1088. size_t data_size);
  1089. ssize_t gnutls_record_send_range(gnutls_session_t session,
  1090. const void *data, size_t data_size,
  1091. const gnutls_range_st * range);
  1092. ssize_t gnutls_record_recv(gnutls_session_t session, void *data,
  1093. size_t data_size);
  1094. typedef struct mbuffer_st *gnutls_packet_t;
  1095. ssize_t
  1096. gnutls_record_recv_packet(gnutls_session_t session,
  1097. gnutls_packet_t *packet);
  1098. void gnutls_packet_get(gnutls_packet_t packet, gnutls_datum_t *data, unsigned char *sequence);
  1099. void gnutls_packet_deinit(gnutls_packet_t packet);
  1100. #define gnutls_read gnutls_record_recv
  1101. #define gnutls_write gnutls_record_send
  1102. ssize_t gnutls_record_recv_seq(gnutls_session_t session, void *data,
  1103. size_t data_size, unsigned char *seq);
  1104. size_t gnutls_record_overhead_size(gnutls_session_t session);
  1105. size_t
  1106. gnutls_est_record_overhead_size(gnutls_protocol_t version,
  1107. gnutls_cipher_algorithm_t cipher,
  1108. gnutls_mac_algorithm_t mac,
  1109. gnutls_compression_method_t comp,
  1110. unsigned int flags) __GNUTLS_CONST__;
  1111. void gnutls_session_enable_compatibility_mode(gnutls_session_t session);
  1112. #define gnutls_record_set_max_empty_records(session, x)
  1113. int gnutls_record_can_use_length_hiding(gnutls_session_t session);
  1114. int gnutls_record_get_direction(gnutls_session_t session);
  1115. size_t gnutls_record_get_max_size(gnutls_session_t session);
  1116. ssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size);
  1117. size_t gnutls_record_check_pending(gnutls_session_t session);
  1118. size_t gnutls_record_check_corked(gnutls_session_t session);
  1119. void gnutls_session_force_valid(gnutls_session_t session);
  1120. int gnutls_prf(gnutls_session_t session,
  1121. size_t label_size, const char *label,
  1122. int server_random_first,
  1123. size_t extra_size, const char *extra,
  1124. size_t outsize, char *out);
  1125. int gnutls_prf_rfc5705(gnutls_session_t session,
  1126. size_t label_size, const char *label,
  1127. size_t context_size, const char *context,
  1128. size_t outsize, char *out);
  1129. int gnutls_prf_raw(gnutls_session_t session,
  1130. size_t label_size, const char *label,
  1131. size_t seed_size, const char *seed,
  1132. size_t outsize, char *out);
  1133. /**
  1134. * gnutls_server_name_type_t:
  1135. * @GNUTLS_NAME_DNS: Domain Name System name type.
  1136. *
  1137. * Enumeration of different server name types.
  1138. */
  1139. typedef enum {
  1140. GNUTLS_NAME_DNS = 1
  1141. } gnutls_server_name_type_t;
  1142. int gnutls_server_name_set(gnutls_session_t session,
  1143. gnutls_server_name_type_t type,
  1144. const void *name, size_t name_length);
  1145. int gnutls_server_name_get(gnutls_session_t session,
  1146. void *data, size_t * data_length,
  1147. unsigned int *type, unsigned int indx);
  1148. unsigned int gnutls_heartbeat_get_timeout(gnutls_session_t session);
  1149. void gnutls_heartbeat_set_timeouts(gnutls_session_t session,
  1150. unsigned int retrans_timeout,
  1151. unsigned int total_timeout);
  1152. #define GNUTLS_HB_PEER_ALLOWED_TO_SEND (1)
  1153. #define GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND (1<<1)
  1154. /* Heartbeat */
  1155. void gnutls_heartbeat_enable(gnutls_session_t session, unsigned int type);
  1156. #define GNUTLS_HB_LOCAL_ALLOWED_TO_SEND (1<<2)
  1157. unsigned gnutls_heartbeat_allowed(gnutls_session_t session, unsigned int type);
  1158. /* Safe renegotiation */
  1159. unsigned gnutls_safe_renegotiation_status(gnutls_session_t session);
  1160. unsigned gnutls_session_ext_master_secret_status(gnutls_session_t session);
  1161. unsigned gnutls_session_etm_status(gnutls_session_t session);
  1162. /**
  1163. * gnutls_session_flags_t:
  1164. * @GNUTLS_SFLAGS_SAFE_RENEGOTIATION: Safe renegotiation (RFC5746) was used
  1165. * @GNUTLS_SFLAGS_EXT_MASTER_SECRET: The extended master secret (RFC7627) extension was used
  1166. * @GNUTLS_SFLAGS_ETM: The encrypt then MAC (RFC7366) extension was used
  1167. * @GNUTLS_SFLAGS_RFC7919: The RFC7919 Diffie-Hellman parameters were negotiated
  1168. * @GNUTLS_SFLAGS_HB_LOCAL_SEND: The heartbeat negotiation allows the local side to send heartbeat messages
  1169. * @GNUTLS_SFLAGS_HB_PEER_SEND: The heartbeat negotiation allows the peer to send heartbeat messages
  1170. * @GNUTLS_SFLAGS_FALSE_START: The appdata set with gnutls_handshake_set_appdata() were sent during handshake (false start)
  1171. *
  1172. * Enumeration of different session parameters.
  1173. */
  1174. typedef enum {
  1175. GNUTLS_SFLAGS_SAFE_RENEGOTIATION = 1,
  1176. GNUTLS_SFLAGS_EXT_MASTER_SECRET = 1<<1,
  1177. GNUTLS_SFLAGS_ETM = 1<<2,
  1178. GNUTLS_SFLAGS_HB_LOCAL_SEND = 1<<3,
  1179. GNUTLS_SFLAGS_HB_PEER_SEND = 1<<4,
  1180. GNUTLS_SFLAGS_FALSE_START = 1<<5,
  1181. GNUTLS_SFLAGS_RFC7919 = 1<<6
  1182. } gnutls_session_flags_t;
  1183. unsigned gnutls_session_get_flags(gnutls_session_t session);
  1184. /**
  1185. * gnutls_supplemental_data_format_type_t:
  1186. * @GNUTLS_SUPPLEMENTAL_UNKNOWN: Unknown data format
  1187. *
  1188. * Enumeration of different supplemental data types (RFC 4680).
  1189. */
  1190. typedef enum {
  1191. GNUTLS_SUPPLEMENTAL_UNKNOWN = 0,
  1192. } gnutls_supplemental_data_format_type_t;
  1193. const char
  1194. *gnutls_supplemental_get_name(gnutls_supplemental_data_format_type_t type);
  1195. /* SessionTicket, RFC 5077. */
  1196. int gnutls_session_ticket_key_generate(gnutls_datum_t * key);
  1197. int gnutls_session_ticket_enable_client(gnutls_session_t session);
  1198. int gnutls_session_ticket_enable_server(gnutls_session_t session,
  1199. const gnutls_datum_t * key);
  1200. /* SRTP, RFC 5764 */
  1201. /**
  1202. * gnutls_srtp_profile_t:
  1203. * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80: 128 bit AES with a 80 bit HMAC-SHA1
  1204. * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32: 128 bit AES with a 32 bit HMAC-SHA1
  1205. * @GNUTLS_SRTP_NULL_HMAC_SHA1_80: NULL cipher with a 80 bit HMAC-SHA1
  1206. * @GNUTLS_SRTP_NULL_HMAC_SHA1_32: NULL cipher with a 32 bit HMAC-SHA1
  1207. *
  1208. * Enumeration of different SRTP protection profiles.
  1209. */
  1210. typedef enum {
  1211. GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80 = 0x0001,
  1212. GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002,
  1213. GNUTLS_SRTP_NULL_HMAC_SHA1_80 = 0x0005,
  1214. GNUTLS_SRTP_NULL_HMAC_SHA1_32 = 0x0006
  1215. } gnutls_srtp_profile_t;
  1216. int gnutls_srtp_set_profile(gnutls_session_t session,
  1217. gnutls_srtp_profile_t profile);
  1218. int gnutls_srtp_set_profile_direct(gnutls_session_t session,
  1219. const char *profiles,
  1220. const char **err_pos);
  1221. int gnutls_srtp_get_selected_profile(gnutls_session_t session,
  1222. gnutls_srtp_profile_t * profile);
  1223. const char *gnutls_srtp_get_profile_name(gnutls_srtp_profile_t profile);
  1224. int gnutls_srtp_get_profile_id(const char *name,
  1225. gnutls_srtp_profile_t * profile);
  1226. int gnutls_srtp_get_keys(gnutls_session_t session,
  1227. void *key_material,
  1228. unsigned int key_material_size,
  1229. gnutls_datum_t * client_key,
  1230. gnutls_datum_t * client_salt,
  1231. gnutls_datum_t * server_key,
  1232. gnutls_datum_t * server_salt);
  1233. int gnutls_srtp_set_mki(gnutls_session_t session,
  1234. const gnutls_datum_t * mki);
  1235. int gnutls_srtp_get_mki(gnutls_session_t session, gnutls_datum_t * mki);
  1236. /* ALPN TLS extension */
  1237. /**
  1238. * gnutls_alpn_flags_t:
  1239. * @GNUTLS_ALPN_MANDATORY: Require ALPN negotiation. The connection will be
  1240. * aborted if no matching ALPN protocol is found.
  1241. * @GNUTLS_ALPN_SERVER_PRECEDENCE: The choices set by the server
  1242. * will take precedence over the client's.
  1243. *
  1244. * Enumeration of different ALPN flags. These are used by gnutls_alpn_set_protocols().
  1245. */
  1246. typedef enum {
  1247. GNUTLS_ALPN_MANDATORY = 1,
  1248. GNUTLS_ALPN_SERVER_PRECEDENCE = (1<<1)
  1249. } gnutls_alpn_flags_t;
  1250. #define GNUTLS_ALPN_MAND GNUTLS_ALPN_MANDATORY
  1251. int gnutls_alpn_get_selected_protocol(gnutls_session_t session,
  1252. gnutls_datum_t * protocol);
  1253. int gnutls_alpn_set_protocols(gnutls_session_t session,
  1254. const gnutls_datum_t * protocols,
  1255. unsigned protocols_size, unsigned flags);
  1256. int gnutls_key_generate(gnutls_datum_t * key, unsigned int key_size);
  1257. /* if you just want some defaults, use the following.
  1258. */
  1259. int gnutls_priority_init(gnutls_priority_t * priority_cache,
  1260. const char *priorities, const char **err_pos);
  1261. void gnutls_priority_deinit(gnutls_priority_t priority_cache);
  1262. int gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,
  1263. unsigned int idx,
  1264. unsigned int *sidx);
  1265. #define GNUTLS_PRIORITY_LIST_INIT_KEYWORDS 1
  1266. #define GNUTLS_PRIORITY_LIST_SPECIAL 2
  1267. const char *
  1268. gnutls_priority_string_list(unsigned iter, unsigned int flags);
  1269. int gnutls_priority_set(gnutls_session_t session,
  1270. gnutls_priority_t priority);
  1271. int gnutls_priority_set_direct(gnutls_session_t session,
  1272. const char *priorities,
  1273. const char **err_pos);
  1274. int gnutls_priority_certificate_type_list(gnutls_priority_t pcache,
  1275. const unsigned int **list);
  1276. int gnutls_priority_sign_list(gnutls_priority_t pcache,
  1277. const unsigned int **list);
  1278. int gnutls_priority_protocol_list(gnutls_priority_t pcache,
  1279. const unsigned int **list);
  1280. int gnutls_priority_ecc_curve_list(gnutls_priority_t pcache,
  1281. const unsigned int **list);
  1282. int
  1283. gnutls_priority_group_list(gnutls_priority_t pcache,
  1284. const unsigned int **list);
  1285. int gnutls_priority_kx_list(gnutls_priority_t pcache,
  1286. const unsigned int **list);
  1287. int gnutls_priority_cipher_list(gnutls_priority_t pcache,
  1288. const unsigned int **list);
  1289. int gnutls_priority_mac_list(gnutls_priority_t pcache,
  1290. const unsigned int **list);
  1291. /* for compatibility
  1292. */
  1293. int gnutls_set_default_priority(gnutls_session_t session);
  1294. /* Returns the name of a cipher suite */
  1295. const char *
  1296. gnutls_cipher_suite_get_name(gnutls_kx_algorithm_t kx_algorithm,
  1297. gnutls_cipher_algorithm_t cipher_algorithm,
  1298. gnutls_mac_algorithm_t mac_algorithm) __GNUTLS_CONST__;
  1299. /* get the currently used protocol version */
  1300. gnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session);
  1301. const char *
  1302. gnutls_protocol_get_name(gnutls_protocol_t version) __GNUTLS_CONST__;
  1303. /* get/set session
  1304. */
  1305. int gnutls_session_set_data(gnutls_session_t session,
  1306. const void *session_data,
  1307. size_t session_data_size);
  1308. int gnutls_session_get_data(gnutls_session_t session, void *session_data,
  1309. size_t * session_data_size);
  1310. int gnutls_session_get_data2(gnutls_session_t session,
  1311. gnutls_datum_t * data);
  1312. void gnutls_session_get_random(gnutls_session_t session,
  1313. gnutls_datum_t * client,
  1314. gnutls_datum_t * server);
  1315. void gnutls_session_get_master_secret(gnutls_session_t session,
  1316. gnutls_datum_t * secret);
  1317. char *gnutls_session_get_desc(gnutls_session_t session);
  1318. typedef int gnutls_certificate_verify_function(gnutls_session_t);
  1319. void gnutls_session_set_verify_function(gnutls_session_t session, gnutls_certificate_verify_function * func);
  1320. /**
  1321. * gnutls_vdata_types_t:
  1322. * @GNUTLS_DT_UNKNOWN: Unknown data type.
  1323. * @GNUTLS_DT_DNS_HOSTNAME: The data contain a null-terminated DNS hostname; the hostname will be
  1324. * matched using the RFC6125 rules. If the data contain a textual IP (v4 or v6) address it will
  1325. * be marched against the IPAddress Alternative name, unless the verification flag %GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES
  1326. * is specified.
  1327. * @GNUTLS_DT_IP_ADDRESS: The data contain a raw IP address (4 or 16 bytes). If will be matched
  1328. * against the IPAddress Alternative name; option available since 3.6.0.
  1329. * @GNUTLS_DT_RFC822NAME: The data contain a null-terminated email address; the email will be
  1330. * matched against the RFC822Name Alternative name of the certificate, or the EMAIL DN component if the
  1331. * former isn't available. Prior to matching the email address will be converted to ACE
  1332. * (ASCII-compatible-encoding).
  1333. * @GNUTLS_DT_KEY_PURPOSE_OID: The data contain a null-terminated key purpose OID. It will be matched
  1334. * against the certificate's Extended Key Usage extension.
  1335. *
  1336. * Enumeration of different typed-data options. They are used as input to certificate
  1337. * verification functions to provide information about the name and purpose of the
  1338. * certificate. Only a single option of a type can be provided to the relevant functions
  1339. * (i.e., options %GNUTLS_DT_DNS_HOSTNAME, %GNUTLS_DT_IP_ADDRESS and
  1340. * %GNUTLS_DT_RFC822NAME cannot be combined).
  1341. */
  1342. typedef enum {
  1343. GNUTLS_DT_UNKNOWN = 0,
  1344. GNUTLS_DT_DNS_HOSTNAME = 1,
  1345. GNUTLS_DT_KEY_PURPOSE_OID = 2,
  1346. GNUTLS_DT_RFC822NAME = 3,
  1347. GNUTLS_DT_IP_ADDRESS = 4
  1348. } gnutls_vdata_types_t;
  1349. typedef struct {
  1350. gnutls_vdata_types_t type;
  1351. unsigned char *data;
  1352. unsigned int size;
  1353. } gnutls_typed_vdata_st;
  1354. void gnutls_session_set_verify_cert(gnutls_session_t session,
  1355. const char *hostname, unsigned flags);
  1356. void
  1357. gnutls_session_set_verify_cert2(gnutls_session_t session,
  1358. gnutls_typed_vdata_st * data,
  1359. unsigned elements, unsigned flags);
  1360. unsigned int gnutls_session_get_verify_cert_status(gnutls_session_t);
  1361. int gnutls_session_set_premaster(gnutls_session_t session,
  1362. unsigned int entity,
  1363. gnutls_protocol_t version,
  1364. gnutls_kx_algorithm_t kx,
  1365. gnutls_cipher_algorithm_t cipher,
  1366. gnutls_mac_algorithm_t mac,
  1367. gnutls_compression_method_t comp,
  1368. const gnutls_datum_t * master,
  1369. const gnutls_datum_t * session_id);
  1370. /* returns the session ID */
  1371. #define GNUTLS_MAX_SESSION_ID 32
  1372. int gnutls_session_get_id(gnutls_session_t session, void *session_id,
  1373. size_t * session_id_size);
  1374. int gnutls_session_get_id2(gnutls_session_t session,
  1375. gnutls_datum_t * session_id);
  1376. int gnutls_session_set_id(gnutls_session_t session,
  1377. const gnutls_datum_t * sid);
  1378. int gnutls_session_channel_binding(gnutls_session_t session,
  1379. gnutls_channel_binding_t cbtype,
  1380. gnutls_datum_t * cb);
  1381. /* checks if this session is a resumed one
  1382. */
  1383. int gnutls_session_is_resumed(gnutls_session_t session);
  1384. int gnutls_session_resumption_requested(gnutls_session_t session);
  1385. typedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,
  1386. gnutls_datum_t data);
  1387. typedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);
  1388. typedef gnutls_datum_t(*gnutls_db_retr_func) (void *, gnutls_datum_t key);
  1389. void gnutls_db_set_cache_expiration(gnutls_session_t session, int seconds);
  1390. unsigned gnutls_db_get_default_cache_expiration(void);
  1391. void gnutls_db_remove_session(gnutls_session_t session);
  1392. void gnutls_db_set_retrieve_function(gnutls_session_t session,
  1393. gnutls_db_retr_func retr_func);
  1394. void gnutls_db_set_remove_function(gnutls_session_t session,
  1395. gnutls_db_remove_func rem_func);
  1396. void gnutls_db_set_store_function(gnutls_session_t session,
  1397. gnutls_db_store_func store_func);
  1398. void gnutls_db_set_ptr(gnutls_session_t session, void *ptr);
  1399. void *gnutls_db_get_ptr(gnutls_session_t session);
  1400. int gnutls_db_check_entry(gnutls_session_t session,
  1401. gnutls_datum_t session_entry);
  1402. time_t gnutls_db_check_entry_time(gnutls_datum_t * entry);
  1403. /**
  1404. * gnutls_handshake_hook_func:
  1405. * @session: the current session
  1406. * @htype: the type of the handshake message (%gnutls_handshake_description_t)
  1407. * @post: non zero if this is a post-process/generation call and zero otherwise
  1408. * @incoming: non zero if this is an incoming message and zero if this is an outgoing message
  1409. * @msg: the (const) data of the handshake message without the handshake headers.
  1410. *
  1411. * Function prototype for handshake hooks. It is set using
  1412. * gnutls_handshake_set_hook_function().
  1413. *
  1414. * Returns: Non zero on error.
  1415. */
  1416. #define GNUTLS_HOOK_POST (1)
  1417. #define GNUTLS_HOOK_PRE (0)
  1418. #define GNUTLS_HOOK_BOTH (-1)
  1419. typedef int (*gnutls_handshake_hook_func) (gnutls_session_t,
  1420. unsigned int htype,
  1421. unsigned post,
  1422. unsigned int incoming,
  1423. const gnutls_datum_t *msg);
  1424. void gnutls_handshake_set_hook_function(gnutls_session_t session,
  1425. unsigned int htype, int post,
  1426. gnutls_handshake_hook_func func);
  1427. #define gnutls_handshake_post_client_hello_func gnutls_handshake_simple_hook_func
  1428. typedef int (*gnutls_handshake_simple_hook_func) (gnutls_session_t);
  1429. void
  1430. gnutls_handshake_set_post_client_hello_function(gnutls_session_t session,
  1431. gnutls_handshake_simple_hook_func func);
  1432. void gnutls_handshake_set_max_packet_length(gnutls_session_t session,
  1433. size_t max);
  1434. /* returns libgnutls version (call it with a NULL argument)
  1435. */
  1436. const char * gnutls_check_version(const char *req_version) __GNUTLS_CONST__;
  1437. /* A macro which will allow optimizing out calls to gnutls_check_version()
  1438. * when the version being compiled with is sufficient.
  1439. * Used as:
  1440. * if (gnutls_check_version_numerc(3,3,16)) {
  1441. */
  1442. #define gnutls_check_version_numeric(a,b,c) \
  1443. ((GNUTLS_VERSION_MAJOR >= (a)) && \
  1444. ((GNUTLS_VERSION_NUMBER >= ( ((a) << 16) + ((b) << 8) + (c) )) || \
  1445. gnutls_check_version(#a "." #b "." #c)))
  1446. /* Functions for setting/clearing credentials
  1447. */
  1448. void gnutls_credentials_clear(gnutls_session_t session);
  1449. /* cred is a structure defined by the kx algorithm
  1450. */
  1451. int gnutls_credentials_set(gnutls_session_t session,
  1452. gnutls_credentials_type_t type, void *cred);
  1453. int gnutls_credentials_get(gnutls_session_t session,
  1454. gnutls_credentials_type_t type, void **cred);
  1455. #define gnutls_cred_set gnutls_credentials_set
  1456. /* x.509 types */
  1457. struct gnutls_pubkey_st;
  1458. typedef struct gnutls_pubkey_st *gnutls_pubkey_t;
  1459. struct gnutls_privkey_st;
  1460. typedef struct gnutls_privkey_st *gnutls_privkey_t;
  1461. struct gnutls_x509_privkey_int;
  1462. typedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;
  1463. struct gnutls_x509_crl_int;
  1464. typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;
  1465. struct gnutls_x509_crt_int;
  1466. typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;
  1467. struct gnutls_x509_crq_int;
  1468. typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;
  1469. struct gnutls_openpgp_keyring_int;
  1470. typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;
  1471. /* Credential structures - used in gnutls_credentials_set(); */
  1472. struct gnutls_certificate_credentials_st;
  1473. typedef struct gnutls_certificate_credentials_st
  1474. *gnutls_certificate_credentials_t;
  1475. typedef gnutls_certificate_credentials_t
  1476. gnutls_certificate_server_credentials;
  1477. typedef gnutls_certificate_credentials_t
  1478. gnutls_certificate_client_credentials;
  1479. typedef struct gnutls_anon_server_credentials_st
  1480. *gnutls_anon_server_credentials_t;
  1481. typedef struct gnutls_anon_client_credentials_st
  1482. *gnutls_anon_client_credentials_t;
  1483. void gnutls_anon_free_server_credentials(gnutls_anon_server_credentials_t
  1484. sc);
  1485. int
  1486. gnutls_anon_allocate_server_credentials(gnutls_anon_server_credentials_t
  1487. * sc);
  1488. void gnutls_anon_set_server_dh_params(gnutls_anon_server_credentials_t res,
  1489. gnutls_dh_params_t dh_params);
  1490. int
  1491. gnutls_anon_set_server_known_dh_params(gnutls_anon_server_credentials_t res,
  1492. gnutls_sec_param_t sec_param);
  1493. void
  1494. gnutls_anon_set_server_params_function(gnutls_anon_server_credentials_t
  1495. res, gnutls_params_function * func);
  1496. void
  1497. gnutls_anon_free_client_credentials(gnutls_anon_client_credentials_t sc);
  1498. int
  1499. gnutls_anon_allocate_client_credentials(gnutls_anon_client_credentials_t
  1500. * sc);
  1501. /* CERTFILE is an x509 certificate in PEM form.
  1502. * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
  1503. */
  1504. void
  1505. gnutls_certificate_free_credentials(gnutls_certificate_credentials_t sc);
  1506. int
  1507. gnutls_certificate_allocate_credentials(gnutls_certificate_credentials_t
  1508. * res);
  1509. int
  1510. gnutls_certificate_get_issuer(gnutls_certificate_credentials_t sc,
  1511. gnutls_x509_crt_t cert,
  1512. gnutls_x509_crt_t * issuer,
  1513. unsigned int flags);
  1514. int gnutls_certificate_get_crt_raw(gnutls_certificate_credentials_t sc,
  1515. unsigned idx1, unsigned idx2,
  1516. gnutls_datum_t * cert);
  1517. int
  1518. gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,
  1519. unsigned index,
  1520. gnutls_x509_crt_t **crt_list,
  1521. unsigned *crt_list_size);
  1522. int
  1523. gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,
  1524. unsigned index,
  1525. gnutls_x509_privkey_t *key);
  1526. void gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc);
  1527. void gnutls_certificate_free_cas(gnutls_certificate_credentials_t sc);
  1528. void gnutls_certificate_free_ca_names(gnutls_certificate_credentials_t sc);
  1529. void gnutls_certificate_free_crls(gnutls_certificate_credentials_t sc);
  1530. void gnutls_certificate_set_dh_params(gnutls_certificate_credentials_t res,
  1531. gnutls_dh_params_t dh_params);
  1532. int gnutls_certificate_set_known_dh_params(gnutls_certificate_credentials_t res,
  1533. gnutls_sec_param_t sec_param);
  1534. void gnutls_certificate_set_verify_flags(gnutls_certificate_credentials_t
  1535. res, unsigned int flags);
  1536. unsigned int
  1537. gnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t res);
  1538. /**
  1539. * gnutls_certificate_flags:
  1540. * @GNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH: Skip the key and certificate matching check.
  1541. * @GNUTLS_CERTIFICATE_API_V2: If set the gnutls_certificate_set_*key* functions will return an index of the added key pair instead of zero.
  1542. *
  1543. * Enumeration of different certificate credentials flags.
  1544. */
  1545. typedef enum gnutls_certificate_flags {
  1546. GNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH = 1,
  1547. GNUTLS_CERTIFICATE_API_V2 = (1<<1)
  1548. } gnutls_certificate_flags;
  1549. void gnutls_certificate_set_flags(gnutls_certificate_credentials_t,
  1550. unsigned flags);
  1551. void gnutls_certificate_set_verify_limits(gnutls_certificate_credentials_t
  1552. res, unsigned int max_bits,
  1553. unsigned int max_depth);
  1554. unsigned int
  1555. gnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t);
  1556. int
  1557. gnutls_certificate_set_x509_system_trust(gnutls_certificate_credentials_t
  1558. cred);
  1559. int
  1560. gnutls_certificate_set_x509_trust_file(gnutls_certificate_credentials_t
  1561. cred, const char *cafile,
  1562. gnutls_x509_crt_fmt_t type);
  1563. int
  1564. gnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred,
  1565. const char *ca_dir,
  1566. gnutls_x509_crt_fmt_t type);
  1567. int gnutls_certificate_set_x509_trust_mem(gnutls_certificate_credentials_t
  1568. res, const gnutls_datum_t * ca,
  1569. gnutls_x509_crt_fmt_t type);
  1570. int
  1571. gnutls_certificate_set_x509_crl_file(gnutls_certificate_credentials_t
  1572. res, const char *crlfile,
  1573. gnutls_x509_crt_fmt_t type);
  1574. int gnutls_certificate_set_x509_crl_mem(gnutls_certificate_credentials_t
  1575. res, const gnutls_datum_t * CRL,
  1576. gnutls_x509_crt_fmt_t type);
  1577. int
  1578. gnutls_certificate_set_x509_key_file(gnutls_certificate_credentials_t
  1579. res, const char *certfile,
  1580. const char *keyfile,
  1581. gnutls_x509_crt_fmt_t type);
  1582. int
  1583. gnutls_certificate_set_x509_key_file2(gnutls_certificate_credentials_t
  1584. res, const char *certfile,
  1585. const char *keyfile,
  1586. gnutls_x509_crt_fmt_t type,
  1587. const char *pass,
  1588. unsigned int flags);
  1589. int gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t
  1590. res, const gnutls_datum_t * cert,
  1591. const gnutls_datum_t * key,
  1592. gnutls_x509_crt_fmt_t type);
  1593. int gnutls_certificate_set_x509_key_mem2(gnutls_certificate_credentials_t
  1594. res, const gnutls_datum_t * cert,
  1595. const gnutls_datum_t * key,
  1596. gnutls_x509_crt_fmt_t type,
  1597. const char *pass,
  1598. unsigned int flags);
  1599. void gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session,
  1600. int status);
  1601. int
  1602. gnutls_certificate_set_x509_simple_pkcs12_file
  1603. (gnutls_certificate_credentials_t res, const char *pkcs12file,
  1604. gnutls_x509_crt_fmt_t type, const char *password);
  1605. int
  1606. gnutls_certificate_set_x509_simple_pkcs12_mem
  1607. (gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,
  1608. gnutls_x509_crt_fmt_t type, const char *password);
  1609. /* New functions to allow setting already parsed X.509 stuff.
  1610. */
  1611. int gnutls_certificate_set_x509_key(gnutls_certificate_credentials_t res,
  1612. gnutls_x509_crt_t * cert_list,
  1613. int cert_list_size,
  1614. gnutls_x509_privkey_t key);
  1615. int gnutls_certificate_set_x509_trust(gnutls_certificate_credentials_t res,
  1616. gnutls_x509_crt_t * ca_list,
  1617. int ca_list_size);
  1618. int gnutls_certificate_set_x509_crl(gnutls_certificate_credentials_t res,
  1619. gnutls_x509_crl_t * crl_list,
  1620. int crl_list_size);
  1621. int gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,
  1622. unsigned index,
  1623. gnutls_x509_privkey_t *key);
  1624. int gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,
  1625. unsigned index,
  1626. gnutls_x509_crt_t **crt_list,
  1627. unsigned *crt_list_size);
  1628. /* OCSP status request extension, RFC 6066 */
  1629. typedef int (*gnutls_status_request_ocsp_func)
  1630. (gnutls_session_t session, void *ptr, gnutls_datum_t * ocsp_response);
  1631. void
  1632. gnutls_certificate_set_ocsp_status_request_function
  1633. (gnutls_certificate_credentials_t res,
  1634. gnutls_status_request_ocsp_func ocsp_func, void *ptr);
  1635. int
  1636. gnutls_certificate_set_ocsp_status_request_function2
  1637. (gnutls_certificate_credentials_t res, unsigned idx,
  1638. gnutls_status_request_ocsp_func ocsp_func, void *ptr);
  1639. int
  1640. gnutls_certificate_set_ocsp_status_request_file
  1641. (gnutls_certificate_credentials_t res, const char *response_file,
  1642. unsigned idx);
  1643. int gnutls_ocsp_status_request_enable_client(gnutls_session_t session,
  1644. gnutls_datum_t * responder_id,
  1645. size_t responder_id_size,
  1646. gnutls_datum_t *
  1647. request_extensions);
  1648. int gnutls_ocsp_status_request_get(gnutls_session_t session,
  1649. gnutls_datum_t * response);
  1650. #define GNUTLS_OCSP_SR_IS_AVAIL 1
  1651. int gnutls_ocsp_status_request_is_checked(gnutls_session_t session,
  1652. unsigned int flags);
  1653. /* global state functions
  1654. */
  1655. int gnutls_global_init(void);
  1656. void gnutls_global_deinit(void);
  1657. /**
  1658. * gnutls_time_func:
  1659. * @t: where to store time.
  1660. *
  1661. * Function prototype for time()-like function. Set with
  1662. * gnutls_global_set_time_function().
  1663. *
  1664. * Returns: Number of seconds since the epoch, or (time_t)-1 on errors.
  1665. */
  1666. typedef time_t(*gnutls_time_func) (time_t * t);
  1667. typedef int (*mutex_init_func) (void **mutex);
  1668. typedef int (*mutex_lock_func) (void **mutex);
  1669. typedef int (*mutex_unlock_func) (void **mutex);
  1670. typedef int (*mutex_deinit_func) (void **mutex);
  1671. void gnutls_global_set_mutex(mutex_init_func init,
  1672. mutex_deinit_func deinit,
  1673. mutex_lock_func lock,
  1674. mutex_unlock_func unlock);
  1675. typedef void *(*gnutls_alloc_function) (size_t);
  1676. typedef void *(*gnutls_calloc_function) (size_t, size_t);
  1677. typedef int (*gnutls_is_secure_function) (const void *);
  1678. typedef void (*gnutls_free_function) (void *);
  1679. typedef void *(*gnutls_realloc_function) (void *, size_t);
  1680. void gnutls_global_set_time_function(gnutls_time_func time_func);
  1681. /* For use in callbacks */
  1682. extern _SYM_EXPORT gnutls_alloc_function gnutls_malloc;
  1683. extern _SYM_EXPORT gnutls_realloc_function gnutls_realloc;
  1684. extern _SYM_EXPORT gnutls_calloc_function gnutls_calloc;
  1685. extern _SYM_EXPORT gnutls_free_function gnutls_free;
  1686. extern _SYM_EXPORT char *(*gnutls_strdup) (const char *);
  1687. /* a variant of memset that doesn't get optimized out */
  1688. void gnutls_memset(void *data, int c, size_t size);
  1689. /* constant time memcmp */
  1690. int gnutls_memcmp(const void *s1, const void *s2, size_t n);
  1691. typedef void (*gnutls_log_func) (int, const char *);
  1692. typedef void (*gnutls_audit_log_func) (gnutls_session_t, const char *);
  1693. void gnutls_global_set_log_function(gnutls_log_func log_func);
  1694. void gnutls_global_set_audit_log_function(gnutls_audit_log_func log_func);
  1695. void gnutls_global_set_log_level(int level);
  1696. /* Diffie-Hellman parameter handling.
  1697. */
  1698. int gnutls_dh_params_init(gnutls_dh_params_t * dh_params);
  1699. void gnutls_dh_params_deinit(gnutls_dh_params_t dh_params);
  1700. int gnutls_dh_params_import_raw(gnutls_dh_params_t dh_params,
  1701. const gnutls_datum_t * prime,
  1702. const gnutls_datum_t * generator);
  1703. int gnutls_dh_params_import_dsa(gnutls_dh_params_t dh_params, gnutls_x509_privkey_t key);
  1704. int gnutls_dh_params_import_raw2(gnutls_dh_params_t dh_params,
  1705. const gnutls_datum_t * prime,
  1706. const gnutls_datum_t * generator,
  1707. unsigned key_bits);
  1708. int gnutls_dh_params_import_pkcs3(gnutls_dh_params_t params,
  1709. const gnutls_datum_t * pkcs3_params,
  1710. gnutls_x509_crt_fmt_t format);
  1711. int gnutls_dh_params_generate2(gnutls_dh_params_t params,
  1712. unsigned int bits);
  1713. int gnutls_dh_params_export_pkcs3(gnutls_dh_params_t params,
  1714. gnutls_x509_crt_fmt_t format,
  1715. unsigned char *params_data,
  1716. size_t * params_data_size);
  1717. int gnutls_dh_params_export2_pkcs3(gnutls_dh_params_t params,
  1718. gnutls_x509_crt_fmt_t format,
  1719. gnutls_datum_t * out);
  1720. int gnutls_dh_params_export_raw(gnutls_dh_params_t params,
  1721. gnutls_datum_t * prime,
  1722. gnutls_datum_t * generator,
  1723. unsigned int *bits);
  1724. int gnutls_dh_params_cpy(gnutls_dh_params_t dst, gnutls_dh_params_t src);
  1725. /* Session stuff
  1726. */
  1727. typedef struct {
  1728. void *iov_base;
  1729. size_t iov_len;
  1730. } giovec_t;
  1731. typedef ssize_t(*gnutls_pull_func) (gnutls_transport_ptr_t, void *,
  1732. size_t);
  1733. typedef ssize_t(*gnutls_push_func) (gnutls_transport_ptr_t, const void *,
  1734. size_t);
  1735. int gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms);
  1736. typedef int (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t,
  1737. unsigned int ms);
  1738. typedef ssize_t(*gnutls_vec_push_func) (gnutls_transport_ptr_t,
  1739. const giovec_t * iov, int iovcnt);
  1740. typedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);
  1741. #if 0
  1742. /* This will be defined as macro. */
  1743. void gnutls_transport_set_int (gnutls_session_t session, int r);
  1744. #endif
  1745. void gnutls_transport_set_int2(gnutls_session_t session, int r, int s);
  1746. #define gnutls_transport_set_int(s, i) gnutls_transport_set_int2(s, i, i)
  1747. void gnutls_transport_get_int2(gnutls_session_t session, int *r, int *s);
  1748. int gnutls_transport_get_int(gnutls_session_t session);
  1749. void gnutls_transport_set_ptr(gnutls_session_t session,
  1750. gnutls_transport_ptr_t ptr);
  1751. void gnutls_transport_set_ptr2(gnutls_session_t session,
  1752. gnutls_transport_ptr_t recv_ptr,
  1753. gnutls_transport_ptr_t send_ptr);
  1754. gnutls_transport_ptr_t gnutls_transport_get_ptr(gnutls_session_t session);
  1755. void gnutls_transport_get_ptr2(gnutls_session_t session,
  1756. gnutls_transport_ptr_t * recv_ptr,
  1757. gnutls_transport_ptr_t * send_ptr);
  1758. void gnutls_transport_set_vec_push_function(gnutls_session_t session,
  1759. gnutls_vec_push_func vec_func);
  1760. void gnutls_transport_set_push_function(gnutls_session_t session,
  1761. gnutls_push_func push_func);
  1762. void gnutls_transport_set_pull_function(gnutls_session_t session,
  1763. gnutls_pull_func pull_func);
  1764. void gnutls_transport_set_pull_timeout_function(gnutls_session_t session,
  1765. gnutls_pull_timeout_func
  1766. func);
  1767. void gnutls_transport_set_errno_function(gnutls_session_t session,
  1768. gnutls_errno_func errno_func);
  1769. void gnutls_transport_set_errno(gnutls_session_t session, int err);
  1770. /* session specific
  1771. */
  1772. void gnutls_session_set_ptr(gnutls_session_t session, void *ptr);
  1773. void *gnutls_session_get_ptr(gnutls_session_t session);
  1774. void gnutls_openpgp_send_cert(gnutls_session_t session,
  1775. gnutls_openpgp_crt_status_t status);
  1776. /* This function returns the hash of the given data.
  1777. */
  1778. int gnutls_fingerprint(gnutls_digest_algorithm_t algo,
  1779. const gnutls_datum_t * data, void *result,
  1780. size_t * result_size);
  1781. /**
  1782. * gnutls_random_art_t:
  1783. * @GNUTLS_RANDOM_ART_OPENSSH: OpenSSH-style random art.
  1784. *
  1785. * Enumeration of different random art types.
  1786. */
  1787. typedef enum gnutls_random_art {
  1788. GNUTLS_RANDOM_ART_OPENSSH = 1
  1789. } gnutls_random_art_t;
  1790. int gnutls_random_art(gnutls_random_art_t type,
  1791. const char *key_type, unsigned int key_size,
  1792. void *fpr, size_t fpr_size, gnutls_datum_t * art);
  1793. /* IDNA */
  1794. #define GNUTLS_IDNA_FORCE_2008 (1<<1)
  1795. int gnutls_idna_map(const char * input, unsigned ilen, gnutls_datum_t *out, unsigned flags);
  1796. int gnutls_idna_reverse_map(const char *input, unsigned ilen, gnutls_datum_t *out, unsigned flags);
  1797. /* SRP
  1798. */
  1799. typedef struct gnutls_srp_server_credentials_st
  1800. *gnutls_srp_server_credentials_t;
  1801. typedef struct gnutls_srp_client_credentials_st
  1802. *gnutls_srp_client_credentials_t;
  1803. void
  1804. gnutls_srp_free_client_credentials(gnutls_srp_client_credentials_t sc);
  1805. int
  1806. gnutls_srp_allocate_client_credentials(gnutls_srp_client_credentials_t *
  1807. sc);
  1808. int gnutls_srp_set_client_credentials(gnutls_srp_client_credentials_t res,
  1809. const char *username,
  1810. const char *password);
  1811. void
  1812. gnutls_srp_free_server_credentials(gnutls_srp_server_credentials_t sc);
  1813. int
  1814. gnutls_srp_allocate_server_credentials(gnutls_srp_server_credentials_t *
  1815. sc);
  1816. int gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t
  1817. res, const char *password_file,
  1818. const char *password_conf_file);
  1819. const char *gnutls_srp_server_get_username(gnutls_session_t session);
  1820. void gnutls_srp_set_prime_bits(gnutls_session_t session,
  1821. unsigned int bits);
  1822. int gnutls_srp_verifier(const char *username,
  1823. const char *password,
  1824. const gnutls_datum_t * salt,
  1825. const gnutls_datum_t * generator,
  1826. const gnutls_datum_t * prime,
  1827. gnutls_datum_t * res);
  1828. /* The static parameters defined in draft-ietf-tls-srp-05
  1829. * Those should be used as input to gnutls_srp_verifier().
  1830. */
  1831. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_prime;
  1832. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_generator;
  1833. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_prime;
  1834. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_generator;
  1835. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_prime;
  1836. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_generator;
  1837. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_prime;
  1838. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_generator;
  1839. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_prime;
  1840. extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_generator;
  1841. /* The static parameters defined in rfc7919
  1842. */
  1843. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_prime;
  1844. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_generator;
  1845. extern _SYM_EXPORT const unsigned int gnutls_ffdhe_8192_key_bits;
  1846. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_prime;
  1847. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_generator;
  1848. extern _SYM_EXPORT const unsigned int gnutls_ffdhe_4096_key_bits;
  1849. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_prime;
  1850. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_generator;
  1851. extern _SYM_EXPORT const unsigned int gnutls_ffdhe_3072_key_bits;
  1852. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_prime;
  1853. extern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_generator;
  1854. extern _SYM_EXPORT const unsigned int gnutls_ffdhe_2048_key_bits;
  1855. typedef int gnutls_srp_server_credentials_function(gnutls_session_t,
  1856. const char *username,
  1857. gnutls_datum_t * salt,
  1858. gnutls_datum_t *
  1859. verifier,
  1860. gnutls_datum_t *
  1861. generator,
  1862. gnutls_datum_t * prime);
  1863. void
  1864. gnutls_srp_set_server_credentials_function(gnutls_srp_server_credentials_t
  1865. cred,
  1866. gnutls_srp_server_credentials_function
  1867. * func);
  1868. typedef int gnutls_srp_client_credentials_function(gnutls_session_t,
  1869. char **, char **);
  1870. void
  1871. gnutls_srp_set_client_credentials_function(gnutls_srp_client_credentials_t
  1872. cred,
  1873. gnutls_srp_client_credentials_function
  1874. * func);
  1875. int gnutls_srp_base64_encode(const gnutls_datum_t * data, char *result,
  1876. size_t * result_size);
  1877. int gnutls_srp_base64_encode2(const gnutls_datum_t * data,
  1878. gnutls_datum_t * result);
  1879. int gnutls_srp_base64_decode(const gnutls_datum_t * b64_data, char *result,
  1880. size_t * result_size);
  1881. int gnutls_srp_base64_decode2(const gnutls_datum_t * b64_data,
  1882. gnutls_datum_t * result);
  1883. #define gnutls_srp_base64_encode_alloc gnutls_srp_base64_encode2
  1884. #define gnutls_srp_base64_decode_alloc gnutls_srp_base64_decode2
  1885. void
  1886. gnutls_srp_set_server_fake_salt_seed(gnutls_srp_server_credentials_t
  1887. sc,
  1888. const gnutls_datum_t * seed,
  1889. unsigned int salt_length);
  1890. /* PSK stuff */
  1891. typedef struct gnutls_psk_server_credentials_st
  1892. *gnutls_psk_server_credentials_t;
  1893. typedef struct gnutls_psk_client_credentials_st
  1894. *gnutls_psk_client_credentials_t;
  1895. /**
  1896. * gnutls_psk_key_flags:
  1897. * @GNUTLS_PSK_KEY_RAW: PSK-key in raw format.
  1898. * @GNUTLS_PSK_KEY_HEX: PSK-key in hex format.
  1899. *
  1900. * Enumeration of different PSK key flags.
  1901. */
  1902. typedef enum gnutls_psk_key_flags {
  1903. GNUTLS_PSK_KEY_RAW = 0,
  1904. GNUTLS_PSK_KEY_HEX
  1905. } gnutls_psk_key_flags;
  1906. void
  1907. gnutls_psk_free_client_credentials(gnutls_psk_client_credentials_t sc);
  1908. int
  1909. gnutls_psk_allocate_client_credentials(gnutls_psk_client_credentials_t *
  1910. sc);
  1911. int gnutls_psk_set_client_credentials(gnutls_psk_client_credentials_t res,
  1912. const char *username,
  1913. const gnutls_datum_t * key,
  1914. gnutls_psk_key_flags flags);
  1915. void
  1916. gnutls_psk_free_server_credentials(gnutls_psk_server_credentials_t sc);
  1917. int
  1918. gnutls_psk_allocate_server_credentials(gnutls_psk_server_credentials_t *
  1919. sc);
  1920. int gnutls_psk_set_server_credentials_file(gnutls_psk_server_credentials_t
  1921. res, const char *password_file);
  1922. int
  1923. gnutls_psk_set_server_credentials_hint(gnutls_psk_server_credentials_t
  1924. res, const char *hint);
  1925. const char *gnutls_psk_server_get_username(gnutls_session_t session);
  1926. const char *gnutls_psk_client_get_hint(gnutls_session_t session);
  1927. typedef int gnutls_psk_server_credentials_function(gnutls_session_t,
  1928. const char *username,
  1929. gnutls_datum_t * key);
  1930. void
  1931. gnutls_psk_set_server_credentials_function(gnutls_psk_server_credentials_t
  1932. cred,
  1933. gnutls_psk_server_credentials_function
  1934. * func);
  1935. typedef int gnutls_psk_client_credentials_function(gnutls_session_t,
  1936. char **username,
  1937. gnutls_datum_t * key);
  1938. void
  1939. gnutls_psk_set_client_credentials_function(gnutls_psk_client_credentials_t
  1940. cred,
  1941. gnutls_psk_client_credentials_function
  1942. * func);
  1943. int gnutls_hex_encode(const gnutls_datum_t * data, char *result,
  1944. size_t * result_size);
  1945. int gnutls_hex_decode(const gnutls_datum_t * hex_data, void *result,
  1946. size_t * result_size);
  1947. int gnutls_hex_encode2(const gnutls_datum_t * data, gnutls_datum_t *result);
  1948. int gnutls_hex_decode2(const gnutls_datum_t * data, gnutls_datum_t *result);
  1949. void
  1950. gnutls_psk_set_server_dh_params(gnutls_psk_server_credentials_t res,
  1951. gnutls_dh_params_t dh_params);
  1952. int
  1953. gnutls_psk_set_server_known_dh_params(gnutls_psk_server_credentials_t res,
  1954. gnutls_sec_param_t sec_param);
  1955. void
  1956. gnutls_psk_set_server_params_function(gnutls_psk_server_credentials_t
  1957. res, gnutls_params_function * func);
  1958. /**
  1959. * gnutls_x509_subject_alt_name_t:
  1960. * @GNUTLS_SAN_DNSNAME: DNS-name SAN.
  1961. * @GNUTLS_SAN_RFC822NAME: E-mail address SAN.
  1962. * @GNUTLS_SAN_URI: URI SAN.
  1963. * @GNUTLS_SAN_IPADDRESS: IP address SAN.
  1964. * @GNUTLS_SAN_OTHERNAME: OtherName SAN.
  1965. * @GNUTLS_SAN_DN: DN SAN.
  1966. * @GNUTLS_SAN_OTHERNAME_XMPP: Virtual SAN, used by certain functions for convenience.
  1967. * @GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL: Virtual SAN, used by certain functions for convenience.
  1968. *
  1969. * Enumeration of different subject alternative names types.
  1970. */
  1971. typedef enum gnutls_x509_subject_alt_name_t {
  1972. GNUTLS_SAN_DNSNAME = 1,
  1973. GNUTLS_SAN_RFC822NAME = 2,
  1974. GNUTLS_SAN_URI = 3,
  1975. GNUTLS_SAN_IPADDRESS = 4,
  1976. GNUTLS_SAN_OTHERNAME = 5,
  1977. GNUTLS_SAN_DN = 6,
  1978. GNUTLS_SAN_MAX = GNUTLS_SAN_DN,
  1979. /* The following are "virtual" subject alternative name types, in
  1980. that they are represented by an otherName value and an OID.
  1981. Used by gnutls_x509_crt_get_subject_alt_othername_oid. */
  1982. GNUTLS_SAN_OTHERNAME_XMPP = 1000,
  1983. GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL
  1984. } gnutls_x509_subject_alt_name_t;
  1985. struct gnutls_openpgp_crt_int;
  1986. typedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;
  1987. struct gnutls_openpgp_privkey_int;
  1988. typedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;
  1989. struct gnutls_pkcs11_privkey_st;
  1990. typedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;
  1991. /**
  1992. * gnutls_privkey_type_t:
  1993. * @GNUTLS_PRIVKEY_X509: X.509 private key, #gnutls_x509_privkey_t.
  1994. * @GNUTLS_PRIVKEY_OPENPGP: OpenPGP private key, #gnutls_openpgp_privkey_t.
  1995. * @GNUTLS_PRIVKEY_PKCS11: PKCS11 private key, #gnutls_pkcs11_privkey_t.
  1996. * @GNUTLS_PRIVKEY_EXT: External private key, operating using callbacks.
  1997. *
  1998. * Enumeration of different private key types.
  1999. */
  2000. typedef enum {
  2001. GNUTLS_PRIVKEY_X509,
  2002. GNUTLS_PRIVKEY_OPENPGP,
  2003. GNUTLS_PRIVKEY_PKCS11,
  2004. GNUTLS_PRIVKEY_EXT
  2005. } gnutls_privkey_type_t;
  2006. typedef struct gnutls_retr2_st {
  2007. gnutls_certificate_type_t cert_type;
  2008. gnutls_privkey_type_t key_type;
  2009. union {
  2010. gnutls_x509_crt_t *x509;
  2011. gnutls_openpgp_crt_t pgp;
  2012. } cert;
  2013. unsigned int ncerts; /* one for pgp keys */
  2014. union {
  2015. gnutls_x509_privkey_t x509;
  2016. gnutls_openpgp_privkey_t pgp;
  2017. gnutls_pkcs11_privkey_t pkcs11;
  2018. } key;
  2019. unsigned int deinit_all; /* if non zero all keys will be deinited */
  2020. } gnutls_retr2_st;
  2021. /* Functions that allow auth_info_t structures handling
  2022. */
  2023. gnutls_credentials_type_t gnutls_auth_get_type(gnutls_session_t session);
  2024. gnutls_credentials_type_t
  2025. gnutls_auth_server_get_type(gnutls_session_t session);
  2026. gnutls_credentials_type_t
  2027. gnutls_auth_client_get_type(gnutls_session_t session);
  2028. /* DH */
  2029. void gnutls_dh_set_prime_bits(gnutls_session_t session, unsigned int bits);
  2030. int gnutls_dh_get_secret_bits(gnutls_session_t session);
  2031. int gnutls_dh_get_peers_public_bits(gnutls_session_t session);
  2032. int gnutls_dh_get_prime_bits(gnutls_session_t session);
  2033. int gnutls_dh_get_group(gnutls_session_t session, gnutls_datum_t * raw_gen,
  2034. gnutls_datum_t * raw_prime);
  2035. int gnutls_dh_get_pubkey(gnutls_session_t session,
  2036. gnutls_datum_t * raw_key);
  2037. /* X509PKI */
  2038. /* These are set on the credentials structure.
  2039. */
  2040. /* use gnutls_certificate_set_retrieve_function2() in abstract.h
  2041. * instead. It's much more efficient.
  2042. */
  2043. typedef int gnutls_certificate_retrieve_function(gnutls_session_t,
  2044. const
  2045. gnutls_datum_t *
  2046. req_ca_rdn,
  2047. int nreqs,
  2048. const
  2049. gnutls_pk_algorithm_t
  2050. * pk_algos,
  2051. int
  2052. pk_algos_length,
  2053. gnutls_retr2_st *);
  2054. void
  2055. gnutls_certificate_set_retrieve_function(gnutls_certificate_credentials_t
  2056. cred,
  2057. gnutls_certificate_retrieve_function
  2058. * func);
  2059. void
  2060. gnutls_certificate_set_verify_function(gnutls_certificate_credentials_t
  2061. cred,
  2062. gnutls_certificate_verify_function
  2063. * func);
  2064. void
  2065. gnutls_certificate_server_set_request(gnutls_session_t session,
  2066. gnutls_certificate_request_t req);
  2067. /* get data from the session
  2068. */
  2069. const gnutls_datum_t *gnutls_certificate_get_peers(gnutls_session_t
  2070. session, unsigned int
  2071. *list_size);
  2072. const gnutls_datum_t *gnutls_certificate_get_ours(gnutls_session_t
  2073. session);
  2074. int gnutls_certificate_get_peers_subkey_id(gnutls_session_t session,
  2075. gnutls_datum_t * id);
  2076. time_t gnutls_certificate_activation_time_peers(gnutls_session_t session);
  2077. time_t gnutls_certificate_expiration_time_peers(gnutls_session_t session);
  2078. int gnutls_certificate_client_get_request_status(gnutls_session_t session);
  2079. int gnutls_certificate_verify_peers2(gnutls_session_t session,
  2080. unsigned int *status);
  2081. int gnutls_certificate_verify_peers3(gnutls_session_t session,
  2082. const char *hostname,
  2083. unsigned int *status);
  2084. int
  2085. gnutls_certificate_verify_peers(gnutls_session_t session,
  2086. gnutls_typed_vdata_st * data,
  2087. unsigned int elements,
  2088. unsigned int *status);
  2089. int gnutls_certificate_verification_status_print(unsigned int status,
  2090. gnutls_certificate_type_t
  2091. type,
  2092. gnutls_datum_t * out,
  2093. unsigned int flags);
  2094. int gnutls_pem_base64_encode(const char *msg, const gnutls_datum_t * data,
  2095. char *result, size_t * result_size);
  2096. int gnutls_pem_base64_decode(const char *header,
  2097. const gnutls_datum_t * b64_data,
  2098. unsigned char *result, size_t * result_size);
  2099. int gnutls_pem_base64_encode2(const char *msg,
  2100. const gnutls_datum_t * data,
  2101. gnutls_datum_t * result);
  2102. int gnutls_pem_base64_decode2(const char *header,
  2103. const gnutls_datum_t * b64_data,
  2104. gnutls_datum_t * result);
  2105. int gnutls_base64_encode2(const gnutls_datum_t * data,
  2106. gnutls_datum_t * result);
  2107. int gnutls_base64_decode2(const gnutls_datum_t * b64_data,
  2108. gnutls_datum_t * result);
  2109. #define gnutls_pem_base64_encode_alloc gnutls_pem_base64_encode2
  2110. #define gnutls_pem_base64_decode_alloc gnutls_pem_base64_decode2
  2111. /* key_usage will be an OR of the following values:
  2112. */
  2113. /* when the key is to be used for signing: */
  2114. #define GNUTLS_KEY_DIGITAL_SIGNATURE 128
  2115. #define GNUTLS_KEY_NON_REPUDIATION 64
  2116. /* when the key is to be used for encryption: */
  2117. #define GNUTLS_KEY_KEY_ENCIPHERMENT 32
  2118. #define GNUTLS_KEY_DATA_ENCIPHERMENT 16
  2119. #define GNUTLS_KEY_KEY_AGREEMENT 8
  2120. #define GNUTLS_KEY_KEY_CERT_SIGN 4
  2121. #define GNUTLS_KEY_CRL_SIGN 2
  2122. #define GNUTLS_KEY_ENCIPHER_ONLY 1
  2123. #define GNUTLS_KEY_DECIPHER_ONLY 32768
  2124. void
  2125. gnutls_certificate_set_params_function(gnutls_certificate_credentials_t
  2126. res, gnutls_params_function * func);
  2127. void gnutls_anon_set_params_function(gnutls_anon_server_credentials_t res,
  2128. gnutls_params_function * func);
  2129. void gnutls_psk_set_params_function(gnutls_psk_server_credentials_t res,
  2130. gnutls_params_function * func);
  2131. int gnutls_hex2bin(const char *hex_data, size_t hex_size,
  2132. void *bin_data, size_t * bin_size);
  2133. /* Trust on first use (or ssh like) functions */
  2134. /* stores the provided information to a database
  2135. */
  2136. typedef int (*gnutls_tdb_store_func) (const char *db_name,
  2137. const char *host,
  2138. const char *service,
  2139. time_t expiration,
  2140. const gnutls_datum_t * pubkey);
  2141. typedef int (*gnutls_tdb_store_commitment_func) (const char *db_name,
  2142. const char *host,
  2143. const char *service,
  2144. time_t expiration,
  2145. gnutls_digest_algorithm_t
  2146. hash_algo,
  2147. const gnutls_datum_t *
  2148. hash);
  2149. /* searches for the provided host/service pair that match the
  2150. * provided public key in the database. */
  2151. typedef int (*gnutls_tdb_verify_func) (const char *db_name,
  2152. const char *host,
  2153. const char *service,
  2154. const gnutls_datum_t * pubkey);
  2155. struct gnutls_tdb_int;
  2156. typedef struct gnutls_tdb_int *gnutls_tdb_t;
  2157. int gnutls_tdb_init(gnutls_tdb_t * tdb);
  2158. void gnutls_tdb_set_store_func(gnutls_tdb_t tdb,
  2159. gnutls_tdb_store_func store);
  2160. void gnutls_tdb_set_store_commitment_func(gnutls_tdb_t tdb,
  2161. gnutls_tdb_store_commitment_func
  2162. cstore);
  2163. void gnutls_tdb_set_verify_func(gnutls_tdb_t tdb,
  2164. gnutls_tdb_verify_func verify);
  2165. void gnutls_tdb_deinit(gnutls_tdb_t tdb);
  2166. int gnutls_verify_stored_pubkey(const char *db_name,
  2167. gnutls_tdb_t tdb,
  2168. const char *host,
  2169. const char *service,
  2170. gnutls_certificate_type_t cert_type,
  2171. const gnutls_datum_t * cert,
  2172. unsigned int flags);
  2173. #define GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN 1
  2174. int gnutls_store_commitment(const char *db_name,
  2175. gnutls_tdb_t tdb,
  2176. const char *host,
  2177. const char *service,
  2178. gnutls_digest_algorithm_t hash_algo,
  2179. const gnutls_datum_t * hash,
  2180. time_t expiration, unsigned int flags);
  2181. int gnutls_store_pubkey(const char *db_name,
  2182. gnutls_tdb_t tdb,
  2183. const char *host,
  2184. const char *service,
  2185. gnutls_certificate_type_t cert_type,
  2186. const gnutls_datum_t * cert,
  2187. time_t expiration, unsigned int flags);
  2188. /* Other helper functions */
  2189. int gnutls_load_file(const char *filename, gnutls_datum_t * data);
  2190. unsigned gnutls_url_is_supported(const char *url);
  2191. /* PIN callback */
  2192. /**
  2193. * gnutls_pin_flag_t:
  2194. * @GNUTLS_PIN_USER: The PIN for the user.
  2195. * @GNUTLS_PIN_SO: The PIN for the security officer (admin).
  2196. * @GNUTLS_PIN_CONTEXT_SPECIFIC: The PIN is for a specific action and key like signing.
  2197. * @GNUTLS_PIN_FINAL_TRY: This is the final try before blocking.
  2198. * @GNUTLS_PIN_COUNT_LOW: Few tries remain before token blocks.
  2199. * @GNUTLS_PIN_WRONG: Last given PIN was not correct.
  2200. *
  2201. * Enumeration of different flags that are input to the PIN function.
  2202. */
  2203. typedef enum {
  2204. GNUTLS_PIN_USER = (1 << 0),
  2205. GNUTLS_PIN_SO = (1 << 1),
  2206. GNUTLS_PIN_FINAL_TRY = (1 << 2),
  2207. GNUTLS_PIN_COUNT_LOW = (1 << 3),
  2208. GNUTLS_PIN_CONTEXT_SPECIFIC = (1 << 4),
  2209. GNUTLS_PIN_WRONG = (1 << 5)
  2210. } gnutls_pin_flag_t;
  2211. #define GNUTLS_PKCS11_PIN_USER GNUTLS_PIN_USER
  2212. #define GNUTLS_PKCS11_PIN_SO GNUTLS_PIN_SO
  2213. #define GNUTLS_PKCS11_PIN_FINAL_TRY GNUTLS_PIN_FINAL_TRY
  2214. #define GNUTLS_PKCS11_PIN_COUNT_LOW GNUTLS_PIN_COUNT_LOW
  2215. #define GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC GNUTLS_PIN_CONTEXT_SPECIFIC
  2216. #define GNUTLS_PKCS11_PIN_WRONG GNUTLS_PIN_WRONG
  2217. /**
  2218. * gnutls_pin_callback_t:
  2219. * @userdata: user-controlled data from gnutls_pkcs11_set_pin_function().
  2220. * @attempt: pin-attempt counter, initially 0.
  2221. * @token_url: URL of token.
  2222. * @token_label: label of token.
  2223. * @flags: a #gnutls_pin_flag_t flag.
  2224. * @pin: buffer to hold PIN, of size @pin_max.
  2225. * @pin_max: size of @pin buffer.
  2226. *
  2227. * Callback function type for PKCS#11 or TPM PIN entry. It is set by
  2228. * functions like gnutls_pkcs11_set_pin_function().
  2229. *
  2230. * The callback should provides the PIN code to unlock the token with
  2231. * label @token_label, specified by the URL @token_url.
  2232. *
  2233. * The PIN code, as a NUL-terminated ASCII string, should be copied
  2234. * into the @pin buffer (of maximum size @pin_max), and return 0 to
  2235. * indicate success. Alternatively, the callback may return a
  2236. * negative gnutls error code to indicate failure and cancel PIN entry
  2237. * (in which case, the contents of the @pin parameter are ignored).
  2238. *
  2239. * When a PIN is required, the callback will be invoked repeatedly
  2240. * (and indefinitely) until either the returned PIN code is correct,
  2241. * the callback returns failure, or the token refuses login (e.g. when
  2242. * the token is locked due to too many incorrect PINs!). For the
  2243. * first such invocation, the @attempt counter will have value zero;
  2244. * it will increase by one for each subsequent attempt.
  2245. *
  2246. * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
  2247. *
  2248. * Since: 2.12.0
  2249. **/
  2250. typedef int (*gnutls_pin_callback_t) (void *userdata, int attempt,
  2251. const char *token_url,
  2252. const char *token_label,
  2253. unsigned int flags,
  2254. char *pin, size_t pin_max);
  2255. void gnutls_certificate_set_pin_function(gnutls_certificate_credentials_t,
  2256. gnutls_pin_callback_t fn,
  2257. void *userdata);
  2258. /* Public string related functions */
  2259. typedef struct gnutls_buffer_st *gnutls_buffer_t;
  2260. int gnutls_buffer_append_data(gnutls_buffer_t, const void *data, size_t data_size);
  2261. #define GNUTLS_UTF8_IGNORE_ERRS 1
  2262. int gnutls_utf8_password_normalize(const unsigned char *password, unsigned password_len,
  2263. gnutls_datum_t *out, unsigned flags);
  2264. /* Public extensions related functions */
  2265. typedef void *gnutls_ext_priv_data_t;
  2266. void gnutls_ext_set_data(gnutls_session_t session, unsigned type,
  2267. gnutls_ext_priv_data_t);
  2268. int gnutls_ext_get_data(gnutls_session_t session, unsigned type,
  2269. gnutls_ext_priv_data_t *);
  2270. typedef int (*gnutls_ext_recv_func) (gnutls_session_t session,
  2271. const unsigned char *data,
  2272. size_t len);
  2273. typedef int (*gnutls_ext_send_func) (gnutls_session_t session,
  2274. gnutls_buffer_t extdata);
  2275. typedef void (*gnutls_ext_deinit_data_func) (gnutls_ext_priv_data_t data);
  2276. typedef int (*gnutls_ext_pack_func) (gnutls_ext_priv_data_t data,
  2277. gnutls_buffer_t packed_data);
  2278. typedef int (*gnutls_ext_unpack_func) (gnutls_buffer_t packed_data,
  2279. gnutls_ext_priv_data_t *data);
  2280. /**
  2281. * gnutls_ext_parse_type_t:
  2282. * @GNUTLS_EXT_NONE: Never parsed
  2283. * @GNUTLS_EXT_ANY: Any extension type (internal use only).
  2284. * @GNUTLS_EXT_APPLICATION: Application extension.
  2285. * @GNUTLS_EXT_TLS: TLS-internal extension.
  2286. * @GNUTLS_EXT_MANDATORY: Extension parsed even if resuming (or extensions are disabled).
  2287. *
  2288. * Enumeration of different TLS extension types. This type is
  2289. * to indicate whether an extension is useful to application
  2290. * level or TLS level only. This is used to parse the
  2291. * application level extensions before the "client_hello" callback
  2292. * is called.
  2293. */
  2294. typedef enum {
  2295. GNUTLS_EXT_ANY = 0,
  2296. GNUTLS_EXT_APPLICATION = 1,
  2297. GNUTLS_EXT_TLS = 2,
  2298. GNUTLS_EXT_MANDATORY = 3,
  2299. GNUTLS_EXT_NONE = 4
  2300. } gnutls_ext_parse_type_t;
  2301. /**
  2302. * gnutls_ext_flags_t:
  2303. * @GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL: If specified the extension registered will override the internal; this does not work with extensions existing prior to 3.6.0.
  2304. *
  2305. * Enumeration of different TLS extension registration flags.
  2306. */
  2307. typedef enum {
  2308. GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL = 1
  2309. } gnutls_ext_flags_t;
  2310. /* Register a custom tls extension
  2311. */
  2312. int gnutls_ext_register(const char *name, int type, gnutls_ext_parse_type_t parse_type,
  2313. gnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func,
  2314. gnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,
  2315. gnutls_ext_unpack_func unpack_func);
  2316. int gnutls_session_ext_register(gnutls_session_t, const char *name, int type, gnutls_ext_parse_type_t parse_type,
  2317. gnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func,
  2318. gnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,
  2319. gnutls_ext_unpack_func unpack_func, unsigned flags);
  2320. const char *gnutls_ext_get_name(unsigned int ext);
  2321. /* Public supplemental data related functions */
  2322. typedef int (*gnutls_supp_recv_func) (gnutls_session_t session,
  2323. const unsigned char * data, size_t data_size);
  2324. typedef int (*gnutls_supp_send_func) (gnutls_session_t session,
  2325. gnutls_buffer_t buf);
  2326. int gnutls_supplemental_register(const char *name,
  2327. gnutls_supplemental_data_format_type_t type,
  2328. gnutls_supp_recv_func supp_recv_func,
  2329. gnutls_supp_send_func supp_send_func);
  2330. int gnutls_session_supplemental_register(gnutls_session_t session, const char *name,
  2331. gnutls_supplemental_data_format_type_t type,
  2332. gnutls_supp_recv_func supp_recv_func,
  2333. gnutls_supp_send_func supp_send_func,
  2334. unsigned int flags);
  2335. void gnutls_supplemental_recv(gnutls_session_t session, unsigned do_recv_supplemental);
  2336. void gnutls_supplemental_send(gnutls_session_t session, unsigned do_send_supplemental);
  2337. /* FIPS140-2 related functions */
  2338. unsigned gnutls_fips140_mode_enabled(void);
  2339. /* Gnutls error codes. The mapping to a TLS alert is also shown in
  2340. * comments.
  2341. */
  2342. #define GNUTLS_E_SUCCESS 0
  2343. #define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
  2344. #define GNUTLS_E_UNKNOWN_CIPHER_TYPE -6
  2345. #define GNUTLS_E_LARGE_PACKET -7
  2346. #define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8 /* GNUTLS_A_PROTOCOL_VERSION */
  2347. #define GNUTLS_E_TLS_PACKET_DECODING_ERROR GNUTLS_E_UNEXPECTED_PACKET_LENGTH
  2348. #define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9 /* GNUTLS_A_DECODE_ERROR */
  2349. #define GNUTLS_E_INVALID_SESSION -10
  2350. #define GNUTLS_E_FATAL_ALERT_RECEIVED -12
  2351. #define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_A_UNEXPECTED_MESSAGE */
  2352. #define GNUTLS_E_WARNING_ALERT_RECEIVED -16
  2353. #define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18
  2354. #define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19
  2355. #define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21 /* GNUTLS_A_HANDSHAKE_FAILURE */
  2356. #define GNUTLS_E_UNWANTED_ALGORITHM -22
  2357. #define GNUTLS_E_MPI_SCAN_FAILED -23
  2358. #define GNUTLS_E_DECRYPTION_FAILED -24 /* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */
  2359. #define GNUTLS_E_MEMORY_ERROR -25
  2360. #define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_A_DECOMPRESSION_FAILURE */
  2361. #define GNUTLS_E_COMPRESSION_FAILED -27
  2362. #define GNUTLS_E_AGAIN -28
  2363. #define GNUTLS_E_EXPIRED -29
  2364. #define GNUTLS_E_DB_ERROR -30
  2365. #define GNUTLS_E_SRP_PWD_ERROR -31
  2366. #define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32
  2367. #define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
  2368. #define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS
  2369. #define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
  2370. #define GNUTLS_E_HASH_FAILED -33
  2371. #define GNUTLS_E_BASE64_DECODING_ERROR -34
  2372. #define GNUTLS_E_MPI_PRINT_FAILED -35
  2373. #define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_A_NO_RENEGOTIATION */
  2374. #define GNUTLS_E_GOT_APPLICATION_DATA -38
  2375. #define GNUTLS_E_RECORD_LIMIT_REACHED -39
  2376. #define GNUTLS_E_ENCRYPTION_FAILED -40
  2377. #define GNUTLS_E_PK_ENCRYPTION_FAILED -44
  2378. #define GNUTLS_E_PK_DECRYPTION_FAILED -45
  2379. #define GNUTLS_E_PK_SIGN_FAILED -46
  2380. #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
  2381. #define GNUTLS_E_KEY_USAGE_VIOLATION -48
  2382. #define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */
  2383. #define GNUTLS_E_INVALID_REQUEST -50
  2384. #define GNUTLS_E_SHORT_MEMORY_BUFFER -51
  2385. #define GNUTLS_E_INTERRUPTED -52
  2386. #define GNUTLS_E_PUSH_ERROR -53
  2387. #define GNUTLS_E_PULL_ERROR -54
  2388. #define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
  2389. #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
  2390. #define GNUTLS_E_PKCS1_WRONG_PAD -57
  2391. #define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58
  2392. #define GNUTLS_E_INTERNAL_ERROR -59
  2393. #define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63
  2394. #define GNUTLS_E_FILE_ERROR -64
  2395. #define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78
  2396. #define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80
  2397. #define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81
  2398. /* returned if you need to generate temporary RSA
  2399. * parameters. These are needed for export cipher suites.
  2400. */
  2401. #define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84
  2402. #define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86
  2403. #define GNUTLS_E_NO_CIPHER_SUITES -87
  2404. #define GNUTLS_E_OPENPGP_GETKEY_FAILED -88
  2405. #define GNUTLS_E_PK_SIG_VERIFY_FAILED -89
  2406. #define GNUTLS_E_ILLEGAL_SRP_USERNAME -90
  2407. #define GNUTLS_E_SRP_PWD_PARSING_ERROR -91
  2408. #define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93
  2409. /* For certificate and key stuff
  2410. */
  2411. #define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67
  2412. #define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68
  2413. #define GNUTLS_E_ASN1_DER_ERROR -69
  2414. #define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70
  2415. #define GNUTLS_E_ASN1_GENERIC_ERROR -71
  2416. #define GNUTLS_E_ASN1_VALUE_NOT_VALID -72
  2417. #define GNUTLS_E_ASN1_TAG_ERROR -73
  2418. #define GNUTLS_E_ASN1_TAG_IMPLICIT -74
  2419. #define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75
  2420. #define GNUTLS_E_ASN1_SYNTAX_ERROR -76
  2421. #define GNUTLS_E_ASN1_DER_OVERFLOW -77
  2422. #define GNUTLS_E_OPENPGP_UID_REVOKED -79
  2423. #define GNUTLS_E_CERTIFICATE_ERROR -43
  2424. #define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR
  2425. #define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60
  2426. #define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61 /* GNUTLS_A_UNSUPPORTED_CERTIFICATE */
  2427. #define GNUTLS_E_X509_UNKNOWN_SAN -62
  2428. #define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94
  2429. #define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95
  2430. #define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96
  2431. #define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97
  2432. #define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98
  2433. #define GNUTLS_E_INVALID_PASSWORD -99
  2434. #define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */
  2435. #define GNUTLS_E_CONSTRAINT_ERROR -101
  2436. #define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102
  2437. #define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103
  2438. #define GNUTLS_E_IA_VERIFY_FAILED -104
  2439. #define GNUTLS_E_UNKNOWN_ALGORITHM -105
  2440. #define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106
  2441. #define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107
  2442. #define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108
  2443. #define GNUTLS_E_UNKNOWN_SRP_USERNAME -109
  2444. #define GNUTLS_E_PREMATURE_TERMINATION -110
  2445. #define GNUTLS_E_MALFORMED_CIDR -111
  2446. #define GNUTLS_E_BASE64_ENCODING_ERROR -201
  2447. #define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202 /* obsolete */
  2448. #define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202
  2449. #define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203
  2450. #define GNUTLS_E_OPENPGP_KEYRING_ERROR -204
  2451. #define GNUTLS_E_X509_UNSUPPORTED_OID -205
  2452. #define GNUTLS_E_RANDOM_FAILED -206
  2453. #define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207
  2454. #define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208
  2455. #define GNUTLS_E_CRYPTO_ALREADY_REGISTERED GNUTLS_E_ALREADY_REGISTERED
  2456. #define GNUTLS_E_ALREADY_REGISTERED -209
  2457. #define GNUTLS_E_HANDSHAKE_TOO_LARGE -210
  2458. #define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211
  2459. #define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212
  2460. #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213
  2461. #define GNUTLS_E_BAD_COOKIE -214
  2462. #define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215
  2463. #define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216
  2464. #define GNUTLS_E_INSUFFICIENT_SECURITY -217
  2465. #define GNUTLS_E_HEARTBEAT_PONG_RECEIVED -292
  2466. #define GNUTLS_E_HEARTBEAT_PING_RECEIVED -293
  2467. #define GNUTLS_E_UNRECOGNIZED_NAME -294
  2468. /* PKCS11 related */
  2469. #define GNUTLS_E_PKCS11_ERROR -300
  2470. #define GNUTLS_E_PKCS11_LOAD_ERROR -301
  2471. #define GNUTLS_E_PARSING_ERROR -302
  2472. #define GNUTLS_E_PKCS11_PIN_ERROR -303
  2473. #define GNUTLS_E_PKCS11_SLOT_ERROR -305
  2474. #define GNUTLS_E_LOCKING_ERROR -306
  2475. #define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307
  2476. #define GNUTLS_E_PKCS11_DEVICE_ERROR -308
  2477. #define GNUTLS_E_PKCS11_DATA_ERROR -309
  2478. #define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310
  2479. #define GNUTLS_E_PKCS11_KEY_ERROR -311
  2480. #define GNUTLS_E_PKCS11_PIN_EXPIRED -312
  2481. #define GNUTLS_E_PKCS11_PIN_LOCKED -313
  2482. #define GNUTLS_E_PKCS11_SESSION_ERROR -314
  2483. #define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315
  2484. #define GNUTLS_E_PKCS11_TOKEN_ERROR -316
  2485. #define GNUTLS_E_PKCS11_USER_ERROR -317
  2486. #define GNUTLS_E_CRYPTO_INIT_FAILED -318
  2487. #define GNUTLS_E_TIMEDOUT -319
  2488. #define GNUTLS_E_USER_ERROR -320
  2489. #define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321
  2490. #define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322
  2491. #define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323
  2492. #define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324
  2493. #define GNUTLS_E_ILLEGAL_PARAMETER -325
  2494. #define GNUTLS_E_NO_PRIORITIES_WERE_SET -326
  2495. #define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327
  2496. #define GNUTLS_E_SESSION_EOF -328
  2497. #define GNUTLS_E_TPM_ERROR -329
  2498. #define GNUTLS_E_TPM_KEY_PASSWORD_ERROR -330
  2499. #define GNUTLS_E_TPM_SRK_PASSWORD_ERROR -331
  2500. #define GNUTLS_E_TPM_SESSION_ERROR -332
  2501. #define GNUTLS_E_TPM_KEY_NOT_FOUND -333
  2502. #define GNUTLS_E_TPM_UNINITIALIZED -334
  2503. #define GNUTLS_E_TPM_NO_LIB -335
  2504. #define GNUTLS_E_NO_CERTIFICATE_STATUS -340
  2505. #define GNUTLS_E_OCSP_RESPONSE_ERROR -341
  2506. #define GNUTLS_E_RANDOM_DEVICE_ERROR -342
  2507. #define GNUTLS_E_AUTH_ERROR -343
  2508. #define GNUTLS_E_NO_APPLICATION_PROTOCOL -344
  2509. #define GNUTLS_E_SOCKETS_INIT_ERROR -345
  2510. #define GNUTLS_E_KEY_IMPORT_FAILED -346
  2511. #define GNUTLS_E_INAPPROPRIATE_FALLBACK -347 /*GNUTLS_A_INAPPROPRIATE_FALLBACK*/
  2512. #define GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR -348
  2513. #define GNUTLS_E_PRIVKEY_VERIFICATION_ERROR -349
  2514. #define GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH -350 /*GNUTLS_A_DECODE_ERROR*/
  2515. #define GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING -351
  2516. #define GNUTLS_E_SELF_TEST_ERROR -400
  2517. #define GNUTLS_E_NO_SELF_TEST -401
  2518. #define GNUTLS_E_LIB_IN_ERROR_STATE -402
  2519. #define GNUTLS_E_PK_GENERATION_ERROR -403
  2520. #define GNUTLS_E_IDNA_ERROR -404
  2521. #define GNUTLS_E_NEED_FALLBACK -405
  2522. #define GNUTLS_E_SESSION_USER_ID_CHANGED -406
  2523. #define GNUTLS_E_HANDSHAKE_DURING_FALSE_START -407
  2524. #define GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE -408
  2525. #define GNUTLS_E_PK_INVALID_PUBKEY -409
  2526. #define GNUTLS_E_PK_INVALID_PRIVKEY -410
  2527. #define GNUTLS_E_NOT_YET_ACTIVATED -411
  2528. #define GNUTLS_E_INVALID_UTF8_STRING -412
  2529. #define GNUTLS_E_NO_EMBEDDED_DATA -413
  2530. #define GNUTLS_E_INVALID_UTF8_EMAIL -414
  2531. #define GNUTLS_E_INVALID_PASSWORD_STRING -415
  2532. #define GNUTLS_E_CERTIFICATE_TIME_ERROR -416
  2533. #define GNUTLS_E_RECORD_OVERFLOW -417 /* GNUTLS_A_RECORD_OVERFLOW */
  2534. #define GNUTLS_E_ASN1_TIME_ERROR -418
  2535. #define GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY -419
  2536. #define GNUTLS_E_PK_INVALID_PUBKEY_PARAMS -420
  2537. #define GNUTLS_E_PK_NO_VALIDATION_PARAMS -421
  2538. #define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250
  2539. /* Internal errors of the library; will never be returned
  2540. * to a calling application */
  2541. #define GNUTLS_E_INT_RET_0 -1251
  2542. #define GNUTLS_E_INT_CHECK_AGAIN -1252
  2543. #define GNUTLS_E_APPLICATION_ERROR_MAX -65000
  2544. #define GNUTLS_E_APPLICATION_ERROR_MIN -65500
  2545. /* *INDENT-OFF* */
  2546. #ifdef __cplusplus
  2547. }
  2548. #endif
  2549. /* *INDENT-ON* */
  2550. #include <gnutls/compat.h>
  2551. #endif /* GNUTLS_H */