|
53 | 53 | #include "wolfhsm/wh_dma.h" |
54 | 54 | #endif /* WOLFHSM_CFG_DMA */ |
55 | 55 | #include "wolfhsm/wh_keyid.h" |
| 56 | +#include "wolfhsm/wh_auth.h" |
56 | 57 |
|
57 | 58 |
|
58 | 59 | /* Forward declaration of the client structure so its elements can reference |
@@ -1866,6 +1867,67 @@ int wh_Client_CustomCbCheckRegisteredResponse(whClientContext* c, |
1866 | 1867 | int wh_Client_CustomCbCheckRegistered(whClientContext* c, uint16_t id, |
1867 | 1868 | int* responseError); |
1868 | 1869 |
|
| 1870 | +/* Auth Manager functions */ |
| 1871 | + |
| 1872 | +/** |
| 1873 | + * @brief Sends an authentication request to the server. |
| 1874 | + * |
| 1875 | + * This function prepares and sends an authentication request message to the server. |
| 1876 | + * The request includes the authentication method and authentication data (e.g., PIN). |
| 1877 | + * This function does not block; it returns immediately after sending the request. |
| 1878 | + * |
| 1879 | + * @param[in] c Pointer to the client context. |
| 1880 | + * @param[in] method The authentication method to use (e.g., WH_AUTH_METHOD_PIN). |
| 1881 | + * @param[in] auth_data Pointer to the authentication data. |
| 1882 | + * @param[in] auth_data_len Length of the authentication data. |
| 1883 | + * @return int Returns 0 on success, or a negative error code on failure. |
| 1884 | + */ |
| 1885 | +int wh_Client_AuthAuthenticateRequest(whClientContext* c, |
| 1886 | + whAuthMethod method, const void* auth_data, uint16_t auth_data_len); |
| 1887 | + |
| 1888 | +/** |
| 1889 | + * @brief Receives an authentication response from the server. |
| 1890 | + * |
| 1891 | + * This function attempts to process an authentication response message from the server. |
| 1892 | + * It validates the response and extracts the return code, user ID, session ID, and |
| 1893 | + * permissions. This function does not block; it returns WH_ERROR_NOTREADY if a |
| 1894 | + * response has not been received. |
| 1895 | + * |
| 1896 | + * @param[in] c Pointer to the client context. |
| 1897 | + * @param[out] out_rc Pointer to store the return code from the server. |
| 1898 | + * @param[out] out_user_id Pointer to store the authenticated user ID. |
| 1899 | + * @param[out] out_session_id Pointer to store the session ID. |
| 1900 | + * @param[out] out_permissions Pointer to store the user permissions. |
| 1901 | + * @return int Returns 0 on success, WH_ERROR_NOTREADY if no response is |
| 1902 | + * available, or a negative error code on failure. |
| 1903 | + */ |
| 1904 | +int wh_Client_AuthAuthenticateResponse(whClientContext* c, int32_t *out_rc, |
| 1905 | + whUserId* out_user_id, whSessionId* out_session_id, |
| 1906 | + whAuthPermissions* out_permissions); |
| 1907 | + |
| 1908 | +/** |
| 1909 | + * @brief Authenticates a user with the server (blocking convenience wrapper). |
| 1910 | + * |
| 1911 | + * This function handles the complete process of sending an authentication request |
| 1912 | + * to the server and receiving the response. It sends the request and repeatedly |
| 1913 | + * attempts to receive a valid response. This function blocks until the entire |
| 1914 | + * operation is complete or an error occurs. |
| 1915 | + * |
| 1916 | + * @param[in] c Pointer to the client context. |
| 1917 | + * @param[in] method The authentication method to use (e.g., WH_AUTH_METHOD_PIN). |
| 1918 | + * @param[in] auth_data Pointer to the authentication data. |
| 1919 | + * @param[in] auth_data_len Length of the authentication data. |
| 1920 | + * @param[out] out_rc Pointer to store the return code from the server. |
| 1921 | + * @param[out] out_user_id Pointer to store the authenticated user ID. |
| 1922 | + * @param[out] out_session_id Pointer to store the session ID. |
| 1923 | + * @param[out] out_permissions Pointer to store the user permissions. |
| 1924 | + * @return int Returns 0 on success, or a negative error code on failure. |
| 1925 | + */ |
| 1926 | +int wh_Client_AuthAuthenticate(whClientContext* c, whAuthMethod method, |
| 1927 | + const void* auth_data, uint16_t auth_data_len, |
| 1928 | + int32_t* out_rc, whUserId* out_user_id, whSessionId* out_session_id, |
| 1929 | + whAuthPermissions* out_permissions); |
| 1930 | + |
1869 | 1931 | /* Certificate functions */ |
1870 | 1932 |
|
1871 | 1933 | /** |
|
0 commit comments