Git Product home page Git Product logo

scard's Issues

i can't install

go get -u github.com/ebfe/scard

github.com/ebfe/scard

../github.com/ebfe/scard/scard_darwin.go:7:11: fatal error: 'PCSC/winscard.h' file not found
#include <PCSC/winscard.h>

get binary response

Hi,
I am using your go lang bindings to connect to a eid card.
The problem is that i can connect to it and send commands using transmit and get successful status from the card, but i am not able to read the data out of the response just the status code.

Can you please help me with this?

compilation error : on go 1.8 + linux

Environment: go1.8 , linux

Error during compilation.

Error Message:
cgo-gcc-prolog:198:2: warning: passing argument 3 of ‘SCardGetStatusChange’ from incompatible pointer type [enabled by default]

/usr/include/PCSC/winscard.h:64:16: note: expected ‘LPSCARD_READERSTATE’ but argument is of type ‘struct *’
PCSC_API LONG SCardGetStatusChange(SCARDCONTEXT hContext,

read NDEF URI attribute

Thanks for this repo, I got example running:

Found 1 readers:
[0] ACS ACR122U PICC Interface
Waiting for a Card
Connecting to card in  ACS ACR122U PICC Interface
Card status:
	reader: ACS ACR122U PICC Interface
	state: 54
	active protocol: 2
	atr: 3b 80 80 01 01
Transmit:
	c-apdu: 00 a4 00 0c 02 3f 00
	r-apdu: 6a 82

But wondering, how do I read the NDEF URI tag my device is sending. Is that a call to transmit with some payload or a simpler way?

Merge with sf1/go-card?

There is a lot of overlap between this project and https://github.com/sf1/go-card.

I am currently using this project because I need GetStatusChange, but sf1/go-card has some nice things too, like the ISO Command APDU factory functions, the Reader struct with IsCardPresent() and WaitForCardPresent().

How do you feel about merging those features into ebfe/scard?

See also: sf1/go-card#1

Error when getting the code

Hi,

I am using go version go1.11 linux/amd64 on Ubuntu 16.04. When I try to get the code with go get github.com/ebfe/scard I get the following error:

# github.com/ebfe/go.pcsclite/scard
cgo-gcc-prolog: In function ‘_cgo_7cdefc941711_Cfunc_SCardGetStatusChange’:
cgo-gcc-prolog:209:56: warning: passing argument 3 of ‘SCardGetStatusChange’ from incompatible pointer type [-Wincompatible-pointer-types]
In file included from ../../../go/src/github.com/ebfe/go.pcsclite/scard/scard.go:12:0:
/usr/include/PCSC/winscard.h:87:16: note: expected ‘LPSCARD_READERSTATE {aka struct <anonymous> *}’ but argument is of type ‘struct <anonymous> *’
  PCSC_API LONG SCardGetStatusChange(SCARDCONTEXT hContext,
                ^
# github.com/ebfe/go.pcsclite/scard
../../../go/src/github.com/ebfe/go.pcsclite/scard/scard.go:150:31: cannot use _Ctype_LPSCARD_READERSTATE(unsafe.Pointer(&crs[0])) (type Ctype_LPSCARD_READERSTATE) as type *_Ctype_struct___2 in argument to func literal

Any ideas?

Kind Regards,
Antonio

Cannot compile for Linux

It works well for windows and mac. But when I try to compile for linux I get:

GOOS=linux GOARCH=arm64 go build -o ../bin/card-reader-driver-amd64-linux

github.com/ebfe/scard

../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:35:12: undefined: scardEstablishContext
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:45:7: undefined: scardIsValidContext
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:58:7: undefined: scardCancel
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:67:7: undefined: scardReleaseContext
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:76:15: undefined: scardListReaders
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:81:14: undefined: strbuf
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:271:11: undefined: strbuf
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:275:11: undefined: strbuf
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:291:37: undefined: strbuf
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:304:21: undefined: strbuf
../../../../go/pkg/mod/github.com/ebfe/[email protected]/scard.go:81:14: too many errors

Any idea?

Identify one card from another

I'm using this module via https://github.com/yawn/ykoath/blob/master/ykoath.go and running into something I'd like to implement.

Right now, if I have multiple yubikeys plugged in, they get the same reader name, suffixed with an integer, but the naming is based on insertion order, so it changes depending on which device I plug in first.

As an example:

package main

import (
	"fmt"

	"github.com/ebfe/scard"
)

func main() {
	context, err := scard.EstablishContext()
	if err != nil {
		panic(err)
	}

	readers, err := context.ListReaders()
	if err != nil {
		panic(err)
	}

	for _, reader := range readers {
		fmt.Println(reader)
	}
}
❯ go run ./main.go
Yubico YubiKey OTP+FIDO+CCID
Yubico YubiKey OTP+FIDO+CCID 01

I poked around a bit at this library to see if there's a way to pull a unique identifier from the attributes, but this seems like the obly attributes that the yubikey supports (thought supports is a bit of a stretch, given that most of them are blank):

Yubico YubiKey OTP+FIDO+CCID 01: AttrChannelId:
Yubico YubiKey OTP+FIDO+CCID 01: AttrIccPresence:
Yubico YubiKey OTP+FIDO+CCID 01: AttrIccInterfaceStatus:
Yubico YubiKey OTP+FIDO+CCID 01: AttrAtrString: ;��1��s�!�WYubiKey@
Yubico YubiKey OTP+FIDO+CCID 01: AttrMaxinput: �

Yubico YubiKey OTP+FIDO+CCID 01: AttrVendorName: Yubico
Yubico YubiKey OTP+FIDO+CCID 01: AttrVendorIfdVersion: C
Yubico YubiKey OTP+FIDO+CCID 01: AttrVendorIfdSerialNo:

Are you aware of a way I can differentiate between the smartcards in a deterministic way?

Incorrect FFI for SCardGetStatusChange in darwin

In darwin, the struct SCARD_READERSTATE is declared as packed with alignment of 1 byte.

type scardReaderState struct { 
        szReader       uintptr
        pvUserData     uintptr
        dwCurrentState uint32
        dwEventState   uint32
        cbAtr          uint32
        rgbAtr         [33]byte
}

Go adds 3 bytes of padding at the end of this struct. So the cast of states in scard_darwin.go is invalid, because there are bytes between the elements of the array which shouldn't be there:

func scardGetStatusChange(ctx uintptr, timeout uint32, states []scardReaderState) Error {                        
        r := C.SCardGetStatusChange(C.SCARDCONTEXT(ctx), C.uint32_t(timeout), (C.LPSCARD_READERSTATE_A)(unsafe.Pointer(&states[0])), C.uint32_t(len(states)))
        return Error(r)
}

As a result, code using GetStatusChange in darwin segfaults.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.