CryptPkcs7VerifyNull.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /** @file
  2. PKCS#7 SignedData Verification Wrapper Implementation which does not provide
  3. real capabilities.
  4. Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include "InternalCryptLib.h"
  8. /**
  9. Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:
  10. Cryptographic Message Syntax Standard". The input signed data could be wrapped
  11. in a ContentInfo structure.
  12. Return FALSE to indicate this interface is not supported.
  13. @param[in] P7Data Pointer to the PKCS#7 message to verify.
  14. @param[in] P7Length Length of the PKCS#7 message in bytes.
  15. @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.
  16. It's caller's responsibility to free the buffer with
  17. Pkcs7FreeSigners().
  18. This data structure is EFI_CERT_STACK type.
  19. @param[out] StackLength Length of signer's certificates in bytes.
  20. @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.
  21. It's caller's responsibility to free the buffer with
  22. Pkcs7FreeSigners().
  23. @param[out] CertLength Length of the trusted certificate in bytes.
  24. @retval FALSE This interface is not supported.
  25. **/
  26. BOOLEAN
  27. EFIAPI
  28. Pkcs7GetSigners (
  29. IN CONST UINT8 *P7Data,
  30. IN UINTN P7Length,
  31. OUT UINT8 **CertStack,
  32. OUT UINTN *StackLength,
  33. OUT UINT8 **TrustedCert,
  34. OUT UINTN *CertLength
  35. )
  36. {
  37. ASSERT (FALSE);
  38. return FALSE;
  39. }
  40. /**
  41. Wrap function to use free() to free allocated memory for certificates.
  42. If the interface is not supported, then ASSERT().
  43. @param[in] Certs Pointer to the certificates to be freed.
  44. **/
  45. VOID
  46. EFIAPI
  47. Pkcs7FreeSigners (
  48. IN UINT8 *Certs
  49. )
  50. {
  51. ASSERT (FALSE);
  52. }
  53. /**
  54. Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:
  55. Cryptographic Message Syntax Standard", and outputs two certificate lists chained and
  56. unchained to the signer's certificates.
  57. The input signed data could be wrapped in a ContentInfo structure.
  58. @param[in] P7Data Pointer to the PKCS#7 message.
  59. @param[in] P7Length Length of the PKCS#7 message in bytes.
  60. @param[out] SignerChainCerts Pointer to the certificates list chained to signer's
  61. certificate. It's caller's responsibility to free the buffer
  62. with Pkcs7FreeSigners().
  63. This data structure is EFI_CERT_STACK type.
  64. @param[out] ChainLength Length of the chained certificates list buffer in bytes.
  65. @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's
  66. responsibility to free the buffer with Pkcs7FreeSigners().
  67. This data structure is EFI_CERT_STACK type.
  68. @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.
  69. @retval TRUE The operation is finished successfully.
  70. @retval FALSE Error occurs during the operation.
  71. **/
  72. BOOLEAN
  73. EFIAPI
  74. Pkcs7GetCertificatesList (
  75. IN CONST UINT8 *P7Data,
  76. IN UINTN P7Length,
  77. OUT UINT8 **SignerChainCerts,
  78. OUT UINTN *ChainLength,
  79. OUT UINT8 **UnchainCerts,
  80. OUT UINTN *UnchainLength
  81. )
  82. {
  83. ASSERT (FALSE);
  84. return FALSE;
  85. }
  86. /**
  87. Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:
  88. Cryptographic Message Syntax Standard". The input signed data could be wrapped
  89. in a ContentInfo structure.
  90. Return FALSE to indicate this interface is not supported.
  91. @param[in] P7Data Pointer to the PKCS#7 message to verify.
  92. @param[in] P7Length Length of the PKCS#7 message in bytes.
  93. @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
  94. is used for certificate chain verification.
  95. @param[in] CertLength Length of the trusted certificate in bytes.
  96. @param[in] InData Pointer to the content to be verified.
  97. @param[in] DataLength Length of InData in bytes.
  98. @retval FALSE This interface is not supported.
  99. **/
  100. BOOLEAN
  101. EFIAPI
  102. Pkcs7Verify (
  103. IN CONST UINT8 *P7Data,
  104. IN UINTN P7Length,
  105. IN CONST UINT8 *TrustedCert,
  106. IN UINTN CertLength,
  107. IN CONST UINT8 *InData,
  108. IN UINTN DataLength
  109. )
  110. {
  111. ASSERT (FALSE);
  112. return FALSE;
  113. }
  114. /**
  115. Extracts the attached content from a PKCS#7 signed data if existed. The input signed
  116. data could be wrapped in a ContentInfo structure.
  117. Return FALSE to indicate this interface is not supported.
  118. @param[in] P7Data Pointer to the PKCS#7 signed data to process.
  119. @param[in] P7Length Length of the PKCS#7 signed data in bytes.
  120. @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.
  121. It's caller's responsibility to free the buffer with FreePool().
  122. @param[out] ContentSize The size of the extracted content in bytes.
  123. @retval TRUE The P7Data was correctly formatted for processing.
  124. @retval FALSE The P7Data was not correctly formatted for processing.
  125. **/
  126. BOOLEAN
  127. EFIAPI
  128. Pkcs7GetAttachedContent (
  129. IN CONST UINT8 *P7Data,
  130. IN UINTN P7Length,
  131. OUT VOID **Content,
  132. OUT UINTN *ContentSize
  133. )
  134. {
  135. ASSERT (FALSE);
  136. return FALSE;
  137. }