Closed maitredede closed 3 months ago
Thanks for the info. I have written this library many years ago and don't remember all the details. Please consider it to be experimental and essentially unmaintained. As of now I do not even have the hardware to test the code, so it is difficult for me to continue development on it.
I will however go ahead and amend the README to be more clear about the demands (which I don't quite recall).
@maitredede Was this a problem that stopped the bindings from working for you? I've installed libfreefare 0.4.0 aka 530ccbc19309c8ab2b8160c2b57fefd747321d04 and I see a bunch of errors related to MifareKeyDeriver when I try to perform an import.
package main
import "github.com/clausecker/openkey"
func main() {
fmt.Println("hello world")
}
$ go run main.go
# github.com/clausecker/freefare
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:56:8: could not determine kind of name for C.FreefareTag
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:35:10: could not determine kind of name for C.MifareKeyDeriver
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:41:12: could not determine kind of name for C.mifare_key_deriver_begin
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:94:14: could not determine kind of name for C.mifare_key_deriver_end
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:107:12: could not determine kind of name for C.mifare_key_deriver_end_raw
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:69:12: could not determine kind of name for C.mifare_key_deriver_update_aid
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:79:12: could not determine kind of name for C.mifare_key_deriver_update_data
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:59:12: could not determine kind of name for C.mifare_key_deriver_update_uid
Yes, you'll need a newer version of libfreefare or an older version of this package. If you would like to continue to work with libfreefare 0.4.0, I can tag an older version in the new Go module style so you can use this package with libfreefare 0.4.0.
What is a sufficiently new version of libfreefare? I tried this one which is about 25 commits after 0.4.0 but got the same error.
commit 646a20da34f5fc77e701e0123c73c1879071ccf5 (HEAD)
Author: Romain Tartière <romain@blogreen.org>
Date: Sun Apr 13 19:47:56 2014 +0200
I don't have a requirement to use a particular version of any library.
Thanks for being so prompt on responding to this, I understand that you have not maintained this library for some time.
Version faac4ae5d881a12d7fb81fc831629ae1d1f10929 should work. That's the last commit before the breaking changes of 1.0.0.
I have prepared a new release based on the 0.3.1 branch that should work with Go modules and libfreefare version 0.4.0. Could you check if everything works fine if you change the freefare dependency to
github.com/clausecker/freefare@c4129c5480756a78318cdc7b94fbcaf2843c10a8
? If you report success, I'll go ahead and push a v0.3.2 release for use with libfreefare 0.4.0 ASAP.
This commit has now been pushed as v0.3.2. Please downgrade to v0.3.2 to use this wrapper with libfreefare-0.4.0.
Sorry I was taking a while to respond but I am still having some issues. I'm not that familiar with go but I think I'm performing this correctly so I made a reproduction of my steps for how I have installed the components. This is the error:
pi@pokepi:~/code/nfc/go/helloworld $ go run main.go # initial error
# github.com/clausecker/freefare
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.0.0-20240420201712-c4129c548075/tag.go:136:31: cannot use *tagptr (variable of type _Ctype_FreefareTag) as type _Ctype_MifareTag in argument to wrapTag
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.0.0-20240420201712-c4129c548075/tag.go:140:12: cannot use (*_Ctype_MifareTag)(unsafe.Pointer(iptr)) (value of type *_Ctype_MifareTag) as type *_Ctype_FreefareTag in assignment
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.0.0-20240420201712-c4129c548075/tag.go:159:38: cannot use *cinfo (variable of type _Ctype_struct___8) as type _Ctype_struct___5 in variable declaration
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.0.0-20240420201712-c4129c548075/tag.go:171:17: cannot use ctag (variable of type _Ctype_FreefareTag) as type _Ctype_MifareTag in argument to wrapTag
This does not look like you have libfreefare 0.4.0 on your system. Rather, these symbols look like they are from after the symbol name change.
In my log I show that I have no other version of libfreefare installed on my system:
pi@pokepi:~/code/nfc/go/helloworld $ go run main.go # uninstalled libfreefare, showing no alternate version of libfreefare on system
# github.com/clausecker/freefare
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.0.0-20240420201712-c4129c548075/aid.go:3:11: fatal error: freefare.h: No such file or directory
3 | // #include <freefare.h>
| ^~~~~~~~~~~~
compilation terminated.
and then install the version you've indicated:
pi@pokepi:~/code/nfc/c/libfreefare $ git checkout faac4ae5d881a12d7fb81fc831629ae1d1f10929
HEAD is now at faac4ae Fix white spaces inconsistencies.
pi@pokepi:~/code/nfc/c/libfreefare $ git reset --hard && git clean -xdf # no repo modification
HEAD is now at faac4ae Fix white spaces inconsistencies.
pi@pokepi:~/code/nfc/c/libfreefare $ autoreconf -vis && ./configure --prefix=/usr && make && sudo make install # install libfreefare from source at target commit
and it appears to complete successfully with
Libraries have been installed in:
/usr/lib
Maybe when I am performing make install I am relinking to a dormant version of libfreefare? but besides that I don't know how this would be happening
For reference...
pi@pokepi:~/code/nfc/go/helloworld $ apt list --installed "*freefare*"
Listing... Done
I repeat: the new v0.3.2 (which is what c4129c5480756a78318cdc7b94fbcaf2843c10a8 is) is for libfreefare-0.4.0. The release. Not any intermediate or development version.
What I was asking you to try earlier was to build v0.4.0 with libfreefare faac4ae5d881a12d7fb81fc831629ae1d1f10929. But it seems like I was wrong and picked too late of a commit. Perhaps try d946230aec3e81a9b641b49f4a8bf5845c246e1a with v0.4.0 if you want to stay on v0.4.0?
Ah apologies, I completely missed that this repository's tag numbering is similar to libfreefare's tag numbering and so I equated any reference to v0.4.0 or similar range with only that library.
The following combination appears to work for me and I can test anything else you like.
github.com/clausecker/freefare@c4129c5480756a78318cdc7b94fbcaf2843c10a8
libfreefare commit faac4ae5d881a12d7fb81fc831629ae1d1f10929
Thanks for the help
Great! github.com/clausecker/freefare@c4129c5480756a78318cdc7b94fbcaf2843c10a8
(aka github.com/clausecker/freefare@v0.3.2
) should also work with libfreefare-0.4.0, but of course it'll build fine with all libfreefare versions until the breaking changes.
Could you also test v0.4.0 of this package with libfreefare commit faac4ae5d881a12d7fb81fc831629ae1d1f10929? If you use libfreefare commit faac4ae5d881a12d7fb81fc831629ae1d1f10929, then you have everything that should be needed to build github.com/clausecker/freefare@v0.4.0
.
github.com/clausecker/freefare@v0.3.2 + faac4ae5d881a12d7fb81fc831629ae1d1f10929 success
github.com/clausecker/freefare@v0.4.0 + faac4ae5d881a12d7fb81fc831629ae1d1f10929 fail
# github.com/clausecker/freefare
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:35:10: could not determine kind of name for C.MifareKeyDeriver
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:41:12: could not determine kind of name for C.mifare_key_deriver_begin
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:94:14: could not determine kind of name for C.mifare_key_deriver_end
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:107:12: could not determine kind of name for C.mifare_key_deriver_end_raw
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:69:12: could not determine kind of name for C.mifare_key_deriver_update_aid
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:79:12: could not determine kind of name for C.mifare_key_deriver_update_data
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:59:12: could not determine kind of name for C.mifare_key_deriver_update_uid
github.com/clausecker/freefare@v0.4.0 + d946230aec3e81a9b641b49f4a8bf5845c246e1a fail
# github.com/clausecker/freefare
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:56:8: could not determine kind of name for C.FreefareTag
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:35:10: could not determine kind of name for C.MifareKeyDeriver
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:41:12: could not determine kind of name for C.mifare_key_deriver_begin
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:94:14: could not determine kind of name for C.mifare_key_deriver_end
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:107:12: could not determine kind of name for C.mifare_key_deriver_end_raw
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:69:12: could not determine kind of name for C.mifare_key_deriver_update_aid
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:79:12: could not determine kind of name for C.mifare_key_deriver_update_data
/home/pi/go/pkg/mod/github.com/clausecker/freefare@v0.4.0/key-deriver.go:59:12: could not determine kind of name for C.mifare_key_deriver_update_uid
Fascinating. This should definitely build. Will have to investigate.
Seems like libfreefare commit b83cbcbb09b3467f455f3e1617f711d9327d4ed8 or later is needed for v0.4.0 of this wrapper. Apparently PR #8 had followed through with some of the upstream symbol renames.
Hi,
I have built libfreefare 0.4.0 from sources : https://github.com/nfc-tools/libfreefare/releases/tag/libfreefare-0.4.0
The type
MifareKeyDeriver
has been added after (year 2018) the tag 0.4.0 has been released (year 2015). Maybe you should state in your doc that your lib needs a self-built version of libfreefare, until a release is done (see https://github.com/nfc-tools/libfreefare/issues/121)