+/**\r
+ Retrieve the TBSCertificate from one given X.509 certificate.\r
+\r
+ @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r
+ @param[in] CertSize Size of the X509 certificate in bytes.\r
+ @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r
+ @param[out] TBSCertSize Size of the TBS certificate in bytes.\r
+\r
+ If Cert is NULL, then return FALSE.\r
+ If TBSCert is NULL, then return FALSE.\r
+ If TBSCertSize is NULL, then return FALSE.\r
+ If this interface is not supported, then return FALSE.\r
+\r
+ @retval TRUE The TBSCertificate was retrieved successfully.\r
+ @retval FALSE Invalid X.509 certificate.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509GetTBSCert (\r
+ IN CONST UINT8 *Cert,\r
+ IN UINTN CertSize,\r
+ OUT UINT8 **TBSCert,\r
+ OUT UINTN *TBSCertSize\r
+ );\r
+\r
+/**\r
+ Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r
+ password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r
+\r
+ If Password or Salt or OutKey is NULL, then return FALSE.\r
+ If the hash algorithm could not be determined, then return FALSE.\r
+ If this interface is not supported, then return FALSE.\r
+\r
+ @param[in] PasswordLength Length of input password in bytes.\r
+ @param[in] Password Pointer to the array for the password.\r
+ @param[in] SaltLength Size of the Salt in bytes.\r
+ @param[in] Salt Pointer to the Salt.\r
+ @param[in] IterationCount Number of iterations to perform. Its value should be\r
+ greater than or equal to 1.\r
+ @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r
+ NOTE: DigestSize will be used to determine the hash algorithm.\r
+ Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r
+ @param[in] KeyLength Size of the derived key buffer in bytes.\r
+ @param[out] OutKey Pointer to the output derived key buffer.\r
+\r
+ @retval TRUE A key was derived successfully.\r
+ @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r
+ @retval FALSE The hash algorithm could not be determined from the digest size.\r
+ @retval FALSE The key derivation operation failed.\r
+ @retval FALSE This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs5HashPassword (\r
+ IN UINTN PasswordLength,\r
+ IN CONST CHAR8 *Password,\r
+ IN UINTN SaltLength,\r
+ IN CONST UINT8 *Salt,\r
+ IN UINTN IterationCount,\r
+ IN UINTN DigestSize,\r
+ IN UINTN KeyLength,\r
+ OUT UINT8 *OutKey\r
+ );\r
+\r
+/**\r
+ Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r
+ encrypted message in a newly allocated buffer.\r
+\r
+ Things that can cause a failure include:\r
+ - X509 key size does not match any known key size.\r
+ - Fail to parse X509 certificate.\r
+ - Fail to allocate an intermediate buffer.\r
+ - Null pointer provided for a non-optional parameter.\r
+ - Data size is too large for the provided key size (max size is a function of key size\r
+ and hash digest size).\r
+\r
+ @param[in] PublicKey A pointer to the DER-encoded X509 certificate that\r
+ will be used to encrypt the data.\r
+ @param[in] PublicKeySize Size of the X509 cert buffer.\r
+ @param[in] InData Data to be encrypted.\r
+ @param[in] InDataSize Size of the data buffer.\r
+ @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer\r
+ to be used when initializing the PRNG. NULL otherwise.\r
+ @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.\r
+ 0 otherwise.\r
+ @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted\r
+ message.\r
+ @param[out] EncryptedDataSize Size of the encrypted message buffer.\r
+\r
+ @retval TRUE Encryption was successful.\r
+ @retval FALSE Encryption failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs1v2Encrypt (\r
+ IN CONST UINT8 *PublicKey,\r
+ IN UINTN PublicKeySize,\r
+ IN UINT8 *InData,\r
+ IN UINTN InDataSize,\r
+ IN CONST UINT8 *PrngSeed OPTIONAL,\r
+ IN UINTN PrngSeedSize OPTIONAL,\r
+ OUT UINT8 **EncryptedData,\r
+ OUT UINTN *EncryptedDataSize\r
+ );\r
+\r
+/**\r
+ The 3rd parameter of Pkcs7GetSigners will return all embedded\r
+ X.509 certificate in one given PKCS7 signature. The format is:\r
+ //\r
+ // UINT8 CertNumber;\r
+ // UINT32 Cert1Length;\r
+ // UINT8 Cert1[];\r
+ // UINT32 Cert2Length;\r
+ // UINT8 Cert2[];\r
+ // ...\r
+ // UINT32 CertnLength;\r
+ // UINT8 Certn[];\r
+ //\r
+\r
+ The two following C-structure are used for parsing CertStack more clearly.\r
+**/\r
+#pragma pack(1)\r
+\r
+typedef struct {\r
+ UINT32 CertDataLength; // The length in bytes of X.509 certificate.\r
+ UINT8 CertDataBuffer[0]; // The X.509 certificate content (DER).\r
+} EFI_CERT_DATA;\r
+\r
+typedef struct {\r
+ UINT8 CertNumber; // Number of X.509 certificate.\r
+ // EFI_CERT_DATA CertArray[]; // An array of X.509 certificate.\r
+} EFI_CERT_STACK;\r
+\r
+#pragma pack()\r
+\r