sscard

package module
v0.0.0-...-ab8e35a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2018 License: MIT Imports: 6 Imported by: 0

README

Super Smart Card(sscard)

Super Smart Card API on top of scard(pcsc handler) with apdu commands.

Builtin APDU devices

  • Thai ID card (public data)

TODO

# Linux: install pcsc library
sudo apt-get install pcscd

# goget
go get -u golang.org/x/net/html/charset
go get -u github.com/gogetth/sscard

# go build example
go build -o sscard github.com/gogetth/sscard/main

./sscard

References

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APDUThaiIDCardAddress = [][]byte{
	{0x80, 0xB0, 0x15, 0x79, 0x02, 0x00, 0x64},
	{0x00, 0xc0, 0x00, 0x00, 0x64},
}

APDUThaiIDCardAddress Address resp: 704/82####...#...#...#...

View Source
var APDUThaiIDCardBirth = [][]byte{
	{0x80, 0xB0, 0x00, 0xD9, 0x02, 0x00, 0x08},
	{0x00, 0xc0, 0x00, 0x00, 0x08},
}

APDUThaiIDCardBirth Date of birth resp: 25351126

View Source
var APDUThaiIDCardCID = [][]byte{
	{0x80, 0xb0, 0x00, 0x04, 0x02, 0x00, 0x0d},
	{0x00, 0xc0, 0x00, 0x00, 0x0d},
}

APDUThaiIDCardCID ...

View Source
var APDUThaiIDCardExpiredate = [][]byte{
	{0x80, 0xB0, 0x01, 0x6F, 0x02, 0x00, 0x08},
	{0x00, 0xc0, 0x00, 0x00, 0x08},
}

APDUThaiIDCardExpiredate Expire Date resp: 25691125

View Source
var APDUThaiIDCardFullInfo = [][]byte{
	{0x80, 0xb0, 0x00, 0x11, 0x02, 0x00, 0xd1},
	{0x00, 0xc0, 0x00, 0x00, 0xd1},
}

APDUThaiIDCardFullInfo Fullname Thai + Eng + BirthDate + Sex

View Source
var APDUThaiIDCardFullnameEn = [][]byte{
	{0x80, 0xb0, 0x00, 0x75, 0x02, 0x00, 0x64},
	{0x00, 0xc0, 0x00, 0x00, 0x64},
}

APDUThaiIDCardFullnameEn Fullname English resp: Mr.#Napat##Rungruangbangchan

View Source
var APDUThaiIDCardFullnameTh = [][]byte{
	{0x80, 0xb0, 0x00, 0x11, 0x02, 0x00, 0x64},
	{0x00, 0xc0, 0x00, 0x00, 0x64},
}

APDUThaiIDCardFullnameTh Fullname Thai

View Source
var APDUThaiIDCardGender = [][]byte{
	{0x80, 0xB0, 0x00, 0xE1, 0x02, 0x00, 0x01},
	{0x00, 0xc0, 0x00, 0x00, 0x01},
}

APDUThaiIDCardGender Gender resp: 1=Male, 2=Female

View Source
var APDUThaiIDCardIssuedate = [][]byte{
	{0x80, 0xB0, 0x01, 0x67, 0x02, 0x00, 0x08},
	{0x00, 0xc0, 0x00, 0x00, 0x08},
}

APDUThaiIDCardIssuedate Issue Date resp: 25610119

View Source
var APDUThaiIDCardIssuer = [][]byte{
	{0x80, 0xB0, 0x01, 0x67, 0x02, 0x00, 0x08},
	{0x00, 0xc0, 0x00, 0x00, 0x08},
}

APDUThaiIDCardIssuer Card Issuer resp: 25610119

View Source
var APDUThaiIDCardPhoto = [][]byte{
	[]byte{0x80, 0xB0, 0x01, 0x7B, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x02, 0x7A, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x03, 0x79, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x04, 0x78, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x05, 0x77, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x06, 0x76, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x07, 0x75, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x08, 0x74, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x09, 0x73, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0A, 0x72, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0B, 0x71, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0C, 0x70, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0D, 0x6F, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0E, 0x6E, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x0F, 0x6D, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x10, 0x6C, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x11, 0x6B, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x12, 0x6A, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x13, 0x69, 0x02, 0x00, 0xFF},
	[]byte{0x80, 0xB0, 0x14, 0x68, 0x02, 0x00, 0xFF},
}

APDUThaiIDCardPhoto Card Photo (JPEG)

View Source
var APDUThaiIDCardPhotoRsp = []byte{0x00, 0xc0, 0x00, 0x00, 0xFF}

APDUThaiIDCardPhotoRsp ...

View Source
var APDUThaiIDCardSelect = [][]byte{{0x00, 0xA4, 0x04, 0x00, 0x08, 0xA0, 0x00, 0x00, 0x00, 0x54, 0x48, 0x00, 0x01}}

APDUThaiIDCardSelect Select Thai ID Card

Functions

func APDUGetBlockRsp

func APDUGetBlockRsp(scardCard Transmiter, apducmds [][]byte, apducmdRsp []byte) ([]byte, error)

APDUGetBlockRsp Send list of APDU and append all response

func APDUGetRsp

func APDUGetRsp(card Transmiter, apducmds [][]byte, ispadzeroOptional ...bool) ([]byte, error)

APDUGetRsp Send list of APDU and get last command response ispadzeroOptional is optional(default = true) to replace adpu tail section

func ThIDCardAddress

func ThIDCardAddress(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardAddress get address from Thai national ID smart card.

func ThIDCardBirth

func ThIDCardBirth(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardBirth get birth date from Thai national ID smart card.

func ThIDCardCID

func ThIDCardCID(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardCID get cid from Thai national ID smart card.

func ThIDCardExpireDate

func ThIDCardExpireDate(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardExpireDate get expire date from Thai national ID smart card.

func ThIDCardFullnameEn

func ThIDCardFullnameEn(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardFullnameEn get full name(English) from Thai national ID smart card.

func ThIDCardFullnameTh

func ThIDCardFullnameTh(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardFullnameTh get full name(Thai) from Thai national ID smart card.

func ThIDCardGender

func ThIDCardGender(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardGender get gender from Thai national ID smart card.

func ThIDCardIssueDate

func ThIDCardIssueDate(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardIssueDate get issue date from Thai national ID smart card.

func ThIDCardIssuer

func ThIDCardIssuer(card Transmiter, opt ...OptThIDCard) (string, error)

ThIDCardIssuer get issuer from Thai national ID smart card.

func WriteBlockToFile

func WriteBlockToFile(databytes []byte, fullname string) (int, error)

WriteBlockToFile i.e: write jpeg to file

Types

type OptThIDCard

type OptThIDCard func(*thidcardOpts)

OptThIDCard provide options for each operation.

func OptSharpToSpace

func OptSharpToSpace() OptThIDCard

OptSharpToSpace add option to convert all # to space before return a string

func OptTis620ToUtf8

func OptTis620ToUtf8() OptThIDCard

OptTis620ToUtf8 add option to convert TIS620 string back to UTF-8 before return a string

type Transmiter

type Transmiter interface {
	Transmit([]byte) ([]byte, error)
}

Transmiter is an interface that wrap the command to communicate with smart card via application protocol data unit (APDU) according to ISO/IEC 7816.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL