|
1 | 1 | /** |
2 | 2 | * Copyright Notice: |
3 | | - * Copyright 2021-2025 DMTF. All rights reserved. |
| 3 | + * Copyright 2021-2026 DMTF. All rights reserved. |
4 | 4 | * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md |
5 | 5 | **/ |
6 | 6 |
|
@@ -1581,6 +1581,99 @@ bool libspdm_kem_decapsulate(uint32_t kem_alg, void *context, |
1581 | 1581 | uint8_t *shared_secret, |
1582 | 1582 | size_t *shared_secret_size); |
1583 | 1583 |
|
| 1584 | +/** |
| 1585 | + * This function concatenates binary data, which is used as info in HKDF expand later. |
| 1586 | + * |
| 1587 | + * @param label An ascii string label for the libspdm_bin_concat. |
| 1588 | + * @param label_size The size in bytes of the ASCII string label, not including NULL terminator. |
| 1589 | + * @param context A pre-defined hash value as the context for the libspdm_bin_concat. |
| 1590 | + * @param length 16 bits length for the libspdm_bin_concat. |
| 1591 | + * @param hash_size The size in bytes of the context hash. |
| 1592 | + * @param out_bin The buffer to store the output binary. |
| 1593 | + * @param out_bin_size The size in bytes for the out_bin. |
| 1594 | + **/ |
| 1595 | +void libspdm_bin_concat(spdm_version_number_t spdm_version, |
| 1596 | + const char *label, size_t label_size, |
| 1597 | + const uint8_t *context, uint16_t length, |
| 1598 | + size_t hash_size, uint8_t *out_bin, |
| 1599 | + size_t *out_bin_size); |
| 1600 | + |
| 1601 | +/** |
| 1602 | + * This function generates SPDM HandshakeKey. |
| 1603 | + * |
| 1604 | + * @param spdm_version The SPDM version number. |
| 1605 | + * @param secret Pointer to the input secret used for key derivation. |
| 1606 | + * For DHE/KEM, input is shared_secret |
| 1607 | + * For PSK, input is psk_hint |
| 1608 | + * For PSK (FIPS test), input is psk |
| 1609 | + * @param secret_size Size of the input secret in bytes. |
| 1610 | + * @param use_psk Indicates whether to use PSK for key generation. |
| 1611 | + * @param base_hash_algo The base hash algorithm identifier to use for key derivation. |
| 1612 | + * @param th1_hash_data Pointer to the TH1 hash data used in the key derivation process. |
| 1613 | + * @param handshake_secret Pointer to the buffer that will receive the generated handshake secret. |
| 1614 | + * @param handshake_secret_size On input, the size of the handshake_secret buffer. |
| 1615 | + * On output, the actual size of the generated handshake secret. |
| 1616 | + * @param request_handshake_secret Pointer to the buffer that will receive the generated request handshake secret. |
| 1617 | + * @param request_handshake_secret_size On input, the size of the request_handshake_secret buffer. |
| 1618 | + * On output, the actual size of the generated handshake secret. |
| 1619 | + * @param response_handshake_secret Pointer to the buffer that will receive the generated response handshake secret. |
| 1620 | + * @param response_handshake_secret_size On input, the size of the response_handshake_secret buffer. |
| 1621 | + * On output, the actual size of the generated handshake secret. |
| 1622 | + * @param fips_test Indicates whether the function is being called for FIPS test purposes. |
| 1623 | + * |
| 1624 | + * @retval true Handshake keys were generated successfully. |
| 1625 | + * @retval false An error occurred during key generation. |
| 1626 | + */ |
| 1627 | +bool libspdm_generate_handshake_key ( |
| 1628 | + spdm_version_number_t spdm_version, |
| 1629 | + const uint8_t *secret, size_t secret_size, |
| 1630 | + bool use_psk, uint32_t base_hash_algo, |
| 1631 | + const uint8_t *th1_hash_data, |
| 1632 | + uint8_t *handshake_secret, size_t *handshake_secret_size, |
| 1633 | + uint8_t *request_handshake_secret, size_t *request_handshake_secret_size, |
| 1634 | + uint8_t *response_handshake_secret, size_t *response_handshake_secret_size, |
| 1635 | + bool fips_test); |
| 1636 | + |
| 1637 | +/** |
| 1638 | + * This function generates SPDM DataKey. |
| 1639 | + * |
| 1640 | + * @param spdm_version The SPDM version number. |
| 1641 | + * @param secret Pointer to the input secret used for key derivation. |
| 1642 | + * For DHE/KEM, input is handshake_secret |
| 1643 | + * For PSK, input is psk_hint |
| 1644 | + * For PSK (FIPS test), input is psk |
| 1645 | + * @param secret_size Size of the input secret in bytes. |
| 1646 | + * @param use_psk Indicates whether to use PSK for key generation. |
| 1647 | + * @param base_hash_algo The base hash algorithm identifier to use for key derivation. |
| 1648 | + * @param th2_hash_data Pointer to the TH2 hash data used in the key derivation process. |
| 1649 | + * @param master_secret Pointer to the buffer that will receive the generated master secret. |
| 1650 | + * @param master_secret_size On input, the size of the master_secret buffer. |
| 1651 | + * On output, the actual size of the generated master secret. |
| 1652 | + * @param request_data_secret Pointer to the buffer that will receive the generated request data secret. |
| 1653 | + * @param request_data_secret_size On input, the size of the request_data_secret buffer. |
| 1654 | + * On output, the actual size of the generated data secret. |
| 1655 | + * @param response_data_secret Pointer to the buffer that will receive the generated response data secret. |
| 1656 | + * @param response_data_secret_size On input, the size of the response_data_secret buffer. |
| 1657 | + * On output, the actual size of the generated data secret. |
| 1658 | + * @param export_master_secret Pointer to the buffer that will receive the generated export master secret. |
| 1659 | + * @param export_master_secret_size On input, the size of the export_master_secret buffer. |
| 1660 | + * On output, the actual size of the generated export master secret. |
| 1661 | + * @param fips_test Indicates whether the function is being called for FIPS test purposes. |
| 1662 | + * |
| 1663 | + * @retval true Handshake keys were generated successfully. |
| 1664 | + * @retval false An error occurred during key generation. |
| 1665 | + */ |
| 1666 | +bool libspdm_generate_data_key ( |
| 1667 | + spdm_version_number_t spdm_version, |
| 1668 | + const uint8_t *secret, size_t secret_size, |
| 1669 | + bool use_psk, uint32_t base_hash_algo, |
| 1670 | + const uint8_t *th2_hash_data, |
| 1671 | + uint8_t *master_secret, size_t *master_secret_size, |
| 1672 | + uint8_t *request_data_secret, size_t *request_data_secret_size, |
| 1673 | + uint8_t *response_data_secret, size_t *response_data_secret_size, |
| 1674 | + uint8_t *export_master_secret, size_t *export_master_secret_size, |
| 1675 | + bool fips_test); |
| 1676 | + |
1584 | 1677 | #if LIBSPDM_FIPS_MODE |
1585 | 1678 | /*run all of the self-tests and returns the results.*/ |
1586 | 1679 | bool libspdm_fips_run_selftest(void *fips_selftest_context); |
|
0 commit comments