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.

63 lines
1.4 KiB

  1. #include "stdafx.h"
  2. #include "SecPI.h"
  3. #include "cipher.hpp"
  4. //#include "..\Common\Include\McsPI.h"
  5. #include "McsPI.h"
  6. BOOL IsValidPlugIn(IMcsDomPlugIn * pPlugIn)
  7. {
  8. BOOL bGood = FALSE;
  9. ISecPlugIn * pSec = NULL;
  10. HRESULT hr = S_OK;
  11. hr = pPlugIn->QueryInterface(IID_ISecPlugIn,(void**)&pSec);
  12. if ( SUCCEEDED(hr) )
  13. {
  14. McsChallenge ch;
  15. LONG one, two;
  16. LONG time1;
  17. ULONG size = sizeof(ch);
  18. srand(GetTickCount());
  19. one = (LONG)rand();
  20. ch.lRand1 = one;
  21. two = (LONG)rand();
  22. ch.lRand2 = two;
  23. time1 = GetTickCount();
  24. ch.lTime = time1;
  25. SimpleCipher((LPBYTE)&ch,size);
  26. hr = pSec->Verify((ULONG*)&ch,size);
  27. if ( SUCCEEDED(hr) )
  28. {
  29. SimpleCipher((LPBYTE)&ch,size);
  30. // verify that the plug-in did the right thing!
  31. if ( ch.MCS[0] == 'M'
  32. && ch.MCS[1] == 'C'
  33. && ch.MCS[2] == 'S'
  34. && ch.MCS[3] == 0
  35. )
  36. {
  37. if ( ch.lRand1 == (one + two)
  38. && ch.lRand2 == (two - one) )
  39. {
  40. if ( ch.lTime == time1+100 )
  41. {
  42. bGood = TRUE;
  43. }
  44. }
  45. }
  46. }
  47. pSec->Release();
  48. }
  49. return bGood;
  50. }