1 /**
2  *  Copyright Notice:
3  *  Copyright 2021-2023 DMTF. All rights reserved.
4  *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5  **/
6 
7 #ifndef RESPONDER_CSRLIB_H
8 #define RESPONDER_CSRLIB_H
9 
10 #include "hal/base.h"
11 #include "internal/libspdm_lib_config.h"
12 #include "library/spdm_return_status.h"
13 #include "industry_standard/spdm.h"
14 
15 #if LIBSPDM_ENABLE_CAPABILITY_CSR_CAP
16 /**
17  * Gen CSR
18  *
19  * @param[in]      base_hash_algo        Indicates the signing algorithm.
20  * @param[in]      base_asym_algo        Indicates the hash algorithm.
21  * @param[in]      need_reset            If true, then device needs to be reset to complete the CSR.
22  *                                       If false
23  *
24  * @param[in]      request                A pointer to the SPDM request data.
25  * @param[in]      request_size           The size of SPDM request data.
26  *
27  * @param[in]      requester_info         Requester info to generate the CSR.
28  * @param[in]      requester_info_length  The length of requester info.
29  *
30  * @param[in]      opaque_data            opaque data to generate the CSR.
31  * @param[in]      opaque_data_length     The length of opaque data.
32  *
33  * @param[in]      csr_len      For input, csr_len is the size of store CSR buffer.
34  *                              For output, csr_len is CSR len for DER format
35  * @param[in]      csr_pointer  On input, csr_pointer is buffer address to store CSR.
36  *                              On output, csr_pointer is address for stored CSR.
37  *                              The csr_pointer address will be changed.
38  *
39  * @param[in]       is_device_cert_model  If true, the cert chain is DeviceCert model.
40  *                                        If false, the cert chain is AliasCert model.
41  *
42  * @retval  true   Success.
43  * @retval  false  Failed to gen CSR.
44  **/
45 extern bool libspdm_gen_csr(uint32_t base_hash_algo, uint32_t base_asym_algo, bool *need_reset,
46                             const void *request, size_t request_size,
47                             uint8_t *requester_info, size_t requester_info_length,
48                             uint8_t *opaque_data, uint16_t opaque_data_length,
49                             size_t *csr_len, uint8_t *csr_pointer,
50                             bool is_device_cert_model);
51 #endif /* LIBSPDM_ENABLE_CAPABILITY_CSR_CAP */
52 
53 #endif /* RESPONDER_CSRLIB_H */
54