Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.9 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998-2000 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // No portion of this source code may be reproduced
  6. // without express written permission of Microsoft Corporation.
  7. //
  8. // This source code is proprietary and confidential.
  9. //
  10. // SYSTEM: Industry Update
  11. //
  12. // CLASS: N/A
  13. // MODULE: TRUST.LIB
  14. // FILE: TRUST.H
  15. //
  16. /////////////////////////////////////////////////////////////////////
  17. //
  18. // DESC: this header file declares functions used to make cabs
  19. // signed by certain providers trusted.
  20. //
  21. // AUTHOR: Charles Ma, converted from WU CDMLIB
  22. // DATE: 10/4/2000
  23. //
  24. /////////////////////////////////////////////////////////////////////
  25. //
  26. // Revision History:
  27. //
  28. // Date Author Description
  29. // ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  30. // 2002-01-18 KenSh Added revocation check param to VerifyFileTrust
  31. //
  32. /////////////////////////////////////////////////////////////////////
  33. //
  34. //
  35. // This file is copied from the Windows AutoUpdate sources at \nt\enduser\windows.com\inc\trust.h
  36. // modified to use BITS logging and remove UI.
  37. //
  38. #pragma once
  39. //
  40. // define the number of bytes needed to store a SHA1 hashing value
  41. // of the public key
  42. //
  43. const UINT HASH_VAL_SIZE = 20;
  44. //
  45. // define structure used to pass in the hash values to the following
  46. // function in order to detect if one of the hash matches the
  47. // public key of the leaf cert of a file.
  48. //
  49. typedef struct _HASH_STRUCT {
  50. UINT uiCount;
  51. PBYTE pCerts;
  52. } CERT_HASH_ARRAY, *pCERT_HASH_ARRAY;
  53. /////////////////////////////////////////////////////////////////////////////
  54. //
  55. // Public Function VerifyFileTrust()
  56. //
  57. // This is a wrapper function for CheckWinTrust that both Whistler
  58. // and WU classic code should use.
  59. //
  60. // Input: szFileName - the file with complete path
  61. // pbSha1HashVae - a pointer to a 20 byte long buffer, containing
  62. // the signature SHA1 hashing value that should
  63. // be used to check this file, or NULL for checking
  64. // known Microsoft cert.
  65. // fCheckRevocation - whether the certificat revocation list (CRL) is
  66. // checked to see whether any of the certs in the chain
  67. // have been revoked. Never prompts the user to initiate
  68. // a dial-up connection. Default = FALSE.
  69. //
  70. // Return: HRESULT - S_OK the file is signed with a valid cert
  71. // or error code.
  72. // If the file is signed correctly but cert is not
  73. // a known Microsoft cert, or it's SHA1 hash does not match
  74. // the one passed in, then CERT_UNTRUSTED_ROOT is returned.
  75. //
  76. // Good Cert: Here is the deifnition of a good cert, in addition to the fact
  77. // that the signature must be valid and not expired.
  78. // (1) The signature was signed with a cert that has
  79. // "Microsoft Root Authority" as root, or
  80. // (2) Parameter pbSha1HashVal is not NULL, and the file's SHA1
  81. // hashing value of signature matches this value, or
  82. // (3) The signature was signed with one of the following known
  83. // Microsoft cert's (they are not rooted to MS) and
  84. // pbSha1HashVal is NULL.
  85. // * Microsoft Corporation
  86. // * Microsoft Corporation MSN (Europe)
  87. // * Microsoft Corporation (Europe)
  88. //
  89. /////////////////////////////////////////////////////////////////////////////
  90. HRESULT VerifyFileTrust(
  91. IN LPCTSTR szFileName,
  92. IN pCERT_HASH_ARRAY pHashArray,
  93. BOOL fCheckRevocation = FALSE
  94. );