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.

88 lines
1.9 KiB

  1. #include <pch.cpp>
  2. #pragma hdrstop
  3. #include "crtem.h"
  4. ////////////////////////
  5. // Cryptographic Provider handle list
  6. CCryptProvList::CCryptProvList()
  7. {
  8. m_pfnIsMatch = CryptProvIsMatch;
  9. m_pfnFreeElt = CryptProvFreeElt;
  10. }
  11. void CreateCryptProvListItem(CRYPTPROV_LIST_ITEM* pli,
  12. DWORD dwAlgId1,
  13. DWORD dwKeySize1,
  14. DWORD dwAlgId2,
  15. DWORD dwKeySize2,
  16. HCRYPTPROV hProvider)
  17. {
  18. pli->pNext = NULL;
  19. pli->dwAlgId1 = dwAlgId1;
  20. pli->dwKeySize1 = dwKeySize1;
  21. pli->dwAlgId2 = dwAlgId2;
  22. pli->dwKeySize2 = dwKeySize2;
  23. pli->hProv = hProvider;
  24. }
  25. BOOL CryptProvIsMatch(
  26. ELT* pCandidate,
  27. ELT* pTemplate)
  28. {
  29. PCRYPTPROV_LIST_ITEM pliCandidate = (PCRYPTPROV_LIST_ITEM) pCandidate;
  30. PCRYPTPROV_LIST_ITEM pliTemplate = (PCRYPTPROV_LIST_ITEM) pTemplate;
  31. // if both algids match
  32. if ((pliCandidate->dwAlgId1 == pliTemplate->dwAlgId1) &&
  33. (pliCandidate->dwAlgId2 == pliTemplate->dwAlgId2))
  34. {
  35. // if both sizes match
  36. if ((pliCandidate->dwKeySize1 == -1) ||
  37. (pliTemplate->dwKeySize1 == -1) ||
  38. (pliCandidate->dwKeySize1 == pliTemplate->dwKeySize1))
  39. {
  40. if ((pliCandidate->dwKeySize2 == -1) ||
  41. (pliTemplate->dwKeySize2 == -1) ||
  42. (pliCandidate->dwKeySize2 == pliTemplate->dwKeySize2))
  43. return TRUE;
  44. }
  45. }
  46. return FALSE;
  47. }
  48. void CryptProvFreeElt(
  49. ELT* p)
  50. {
  51. if (NULL == p)
  52. return;
  53. PCRYPTPROV_LIST_ITEM pli = (PCRYPTPROV_LIST_ITEM) p;
  54. // do all necessary freeing
  55. if (pli->hProv != 0)
  56. CryptReleaseContext((HCRYPTPROV)pli->hProv, 0);
  57. ZeroMemory(pli, sizeof(CRYPTPROV_LIST_ITEM)); // make sure contents invalid
  58. SSFree(pli);
  59. }