From d65ab089b9ceb8ef8ab9373ab7c450b2a1957cd8 Mon Sep 17 00:00:00 2001 From: Wenxing Hou Date: Thu, 29 Feb 2024 15:11:00 +0800 Subject: [PATCH] Clear libspdm_x509_get_extension_data return description Fix the issue: #2590 Signed-off-by: Wenxing Hou --- include/hal/library/cryptlib/cryptlib_cert.h | 9 ++++++--- os_stub/cryptlib_mbedtls/pk/x509.c | 16 ++++++---------- os_stub/cryptlib_null/pk/x509.c | 16 ++++++---------- os_stub/cryptlib_openssl/pk/x509.c | 16 ++++++---------- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/include/hal/library/cryptlib/cryptlib_cert.h b/include/hal/library/cryptlib/cryptlib_cert.h index 8bc485fa392..f69f75632e6 100644 --- a/include/hal/library/cryptlib/cryptlib_cert.h +++ b/include/hal/library/cryptlib/cryptlib_cert.h @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -112,8 +112,11 @@ extern bool libspdm_x509_get_issuer_name(const uint8_t *cert, size_t cert_size, * @param[out] extension_data Extension bytes. * @param[in, out] extension_data_size Extension bytes size. * - * @retval true - * @retval false + * @return true If the returned extension_data_size == 0, it means that cert and oid are valid, but the oid extension is not found; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found; + * @return false If the returned extension_data_size == 0, it means that cert or oid are invalid; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found, + * but the store buffer is too small. **/ extern bool libspdm_x509_get_extension_data(const uint8_t *cert, size_t cert_size, const uint8_t *oid, size_t oid_size, diff --git a/os_stub/cryptlib_mbedtls/pk/x509.c b/os_stub/cryptlib_mbedtls/pk/x509.c index e4e36493930..e2120df66bc 100644 --- a/os_stub/cryptlib_mbedtls/pk/x509.c +++ b/os_stub/cryptlib_mbedtls/pk/x509.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -1225,15 +1225,11 @@ libspdm_internal_x509_find_extension_data(uint8_t *start, uint8_t *end, const ui * @param[out] extension_data Extension bytes. * @param[in, out] extension_data_size Extension bytes size. * - * @retval RETURN_SUCCESS The certificate Extension data retrieved successfully. - * @retval RETURN_INVALID_PARAMETER If cert is NULL. - * If extension_data_size is NULL. - * If extension_data is not NULL and *extension_data_size is 0. - * If Certificate is invalid. - * @retval RETURN_NOT_FOUND If no Extension entry match oid. - * @retval RETURN_BUFFER_TOO_SMALL If the extension_data is NULL. The required buffer size - * is returned in the extension_data_size parameter. - * @retval RETURN_UNSUPPORTED The operation is not supported. + * @return true If the returned extension_data_size == 0, it means that cert and oid are valid, but the oid extension is not found; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found; + * @return false If the returned extension_data_size == 0, it means that cert or oid are invalid; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found, + * but the store buffer is too small. **/ bool libspdm_x509_get_extension_data(const uint8_t *cert, size_t cert_size, const uint8_t *oid, size_t oid_size, diff --git a/os_stub/cryptlib_null/pk/x509.c b/os_stub/cryptlib_null/pk/x509.c index fd1030a19c3..82e4e159a42 100644 --- a/os_stub/cryptlib_null/pk/x509.c +++ b/os_stub/cryptlib_null/pk/x509.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -570,15 +570,11 @@ bool libspdm_x509_get_signature_algorithm(const uint8_t *cert, * @param[out] extension_data Extension bytes. * @param[in, out] extension_data_size Extension bytes size. * - * @retval RETURN_SUCCESS The certificate Extension data retrieved successfully. - * @retval RETURN_INVALID_PARAMETER If cert is NULL. - * If extension_data_size is NULL. - * If extension_data is not NULL and *extension_data_size is 0. - * If Certificate is invalid. - * @retval RETURN_NOT_FOUND If no Extension entry match oid. - * @retval RETURN_BUFFER_TOO_SMALL If the extension_data is NULL. The required buffer size - * is returned in the extension_data_size parameter. - * @retval RETURN_UNSUPPORTED The operation is not supported. + * @return true If the returned extension_data_size == 0, it means that cert and oid are valid, but the oid extension is not found; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found; + * @return false If the returned extension_data_size == 0, it means that cert or oid are invalid; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found, + * but the store buffer is too small. **/ bool libspdm_x509_get_extension_data(const uint8_t *cert, size_t cert_size, const uint8_t *oid, size_t oid_size, diff --git a/os_stub/cryptlib_openssl/pk/x509.c b/os_stub/cryptlib_openssl/pk/x509.c index b0881520837..14bdc8504c7 100644 --- a/os_stub/cryptlib_openssl/pk/x509.c +++ b/os_stub/cryptlib_openssl/pk/x509.c @@ -1,6 +1,6 @@ /** * Copyright Notice: - * Copyright 2021-2022 DMTF. All rights reserved. + * Copyright 2021-2024 DMTF. All rights reserved. * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md **/ @@ -1326,15 +1326,11 @@ bool libspdm_x509_get_key_usage(const uint8_t *cert, size_t cert_size, * @param[out] extension_data Extension bytes. * @param[in, out] extension_data_size Extension bytes size. * - * @retval RETURN_SUCCESS The certificate Extension data retrieved successfully. - * @retval RETURN_INVALID_PARAMETER If cert is NULL. - * If extension_data_size is NULL. - * If extension_data is not NULL and *extension_data_size is 0. - * If Certificate is invalid. - * @retval RETURN_NOT_FOUND If no Extension entry match oid. - * @retval RETURN_BUFFER_TOO_SMALL If the extension_data is NULL. The required buffer size - * is returned in the extension_data_size parameter. - * @retval RETURN_UNSUPPORTED The operation is not supported. + * @return true If the returned extension_data_size == 0, it means that cert and oid are valid, but the oid extension is not found; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found; + * @return false If the returned extension_data_size == 0, it means that cert or oid are invalid; + * If the returned extension_data_size != 0, it means that cert and oid are valid, and the oid extension is found, + * but the store buffer is too small. **/ bool libspdm_x509_get_extension_data(const uint8_t *cert, size_t cert_size, const uint8_t *oid, size_t oid_size,