none
SmartCard Mini Driver Certification - ResetATR RRS feed

  • Question

  • Hi All,

    I'm testing smart card minidriver with CMCK tool (cmck.exe) in Win 7 x86 client. When I run the Installation test "ResetATR", the test fails with error code "The data is invalid" (0xd). The text that is displayed is "ATR and ATRMask length mismtach".

    I'm unable to find any solution through mini driver logs as I see the ATR not being changed after ResetATR test is called. 

    Does any body have any clue how I can debug further to get more details in understanding the problem?

    Thanks,

    Madhukar

    Wednesday, October 30, 2013 9:22 AM

Answers

  • What is the value of the ATR returned and the values of ATR and ATRMask in your minidriver's registry entries? The smart card minidriver spec (located at http://msdn.microsoft.com/en-us/windows/hardware/gg487500.aspx) talks about this pairing process in section A.1 as follows:

    The operating system follows these steps to pair a smart card with an already installed minidriver:

    • Get the ATR from the smart card.
    • Iterate through entries in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Calais\SmartCards registry key and do the following:
    • Apply ATRMask subkey value that is stored in the registry to the ATR that was acquired from the smart card.
    • Compare the masked ATR value to the ATR subkey value that is stored in the registry.
    • If the two ATR values match, stop processing and pair the corresponding minidriver with the smart card.

    Smart card ATR and ATRMask values must be carefully chosen to avoid the erroneous pairing of a minidriver with a smart card. The smart card ATR value that is stored in the registry should be the expected value after the ATRMask has been applied to an ATR read from a smart card. Otherwise, the masked ATR values from the card and the registry do not match and the pairing fails.


    Jeff Shipman [MSFT] -- This posting is provided "AS IS" with no warranties, and confers no rights.


    Wednesday, October 30, 2013 5:16 PM
  • The test is required to pass for certification because if the ATR and ATRMask checks fail, you will find issues loading the minidriver after certain types of reset. To deal with this, we recommend packaging a filter driver with your minidriver package that can make sure the same ATR comes out after all reset types and then this test will pass. You can find a sample at http://support.microsoft.com/kb/981665/en-us

    Jeff Shipman [MSFT] -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by gubbam Monday, November 4, 2013 5:02 AM
    Friday, November 1, 2013 4:54 PM

All replies

  • What is the value of the ATR returned and the values of ATR and ATRMask in your minidriver's registry entries? The smart card minidriver spec (located at http://msdn.microsoft.com/en-us/windows/hardware/gg487500.aspx) talks about this pairing process in section A.1 as follows:

    The operating system follows these steps to pair a smart card with an already installed minidriver:

    • Get the ATR from the smart card.
    • Iterate through entries in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Calais\SmartCards registry key and do the following:
    • Apply ATRMask subkey value that is stored in the registry to the ATR that was acquired from the smart card.
    • Compare the masked ATR value to the ATR subkey value that is stored in the registry.
    • If the two ATR values match, stop processing and pair the corresponding minidriver with the smart card.

    Smart card ATR and ATRMask values must be carefully chosen to avoid the erroneous pairing of a minidriver with a smart card. The smart card ATR value that is stored in the registry should be the expected value after the ATRMask has been applied to an ATR read from a smart card. Otherwise, the masked ATR values from the card and the registry do not match and the pairing fails.


    Jeff Shipman [MSFT] -- This posting is provided "AS IS" with no warranties, and confers no rights.


    Wednesday, October 30, 2013 5:16 PM
  • The ATR is 0x3B,0x6B,0x00,0x00,0x80,0x65,0xB0,0x83,0x01,0x03,0x74,0x83,0x00,0x90,0x00 and the ATR mask is 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF in the registry. The same ATR is returned in pbATR of CARD_DATA structure when ResetATR is called but still the test fails.

    Thanks

    Madhukar

    Thursday, October 31, 2013 4:59 AM
  • pbATR in CARD_DATA is not a return value from the mini-driver. It is provided by the caller of the mini-driver, but in any case is not involved in this test so should not be relied upon.. The ResetATR test will only use SCardReconnect() to reset and reconnect to the card and then call SCardStatus() to get the ATR for comparison. One of the ATRs after warm or cold reset is changing to no longer be the length of the mask.

    Jeff Shipman [MSFT] -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, October 31, 2013 7:02 PM
  • To test this, I had developed a sample application which does SCardReconnect() with dwInitialization set to
    SCARD_RESET_CARD but the ATR returned is always the original one. I had also tried 

    SCARD_UNPOWER_CARD but with same result. I retrieved the ATR by calling SCardStatus().

    Is there a way I can debug the CMCK tests and see what is the ATR returned when ResetATR is called.

    Also, does the test compares the ATR length what is read by SCardStatus() and ATR mask length from registry?

    Regards,

    Madhukar

    Friday, November 1, 2013 5:09 AM
  • Please ignore my previous reply.

    I actually see the ATR and its ATR length being changed after Reconnect().

    I have a question here, Does the CMCK test ResetATR expect the ATR and its length to remain same after Reset is done? But in case of the smart card I'm using, Is this test failure acceptable?

    Thanks,

    Madhukar

    Friday, November 1, 2013 6:25 AM
  • The test is required to pass for certification because if the ATR and ATRMask checks fail, you will find issues loading the minidriver after certain types of reset. To deal with this, we recommend packaging a filter driver with your minidriver package that can make sure the same ATR comes out after all reset types and then this test will pass. You can find a sample at http://support.microsoft.com/kb/981665/en-us

    Jeff Shipman [MSFT] -- This posting is provided "AS IS" with no warranties, and confers no rights.

    • Marked as answer by gubbam Monday, November 4, 2013 5:02 AM
    Friday, November 1, 2013 4:54 PM
  • Thank you for the reply. I would try using filter sample.
    Monday, November 4, 2013 5:02 AM
  • I was able successfully test mini driver using CMCK tests in x86 PC. However, I'm not able to load the ATR filter driver in x64 machine. I want to perform logo testing in x64 machine. I'm installing the filter driver manually with out any INF file. How can I install ATR filter driver manually for logo testing in x64 machine? Can I self sign the .sys file and make it work?

    Thanks,

    Madhukar

    Friday, June 13, 2014 8:33 AM