TlsLib.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. /** @file
  2. Defines TLS Library APIs.
  3. Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __TLS_LIB_H__
  7. #define __TLS_LIB_H__
  8. /**
  9. Initializes the OpenSSL library.
  10. This function registers ciphers and digests used directly and indirectly
  11. by SSL/TLS, and initializes the readable error messages.
  12. This function must be called before any other action takes places.
  13. @retval TRUE The OpenSSL library has been initialized.
  14. @retval FALSE Failed to initialize the OpenSSL library.
  15. **/
  16. BOOLEAN
  17. EFIAPI
  18. TlsInitialize (
  19. VOID
  20. );
  21. /**
  22. Free an allocated SSL_CTX object.
  23. @param[in] TlsCtx Pointer to the SSL_CTX object to be released.
  24. **/
  25. VOID
  26. EFIAPI
  27. TlsCtxFree (
  28. IN VOID *TlsCtx
  29. );
  30. /**
  31. Creates a new SSL_CTX object as framework to establish TLS/SSL enabled
  32. connections.
  33. @param[in] MajorVer Major Version of TLS/SSL Protocol.
  34. @param[in] MinorVer Minor Version of TLS/SSL Protocol.
  35. @return Pointer to an allocated SSL_CTX object.
  36. If the creation failed, TlsCtxNew() returns NULL.
  37. **/
  38. VOID *
  39. EFIAPI
  40. TlsCtxNew (
  41. IN UINT8 MajorVer,
  42. IN UINT8 MinorVer
  43. );
  44. /**
  45. Free an allocated TLS object.
  46. This function removes the TLS object pointed to by Tls and frees up the
  47. allocated memory. If Tls is NULL, nothing is done.
  48. @param[in] Tls Pointer to the TLS object to be freed.
  49. **/
  50. VOID
  51. EFIAPI
  52. TlsFree (
  53. IN VOID *Tls
  54. );
  55. /**
  56. Create a new TLS object for a connection.
  57. This function creates a new TLS object for a connection. The new object
  58. inherits the setting of the underlying context TlsCtx: connection method,
  59. options, verification setting.
  60. @param[in] TlsCtx Pointer to the SSL_CTX object.
  61. @return Pointer to an allocated SSL object.
  62. If the creation failed, TlsNew() returns NULL.
  63. **/
  64. VOID *
  65. EFIAPI
  66. TlsNew (
  67. IN VOID *TlsCtx
  68. );
  69. /**
  70. Checks if the TLS handshake was done.
  71. This function will check if the specified TLS handshake was done.
  72. @param[in] Tls Pointer to the TLS object for handshake state checking.
  73. @retval TRUE The TLS handshake was done.
  74. @retval FALSE The TLS handshake was not done.
  75. **/
  76. BOOLEAN
  77. EFIAPI
  78. TlsInHandshake (
  79. IN VOID *Tls
  80. );
  81. /**
  82. Perform a TLS/SSL handshake.
  83. This function will perform a TLS/SSL handshake.
  84. @param[in] Tls Pointer to the TLS object for handshake operation.
  85. @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
  86. @param[in] BufferInSize Packet size in bytes for the most recently received TLS
  87. Handshake packet.
  88. @param[out] BufferOut Pointer to the buffer to hold the built packet.
  89. @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
  90. the buffer size provided by the caller. On output, it
  91. is the buffer size in fact needed to contain the
  92. packet.
  93. @retval EFI_SUCCESS The required TLS packet is built successfully.
  94. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  95. Tls is NULL.
  96. BufferIn is NULL but BufferInSize is NOT 0.
  97. BufferInSize is 0 but BufferIn is NOT NULL.
  98. BufferOutSize is NULL.
  99. BufferOut is NULL if *BufferOutSize is not zero.
  100. @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
  101. @retval EFI_ABORTED Something wrong during handshake.
  102. **/
  103. EFI_STATUS
  104. EFIAPI
  105. TlsDoHandshake (
  106. IN VOID *Tls,
  107. IN UINT8 *BufferIn, OPTIONAL
  108. IN UINTN BufferInSize, OPTIONAL
  109. OUT UINT8 *BufferOut, OPTIONAL
  110. IN OUT UINTN *BufferOutSize
  111. );
  112. /**
  113. Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
  114. TLS session has errors and the response packet needs to be Alert message based on error type.
  115. @param[in] Tls Pointer to the TLS object for state checking.
  116. @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
  117. @param[in] BufferInSize Packet size in bytes for the most recently received TLS
  118. Alert packet.
  119. @param[out] BufferOut Pointer to the buffer to hold the built packet.
  120. @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
  121. the buffer size provided by the caller. On output, it
  122. is the buffer size in fact needed to contain the
  123. packet.
  124. @retval EFI_SUCCESS The required TLS packet is built successfully.
  125. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  126. Tls is NULL.
  127. BufferIn is NULL but BufferInSize is NOT 0.
  128. BufferInSize is 0 but BufferIn is NOT NULL.
  129. BufferOutSize is NULL.
  130. BufferOut is NULL if *BufferOutSize is not zero.
  131. @retval EFI_ABORTED An error occurred.
  132. @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
  133. **/
  134. EFI_STATUS
  135. EFIAPI
  136. TlsHandleAlert (
  137. IN VOID *Tls,
  138. IN UINT8 *BufferIn, OPTIONAL
  139. IN UINTN BufferInSize, OPTIONAL
  140. OUT UINT8 *BufferOut, OPTIONAL
  141. IN OUT UINTN *BufferOutSize
  142. );
  143. /**
  144. Build the CloseNotify packet.
  145. @param[in] Tls Pointer to the TLS object for state checking.
  146. @param[in, out] Buffer Pointer to the buffer to hold the built packet.
  147. @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
  148. the buffer size provided by the caller. On output, it
  149. is the buffer size in fact needed to contain the
  150. packet.
  151. @retval EFI_SUCCESS The required TLS packet is built successfully.
  152. @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
  153. Tls is NULL.
  154. BufferSize is NULL.
  155. Buffer is NULL if *BufferSize is not zero.
  156. @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
  157. **/
  158. EFI_STATUS
  159. EFIAPI
  160. TlsCloseNotify (
  161. IN VOID *Tls,
  162. IN OUT UINT8 *Buffer,
  163. IN OUT UINTN *BufferSize
  164. );
  165. /**
  166. Attempts to read bytes from one TLS object and places the data in Buffer.
  167. This function will attempt to read BufferSize bytes from the TLS object
  168. and places the data in Buffer.
  169. @param[in] Tls Pointer to the TLS object.
  170. @param[in,out] Buffer Pointer to the buffer to store the data.
  171. @param[in] BufferSize The size of Buffer in bytes.
  172. @retval >0 The amount of data successfully read from the TLS object.
  173. @retval <=0 No data was successfully read.
  174. **/
  175. INTN
  176. EFIAPI
  177. TlsCtrlTrafficOut (
  178. IN VOID *Tls,
  179. IN OUT VOID *Buffer,
  180. IN UINTN BufferSize
  181. );
  182. /**
  183. Attempts to write data from the buffer to TLS object.
  184. This function will attempt to write BufferSize bytes data from the Buffer
  185. to the TLS object.
  186. @param[in] Tls Pointer to the TLS object.
  187. @param[in] Buffer Pointer to the data buffer.
  188. @param[in] BufferSize The size of Buffer in bytes.
  189. @retval >0 The amount of data successfully written to the TLS object.
  190. @retval <=0 No data was successfully written.
  191. **/
  192. INTN
  193. EFIAPI
  194. TlsCtrlTrafficIn (
  195. IN VOID *Tls,
  196. IN VOID *Buffer,
  197. IN UINTN BufferSize
  198. );
  199. /**
  200. Attempts to read bytes from the specified TLS connection into the buffer.
  201. This function tries to read BufferSize bytes data from the specified TLS
  202. connection into the Buffer.
  203. @param[in] Tls Pointer to the TLS connection for data reading.
  204. @param[in,out] Buffer Pointer to the data buffer.
  205. @param[in] BufferSize The size of Buffer in bytes.
  206. @retval >0 The read operation was successful, and return value is the
  207. number of bytes actually read from the TLS connection.
  208. @retval <=0 The read operation was not successful.
  209. **/
  210. INTN
  211. EFIAPI
  212. TlsRead (
  213. IN VOID *Tls,
  214. IN OUT VOID *Buffer,
  215. IN UINTN BufferSize
  216. );
  217. /**
  218. Attempts to write data to a TLS connection.
  219. This function tries to write BufferSize bytes data from the Buffer into the
  220. specified TLS connection.
  221. @param[in] Tls Pointer to the TLS connection for data writing.
  222. @param[in] Buffer Pointer to the data buffer.
  223. @param[in] BufferSize The size of Buffer in bytes.
  224. @retval >0 The write operation was successful, and return value is the
  225. number of bytes actually written to the TLS connection.
  226. @retval <=0 The write operation was not successful.
  227. **/
  228. INTN
  229. EFIAPI
  230. TlsWrite (
  231. IN VOID *Tls,
  232. IN VOID *Buffer,
  233. IN UINTN BufferSize
  234. );
  235. /**
  236. Set a new TLS/SSL method for a particular TLS object.
  237. This function sets a new TLS/SSL method for a particular TLS object.
  238. @param[in] Tls Pointer to a TLS object.
  239. @param[in] MajorVer Major Version of TLS/SSL Protocol.
  240. @param[in] MinorVer Minor Version of TLS/SSL Protocol.
  241. @retval EFI_SUCCESS The TLS/SSL method was set successfully.
  242. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  243. @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
  244. **/
  245. EFI_STATUS
  246. EFIAPI
  247. TlsSetVersion (
  248. IN VOID *Tls,
  249. IN UINT8 MajorVer,
  250. IN UINT8 MinorVer
  251. );
  252. /**
  253. Set TLS object to work in client or server mode.
  254. This function prepares a TLS object to work in client or server mode.
  255. @param[in] Tls Pointer to a TLS object.
  256. @param[in] IsServer Work in server mode.
  257. @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
  258. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  259. @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
  260. **/
  261. EFI_STATUS
  262. EFIAPI
  263. TlsSetConnectionEnd (
  264. IN VOID *Tls,
  265. IN BOOLEAN IsServer
  266. );
  267. /**
  268. Set the ciphers list to be used by the TLS object.
  269. This function sets the ciphers for use by a specified TLS object.
  270. @param[in] Tls Pointer to a TLS object.
  271. @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
  272. cipher identifier comes from the TLS Cipher Suite
  273. Registry of the IANA, interpreting Byte1 and Byte2
  274. in network (big endian) byte order.
  275. @param[in] CipherNum The number of cipher in the list.
  276. @retval EFI_SUCCESS The ciphers list was set successfully.
  277. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  278. @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
  279. @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
  280. **/
  281. EFI_STATUS
  282. EFIAPI
  283. TlsSetCipherList (
  284. IN VOID *Tls,
  285. IN UINT16 *CipherId,
  286. IN UINTN CipherNum
  287. );
  288. /**
  289. Set the compression method for TLS/SSL operations.
  290. This function handles TLS/SSL integrated compression methods.
  291. @param[in] CompMethod The compression method ID.
  292. @retval EFI_SUCCESS The compression method for the communication was
  293. set successfully.
  294. @retval EFI_UNSUPPORTED Unsupported compression method.
  295. **/
  296. EFI_STATUS
  297. EFIAPI
  298. TlsSetCompressionMethod (
  299. IN UINT8 CompMethod
  300. );
  301. /**
  302. Set peer certificate verification mode for the TLS connection.
  303. This function sets the verification mode flags for the TLS connection.
  304. @param[in] Tls Pointer to the TLS object.
  305. @param[in] VerifyMode A set of logically or'ed verification mode flags.
  306. **/
  307. VOID
  308. EFIAPI
  309. TlsSetVerify (
  310. IN VOID *Tls,
  311. IN UINT32 VerifyMode
  312. );
  313. /**
  314. Sets a TLS/SSL session ID to be used during TLS/SSL connect.
  315. This function sets a session ID to be used when the TLS/SSL connection is
  316. to be established.
  317. @param[in] Tls Pointer to the TLS object.
  318. @param[in] SessionId Session ID data used for session resumption.
  319. @param[in] SessionIdLen Length of Session ID in bytes.
  320. @retval EFI_SUCCESS Session ID was set successfully.
  321. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  322. @retval EFI_UNSUPPORTED No available session for ID setting.
  323. **/
  324. EFI_STATUS
  325. EFIAPI
  326. TlsSetSessionId (
  327. IN VOID *Tls,
  328. IN UINT8 *SessionId,
  329. IN UINT16 SessionIdLen
  330. );
  331. /**
  332. Adds the CA to the cert store when requesting Server or Client authentication.
  333. This function adds the CA certificate to the list of CAs when requesting
  334. Server or Client authentication for the chosen TLS connection.
  335. @param[in] Tls Pointer to the TLS object.
  336. @param[in] Data Pointer to the data buffer of a DER-encoded binary
  337. X.509 certificate or PEM-encoded X.509 certificate.
  338. @param[in] DataSize The size of data buffer in bytes.
  339. @retval EFI_SUCCESS The operation succeeded.
  340. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  341. @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
  342. @retval EFI_ABORTED Invalid X.509 certificate.
  343. **/
  344. EFI_STATUS
  345. EFIAPI
  346. TlsSetCaCertificate (
  347. IN VOID *Tls,
  348. IN VOID *Data,
  349. IN UINTN DataSize
  350. );
  351. /**
  352. Loads the local public certificate into the specified TLS object.
  353. This function loads the X.509 certificate into the specified TLS object
  354. for TLS negotiation.
  355. @param[in] Tls Pointer to the TLS object.
  356. @param[in] Data Pointer to the data buffer of a DER-encoded binary
  357. X.509 certificate or PEM-encoded X.509 certificate.
  358. @param[in] DataSize The size of data buffer in bytes.
  359. @retval EFI_SUCCESS The operation succeeded.
  360. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  361. @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
  362. @retval EFI_ABORTED Invalid X.509 certificate.
  363. **/
  364. EFI_STATUS
  365. EFIAPI
  366. TlsSetHostPublicCert (
  367. IN VOID *Tls,
  368. IN VOID *Data,
  369. IN UINTN DataSize
  370. );
  371. /**
  372. Adds the local private key to the specified TLS object.
  373. This function adds the local private key (PEM-encoded RSA or PKCS#8 private
  374. key) into the specified TLS object for TLS negotiation.
  375. @param[in] Tls Pointer to the TLS object.
  376. @param[in] Data Pointer to the data buffer of a PEM-encoded RSA
  377. or PKCS#8 private key.
  378. @param[in] DataSize The size of data buffer in bytes.
  379. @retval EFI_SUCCESS The operation succeeded.
  380. @retval EFI_UNSUPPORTED This function is not supported.
  381. @retval EFI_ABORTED Invalid private key data.
  382. **/
  383. EFI_STATUS
  384. EFIAPI
  385. TlsSetHostPrivateKey (
  386. IN VOID *Tls,
  387. IN VOID *Data,
  388. IN UINTN DataSize
  389. );
  390. /**
  391. Adds the CA-supplied certificate revocation list for certificate validation.
  392. This function adds the CA-supplied certificate revocation list data for
  393. certificate validity checking.
  394. @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
  395. @param[in] DataSize The size of data buffer in bytes.
  396. @retval EFI_SUCCESS The operation succeeded.
  397. @retval EFI_UNSUPPORTED This function is not supported.
  398. @retval EFI_ABORTED Invalid CRL data.
  399. **/
  400. EFI_STATUS
  401. EFIAPI
  402. TlsSetCertRevocationList (
  403. IN VOID *Data,
  404. IN UINTN DataSize
  405. );
  406. /**
  407. Gets the protocol version used by the specified TLS connection.
  408. This function returns the protocol version used by the specified TLS
  409. connection.
  410. If Tls is NULL, then ASSERT().
  411. @param[in] Tls Pointer to the TLS object.
  412. @return The protocol version of the specified TLS connection.
  413. **/
  414. UINT16
  415. EFIAPI
  416. TlsGetVersion (
  417. IN VOID *Tls
  418. );
  419. /**
  420. Gets the connection end of the specified TLS connection.
  421. This function returns the connection end (as client or as server) used by
  422. the specified TLS connection.
  423. If Tls is NULL, then ASSERT().
  424. @param[in] Tls Pointer to the TLS object.
  425. @return The connection end used by the specified TLS connection.
  426. **/
  427. UINT8
  428. EFIAPI
  429. TlsGetConnectionEnd (
  430. IN VOID *Tls
  431. );
  432. /**
  433. Gets the cipher suite used by the specified TLS connection.
  434. This function returns current cipher suite used by the specified
  435. TLS connection.
  436. @param[in] Tls Pointer to the TLS object.
  437. @param[in,out] CipherId The cipher suite used by the TLS object.
  438. @retval EFI_SUCCESS The cipher suite was returned successfully.
  439. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  440. @retval EFI_UNSUPPORTED Unsupported cipher suite.
  441. **/
  442. EFI_STATUS
  443. EFIAPI
  444. TlsGetCurrentCipher (
  445. IN VOID *Tls,
  446. IN OUT UINT16 *CipherId
  447. );
  448. /**
  449. Gets the compression methods used by the specified TLS connection.
  450. This function returns current integrated compression methods used by
  451. the specified TLS connection.
  452. @param[in] Tls Pointer to the TLS object.
  453. @param[in,out] CompressionId The current compression method used by
  454. the TLS object.
  455. @retval EFI_SUCCESS The compression method was returned successfully.
  456. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  457. @retval EFI_ABORTED Invalid Compression method.
  458. @retval EFI_UNSUPPORTED This function is not supported.
  459. **/
  460. EFI_STATUS
  461. EFIAPI
  462. TlsGetCurrentCompressionId (
  463. IN VOID *Tls,
  464. IN OUT UINT8 *CompressionId
  465. );
  466. /**
  467. Gets the verification mode currently set in the TLS connection.
  468. This function returns the peer verification mode currently set in the
  469. specified TLS connection.
  470. If Tls is NULL, then ASSERT().
  471. @param[in] Tls Pointer to the TLS object.
  472. @return The verification mode set in the specified TLS connection.
  473. **/
  474. UINT32
  475. EFIAPI
  476. TlsGetVerify (
  477. IN VOID *Tls
  478. );
  479. /**
  480. Gets the session ID used by the specified TLS connection.
  481. This function returns the TLS/SSL session ID currently used by the
  482. specified TLS connection.
  483. @param[in] Tls Pointer to the TLS object.
  484. @param[in,out] SessionId Buffer to contain the returned session ID.
  485. @param[in,out] SessionIdLen The length of Session ID in bytes.
  486. @retval EFI_SUCCESS The Session ID was returned successfully.
  487. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  488. @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
  489. **/
  490. EFI_STATUS
  491. EFIAPI
  492. TlsGetSessionId (
  493. IN VOID *Tls,
  494. IN OUT UINT8 *SessionId,
  495. IN OUT UINT16 *SessionIdLen
  496. );
  497. /**
  498. Gets the client random data used in the specified TLS connection.
  499. This function returns the TLS/SSL client random data currently used in
  500. the specified TLS connection.
  501. @param[in] Tls Pointer to the TLS object.
  502. @param[in,out] ClientRandom Buffer to contain the returned client
  503. random data (32 bytes).
  504. **/
  505. VOID
  506. EFIAPI
  507. TlsGetClientRandom (
  508. IN VOID *Tls,
  509. IN OUT UINT8 *ClientRandom
  510. );
  511. /**
  512. Gets the server random data used in the specified TLS connection.
  513. This function returns the TLS/SSL server random data currently used in
  514. the specified TLS connection.
  515. @param[in] Tls Pointer to the TLS object.
  516. @param[in,out] ServerRandom Buffer to contain the returned server
  517. random data (32 bytes).
  518. **/
  519. VOID
  520. EFIAPI
  521. TlsGetServerRandom (
  522. IN VOID *Tls,
  523. IN OUT UINT8 *ServerRandom
  524. );
  525. /**
  526. Gets the master key data used in the specified TLS connection.
  527. This function returns the TLS/SSL master key material currently used in
  528. the specified TLS connection.
  529. @param[in] Tls Pointer to the TLS object.
  530. @param[in,out] KeyMaterial Buffer to contain the returned key material.
  531. @retval EFI_SUCCESS Key material was returned successfully.
  532. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  533. @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
  534. **/
  535. EFI_STATUS
  536. EFIAPI
  537. TlsGetKeyMaterial (
  538. IN VOID *Tls,
  539. IN OUT UINT8 *KeyMaterial
  540. );
  541. /**
  542. Gets the CA Certificate from the cert store.
  543. This function returns the CA certificate for the chosen
  544. TLS connection.
  545. @param[in] Tls Pointer to the TLS object.
  546. @param[out] Data Pointer to the data buffer to receive the CA
  547. certificate data sent to the client.
  548. @param[in,out] DataSize The size of data buffer in bytes.
  549. @retval EFI_SUCCESS The operation succeeded.
  550. @retval EFI_UNSUPPORTED This function is not supported.
  551. @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
  552. **/
  553. EFI_STATUS
  554. EFIAPI
  555. TlsGetCaCertificate (
  556. IN VOID *Tls,
  557. OUT VOID *Data,
  558. IN OUT UINTN *DataSize
  559. );
  560. /**
  561. Gets the local public Certificate set in the specified TLS object.
  562. This function returns the local public certificate which was currently set
  563. in the specified TLS object.
  564. @param[in] Tls Pointer to the TLS object.
  565. @param[out] Data Pointer to the data buffer to receive the local
  566. public certificate.
  567. @param[in,out] DataSize The size of data buffer in bytes.
  568. @retval EFI_SUCCESS The operation succeeded.
  569. @retval EFI_INVALID_PARAMETER The parameter is invalid.
  570. @retval EFI_NOT_FOUND The certificate is not found.
  571. @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
  572. **/
  573. EFI_STATUS
  574. EFIAPI
  575. TlsGetHostPublicCert (
  576. IN VOID *Tls,
  577. OUT VOID *Data,
  578. IN OUT UINTN *DataSize
  579. );
  580. /**
  581. Gets the local private key set in the specified TLS object.
  582. This function returns the local private key data which was currently set
  583. in the specified TLS object.
  584. @param[in] Tls Pointer to the TLS object.
  585. @param[out] Data Pointer to the data buffer to receive the local
  586. private key data.
  587. @param[in,out] DataSize The size of data buffer in bytes.
  588. @retval EFI_SUCCESS The operation succeeded.
  589. @retval EFI_UNSUPPORTED This function is not supported.
  590. @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
  591. **/
  592. EFI_STATUS
  593. EFIAPI
  594. TlsGetHostPrivateKey (
  595. IN VOID *Tls,
  596. OUT VOID *Data,
  597. IN OUT UINTN *DataSize
  598. );
  599. /**
  600. Gets the CA-supplied certificate revocation list data set in the specified
  601. TLS object.
  602. This function returns the CA-supplied certificate revocation list data which
  603. was currently set in the specified TLS object.
  604. @param[out] Data Pointer to the data buffer to receive the CRL data.
  605. @param[in,out] DataSize The size of data buffer in bytes.
  606. @retval EFI_SUCCESS The operation succeeded.
  607. @retval EFI_UNSUPPORTED This function is not supported.
  608. @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
  609. **/
  610. EFI_STATUS
  611. EFIAPI
  612. TlsGetCertRevocationList (
  613. OUT VOID *Data,
  614. IN OUT UINTN *DataSize
  615. );
  616. #endif // __TLS_LIB_H__