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.

968 lines
26 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: ibm.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. /*++
  11. Module Name:
  12. ibmmfc41.cpp
  13. Abstract:
  14. This is a plug-in for the smart card driver test suite.
  15. This plug-in is smart card dependent
  16. Environment:
  17. Win32 application
  18. Revision History :
  19. Jan 1998 - initial version
  20. --*/
  21. #include <stdarg.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <afx.h>
  25. #include <afxtempl.h>
  26. #include <winioctl.h>
  27. #include <winsmcrd.h>
  28. #include "ifdtest.h"
  29. void MyCardEntry(class CCardProvider& in_CCardProvider);
  30. //
  31. // Create a card provider object
  32. // Note: all global varibales and all functions have to be static
  33. //
  34. static class CCardProvider MyCard(MyCardEntry);
  35. static ULONG
  36. MyCardSetProtocol(
  37. class CCardProvider& in_CCardProvider,
  38. class CReader& in_CReader
  39. )
  40. /*++
  41. Routine Description:
  42. This function will be called after the card has been correctly
  43. identified. We should here set the protocol that we need
  44. for further transmissions
  45. Arguments:
  46. in_CCardProvider - ref. to our card provider object
  47. in_CReader - ref. to the reader object
  48. Return Value:
  49. IFDSTATUS_FAILED - we were unable to set the protocol correctly
  50. IFDSTATUS_SUCCESS - protocol set correctly
  51. --*/
  52. {
  53. ULONG l_lResult;
  54. TestStart("Try to set incorrect protocol T=0");
  55. l_lResult = in_CReader.SetProtocol(SCARD_PROTOCOL_T0);
  56. // The test MUST fail with the incorrect protocol
  57. TEST_CHECK_NOT_SUPPORTED("Set protocol failed", l_lResult);
  58. TestEnd();
  59. // Now set the correct protocol
  60. TestStart("Set protocol T=1");
  61. l_lResult = in_CReader.SetProtocol(SCARD_PROTOCOL_T1);
  62. TEST_CHECK_SUCCESS("Set protocol failed", l_lResult);
  63. TestEnd();
  64. if (l_lResult != ERROR_SUCCESS) {
  65. return IFDSTATUS_FAILED;
  66. }
  67. return IFDSTATUS_SUCCESS;
  68. }
  69. static ULONG
  70. MyCardTest(
  71. class CCardProvider& in_CCardProvider,
  72. class CReader& in_CReader
  73. )
  74. /*++
  75. Routine Description:
  76. This serves as the test function for a particular smart card
  77. Arguments:
  78. in_CReader - ref. to class that provides all information for the test
  79. Return Value:
  80. IFDSTATUS value
  81. --*/
  82. {
  83. ULONG l_lResult;
  84. ULONG l_uResultLength, l_uExpectedLength, l_uIndex;
  85. PUCHAR l_pchResult;
  86. UCHAR l_rgchBuffer[512], l_rgchBuffer2[512];
  87. switch (in_CCardProvider.GetTestNo()) {
  88. case 1: {
  89. //
  90. // select a file 0007 and write data pattern 0 to N-1 to the card.
  91. // Then read the data back and verify correctness.
  92. // Check IFSC and IFSD above card limits
  93. //
  94. //
  95. // Select a file
  96. //
  97. TestStart("SELECT FILE 0007");
  98. l_lResult = in_CReader.Transmit(
  99. (PUCHAR) "\xa4\xa4\x00\x00\x02\x00\x07",
  100. 7,
  101. &l_pchResult,
  102. &l_uResultLength
  103. );
  104. TestCheck(
  105. l_lResult, "==", ERROR_SUCCESS,
  106. l_uResultLength, 16,
  107. l_pchResult[14], l_pchResult[15], 0x90, 0x00,
  108. l_pchResult,
  109. (PUCHAR) "\x63\x0c\x03\xe8\x00\x07\x00\x00\x00\xff\xff\x11\x01\x00\x90\x00",
  110. l_uResultLength
  111. );
  112. TEST_END();
  113. if (TestFailed()) {
  114. return IFDSTATUS_FAILED;
  115. }
  116. //
  117. // Do a couple of writes and reads up to maximum size
  118. // Check behaviour above IFSC and IFSD Limits
  119. //
  120. //
  121. // Generate a 'test' pattern which will be written to the card
  122. //
  123. for (l_uIndex = 0; l_uIndex < 254; l_uIndex++) {
  124. l_rgchBuffer[5 + l_uIndex] = (UCHAR) l_uIndex;
  125. }
  126. //
  127. // This is the amount of bytes we write to the card in each loop
  128. //
  129. ULONG l_auNumBytes[] = { 1 , 25, 50, 75, 100, 125, 128, 150, 175, 200, 225, 250, 254 };
  130. time_t l_TimeStart;
  131. time(&l_TimeStart);
  132. for (ULONG l_uTest = 0; l_uTest < sizeof(l_auNumBytes) / sizeof(l_auNumBytes[0]); l_uTest++) {
  133. ULONG l_uNumBytes = l_auNumBytes[l_uTest];
  134. //
  135. // Write
  136. //
  137. TestStart("WRITE BINARY %3d Byte(s)", l_uNumBytes);
  138. //
  139. // Tpdu for write binary
  140. //
  141. memcpy(l_rgchBuffer, "\xa4\xd6\x00\x00", 4);
  142. //
  143. // Append number of bytes (note: the buffer contains the pattern already)
  144. //
  145. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  146. l_lResult = in_CReader.Transmit(
  147. l_rgchBuffer,
  148. 5 + l_uNumBytes,
  149. &l_pchResult,
  150. &l_uResultLength
  151. );
  152. if (l_uNumBytes <= 128) {
  153. TestCheck(
  154. l_lResult, "==", ERROR_SUCCESS,
  155. l_uResultLength, 2,
  156. l_pchResult[0], l_pchResult[1], 0x90, 0x00,
  157. NULL, NULL, NULL
  158. );
  159. } else {
  160. TestCheck(
  161. l_lResult, "==", ERROR_SUCCESS,
  162. l_uResultLength, 2,
  163. l_pchResult[0], l_pchResult[1], 0x67, 0x00,
  164. NULL, NULL, NULL
  165. );
  166. }
  167. TEST_END();
  168. //
  169. // Read
  170. //
  171. TestStart("READ BINARY %3d Byte(s)", l_uNumBytes);
  172. //
  173. // tpdu for read binary
  174. //
  175. memcpy(l_rgchBuffer, "\xa4\xB0\x00\x00", 4);
  176. //
  177. // Append number of bytes
  178. //
  179. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  180. l_lResult = in_CReader.Transmit(
  181. l_rgchBuffer,
  182. 5,
  183. &l_pchResult,
  184. &l_uResultLength
  185. );
  186. //
  187. // check if the right number of bytes has been returned
  188. //
  189. l_uExpectedLength = min(128, l_uNumBytes);
  190. TestCheck(
  191. l_lResult, "==", ERROR_SUCCESS,
  192. l_uResultLength, l_uExpectedLength + 2,
  193. l_pchResult[l_uExpectedLength],
  194. l_pchResult[l_uExpectedLength + 1],
  195. 0x90, 0x00,
  196. l_pchResult, l_rgchBuffer + 5, l_uExpectedLength
  197. );
  198. TEST_END();
  199. }
  200. time_t l_TimeEnd;
  201. time(&l_TimeEnd);
  202. CTime l_CTimeStart(l_TimeStart);
  203. CTime l_CTimeEnd(l_TimeEnd);
  204. CTimeSpan l_CTimeElapsed = l_CTimeEnd - l_CTimeStart;
  205. if (l_CTimeElapsed.GetTotalSeconds() < 10) {
  206. LogMessage(
  207. "Reader performance is good (%u sec)",
  208. l_CTimeElapsed.GetTotalSeconds()
  209. );
  210. } else if (l_CTimeElapsed.GetTotalSeconds() < 30) {
  211. LogMessage(
  212. "Reader performance is average (%u sec)",
  213. l_CTimeElapsed.GetTotalSeconds()
  214. );
  215. } else {
  216. LogMessage(
  217. "Reader performance is bad (%u sec)",
  218. l_CTimeElapsed.GetTotalSeconds()
  219. );
  220. }
  221. break;
  222. }
  223. case 2: {
  224. //
  225. // Select a file 0007 and write alternately pattern 55 and AA
  226. // to the card.
  227. // Read the data back and verify correctness after each write.
  228. //
  229. //
  230. // Select a file
  231. //
  232. TestStart("SELECT FILE 0007");
  233. l_lResult = in_CReader.Transmit(
  234. (PUCHAR) "\xa4\xa4\x00\x00\x02\x00\x07",
  235. 7,
  236. &l_pchResult,
  237. &l_uResultLength
  238. );
  239. TestCheck(
  240. l_lResult, "==", ERROR_SUCCESS,
  241. l_uResultLength, 16,
  242. l_pchResult[14], l_pchResult[15], 0x90, 0x00,
  243. l_pchResult,
  244. (PUCHAR) "\x63\x0c\x03\xe8\x00\x07\x00\x00\x00\xff\xff\x11\x01\x00\x90\x00",
  245. l_uResultLength
  246. );
  247. TEST_END();
  248. //
  249. // Do a couple of writes and reads alternately
  250. // with patterns 55h and AAh
  251. //
  252. //
  253. // Generate a 'test' pattern which will be written to the card
  254. //
  255. for (l_uIndex = 0; l_uIndex < 254; l_uIndex++) {
  256. l_rgchBuffer[5 + l_uIndex] = (UCHAR) 0x55;
  257. l_rgchBuffer2[5 + l_uIndex] = (UCHAR) 0xAA;
  258. }
  259. //
  260. // This is the amount of bytes we write to the card in each loop
  261. //
  262. ULONG l_uNumBytes = 128;
  263. for (ULONG l_uTest = 0; l_uTest < 2; l_uTest++) {
  264. //
  265. // Write
  266. //
  267. TestStart("WRITE BINARY %3d Byte(s) Pattern 55h", l_uNumBytes);
  268. //
  269. // Tpdu for write binary
  270. //
  271. memcpy(l_rgchBuffer, "\xa4\xd6\x00\x00", 4);
  272. //
  273. // Append number of bytes (note: the buffer contains the pattern already)
  274. //
  275. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  276. l_lResult = in_CReader.Transmit(
  277. l_rgchBuffer,
  278. 5 + l_uNumBytes,
  279. &l_pchResult,
  280. &l_uResultLength
  281. );
  282. TestCheck(
  283. l_lResult, "==", ERROR_SUCCESS,
  284. l_uResultLength, 2,
  285. l_pchResult[0], l_pchResult[1], 0x90, 0x00,
  286. NULL, NULL, NULL
  287. );
  288. TEST_END();
  289. //
  290. // Read
  291. //
  292. TestStart("READ BINARY %3d Byte(s) Pattern 55h", l_uNumBytes);
  293. //
  294. // tpdu for read binary
  295. //
  296. memcpy(l_rgchBuffer, "\xa4\xB0\x00\x00", 4);
  297. //
  298. // Append number of bytes
  299. //
  300. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  301. l_lResult = in_CReader.Transmit(
  302. l_rgchBuffer,
  303. 5,
  304. &l_pchResult,
  305. &l_uResultLength
  306. );
  307. l_uExpectedLength = min(128, l_uNumBytes);
  308. TestCheck(
  309. l_lResult, "==", ERROR_SUCCESS,
  310. l_uResultLength, l_uExpectedLength + 2,
  311. l_pchResult[l_uNumBytes], l_pchResult[l_uNumBytes + 1],
  312. 0x90, 0x00,
  313. l_pchResult, l_rgchBuffer + 5, l_uExpectedLength
  314. );
  315. TEST_END();
  316. //
  317. // Write
  318. //
  319. TestStart("WRITE BINARY %3d Byte(s) Pattern AAh", l_uNumBytes);
  320. //
  321. // Tpdu for write binary
  322. //
  323. memcpy(l_rgchBuffer2, "\xa4\xd6\x00\x00", 4);
  324. //
  325. // Append number of bytes (note: the buffer contains the pattern already)
  326. //
  327. l_rgchBuffer2[4] = (UCHAR) l_uNumBytes;
  328. l_lResult = in_CReader.Transmit(
  329. l_rgchBuffer2,
  330. 5 + l_uNumBytes,
  331. &l_pchResult,
  332. &l_uResultLength
  333. );
  334. TestCheck(
  335. l_lResult, "==", ERROR_SUCCESS,
  336. l_uResultLength, 2,
  337. l_pchResult[0], l_pchResult[1],
  338. 0x90, 0x00,
  339. NULL, NULL, NULL
  340. );
  341. TEST_END();
  342. //
  343. // Read
  344. //
  345. TestStart("READ BINARY %3d Byte(s) Pattern AAh", l_uNumBytes);
  346. //
  347. // tpdu for read binary
  348. //
  349. memcpy(l_rgchBuffer2, "\xa4\xB0\x00\x00", 4);
  350. //
  351. // Append number of bytes
  352. //
  353. l_rgchBuffer2[4] = (UCHAR) l_uNumBytes;
  354. l_lResult = in_CReader.Transmit(
  355. l_rgchBuffer2,
  356. 5,
  357. &l_pchResult,
  358. &l_uResultLength
  359. );
  360. l_uExpectedLength = min(128, l_uNumBytes);
  361. TestCheck(
  362. l_lResult, "==", ERROR_SUCCESS,
  363. l_uResultLength, l_uExpectedLength + 2,
  364. l_pchResult[l_uNumBytes], l_pchResult[l_uNumBytes + 1],
  365. 0x90, 0x00,
  366. l_pchResult, l_rgchBuffer2 + 5, min(l_uExpectedLength,125)
  367. );
  368. TEST_END();
  369. }
  370. break;
  371. }
  372. case 3: {
  373. // select a file 0007 and write alternately pattern 00 and FF
  374. // to the card.
  375. // Read the data back and verify correctness after each write.
  376. //
  377. // Select a file
  378. //
  379. TestStart("SELECT FILE 0007");
  380. l_lResult = in_CReader.Transmit(
  381. (PUCHAR) "\xa4\xa4\x00\x00\x02\x00\x07",
  382. 7,
  383. &l_pchResult,
  384. &l_uResultLength
  385. );
  386. TestCheck(
  387. l_lResult, "==", ERROR_SUCCESS,
  388. l_uResultLength, 16,
  389. l_pchResult[14], l_pchResult[15], 0x90, 0x00,
  390. l_pchResult,
  391. (PUCHAR) "\x63\x0c\x03\xe8\x00\x07\x00\x00\x00\xff\xff\x11\x01\x00\x90\x00",
  392. l_uResultLength
  393. );
  394. TEST_END();
  395. //
  396. // Do a couple of writes and reads alternately
  397. // with patterns 00h and FFh
  398. //
  399. //
  400. // Generate a 'test' pattern which will be written to the card
  401. //
  402. for (l_uIndex = 0; l_uIndex < 254; l_uIndex++) {
  403. l_rgchBuffer[5 + l_uIndex] = (UCHAR) 0x00;
  404. l_rgchBuffer2[5 + l_uIndex] = (UCHAR) 0xFF;
  405. }
  406. //
  407. // This is the amount of bytes we write to the card in each loop
  408. //
  409. ULONG l_uNumBytes = 128;
  410. for (ULONG l_uTest = 0; l_uTest < 2; l_uTest++) {
  411. //
  412. // Write
  413. //
  414. TestStart("WRITE BINARY %3d Byte(s) Pattern 00h", l_uNumBytes);
  415. //
  416. // Tpdu for write binary
  417. //
  418. memcpy(l_rgchBuffer, "\xa4\xd6\x00\x00", 4);
  419. //
  420. // Append number of bytes (note: the buffer contains the pattern already)
  421. //
  422. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  423. l_lResult = in_CReader.Transmit(
  424. l_rgchBuffer,
  425. 5 + l_uNumBytes,
  426. &l_pchResult,
  427. &l_uResultLength
  428. );
  429. TestCheck(
  430. l_lResult, "==", ERROR_SUCCESS,
  431. l_uResultLength, 2,
  432. l_pchResult[0], l_pchResult[1], 0x90, 0x00,
  433. NULL, NULL, NULL
  434. );
  435. TEST_END();
  436. //
  437. // Read
  438. //
  439. TestStart("READ BINARY %3d Byte(s) Pattern 00h", l_uNumBytes);
  440. //
  441. // tpdu for read binary
  442. //
  443. memcpy(l_rgchBuffer, "\xa4\xB0\x00\x00", 4);
  444. //
  445. // Append number of bytes
  446. //
  447. l_rgchBuffer[4] = (UCHAR) l_uNumBytes;
  448. l_lResult = in_CReader.Transmit(
  449. l_rgchBuffer,
  450. 5,
  451. &l_pchResult,
  452. &l_uResultLength
  453. );
  454. l_uExpectedLength = min(128, l_uNumBytes);
  455. TestCheck(
  456. l_lResult, "==", ERROR_SUCCESS,
  457. l_uResultLength, l_uExpectedLength + 2,
  458. l_pchResult[l_uNumBytes], l_pchResult[l_uNumBytes + 1],
  459. 0x90, 0x00,
  460. l_pchResult,
  461. l_rgchBuffer + 5,
  462. l_uExpectedLength
  463. );
  464. TEST_END();
  465. //
  466. // Write
  467. //
  468. TestStart("WRITE BINARY %3d Byte(s) Pattern FFh", l_uNumBytes);
  469. //
  470. // Tpdu for write binary
  471. //
  472. memcpy(l_rgchBuffer2, "\xa4\xd6\x00\x00", 4);
  473. //
  474. // Append number of bytes (note: the buffer contains the pattern already)
  475. //
  476. l_rgchBuffer2[4] = (UCHAR) l_uNumBytes;
  477. l_lResult = in_CReader.Transmit(
  478. l_rgchBuffer2,
  479. 5 + l_uNumBytes,
  480. &l_pchResult,
  481. &l_uResultLength
  482. );
  483. TestCheck(
  484. l_lResult, "==", ERROR_SUCCESS,
  485. l_uResultLength, 2,
  486. l_pchResult[0], l_pchResult[1],
  487. 0x90, 0x00,
  488. NULL, NULL, NULL
  489. );
  490. TEST_END();
  491. //
  492. // Read
  493. //
  494. TestStart("READ BINARY %3d Byte(s) Pattern FFh", l_uNumBytes);
  495. //
  496. // tpdu for read binary
  497. //
  498. memcpy(l_rgchBuffer2, "\xa4\xB0\x00\x00", 4);
  499. //
  500. // Append number of bytes
  501. //
  502. l_rgchBuffer2[4] = (UCHAR) l_uNumBytes;
  503. l_lResult = in_CReader.Transmit(
  504. l_rgchBuffer2,
  505. 5,
  506. &l_pchResult,
  507. &l_uResultLength
  508. );
  509. l_uExpectedLength = min(128, l_uNumBytes);
  510. TestCheck(
  511. l_lResult, "==", ERROR_SUCCESS,
  512. l_uResultLength, l_uExpectedLength + 2,
  513. l_pchResult[l_uNumBytes], l_pchResult[l_uNumBytes + 1],
  514. 0x90, 0x00,
  515. l_pchResult,
  516. l_rgchBuffer2 + 5,
  517. min(l_uExpectedLength,125)
  518. );
  519. TEST_END();
  520. }
  521. break;
  522. }
  523. case 4: {
  524. //
  525. // Select Command for Nonexisting File
  526. //
  527. TestStart("SELECT NONEXISTING FILE");
  528. l_lResult = in_CReader.Transmit(
  529. (PUCHAR) "\xa4\xa4\x00\x00\x02\x77\x77",
  530. 7,
  531. &l_pchResult,
  532. &l_uResultLength
  533. );
  534. TestCheck(
  535. l_lResult, "==", ERROR_SUCCESS,
  536. l_uResultLength, 2,
  537. l_pchResult[0], l_pchResult[1],
  538. 0x94, 0x04,
  539. NULL, NULL, NULL
  540. );
  541. TEST_END();
  542. break;
  543. }
  544. case 5: {
  545. //
  546. // Select Command without Fileid
  547. //
  548. TestStart("SELECT COMMAND WITHOUT FILEID");
  549. l_lResult = in_CReader.Transmit(
  550. (PUCHAR) "\xa4\xa4\x00\x00",
  551. 4,
  552. &l_pchResult,
  553. &l_uResultLength
  554. );
  555. TestCheck(
  556. l_lResult, "==", ERROR_SUCCESS,
  557. l_uResultLength, 2,
  558. l_pchResult[0], l_pchResult[1],
  559. 0x67, 0x00,
  560. NULL, NULL, NULL
  561. );
  562. TEST_END();
  563. break;
  564. }
  565. case 6: {
  566. //
  567. // Select Command with path too short
  568. //
  569. TestStart("SELECT COMMAND PATH WITH PATH TOO SHORT");
  570. l_lResult = in_CReader.Transmit(
  571. (PUCHAR) "\xa4\xa4\x00\x00\x01\x77",
  572. 6,
  573. &l_pchResult,
  574. &l_uResultLength
  575. );
  576. TestCheck(
  577. l_lResult, "==", ERROR_SUCCESS,
  578. l_uResultLength, 2,
  579. l_pchResult[0], l_pchResult[1],
  580. 0x67, 0x00,
  581. NULL, NULL, NULL
  582. );
  583. TEST_END();
  584. break;
  585. }
  586. case 7: {
  587. //
  588. // Select Command with wrong Lc
  589. //
  590. TestStart("SELECT COMMAND PATH WITH WRONG LC");
  591. l_lResult = in_CReader.Transmit(
  592. (PUCHAR) "\xa4\xa4\x00\x00\x08\x00",
  593. 6,
  594. &l_pchResult,
  595. &l_uResultLength
  596. );
  597. TestCheck(
  598. l_lResult, "==", ERROR_SUCCESS,
  599. l_uResultLength, 2,
  600. l_pchResult[0], l_pchResult[1],
  601. 0x67, 0x00,
  602. NULL, NULL, NULL
  603. );
  604. TEST_END();
  605. break;
  606. }
  607. case 8: {
  608. //
  609. // Select Command too short
  610. //
  611. TestStart("SELECT COMMAND TOO SHORT");
  612. l_lResult = in_CReader.Transmit(
  613. (PUCHAR) "\xa4\xa4\x00",
  614. 3,
  615. &l_pchResult,
  616. &l_uResultLength
  617. );
  618. TestCheck(
  619. l_lResult, "==", ERROR_SUCCESS,
  620. l_uResultLength, 2,
  621. l_pchResult[0], l_pchResult[1],
  622. 0x6f, 0x00,
  623. NULL, NULL, NULL
  624. );
  625. TEST_END();
  626. break;
  627. }
  628. case 9: {
  629. //
  630. // Select Command with invalid P2
  631. //
  632. TestStart("SELECT COMMAND WITH INVALID P2");
  633. l_lResult = in_CReader.Transmit(
  634. (PUCHAR) "\xa4\xa4\x00\x02\x02\x00\x07",
  635. 7,
  636. &l_pchResult,
  637. &l_uResultLength
  638. );
  639. TestCheck(
  640. l_lResult, "==", ERROR_SUCCESS,
  641. l_uResultLength, 2,
  642. l_pchResult[0], l_pchResult[1],
  643. 0x6b, 0x00,
  644. NULL, NULL, NULL
  645. );
  646. TEST_END();
  647. break;
  648. }
  649. case 10: {
  650. //
  651. // Select command without fileid but with Le
  652. //
  653. TestStart("SELECT COMMAND WITHOUT FILEID BUT WITH Le");
  654. l_lResult = in_CReader.Transmit(
  655. (PUCHAR) "\xa4\xa4\x00\x00\x00",
  656. 5,
  657. &l_pchResult,
  658. &l_uResultLength
  659. );
  660. TestCheck(
  661. l_lResult, "==", ERROR_SUCCESS,
  662. l_uResultLength, 2,
  663. l_pchResult[0], l_pchResult[1],
  664. 0x67, 0x00,
  665. NULL, NULL, NULL
  666. );
  667. TEST_END();
  668. break;
  669. }
  670. case 11: {
  671. //
  672. // Use Change Speed command to simulate unresponsive card
  673. //
  674. //
  675. // Select a file
  676. //
  677. TestStart("SELECT FILE 0007");
  678. l_lResult = in_CReader.Transmit(
  679. (PUCHAR) "\xa4\xa4\x00\x00\x02\x00\x07",
  680. 7,
  681. &l_pchResult,
  682. &l_uResultLength
  683. );
  684. TestCheck(
  685. l_lResult, "==", ERROR_SUCCESS,
  686. l_uResultLength, 16,
  687. l_pchResult[14], l_pchResult[15], 0x90, 0x00,
  688. l_pchResult,
  689. (PUCHAR) "\x63\x0c\x03\xe8\x00\x07\x00\x00\x00\xff\xff\x11\x01\x00\x90\x00",
  690. l_uResultLength
  691. );
  692. TEST_END();
  693. //
  694. // Perform change speed command to simulate unresponsive card
  695. //
  696. TestStart("CHANGE SPEED");
  697. l_lResult = in_CReader.Transmit(
  698. (PUCHAR) "\xb6\x42\x00\x40",
  699. 4,
  700. &l_pchResult,
  701. &l_uResultLength
  702. );
  703. TestCheck(
  704. l_lResult, "==", ERROR_SUCCESS,
  705. l_uResultLength, 2,
  706. l_pchResult[0], l_pchResult[1],
  707. 0x90, 0x00,
  708. NULL, NULL, NULL
  709. );
  710. TEST_END();
  711. //
  712. // Select a file to verify bad return code
  713. //
  714. TestStart("SELECT FILE 0007 WILL GET NO VALID RESPONSE");
  715. l_lResult = in_CReader.Transmit(
  716. (PUCHAR) "\xa4\xa4\x00\x00\x02\x00\x07",
  717. 7,
  718. &l_pchResult,
  719. &l_uResultLength
  720. );
  721. TestCheck(
  722. l_lResult, "!=", ERROR_SUCCESS,
  723. NULL, NULL,
  724. NULL, NULL,
  725. NULL, NULL,
  726. NULL, NULL, NULL
  727. );
  728. TEST_END();
  729. return IFDSTATUS_END;
  730. }
  731. default:
  732. return IFDSTATUS_FAILED;
  733. }
  734. return IFDSTATUS_SUCCESS;
  735. }
  736. static void
  737. MyCardEntry(
  738. class CCardProvider& in_CCardProvider
  739. )
  740. /*++
  741. Routine Description:
  742. This function registers all callbacks from the test suite
  743. Arguments:
  744. CCardProvider - ref. to card provider class
  745. Return Value:
  746. -
  747. --*/
  748. {
  749. // Set protocol callback
  750. in_CCardProvider.SetProtocol(MyCardSetProtocol);
  751. // Card test callback
  752. in_CCardProvider.SetCardTest(MyCardTest);
  753. // Name of our card
  754. in_CCardProvider.SetCardName("IBM");
  755. in_CCardProvider.SetAtr((PBYTE) "\x3b\xef\x00\xff\x81\x31\x86\x45\x49\x42\x4d\x20\x4d\x46\x43\x34\x30\x30\x30\x30\x38\x33\x31\x43", 24);
  756. }