1 /**
2  *  Copyright Notice:
3  *  Copyright 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 REQUESTER_REQASYMSIGNLIB_H
8 #define REQUESTER_REQASYMSIGNLIB_H
9 
10 #include "hal/base.h"
11 #include "internal/libspdm_lib_config.h"
12 
13 #if LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP
14 /**
15  * Sign an SPDM message data.
16  *
17  * @param  req_base_asym_alg Indicates the signing algorithm.
18  * @param  base_hash_algo    Indicates the hash algorithm.
19  * @param  is_data_hash      Indicates the message type.
20  *                           If true, raw message before hash.
21  *                           If false, message hash.
22  * @param  message           A pointer to a message to be signed.
23  * @param  message_size      The size in bytes of the message to be signed.
24  * @param  signature         A pointer to a destination buffer to store the signature.
25  * @param  sig_size          On input, indicates the size, in bytes, of the destination buffer to
26  *                           store the signature.
27  *                           On output, indicates the size, in bytes, of the signature in the
28  *                           buffer.
29  *
30  * @retval true  signing success.
31  * @retval false signing fail.
32  **/
33 extern bool libspdm_requester_data_sign(
34     spdm_version_number_t spdm_version,
35     uint8_t op_code,
36     uint16_t req_base_asym_alg,
37     uint32_t base_hash_algo, bool is_data_hash,
38     const uint8_t *message, size_t message_size,
39     uint8_t *signature, size_t *sig_size);
40 
41 #if LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP
42 /**
43  * This functions returns the opaque data in a CHALLENGE_AUTH response.
44  *
45  * @param spdm_version  Indicates the negotiated s version.
46  *
47  * @param  slot_id       The number of slot for the certificate chain.
48  *
49  * @param  measurement_summary_hash        The measurement summary hash.
50  * @param  measurement_summary_hash_size   The size of measurement summary hash.
51  *
52  * @param opaque_data
53  * A pointer to a destination buffer whose size, in bytes, is opaque_data_size. The opaque data is
54  * copied to this buffer.
55  *
56  * @param opaque_data_size
57  * On input, indicates the size, in bytes, of the destination buffer.
58  * On output, indicates the size of the opaque data.
59  **/
60 extern bool libspdm_encap_challenge_opaque_data(
61     spdm_version_number_t spdm_version,
62     uint8_t slot_id,
63     uint8_t *measurement_summary_hash,
64     size_t measurement_summary_hash_size,
65     void *opaque_data,
66     size_t *opaque_data_size);
67 #endif/*LIBSPDM_ENABLE_CAPABILITY_CHAL_CAP*/
68 
69 #endif /* LIBSPDM_ENABLE_CAPABILITY_MUT_AUTH_CAP */
70 
71 #endif /* REQUESTER_REQASYMSIGNLIB_H */
72