Menu

#7 usimtool.py doesn't support authentication using admin PINs

2.0
closed
None
2015-08-20
2015-08-19
No

To set some options (e.g. IMSI) on my SIM, I need to authenticate using one of the admin PINs.

I've added "pinA1" and "pinA4" commands to my copy of the code, and thought you might be interested in taking it upstream?

384c384
<   if apdu_class == iso7816.CLS_GSM_USIM and pinnr > 1:
---
>   if apdu_class == iso7816.CLS_GSM_USIM and pinnr == 2:
627a628,641
> # Execute the "pinA1" command.  This proves to the SIM we know admin
> # pin 1, so that commands that require it will execute.
> #
> def pinA1Cmd(card, arg, params):
>   pinOp(card, arg, iso7816.INS_GSM_VERIFY_CHV, 10, params)
>
> #
> # Execute the "pinA4" command.  This proves to the SIM we know admin
> # pin 1, so that commands that require it will execute.
> #
> def pinA4Cmd(card, arg, params):
>   pinOp(card, arg, iso7816.INS_GSM_VERIFY_CHV, 13, params)
>
> #
768a783,784
>     'pinA1':  pinA1Cmd,
>     'pinA4':  pinA4Cmd,

I'm not quite sure about the first change (on checking the pinnr and setting it to be 0x81 if it's greater than 1) - this shouldn't apply for the admin PINs, but maybe it should for other PINs?

I've also only added admin 1 and 4 PINs (because my SIMs only seem to use these two levels, so I haven't been able to test anything else). I'd be happy to add support for other admin PINs, but wouldn't be able to test.

Please let me know if you're interested in this enhancement, and if you have any feedback on the top questions at the end. Thanks!

Discussion

  • Matt Williams

    Matt Williams - 2015-08-19

    Apologies for the formatting - I'm to used to Github markdown - hopefully this should be better:

    384c384
    <   if apdu_class == iso7816.CLS_GSM_USIM and pinnr > 1:
    ---
    >   if apdu_class == iso7816.CLS_GSM_USIM and pinnr == 2:
    627a628,641
    > # Execute the "pinA1" command.  This proves to the SIM we know admin
    > # pin 1, so that commands that require it will execute.
    > #
    > def pinA1Cmd(card, arg, params):
    >   pinOp(card, arg, iso7816.INS_GSM_VERIFY_CHV, 10, params)
    >
    > #
    > # Execute the "pinA4" command.  This proves to the SIM we know admin
    > # pin 1, so that commands that require it will execute.
    > #
    > def pinA4Cmd(card, arg, params):
    >   pinOp(card, arg, iso7816.INS_GSM_VERIFY_CHV, 13, params)
    >
    > #
    768a783,784
    >     'pinA1':  pinA1Cmd,
    >     'pinA4':  pinA4Cmd,
    
     
  • Russell Stuart

    Russell Stuart - 2015-08-19

    Yikes, you are busy. I was in the process of doing #6 and you post this.

    Should your comment for def pinA4() be This proves to the SIM we know admin pin 2?

    And do you have more? If so SourceForge does support a "fork" feature, like GitHub. I've never used it, but maybe it's time, it's more efficient than me cut & pasting patches.

     
  • Matt Williams

    Matt Williams - 2015-08-19

    Thanks!

    Good spot on the pinA4 comment - it should probably actually be This proves to the SIM we know admin pin _4_.

    I don't have any more issues queued up for now. I've been playing around with programming LTE SIMs using this, and these were a couple of enhancements I needed - I'd had them sitting around on my laptop for a couple of weeks and thought I should share them. It's possible I'll have more in future, and am happy to fork if needed (or supply patches in a more sensible manner - I could attach them as text attachments on the issue) - what would work best for you?

     
    • Russell Stuart

      Russell Stuart - 2015-08-19

      Re patch format: for little stuff like this diffs are fine, but that last one was on the borderline of little. The email system mangles them so patch doesn't recognise them, so I apply them manually. That isn't difficult for small patches, but for big ones it becomes error prone.

      For larger stuff Hg can email patches, and you can attach them here. If SourceForge has the equivalent of pull requests that that would be easiest of all.

       
  • Russell Stuart

    Russell Stuart - 2015-08-19

    Applied in 0.14.

     
  • Russell Stuart

    Russell Stuart - 2015-08-19
    • status: open --> closed
     
  • Matt Williams

    Matt Williams - 2015-08-20

    Thanks! In future, I'll attach patches as text files to issues!

     

Log in to post a comment.