1
0

wolfssl.ads 28 KB

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