From e2a673b85336bc2d88f0b3975679b2ae7bf92f2e Mon Sep 17 00:00:00 2001 From: Bret Barkelew Date: Mon, 25 Mar 2019 12:01:08 +0800 Subject: [PATCH] CryptoPkg/BaseCryptLib.h: Add new API to get organization name REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1401 Add a prototype declaration of the new API X509GetOrganizationName in the header file. Signed-off-by: Zhichao Gao Cc: Ting Ye Cc: Gang Wei Cc: Wang Jian J Cc: Liming Gao Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Reviewed-by: Jian J Wang --- CryptoPkg/Include/Library/BaseCryptLib.h | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/Library/BaseCryptLib.h index 1350000b79..6183bb0df4 100644 --- a/CryptoPkg/Include/Library/BaseCryptLib.h +++ b/CryptoPkg/Include/Library/BaseCryptLib.h @@ -2200,6 +2200,41 @@ X509GetCommonName ( IN OUT UINTN *CommonNameSize ); +/** + Retrieve the organization name (O) string from one X.509 certificate. + + @param[in] Cert Pointer to the DER-encoded X509 certificate. + @param[in] CertSize Size of the X509 certificate in bytes. + @param[out] NameBuffer Buffer to contain the retrieved certificate organization + name string. At most NameBufferSize bytes will be + written and the string will be null terminated. May be + NULL in order to determine the size buffer needed. + @param[in,out] NameBufferSize The size in bytes of the Name buffer on input, + and the size of buffer returned Name on output. + If NameBuffer is NULL then the amount of space needed + in buffer (including the final null) is returned. + + @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully. + @retval RETURN_INVALID_PARAMETER If Cert is NULL. + If NameBufferSize is NULL. + If NameBuffer is not NULL and *CommonNameSize is 0. + If Certificate is invalid. + @retval RETURN_NOT_FOUND If no Organization Name entry exists. + @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size + (including the final null) is returned in the + CommonNameSize parameter. + @retval RETURN_UNSUPPORTED The operation is not supported. + +**/ +RETURN_STATUS +EFIAPI +X509GetOrganizationName ( + IN CONST UINT8 *Cert, + IN UINTN CertSize, + OUT CHAR8 *NameBuffer, OPTIONAL + IN OUT UINTN *NameBufferSize + ); + /** Verify one X509 certificate was issued by the trusted CA. -- 2.39.2