1
0

wolfssl.ads 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. -- wolfssl.ads
  2. --
  3. -- Copyright (C) 2006-2023 wolfSSL Inc.
  4. --
  5. -- This file is part of wolfSSL.
  6. --
  7. -- wolfSSL is free software; you can redistribute it and/or modify
  8. -- it under the terms of the GNU General Public License as published by
  9. -- the Free Software Foundation; either version 2 of the License, or
  10. -- (at your option) any later version.
  11. --
  12. -- wolfSSL is distributed in the hope that it will be useful,
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. -- GNU General Public License for more details.
  16. --
  17. -- You should have received a copy of the GNU General Public License
  18. -- along with this program; if not, write to the Free Software
  19. -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. --
  21. with Interfaces.C;
  22. -- This package is annotated "with SPARK_Mode" that SPARK can verify
  23. -- the API of this package is used correctly.
  24. package WolfSSL with SPARK_Mode is
  25. type Subprogram_Result is new Integer;
  26. Success : constant Subprogram_Result;
  27. Failure : constant Subprogram_Result;
  28. function Initialize return Subprogram_Result;
  29. -- Initializes the wolfSSL library for use. Must be called once per
  30. -- application and before any other call to the library.
  31. function Finalize return Subprogram_Result;
  32. -- Un-initializes the wolfSSL library from further use.
  33. -- Doesn't have to be called, though it will free any resources
  34. -- used by the library.
  35. subtype char_array is Interfaces.C.char_array; -- Remove?
  36. subtype Byte_Type is Interfaces.C.char;
  37. subtype Byte_Index is Interfaces.C.size_t range 0 .. 16_000;
  38. subtype Byte_Array is Interfaces.C.char_array;
  39. type Context_Type is limited private;
  40. -- Instances of this type are called SSL Contexts.
  41. function Is_Valid (Context : Context_Type) return Boolean;
  42. -- Indicates if the SSL Context has successfully been initialized.
  43. -- If initialized, the SSL Context has allocated resources
  44. -- that needs to be deallocated before application exit.
  45. type Method_Type is limited private;
  46. function TLSv1_2_Server_Method return Method_Type;
  47. -- This function is used to indicate that the application is a server
  48. -- and will only support the TLS 1.2 protocol.
  49. function TLSv1_2_Client_Method return Method_Type;
  50. -- This function is used to indicate that the application is a client
  51. -- and will only support the TLS 1.2 protocol.
  52. function TLSv1_3_Server_Method return Method_Type;
  53. -- This function is used to indicate that the application is a server
  54. -- and will only support the TLS 1.3 protocol.
  55. function TLSv1_3_Client_Method return Method_Type;
  56. -- This function is used to indicate that the application is a client
  57. -- and will only support the TLS 1.3 protocol.
  58. procedure Create_Context (Method : Method_Type;
  59. Context : out Context_Type);
  60. -- This function creates a new SSL context, taking a desired SSL/TLS
  61. -- protocol method for input.
  62. -- If successful Is_Valid (Context) = True, otherwise False.
  63. procedure Free (Context : in out Context_Type) with
  64. Pre => Is_Valid (Context),
  65. Post => not Is_Valid (Context);
  66. -- This function frees an allocated SSL Context object.
  67. type Mode_Type is private;
  68. function "&" (Left, Right : Mode_Type) return Mode_Type;
  69. Verify_None : constant Mode_Type;
  70. -- Client mode: the client will not verify the certificate received
  71. -- from the server and the handshake will continue as normal.
  72. --
  73. -- Server mode: the server will not send a certificate request to
  74. -- the client. As such, client verification will not be enabled.
  75. Verify_Peer : constant Mode_Type;
  76. -- Client mode: the client will verify the certificate received from
  77. -- the server during the handshake. This is turned on by default
  78. -- in wolfSSL, therefore, using this option has no effect.
  79. --
  80. -- Server mode: the server will send a certificate request to
  81. -- the client and verify the client certificate received.
  82. Verify_Fail_If_No_Peer_Cert : constant Mode_Type;
  83. -- Client mode: no effect when used on the client side.
  84. --
  85. -- Server mode: the verification will fail on the server side if
  86. -- the client fails to send a certificate when requested to do so
  87. -- (when using Verify_Peer on the SSL server).
  88. Verify_Client_Once : constant Mode_Type;
  89. Verify_Post_Handshake : constant Mode_Type;
  90. Verify_Fail_Except_Psk : constant Mode_Type;
  91. -- Client mode: no effect when used on the client side.
  92. --
  93. -- Server mode: the verification is the same as
  94. -- Verify_Fail_If_No_Peer_Cert except in the case of a PSK connection.
  95. -- If a PSK connection is being made then the connection
  96. -- will go through without a peer cert.
  97. Verify_Default : constant Mode_Type;
  98. procedure Set_Verify (Context : Context_Type;
  99. Mode : Mode_Type) with
  100. Pre => Is_Valid (Context);
  101. -- This function sets the verification method for remote peers
  102. type File_Format is private;
  103. Format_Asn1 : constant File_Format;
  104. Format_Pem : constant File_Format;
  105. Format_Default : constant File_Format;
  106. function Use_Certificate_File (Context : Context_Type;
  107. File : String;
  108. Format : File_Format)
  109. return Subprogram_Result with
  110. Pre => Is_Valid (Context);
  111. -- This function loads a certificate file into the SSL context.
  112. -- The file is provided by the file argument. The format argument
  113. -- specifies the format type of the file, either ASN1 or
  114. -- PEM file types. Please see the examples for proper usage.
  115. function Use_Certificate_Buffer (Context : Context_Type;
  116. Input : char_array;
  117. Format : File_Format)
  118. return Subprogram_Result with
  119. Pre => Is_Valid (Context);
  120. -- This function loads a certificate buffer into the SSL Context.
  121. -- It behaves like the non-buffered version (Use_Certificate_File),
  122. -- only differing in its ability to be called with a buffer as input
  123. -- instead of a file. The buffer is provided by the Input argument.
  124. -- Format specifies the format type of the buffer; ASN1 or PEM.
  125. -- Please see the examples for proper usage.
  126. function Use_Private_Key_File (Context : Context_Type;
  127. File : String;
  128. Format : File_Format)
  129. return Subprogram_Result with
  130. Pre => Is_Valid (Context);
  131. -- This function loads a private key file into the SSL context.
  132. -- The file is provided by the File argument. The Format argument
  133. -- specifies the format type of the file - ASN1 or PEM.
  134. -- Please see the examples for proper usage.
  135. function Use_Private_Key_Buffer (Context : Context_Type;
  136. Input : Byte_Array;
  137. Format : File_Format)
  138. return Subprogram_Result with
  139. Pre => Is_Valid (Context);
  140. -- This function loads a private key buffer into the SSL Context.
  141. -- It behaves like the non-buffered version (Use_Private_Key_File),
  142. -- only differing in its ability to be called with a buffer as input
  143. -- instead of a file. The buffer is provided by the Input argument.
  144. -- Format specifies the format type of the buffer; ASN1 or PEM.
  145. -- Please see the examples for proper usage.
  146. function Load_Verify_Locations (Context : Context_Type;
  147. File : String;
  148. Path : String)
  149. return Subprogram_Result with
  150. Pre => Is_Valid (Context);
  151. -- This function loads PEM-formatted CA certificate files into
  152. -- the SSL context. These certificates will be treated as trusted
  153. -- root certificates and used to verify certs received from peers
  154. -- during the SSL handshake. The root certificate file,
  155. -- provided by the File argument, may be a single certificate or
  156. -- a file containing multiple certificates. If multiple CA certs
  157. -- are included in the same file, wolfSSL will load them in the same
  158. -- order they are presented in the file. The path argument is
  159. -- a pointer to the name of a directory that contains certificates
  160. -- of trusted root CAs. If the value of File is not empty "",
  161. -- path may be specified as "" if not needed. If path is specified
  162. -- and NO_WOLFSSL_DIR was not defined when building the library,
  163. -- wolfSSL will load all CA certificates located in the given
  164. -- directory. This function will attempt to load all files in
  165. -- the directory. This function expects PEM formatted CERT_TYPE file
  166. -- with header "--BEGIN CERTIFICATE--".
  167. function Load_Verify_Buffer (Context : Context_Type;
  168. Input : Byte_Array;
  169. Format : File_Format)
  170. return Subprogram_Result with
  171. Pre => Is_Valid (Context);
  172. -- This function loads a CA certificate buffer into the SSL
  173. -- Context. It behaves like the non-buffered version, only differing
  174. -- in its ability to be called with a buffer as input instead of
  175. -- a file. The buffer is provided by the Input argument.
  176. -- Format specifies the format type of the buffer; ASN1 or PEM.
  177. -- More than one CA certificate may be loaded
  178. -- per buffer as long as the format is in PEM.
  179. -- Please see the examples for proper usage.
  180. type WolfSSL_Type is limited private;
  181. -- Instances of this type are called SSL Sessions.
  182. function Is_Valid (Ssl : WolfSSL_Type) return Boolean;
  183. -- Indicates if the SSL Session has successfully been initialized.
  184. -- If initialized, the SSL Session has allocated resources
  185. -- that needs to be deallocated before application exit.
  186. procedure Create_WolfSSL (Context : Context_Type;
  187. Ssl : out WolfSSL_Type) with
  188. Pre => Is_Valid (Context);
  189. -- This function creates a new SSL session, taking an already created
  190. -- SSL context as input.
  191. -- If successful Is_Valid (Ssl) = True, otherwise False.
  192. function Use_Certificate_File (Ssl : WolfSSL_Type;
  193. File : String;
  194. Format : File_Format)
  195. return Subprogram_Result with
  196. Pre => Is_Valid (Ssl);
  197. -- This function loads a certificate file into the SSL session.
  198. -- The certificate file is provided by the file argument.
  199. -- The format argument specifies the format type of the file
  200. -- either ASN1 or PEM.
  201. function Use_Certificate_Buffer (Ssl : WolfSSL_Type;
  202. Input : char_array;
  203. Format : File_Format)
  204. return Subprogram_Result with
  205. Pre => Is_Valid (Ssl);
  206. -- This function loads a certificate buffer into the SSL session
  207. -- object. It behaves like the non-buffered version, only differing
  208. -- in its ability to be called with a buffer as input instead
  209. -- of a file. The buffer is provided by the Input argument.
  210. -- Format specifies the format type of the buffer; ASN1 or PEM.
  211. -- Please see the examples for proper usage.
  212. function Use_Private_Key_File (Ssl : WolfSSL_Type;
  213. File : String;
  214. Format : File_Format)
  215. return Subprogram_Result with
  216. Pre => Is_Valid (Ssl);
  217. -- This function loads a private key file into the SSL session.
  218. -- The key file is provided by the File argument. The Format argument
  219. -- specifies the format type of the file - ASN1 or PEM.
  220. function Use_Private_Key_Buffer (Ssl : WolfSSL_Type;
  221. Input : Byte_Array;
  222. Format : File_Format)
  223. return Subprogram_Result with
  224. Pre => Is_Valid (Ssl);
  225. -- This function loads a private key buffer into the SSL session
  226. -- object. It behaves like the non-buffered version, only differing
  227. -- in its ability to be called with a buffer as input instead
  228. -- of a file. The buffer is provided by the Input argument.
  229. -- Format specifies the format type of the buffer; ASN1 or PEM.
  230. -- Please see the examples for proper usage.
  231. function Attach (Ssl : WolfSSL_Type;
  232. Socket : Integer)
  233. return Subprogram_Result with
  234. Pre => Is_Valid (Ssl);
  235. -- Attach wolfSSL to the socket.
  236. --
  237. -- This function assigns a file descriptor (Socket) as
  238. -- the input/output facility for the SSL connection.
  239. -- Typically this will be a socket file descriptor.
  240. procedure Keep_Arrays (Ssl : WolfSSL_Type) with
  241. Pre => Is_Valid (Ssl);
  242. -- Normally, at the end of the SSL handshake, wolfSSL frees
  243. -- temporary arrays. Calling this function before the handshake
  244. -- begins will prevent wolfSSL from freeing temporary arrays.
  245. -- Temporary arrays may be needed for things such as
  246. -- wolfSSL_get_keys() or PSK hints. When the user is done with
  247. -- temporary arrays, either Free_Arrays(..) may be called to free
  248. -- the resources immediately, or alternatively the resources will
  249. -- be freed when the associated SSL object is freed.
  250. procedure Free_Arrays (Ssl : WolfSSL_Type) with
  251. Pre => Is_Valid (Ssl);
  252. -- Normally, at the end of the SSL handshake, wolfSSL frees temporary
  253. -- arrays. If Keep_Arrays(..) has been called before the handshake,
  254. -- wolfSSL will not free temporary arrays. This function explicitly
  255. -- frees temporary arrays and should be called when the user is done
  256. -- with temporary arrays and does not want to wait for the SSL object
  257. -- to be freed to free these resources.
  258. function Accept_Connection (Ssl : WolfSSL_Type)
  259. return Subprogram_Result with
  260. Pre => Is_Valid (Ssl);
  261. -- The name of this function is not Accept (..) because the word
  262. -- "accept" is a reserved keyword in the Ada language.
  263. --
  264. -- This function is called on the server side and waits for an
  265. -- SSL client to initiate the SSL/TLS handshake. When this function
  266. -- is called, the underlying communication channel has already been
  267. -- set up. This function works with both blocking and
  268. -- non-blocking I/O. When the underlying I/O is non-blocking,
  269. -- Accept_Connection (..) will return when the underlying I/O could
  270. -- not satisfy the needs of Accept_Connection (..) to continue
  271. -- the handshake. In this case, a call to Get_Error(..) will
  272. -- yield either Error_Want_Read or Error_Want_Write.
  273. -- The calling process must then repeat the call to
  274. -- Accept_Connection (..) when data is available to read and
  275. -- wolfSSL will pick up where it left off. When using a
  276. -- non_blocking socket, nothing needs to be done, but select() can
  277. -- be used to check for the required condition.
  278. -- If the underlying I/O is blocking, Accept_Connection (..) will
  279. -- only return once the handshake has been finished or
  280. -- an error occurred.
  281. -- This record type has discriminants with default values to be able
  282. -- to compile this code under the restriction No Secondary Stack.
  283. type Read_Result (Success : Boolean := False;
  284. Last : Byte_Index := Byte_Index'Last) is record
  285. case Success is
  286. when True => Buffer : Byte_Array (1 .. Last);
  287. when False => Code : Subprogram_Result; -- Error code
  288. end case;
  289. end record;
  290. function Read (Ssl : WolfSSL_Type) return Read_Result with
  291. Pre => Is_Valid (Ssl);
  292. -- This function reads a number of bytes from the SSL session (ssl)
  293. -- internal read buffer into the buffer data. The bytes read are
  294. -- removed from the internal receive buffer.
  295. -- If necessary Read(..) will negotiate an SSL/TLS session
  296. -- if the handshake has not already
  297. -- been performed yet by Connect(..) or Accept_Connection (..).
  298. -- The SSL/TLS protocol uses SSL records which have a maximum size
  299. -- of 16kB (the max record size can be controlled by the
  300. -- MAX_RECORD_SIZE define in /wolfssl/internal.h). As such, wolfSSL
  301. -- needs to read an entire SSL record internally before it is able
  302. -- to process and decrypt the record. Because of this, a call to
  303. -- Read(..) will only be able to return the maximum buffer
  304. -- size which has been decrypted at the time of calling. There may
  305. -- be additional not-yet-decrypted data waiting in the internal
  306. -- wolfSSL receive buffer which will be retrieved and decrypted with
  307. -- the next call to Read(..).
  308. -- This record type has discriminants with default values to be able
  309. -- to compile this code under the restriction No Secondary Stack.
  310. type Write_Result (Success : Boolean := False) is record
  311. case Success is
  312. when True => Bytes_Written : Byte_Index;
  313. when False => Code : Subprogram_Result; -- Error code
  314. end case;
  315. end record;
  316. function Write (Ssl : WolfSSL_Type;
  317. Data : Byte_Array) return Write_Result with
  318. Pre => Is_Valid (Ssl);
  319. -- The number of bytes written is returned.
  320. -- This function writes bytes from the buffer, Data,
  321. -- to the SSL connection, ssl. If necessary, Write(..) will
  322. -- negotiate an SSL/TLS session if the handshake has not already
  323. -- been performed yet by Connect(..) or Accept_Connection(..).
  324. -- Write(..) works with both blocking and non-blocking I/O.
  325. -- When the underlying I/O is non-blocking, Write(..) will return
  326. -- when the underlying I/O could not satisfy the needs of Write(..)
  327. -- to continue. In this case, a call to Get_Error(..) will
  328. -- yield either Error_Want_Read or Error_Want_Write.
  329. -- The calling process must then repeat the call to Write(..)
  330. -- when the underlying I/O is ready. If the underlying I/O is
  331. -- blocking, Write(..) will only return once the buffer data
  332. -- has been completely written or an error occurred.
  333. function Shutdown (Ssl : WolfSSL_Type) return Subprogram_Result with
  334. Pre => Is_Valid (Ssl);
  335. -- This function shuts down an active SSL/TLS connection using
  336. -- the SSL session, ssl. This function will try to send a
  337. -- "close notify" alert to the peer. The calling application can
  338. -- choose to wait for the peer to send its "close notify" alert
  339. -- in response or just go ahead and shut down the underlying
  340. -- connection after directly calling wolfSSL_shutdown (to save
  341. -- resources). Either option is allowed by the TLS specification.
  342. -- If the underlying connection will be used again in the future,
  343. -- the complete two_directional shutdown procedure must be performed
  344. -- to keep synchronization intact between the peers.
  345. -- Shutdown(..) works with both blocking and non_blocking I/O.
  346. -- When the underlying I/O is non_blocking, Shutdown(..) will
  347. -- return an error if the underlying I/O could not satisfy the needs
  348. -- of Shutdown(..) to continue. In this case, a call to
  349. -- Get_Error(..) will yield either Error_Want_Read or
  350. -- Error_Want_Write. The calling process must then repeat
  351. -- the call to Shutdown() when the underlying I/O is ready.
  352. procedure Free (Ssl : in out WolfSSL_Type) with
  353. Pre => Is_Valid (Ssl),
  354. Post => not Is_Valid (Ssl);
  355. -- Frees the resources allocated by the SSL session object.
  356. function Connect (Ssl : WolfSSL_Type) return Subprogram_Result with
  357. Pre => Is_Valid (Ssl);
  358. -- This function is called on the client side and initiates
  359. -- an SSL/TLS handshake with a server. When this function is called,
  360. -- the underlying communication channel has already been set up.
  361. -- Connect(..) works with both blocking and non_blocking I/O.
  362. -- When the underlying I/O is non_blocking, Connect(..) will
  363. -- return when the underlying I/O could not satisfy the needs
  364. -- of wolfSSL_connect to continue the handshake. In this case,
  365. -- a call to Get_Error(..) will yield either
  366. -- Error_Want_Read or SSL_ERROR_WANT_WRITE. The calling process
  367. -- must then repeat the call to Connect(..) when
  368. -- the underlying I/O is ready and wolfSSL will pick up where
  369. -- it left off. When using a non_blocking socket, nothing needs
  370. -- to be done, but select() can be used to check for the required
  371. -- condition. If the underlying I/O is blocking, Connect(..)
  372. -- will only return once the handshake has been finished or an error
  373. -- occurred. wolfSSL takes a different approach to certificate
  374. -- verification than OpenSSL does. The default policy for the client
  375. -- is to verify the server, this means that if you don't load CAs
  376. -- to verify the server you'll get a connect error,
  377. -- unable to verify. It you want to mimic OpenSSL behavior
  378. -- of having SSL_connect succeed even if verifying the server fails
  379. -- and reducing security you can do this by calling:
  380. -- Set_Verify (Ctx, Verify_None, 0); before calling
  381. -- Create_WolfSSL(...); Though it's not recommended.
  382. type Error_Code is new Integer;
  383. Error_Want_Read : constant Error_Code;
  384. Error_Want_Write : constant Error_Code;
  385. function Get_Error (Ssl : WolfSSL_Type;
  386. Result : Subprogram_Result) return Error_Code;
  387. -- This function returns a unique error code describing why
  388. -- the previous API function call (Connect, Accept_Connection,
  389. -- Read, Write, etc.) resulted in an error return code.
  390. -- After Get_Error is called and returns the unique error code,
  391. -- wolfSSL_ERR_error_string() may be called to get a human readable
  392. -- error string.
  393. subtype Error_Message_Index is Natural range 0 .. 80;
  394. -- The default error message length is 80 in WolfSSL unless
  395. -- configured to another value. See the result
  396. -- of the Max_Error_Size function.
  397. type Error_Message (Last : Error_Message_Index := 0) is record
  398. Text : String (1 .. Last);
  399. end record;
  400. function Error (Code : Error_Code) return Error_Message;
  401. -- This function converts an error code returned by Get_Error(..)
  402. -- into a more human readable error string. Code is the error code
  403. -- returned by Get_error(). The maximum length of error strings is
  404. -- 80 characters by default, as defined by MAX_ERROR_SZ
  405. -- is wolfssl/wolfcrypt/error.h.
  406. function Max_Error_Size return Natural;
  407. -- Returns the value of the defined MAX_ERROR_SZ integer
  408. -- in wolfssl/wolfcrypt/error.h.
  409. private
  410. pragma SPARK_Mode (Off);
  411. subtype int is Interfaces.C.int; use type int;
  412. type Opaque_Method is limited null record;
  413. type Opaque_Context is limited null record;
  414. type Opaque_WolfSSL is limited null record;
  415. -- Access-to-object types with convention C uses the same amount of
  416. -- memory for storing pointers as is done in the C programming
  417. -- language. The following access type definitions are used in
  418. -- the Ada binding to the WolfSSL library:
  419. type Context_Type is access Opaque_Context with Convention => C;
  420. type Method_Type is access Opaque_Method with Convention => C;
  421. type WolfSSL_Type is access Opaque_WolfSSL with Convention => C;
  422. subtype Unsigned_32 is Interfaces.Unsigned_32; use type Unsigned_32;
  423. type Mode_Type is new Unsigned_32;
  424. -- The following imported subprograms are used to initialize
  425. -- the constants defined in the public part of this package
  426. -- specification. They cannot therefore be moved to the body
  427. -- of this package.
  428. function WolfSSL_Verify_None return int with
  429. Convention => C,
  430. External_Name => "get_wolfssl_verify_none",
  431. Import => True;
  432. function WolfSSL_Verify_Peer return int with
  433. Convention => C,
  434. External_Name => "get_wolfssl_verify_peer",
  435. Import => True;
  436. function WolfSSL_Verify_Fail_If_No_Peer_Cert return int with
  437. Convention => C,
  438. External_Name => "get_wolfssl_verify_fail_if_no_peer_cert",
  439. Import => True;
  440. function WolfSSL_Verify_Client_Once return int with
  441. Convention => C,
  442. External_Name => "get_wolfssl_verify_client_once",
  443. Import => True;
  444. function WolfSSL_Verify_Post_Handshake return int with
  445. Convention => C,
  446. External_Name => "get_wolfssl_verify_post_handshake",
  447. Import => True;
  448. function WolfSSL_Verify_Fail_Except_Psk return int with
  449. Convention => C,
  450. External_Name => "get_wolfssl_verify_fail_except_psk",
  451. Import => True;
  452. function WolfSSL_Verify_Default return int with
  453. Convention => C,
  454. External_Name => "get_wolfssl_verify_default",
  455. Import => True;
  456. Verify_None : constant Mode_Type := Mode_Type (WolfSSL_Verify_None);
  457. Verify_Peer : constant Mode_Type := Mode_Type (WolfSSL_Verify_Peer);
  458. Verify_Fail_If_No_Peer_Cert : constant Mode_Type :=
  459. Mode_Type (WolfSSL_Verify_Fail_If_No_Peer_Cert);
  460. Verify_Client_Once : constant Mode_Type :=
  461. Mode_Type (WolfSSL_Verify_Client_Once);
  462. Verify_Post_Handshake : constant Mode_Type :=
  463. Mode_Type (WolfSSL_Verify_Post_Handshake);
  464. Verify_Fail_Except_Psk : constant Mode_Type :=
  465. Mode_Type (WolfSSL_Verify_Fail_Except_Psk);
  466. Verify_Default : constant Mode_Type :=
  467. Mode_Type (WolfSSL_Verify_Default);
  468. type File_Format is new Unsigned_32;
  469. function WolfSSL_Filetype_Asn1 return int with
  470. Convention => C,
  471. External_Name => "get_wolfssl_filetype_asn1",
  472. Import => True;
  473. function WolfSSL_Filetype_Pem return int with
  474. Convention => C,
  475. External_Name => "get_wolfssl_filetype_pem",
  476. Import => True;
  477. function WolfSSL_Filetype_Default return int with
  478. Convention => C,
  479. External_Name => "get_wolfssl_filetype_default",
  480. Import => True;
  481. Format_Asn1 : constant File_Format :=
  482. File_Format (WolfSSL_Filetype_Asn1);
  483. Format_Pem : constant File_Format :=
  484. File_Format (WolfSSL_Filetype_Pem);
  485. Format_Default : constant File_Format :=
  486. File_Format (WolfSSL_Filetype_Default);
  487. function Get_WolfSSL_Success return int with
  488. Convention => C,
  489. External_Name => "get_wolfssl_success",
  490. Import => True;
  491. function Get_WolfSSL_Failure return int with
  492. Convention => C,
  493. External_Name => "get_wolfssl_failure",
  494. Import => True;
  495. Success : constant Subprogram_Result :=
  496. Subprogram_Result (Get_WolfSSL_Success);
  497. Failure : constant Subprogram_Result :=
  498. Subprogram_Result (Get_WolfSSL_Failure);
  499. function Get_WolfSSL_Error_Want_Read return int with
  500. Convention => C,
  501. External_Name => "get_wolfssl_error_want_read",
  502. Import => True;
  503. function Get_WolfSSL_Error_Want_Write return int with
  504. Convention => C,
  505. External_Name => "get_wolfssl_error_want_write",
  506. Import => True;
  507. Error_Want_Read : constant Error_Code :=
  508. Error_Code (Get_WolfSSL_Error_Want_Read);
  509. Error_Want_Write : constant Error_Code :=
  510. Error_Code (Get_WolfSSL_Error_Want_Write);
  511. end WolfSSL;