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
2.8 KiB

  1. #pragma once
  2. #include "wincrypt.h"
  3. #include "fusionarray.h"
  4. #include "fusionhandle.h"
  5. //
  6. // If someone invents a hash with more than 512 bytes, ?JonWis will eat his socks.
  7. //
  8. #define MAX_HASH_BYTES ( 512 )
  9. #define STRONG_NAME_BYTE_LENGTH ( 8 )
  10. BOOL
  11. SxspHashStringToBytes(
  12. IN PCWSTR pszHashString,
  13. IN SIZE_T cchHashString,
  14. OUT CFusionArray<BYTE> &dest
  15. );
  16. BOOL
  17. SxspHashBytesToString(
  18. IN const BYTE* pbSource,
  19. IN SIZE_T cbSource,
  20. OUT CBaseStringBuffer &sbDestination
  21. );
  22. BOOL
  23. SxspHashBytesToString(
  24. IN const BYTE* pbSource,
  25. IN SIZE_T cbSource,
  26. OUT CBaseStringBuffer &rsbDestination
  27. );
  28. BOOL
  29. SxspGetStrongNameOfKey(
  30. IN const CFusionArray<BYTE>& PublicKeyBits,
  31. OUT CFusionArray<BYTE>& StrongNameBits
  32. );
  33. BOOL
  34. SxspDoesStrongNameMatchKey(
  35. IN const CBaseStringBuffer &rsbKeyString,
  36. IN const CBaseStringBuffer &rsbStrongNameString,
  37. OUT BOOL &rfKeyMatchesStrongName
  38. );
  39. BOOL
  40. SxspGetStrongNameOfKey(
  41. IN const CBaseStringBuffer &sbKeyString,
  42. OUT CBaseStringBuffer &sbStrongNameOutput
  43. );
  44. BOOL
  45. SxspAcquireStrongNameFromCertContext(
  46. CBaseStringBuffer &rbuffStrongNameString,
  47. CBaseStringBuffer &rbuffPublicKeyString,
  48. PCCERT_CONTEXT pCertContext
  49. );
  50. typedef struct _SXS_PUBLIC_KEY_INFO
  51. {
  52. unsigned int SigAlgID;
  53. unsigned int HashAlgID;
  54. ULONG KeyLength;
  55. BYTE pbKeyInfo[1];
  56. } SXS_PUBLIC_KEY_INFO, *PSXS_PUBLIC_KEY_INFO;
  57. class CPublicKeyInformation
  58. {
  59. private:
  60. CFusionArray<BYTE> m_StrongNameBytes;
  61. CSmallStringBuffer m_StrongNameString;
  62. CFusionArray<BYTE> m_PublicKeyBytes;
  63. CSmallStringBuffer m_PublicKeyByteString;
  64. CStringBuffer m_SignerDisplayName;
  65. CStringBuffer m_CatalogSourceFileName;
  66. bool m_fInitialized;
  67. ULONG m_KeyLength;
  68. public:
  69. BOOL GetStrongNameString(OUT CBaseStringBuffer &rsbStrongNameString ) const;
  70. BOOL GetStrongNameBytes(OUT CFusionArray<BYTE> &cbStrongNameBytes ) const;
  71. BOOL GetPublicKeyBitLength(OUT ULONG& ulKeyLength ) const;
  72. BOOL GetWrappedPublicKeyBytes(OUT CFusionArray<BYTE> &cbPublicKeyBytes ) const;
  73. BOOL GetSignerNiceName(OUT CBaseStringBuffer &rsbSignerNameString );
  74. BOOL DoesStrongNameMatchSigner( IN const CBaseStringBuffer &rsbToTest, OUT BOOL &rfFoundInCatalog ) const;
  75. CPublicKeyInformation();
  76. ~CPublicKeyInformation();
  77. BOOL Initialize(IN const CBaseStringBuffer &rsbCatalogName);
  78. BOOL Initialize(IN PCWSTR pszCatalogName);
  79. BOOL Initialize(IN CFusionFile &rFileHandle);
  80. BOOL Initialize(IN const PCCERT_CONTEXT pContext);
  81. private:
  82. CPublicKeyInformation( const CPublicKeyInformation &);
  83. CPublicKeyInformation& operator=( const CPublicKeyInformation & );
  84. };