{"id":23442196,"url":"https://github.com/rambo/nfc_lock","last_synced_at":"2025-08-26T04:31:09.315Z","repository":{"id":22386531,"uuid":"25723312","full_name":"rambo/nfc_lock","owner":"rambo","description":"(more) secure electric lock with DESFire EV1 NFC tags","archived":false,"fork":false,"pushed_at":"2024-02-24T08:37:55.000Z","size":1740,"stargazers_count":26,"open_issues_count":0,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-16T03:53:57.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rambo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2014-10-25T07:06:45.000Z","updated_at":"2023-10-01T13:57:31.000Z","dependencies_parsed_at":"2022-08-21T03:31:13.985Z","dependency_job_id":"291713c0-e64d-4db0-be31-8da6486d0223","html_url":"https://github.com/rambo/nfc_lock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambo%2Fnfc_lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambo%2Fnfc_lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambo%2Fnfc_lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rambo%2Fnfc_lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rambo","download_url":"https://codeload.github.com/rambo/nfc_lock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230995463,"owners_count":18312455,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T17:28:58.116Z","updated_at":"2024-12-23T17:28:59.538Z","avatar_url":"https://github.com/rambo.png","language":"C","funding_links":[],"categories":["Existing Projects"],"sub_categories":[],"readme":"nfc_lock\n========\n\n(more) secure electric lock with DESFire EV1 NFC tags\n\n## libnfc and libfreefare\n\n    sudo apt-add-repository ppa:christopher-hoskin/ppa\n    sudo apt-get update\n    sudo apt-get install libnfc5 libnfc-bin libnfc-pn53x-examples libnfc-examples\n    sudo apt-get install libfreefare0 libfreefare-bin\n    sudo apt-get install python-zmq python-yaml python-tornado\n\n`python-yaml` and `python-tornado` can be installed to virtualenv (esp tornado might be better to install via pip even if not to virtualenv the deb pulls unneccessary dependencies), zmq will be painful to install via pip, use the system package.\n\n### For compiling\n\nFor the C programs.\n\n    sudo apt-get install libfreefare-dev libnfc-dev libssl-dev pkg-config libzmq-dev\n\n### RasPi\n\nAll libraries should be part of normal releases now.\n\n## Terms\n\n  - Card (PICC in NXP terms): The DESFire EV1 chip+antenna in a package (fob, card, sticker...)\n  - Pre-Personalization step: Where card default master key is changed and applications are defined.\n  - Application: collection of files on the card, application can have multiple keys for various purposes\n  - Provisioning (or personalization) step: Where a personalized card is issued to a card holder and the card (plus backing datababase) is updated with relevant info\n  - Diversified key: Key that has been derived from a master key via the method described in NXP AN19022\n\n## SQLite for keys\n\nCreate a test file `sqlite3 keys.db`:\n\n\n    CREATE TABLE valid_tokens (value TEXT UNIQUE, type INTEGER, acl INTEGER, external_ids TEXT);\n    CREATE TABLE revoked_tokens (value TEXT UNIQUE, type INTEGER);\n\nPrepare some tags and insert their (real) UIDs to the grants and revokes\n\n    INSERT INTO revoked_tokens VALUES (\"04453069b21e80\");\n    INSERT INTO valid_tokens VALUES (\"04212f69b21e80\", 0, 1);\n\nIn reality you will generate this file based on your person registry (keep track of validity times etc there, then regenerate the keydb for the door).\n\n## Hacking\n\nRemember to valgrind your C programs (`valgrind -v --leak-check=yes  myprog args`) at the same time as you do general functionality testing.\n\n### RasPi\n\nIt seems Valgrind does not (and will not) support some instructions we use to talk with the NFC chips, see (this stackoverflow)[valgrindworkaround] for a workaround.\n\n[valgrindworkaround]: http://stackoverflow.com/questions/20066215/valgrind-unrecognizes-memcmp-instruction-in-raspberry-pi#comment-29892760\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambo%2Fnfc_lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frambo%2Fnfc_lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frambo%2Fnfc_lock/lists"}