]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/BaseCryptLibNull/Pk/CryptPkcs7VerifyNull.c
CryptoPkg: Add Null instance of the BaseCryptLib class
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibNull / Pk / CryptPkcs7VerifyNull.c
diff --git a/CryptoPkg/Library/BaseCryptLibNull/Pk/CryptPkcs7VerifyNull.c b/CryptoPkg/Library/BaseCryptLibNull/Pk/CryptPkcs7VerifyNull.c
new file mode 100644 (file)
index 0000000..0ddf16a
--- /dev/null
@@ -0,0 +1,163 @@
+/** @file\r
+  PKCS#7 SignedData Verification Wrapper Implementation which does not provide\r
+  real capabilities.\r
+\r
+Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "InternalCryptLib.h"\r
+\r
+/**\r
+  Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[out] CertStack    Pointer to Signer's certificates retrieved from P7Data.\r
+                           It's caller's responsibility to free the buffer with\r
+                           Pkcs7FreeSigners().\r
+                           This data structure is EFI_CERT_STACK type.\r
+  @param[out] StackLength  Length of signer's certificates in bytes.\r
+  @param[out] TrustedCert  Pointer to a trusted certificate from Signer's certificates.\r
+                           It's caller's responsibility to free the buffer with\r
+                           Pkcs7FreeSigners().\r
+  @param[out] CertLength   Length of the trusted certificate in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetSigners (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT UINT8        **CertStack,\r
+  OUT UINTN        *StackLength,\r
+  OUT UINT8        **TrustedCert,\r
+  OUT UINTN        *CertLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Wrap function to use free() to free allocated memory for certificates.\r
+\r
+  If the interface is not supported, then ASSERT().\r
+\r
+  @param[in]  Certs        Pointer to the certificates to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Pkcs7FreeSigners (\r
+  IN  UINT8        *Certs\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+}\r
+\r
+/**\r
+  Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r
+  unchained to the signer's certificates.\r
+  The input signed data could be wrapped in a ContentInfo structure.\r
+\r
+  @param[in]  P7Data            Pointer to the PKCS#7 message.\r
+  @param[in]  P7Length          Length of the PKCS#7 message in bytes.\r
+  @param[out] SignerChainCerts  Pointer to the certificates list chained to signer's\r
+                                certificate. It's caller's responsibility to free the buffer\r
+                                with Pkcs7FreeSigners().\r
+                                This data structure is EFI_CERT_STACK type.\r
+  @param[out] ChainLength       Length of the chained certificates list buffer in bytes.\r
+  @param[out] UnchainCerts      Pointer to the unchained certificates lists. It's caller's\r
+                                responsibility to free the buffer with Pkcs7FreeSigners().\r
+                                This data structure is EFI_CERT_STACK type.\r
+  @param[out] UnchainLength     Length of the unchained certificates list buffer in bytes.\r
+\r
+  @retval  TRUE         The operation is finished successfully.\r
+  @retval  FALSE        Error occurs during the operation.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetCertificatesList (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT UINT8        **SignerChainCerts,\r
+  OUT UINTN        *ChainLength,\r
+  OUT UINT8        **UnchainCerts,\r
+  OUT UINTN        *UnchainLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r
+  Cryptographic Message Syntax Standard". The input signed data could be wrapped\r
+  in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]  P7Data       Pointer to the PKCS#7 message to verify.\r
+  @param[in]  P7Length     Length of the PKCS#7 message in bytes.\r
+  @param[in]  TrustedCert  Pointer to a trusted/root certificate encoded in DER, which\r
+                           is used for certificate chain verification.\r
+  @param[in]  CertLength   Length of the trusted certificate in bytes.\r
+  @param[in]  InData       Pointer to the content to be verified.\r
+  @param[in]  DataLength   Length of InData in bytes.\r
+\r
+  @retval FALSE  This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7Verify (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  IN  CONST UINT8  *TrustedCert,\r
+  IN  UINTN        CertLength,\r
+  IN  CONST UINT8  *InData,\r
+  IN  UINTN        DataLength\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r
+  data could be wrapped in a ContentInfo structure.\r
+\r
+  Return FALSE to indicate this interface is not supported.\r
+\r
+  @param[in]   P7Data       Pointer to the PKCS#7 signed data to process.\r
+  @param[in]   P7Length     Length of the PKCS#7 signed data in bytes.\r
+  @param[out]  Content      Pointer to the extracted content from the PKCS#7 signedData.\r
+                            It's caller's responsibility to free the buffer with FreePool().\r
+  @param[out]  ContentSize  The size of the extracted content in bytes.\r
+\r
+  @retval     TRUE          The P7Data was correctly formatted for processing.\r
+  @retval     FALSE         The P7Data was not correctly formatted for processing.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+Pkcs7GetAttachedContent (\r
+  IN  CONST UINT8  *P7Data,\r
+  IN  UINTN        P7Length,\r
+  OUT VOID         **Content,\r
+  OUT UINTN        *ContentSize\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r