X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=CryptoPkg%2FInclude%2FLibrary%2FBaseCryptLib.h;h=d3b211bec5b67a90d3d8a8417a09e22040cc3dc6;hp=e36041bf4f782c3c60e14c73f770b682fc299e8e;hb=952bd2291872b5e2d302f8de1349239bfbd0332c;hpb=2ac68e8b549b646607149919a2780bcd7234d92d diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/Library/BaseCryptLib.h index e36041bf4f..d3b211bec5 100644 --- a/CryptoPkg/Include/Library/BaseCryptLib.h +++ b/CryptoPkg/Include/Library/BaseCryptLib.h @@ -4,7 +4,7 @@ primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI security functionality enabling. -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1631,6 +1631,8 @@ RsaGenerateKey ( /** Validates key components of RSA context. + NOTE: This function performs integrity checks on all the RSA key material, so + the RSA key structure must contain all the private key data. This function validates key compoents of RSA context in following aspects: - Whether p is a prime @@ -1859,7 +1861,7 @@ X509ConstructCertificate ( If X509Stack is NULL, then return FALSE. If this interface is not supported, then return FALSE. - @param[in, out] X509Stack On input, pointer to an existing X509 stack object. + @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object. On output, pointer to the X509 stack object with new inserted X509 certificate. @param ... A list of DER-encoded single certificate data followed @@ -1906,6 +1908,32 @@ X509StackFree ( IN VOID *X509Stack ); +/** + Retrieve the TBSCertificate from one given X.509 certificate. + + @param[in] Cert Pointer to the given DER-encoded X509 certificate. + @param[in] CertSize Size of the X509 certificate in bytes. + @param[out] TBSCert DER-Encoded To-Be-Signed certificate. + @param[out] TBSCertSize Size of the TBS certificate in bytes. + + If Cert is NULL, then return FALSE. + If TBSCert is NULL, then return FALSE. + If TBSCertSize is NULL, then return FALSE. + If this interface is not supported, then return FALSE. + + @retval TRUE The TBSCertificate was retrieved successfully. + @retval FALSE Invalid X.509 certificate. + +**/ +BOOLEAN +EFIAPI +X509GetTBSCert ( + IN CONST UINT8 *Cert, + IN UINTN CertSize, + OUT UINT8 **TBSCert, + OUT UINTN *TBSCertSize + ); + /** Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7: Cryptographic Message Syntax Standard". The input signed data could be wrapped @@ -2027,6 +2055,35 @@ Pkcs7Verify ( IN UINTN DataLength ); +/** + Extracts the attached content from a PKCS#7 signed data if existed. The input signed + data could be wrapped in a ContentInfo structure. + + If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow, + then return FAlSE. If the P7Data is not correctly formatted, then return FALSE. + + Caution: This function may receive untrusted input. So this function will do + basic check for PKCS#7 data structure. + + @param[in] P7Data Pointer to the PKCS#7 signed data to process. + @param[in] P7Length Length of the PKCS#7 signed data in bytes. + @param[out] Content Pointer to the extracted content from the PKCS#7 signedData. + It's caller's responsiblity to free the buffer. + @param[out] ContentSize The size of the extracted content in bytes. + + @retval TRUE The P7Data was correctly formatted for processing. + @retval FALSE The P7Data was not correctly formatted for processing. + +*/ +BOOLEAN +EFIAPI +Pkcs7GetAttachedContent ( + IN CONST UINT8 *P7Data, + IN UINTN P7Length, + OUT VOID **Content, + OUT UINTN *ContentSize + ); + /** Verifies the validility of a PE/COFF Authenticode Signature as described in "Windows Authenticode Portable Executable Signature Format". @@ -2067,6 +2124,7 @@ AuthenticodeVerify ( signature. If AuthData is NULL, then return FALSE. + If this interface is not supported, then return FALSE. @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed PE/COFF image to be verified. @@ -2306,4 +2364,4 @@ RandomBytes ( IN UINTN Size ); -#endif // __BASE_CRYPT_LIB_H__ \ No newline at end of file +#endif // __BASE_CRYPT_LIB_H__