OSX CryptoTokenKit SmartCard returned error 6d00

久未见 提交于 2020-01-05 11:36:29

问题


I'm trying to read the master file of a smartcard on OSX using CryptoTokenKit but I always get statusword 6d00 as response. I also tried to run the trivial example with some modifications but get the same error. My reader is Gemalto PC Twin Reader.

Please let me know if you have any suggestion to fix it.

I'm using the following code:

    TKSmartCardSlot *slot = [self.smartCardManager slotWithName:slotName];
    TKSmartCard *card = [slot makeSmartCard];
    card.sensitive = YES;
    [card beginSessionWithReply:^(BOOL success, NSError *error)  {
        NSLog(@"%@", error);
        NSLog(@"Proto: %ld", card.currentProtocol);
        NSData *data = [CommonUtil dataFromHexString:@"3F00"]; //<3f00>
        NSLog(@"%@", data);
        [card sendIns:0xA4 p1:0x00 p2:0x00 data:data le:@0
                reply:^(NSData *replyData, UInt16 sw, NSError *error)
         {
             NSLog(@"Response: %@", replyData);
             if (error) {
                 if (error.code == TKErrorCodeCommunicationError) {
                     // set response error code.
                 }
                 NSLog(@"%@", error);
             }
         }];
    }];

回答1:


It is silly, but in the apdu where no response data is expected without the success code 90 00, le should be nil.

[card sendIns:0xA4 p1:0x00 p2:0x00 data:nil le:nil
                reply:^(NSData *replyData, UInt16 sw, NSError *error)
         {
         }



回答2:


Status Word 6D00 is " Instruction code not supported or invalid " http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx

Not all the cards allow to select the Master File (0x3F00).



来源:https://stackoverflow.com/questions/31220795/osx-cryptotokenkit-smartcard-returned-error-6d00

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!