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.

69 lines
1.4 KiB

  1. #include <windows.h>
  2. #include <wincrypt.h>
  3. #include <winscard.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #define CAPI_TEST_CASE(X) { if (! X) { dwSts = GetLastError(); printf("%s", #X); goto Ret; } }
  8. #define TEST_ITERATIONS 1000
  9. /*
  10. void DisplayHelp(void)
  11. {
  12. printf("Usage: scnarios [option]\n");
  13. printf(" -1 : Test simulated enrollment\n");
  14. printf(" -2 : Test simulated certificate propagation\n");
  15. printf(" -3 : Test simulated logon\n");
  16. printf(" -c : Cleanup (delete default container)\n");
  17. }
  18. */
  19. DWORD DoCryptAcquireContext(void)
  20. {
  21. HCRYPTPROV hProv = 0;
  22. DWORD dwSts = ERROR_SUCCESS;
  23. CAPI_TEST_CASE(CryptAcquireContext(
  24. &hProv,
  25. NULL,
  26. MS_SCARD_PROV_W,
  27. PROV_RSA_FULL,
  28. 0));
  29. CAPI_TEST_CASE(CryptReleaseContext(hProv, 0));
  30. Ret:
  31. return dwSts;
  32. }
  33. int _cdecl main(int argc, char * argv[])
  34. {
  35. DWORD dwSts = ERROR_SUCCESS;
  36. DWORD iteration = 0;
  37. dwSts = DoCryptAcquireContext();
  38. if (ERROR_SUCCESS != dwSts)
  39. goto Ret;
  40. for (iteration = 0; iteration < TEST_ITERATIONS; iteration++)
  41. {
  42. dwSts = DoCryptAcquireContext();
  43. if (ERROR_SUCCESS != dwSts)
  44. goto Ret;
  45. }
  46. Ret:
  47. if (ERROR_SUCCESS != dwSts)
  48. printf(" failed, 0x%x\n", dwSts);
  49. else
  50. printf("Success.\n");
  51. return 0;
  52. }