Writing a string to a SLE5542 Smart Card

November 21st, 2017

Surprisingly, no-one has clear documentation on how to do this.

To do this, you’ll need a smart card writer and some blank SLE5542 smart cards. I’m using:

KKmoon PC/SC Contact IC Chip Smart Card Reader Writer ACR38U I1 USB Support CT-API Programming Interface+5pcs SLE5542 Cards

You’ll also want scriptor to interface with the card.

First step, reset the card:

FF A4 00 00 01 06

You should get a response similar to:

FF A4 00 00 01 06
> FF A4 00 00 01 06
< 90 00 : Normal processing.

Next step, read the contents (start at 0 bytes, read FF bytes) of the card:

FF B0 00 00 FF

You should get a response similar to:

FF B0 00 00 FF
> FF B0 00 00 FF
< A2 13 10 91 FF FF 81 15 FF FF FF FF FF FF FF FF
FF FF FF FF FF D2 76 00 00 04 00 FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 90
00 : Normal processing.

If you want to write to the card, you now need to authenticate. The default pin code is FF FF FF.

FF 20 00 00 03 FF FF FF

You should get an error code 07 as a response. This means successful authentication. Any other response indicates an invalid passcode.

FF 20 00 00 03 FF FF FF
> FF 20 00 00 03 FF FF FF
< 90 07 : Error not defined by ISO 7816

Finally, to write to the card. In this case we’ll zero all the data (start at 00 bytes, write FF bytes, the rest is payload):

FF D0 20 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

You should expect a response similar to:

FF D0 20 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> FF D0 20 00 ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
< 90 00 : Normal processing.

Finally, verify what you have written:

FF B0 00 00 FF

And you get:

FF B0 00 00 FF
> FF B0 00 00 FF
< 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90
00 : Normal processing.

irssi, bitlbee, jabber, openfire and ASCII Control Characters

August 7th, 2013

I’ve recently been hit by an issue where irssi (and bitlbee, and openfire) have been leaking non-printable ASCII Control characters to a Jabber chat room.

This has been triggering an XML Parse Error in Pidgin clients, which causes them to disconnect and reconnect to the Jabber server. This is especially annoying when the server replays chat history to clients. You end up with all Pidgin clients unable to stay connected to your Jabber server. Oops.

I’ve written a quick hacky script for irssi that filters out non-ASCII characters, so they’re not sent to the server and that warns you that you’re doing somethig wrong:

use Irssi;
use strict;
 
use vars qw($VERSION %IRSSI);
 
$VERSION = "0.1";
%IRSSI = (
    authors     => 'Andy Millar',
    name        => 'filter_charset',
    description => 'Filter Outbount Charset',
    license     => 'none',
    url         => 'none',
);
 
 
Irssi::signal_add_first 'send text', 'filter_charset';
 
sub filter_charset {
  my ($text, $server, $win_item) = @_;
  if ($text =~ m/[^[:print:]]/) {
    Irssi::active_win->print("Cannot send line - invalid characters: ##$text##", MSGLEVEL_CLIENTCRAP);
    Irssi::signal_stop();
  }
}

Put this in ~/.irssi/scripts/filter_charset.pl and then /load filter_charset.pl.

Monkey in the spring sun…

February 20th, 2012

Monkey in spring sun on 19th February 2012

Monkey after the snow…

February 20th, 2012

Monkey after snow on 12th February 2012

Logon failure: the user has not been granted the requested logon type at this computer

November 12th, 2011

If you get the error:

Logon failure: the user has not been granted the requested logon type at this computer

When trying to add a computer to a domain or trying to map a network drive, then chances are someone has been stupid.

Check rsop to make sure that the following policy hasn’t been changed to anything silly:

Administrative Tools
> Local Security Settings
>> Local Policies
>>> User Rights Assignment
>>>> Access this computer from the network

This should probably be the list that is suggested in the explanation for this policy and at least include Authenticated Users.

Bacon Explosion!

June 29th, 2011

I was linked to an entertaining recipe on The Bacon Explosion today and couldn’t resist trying it. I figured I should take photographic evidence of the process as proof, so here it is…

The ingredients:

You need an insane amount of:

  • Streaky Bacon
  • Sausage Meat
  • BBQ Sauce
  • BBQ Rub/Powder

Firstly you make a lattice of bacon, you’re supposed to make it as tight as you can.

You should end up with something looking rather close to:

Now sprinkle the lattice with BBQ Rub/Powder:

Then squash your sausage meat ontop:

Now liberally apply chopped cooked bacon:

Cover with copious amounts of BBQ Sauce:

And roll up into a sausage, leaving the lattice behind:

Pinch the ends a little to keep all the goodness in:

Now roll the lattice around the sausage meat, and place the seam at the bottom. Cover liberally in BBQ Rub/Powder:

Now place in a pre-heated oven at 180c for around 75 minutes, I used a glass dish to keep the fat and juices in:

Around half way through the cooking it looked like:

And now it’s done, look at all that bacon juice:

Take out of the cooking container and place on a chopping board to cut:

And now display pure bacon perfection:

The recipe is shamelessly stolen from BBQ Addicts

Orange 3G with Fedora 13

June 27th, 2011

Orange’s 3G internet dongle is a HUAWEI E1752.

By default, this doesn’t appear to be detected by NetworkManager with Fedora 13.

This is because it requires usb_modeswitch to work. Installing the usb_modeswitch package fixed it and the dongle was picked up by NetworkManager.