Compare commits

..
141 Commits
Author SHA1 Message Date
Iceman f524d97378 Update README.md
updated in order to trigger the actions to run.
2023-06-04 18:01:13 +02:00
Iceman 6e0b127af2 Update firmware-push.yml 2023-06-01 20:31:05 +02:00
Iceman 1994131251 Update firmware-push.yml 2023-06-01 20:28:14 +02:00
Iceman c50604ab28 Update firmware-push.yml 2023-06-01 20:14:04 +02:00
Iceman c090d1362d Update firmware-push.yml 2023-06-01 19:21:52 +02:00
Iceman a3c73cd710 Update firmware-push.yml 2023-06-01 19:18:56 +02:00
Iceman c0a3e35520 Update firmware-pr.yml 2023-06-01 19:18:41 +02:00
Iceman 1033042e0b Update firmware-push.yml 2023-06-01 19:17:52 +02:00
Iceman e547d1a139 Merge pull request #26 from monster1025/ProxgrindMifareFix
Fix timeout while working with russian subway validators.
2023-06-01 14:29:46 +02:00
Iceman db4488366f Merge pull request #99 from shidevil/proxgrind
Typo in readme
2023-06-01 14:27:02 +02:00
Iceman f1706f2c3e Merge pull request #101 from gentilkiwi/proxgrind
NTAG213 and NTAG216 support in addition to NTAG215
2023-06-01 14:26:21 +02:00
Benjamin DELPY fe15f7064b NTAG213 and NTAG216 support in addition to NTAG215
Inspired from @xeonxu 's https://github.com/iceman1001/ChameleonMini-rebooted/pull/194 , a PR to support NTAG213 and NTAG216 in ChameleonMini revG - without size problem
2023-06-01 11:02:42 +02:00
shidevil 3bc9207602 Typo in readme 2022-11-27 22:28:56 +08:00
Iceman bb13d083a3 Merge pull request #94 from nvx/bugfix/iclass_update
fix bug with iclass UPDATE command
2022-07-09 05:48:54 +02:00
nvx 7667c2430d fix bug with iclass UPDATE command 2022-07-09 11:34:25 +10:00
Iceman e24a1ddd47 Merge pull request #90 from sawft99/proxgrind
Update to Readme
2022-06-28 21:11:29 +02:00
Iceman 4de793f4b1 Merge pull request #85 from xeonxu/wsl
Use a variable named DFU_PROG to identify dfu-programmer.
2022-06-28 21:10:36 +02:00
Iceman 1132f7182c Merge pull request #91 from nvx/iclass
iClass support
2022-06-28 21:09:39 +02:00
nvx 4bb28e8617 iClass support
Requires enabling in Makefile and disabling other options to fit in program space below 64k
2022-06-28 16:57:39 +10:00
sawft99 70f66f1cb8 Update README.md 2022-06-07 15:50:08 -04:00
sawft99 516e67345c Update README.md 2022-06-07 15:47:29 -04:00
sawft99 0828ed9dea Update README.md 2022-06-07 15:09:10 -04:00
sawft99 2d31453780 Update README.md 2022-06-07 14:42:59 -04:00
sawft99 c9068c49b4 Add Clone_MFU command 2022-06-03 16:13:19 -04:00
sawft99 b15ba66e24 Update README.md 2022-06-03 14:11:19 -04:00
sawft99 11844d6a36 Update README.md 2022-06-03 13:59:31 -04:00
sawft99 c94d44d690 Add info on documentation 2022-06-03 11:27:04 -04:00
sawft99 f651832afd Update README.md 2022-06-03 09:19:29 -04:00
sawft99 87be57ec64 Update README.md 2022-06-03 09:12:18 -04:00
sawft99 871112d679 Added DFU Programmer Info 2022-06-03 01:54:48 -04:00
sawft99 34e1563f60 Update README.md 2022-06-03 01:07:52 -04:00
sawft99 32312b7563 Add driver instructions
Also reorganized some parts
2022-06-03 00:27:13 -04:00
sawft99 fc62b8b37d Update README.md 2022-06-02 23:19:27 -04:00
sawft99 a47c965388 Fix links 2022-06-02 23:01:11 -04:00
sawft99 ab4c789381 Update README.md 2022-06-02 22:47:58 -04:00
sawft99 77a39bcbe6 Consistent bolding
Other minor changes as well.
2022-06-02 19:31:25 -04:00
sawft99 4dd13e7246 Spacing 2022-06-02 16:22:28 -04:00
sawft99 0539337f70 Update README.md 2022-06-02 15:37:44 -04:00
sawft99 0e89d1037a Update README.md 2022-06-02 00:53:14 -04:00
sawft99 2f5e5c2a4c Update README.md 2022-06-01 09:57:58 -04:00
sawft99 3f8abc6dcc Update README.md 2022-06-01 08:59:16 -04:00
sawft99 d0458a1659 Update README.md 2022-06-01 08:56:54 -04:00
sawft99 091cfb77e9 Update README.md 2022-05-31 18:15:49 -04:00
sawft99 e49ad0a7e9 More minor changes 2022-05-31 17:20:58 -04:00
sawft99 91dcf1167d Minor fixes
Minor fixes
2022-05-31 17:08:01 -04:00
sawft99 78a1591392 Update to Readme
Reorganized much of the info.  Removed redundant entries. Grammar changes. Consistent wording and format. Added a small amount of new info.
2022-05-31 16:39:47 -04:00
Monster 285d2f9acd Merge branch 'RfidResearchGroup:proxgrind' into ProxgrindMifareFix 2022-04-26 21:24:28 +03:00
Noe Xu 93ce9450d1 Use a variable named DFU_PROG to identify dfu-programmer. And it's convenient for using `make dfu-prog' under WSL. 2022-02-08 20:03:20 +08:00
Iceman 17f32094d9 Merge pull request #83 from ceres-c/iso15_merge_rrg
ISO15693 sniffing codec
2022-02-01 19:09:08 +01:00
Federico Cerutti 59f68ac4c9 Fixed check-size in makefile and updated readme 2022-02-01 18:07:20 +01:00
Federico Cerutti d3299fee43 Calling AppProcess as suggested by @cacke-r 2022-02-01 00:03:15 +01:00
Federico Cerutti 3b53376b56 Ported fptrs fixes 2022-02-01 00:03:13 +01:00
Federico Cerutti 89dde5c609 Printing unknown log entries hex code 2022-02-01 00:01:54 +01:00
Federico Cerutti c692e0ea11 ISO15693 sniff codec 2022-01-31 23:59:50 +01:00
Iceman bea9cc45be Merge pull request #81 from bettse/patch-1
Update README.md
2022-01-08 21:14:47 +01:00
Eric Betts 4a7ab54bca Update README.md
Add link to iOS app
2022-01-08 09:57:24 -08:00
Iceman 90f04ac26a Merge pull request #66 from mgp25/proxgrind
NTAG 215 Support + ChamTool update
2021-08-18 20:42:31 +02:00
un1k0n eb9e3965b2 ChamTool: Updated clear slot function 2021-05-25 16:24:47 +02:00
mgp25 a35544b18f Chamtool: Clear slot 2021-05-25 01:25:37 +02:00
mgp25 74bf966f03 Create .gitignore 2021-05-24 22:50:31 +02:00
mgp25 1235ee1198 NTAG215 from @gcammisa 2021-05-24 22:50:24 +02:00
Iceman 6a2a976fd9 Merge pull request #59 from nieldk/proxgrind
Corrected check-size
2021-02-02 15:48:03 +01:00
Niel Nielsen 29463e885d Corrected check-size
Checksize added --mcu=atxmega128a4u to output programsize and not eep size
2021-02-02 15:26:25 +01:00
Iceman 33a87501db Merge pull request #58 from nieldk/proxgrind
Update Makefile
2021-02-02 14:30:15 +01:00
Niel Nielsen 5845b7bba9 Update Makefile
Makefile updated to calculate elf size correctly
2021-02-02 14:21:12 +01:00
iceman1001 e873206fb4 re-enable sniff/clone 14a. 2020-11-27 23:23:46 +01:00
Iceman 93d4ee1ebf Merge pull request #53 from The-White-Fox/FixComments
Fix mandarin chinese comments
2020-11-27 19:46:41 +01:00
Iceman 3ace917971 Merge pull request #48 from Smith-S/proxgrind
Fix some minor typo
2020-11-27 19:46:07 +01:00
Iceman 844843d248 Merge pull request #46 from nieldk/proxgrind
Update Makefile
2020-11-27 19:45:25 +01:00
Iceman 59846bbe11 Merge pull request #47 from ceres-c/elf-sections-fix-rrg
Elf sections size check before flashing
2020-11-27 19:44:38 +01:00
The-White-Fox 1c6e23b129 Fix mandarin chinese comments
Fix some nice but mandarin chinese comments and replaced  it with its google translation.
Should be buildable for now (cause some unexplicable build errors in first try).
2020-11-10 14:50:50 +01:00
Federico Cerutti 10ac19d698 Additional reader mode ifdefs 2020-10-15 21:02:24 +02:00
Federico Cerutti 5ef496816d Working in windows under cygwin 2020-10-15 02:02:02 +02:00
Federico Cerutti 9c135cd1e4 Disabled sniff/reader codecs compilation
Had to make some minor changes to Commands.c and CommandLine.c
to allow building without these codecs
2020-10-15 02:01:54 +02:00
Federico Cerutti bc3ae6b768 Elf sections check before flash
Due to the addition of new codecs and applications, code size grew to
overwrite the part of FRAM currently used to store card slots (settings).
This simple (although hacky) makefile command verifies if such an
issue will occur before flashing the firmware.
2020-10-15 01:59:57 +02:00
Niel Nielsen f9be25ea06 Update Makefile
Add LTO to reduce final binary size, which fixes issues witg eg long-press
2020-10-14 21:25:41 +02:00
Smith-S 353f945313 Fix some minor typo
Typo minor fix.
2020-10-13 16:18:42 +07:00
Iceman 7f310af7ad Merge pull request #41 from luminouw/feature/custom_atqa_sak
Added ATQA and SAK commands, ported from RevE firmware
2020-09-17 20:20:37 +02:00
luminouw 7055e26170 Added ATQA and SAK commands, ported from RevE firmware 2020-09-17 19:53:29 +02:00
Iceman d4a79265f1 Merge pull request #40 from aveao/rrg-cm-ceresfix
Port ISO15693 codec and applications updates by ceres-c to the right branch
2020-09-15 20:16:06 +02:00
Ave c5b07988dc Merge remote-tracking branch 'ceres/rrg-iso15693-codec-upd' into proxgrind 2020-09-15 21:08:19 +03:00
Iceman 152dc71cb3 Merge pull request #39 from linuxgemini/ghactions-improved
Improved Github Actions
2020-09-13 18:45:47 +02:00
İlteriş Eroğlu e356af95a7 Create firmware-pr.yml 2020-09-13 14:37:27 +03:00
İlteriş Eroğlu d0b3db9af6 Move current conf to push only + auto pre-release 2020-09-13 14:36:51 +03:00
Iceman 6b5857e90c Merge pull request #38 from linuxgemini/githubactions
Create initial CI configuration
2020-09-13 01:27:08 +02:00
İlteriş Eroğlu edb986656b Create firmware.yml 2020-09-13 02:14:37 +03:00
Iceman 2a9dcfadd2 Merge pull request #36 from aveao/rrgulfix
UL: Handle compatibility writes correctly
2020-09-13 00:53:48 +02:00
Ave b430b37f70 UL: Handle compatibility writes correctly 2020-09-08 00:10:35 +03:00
DXL cc2b0dbd20 Update README.md 2020-08-26 22:44:17 +08:00
DXL c4bf25920b Update README.md 2020-08-26 22:43:49 +08:00
DXL 3aa7f30c4a ChameleonTiny Android APK 2020-08-07 19:28:08 +08:00
DXL 5c6e4084f2 Delete Chameleon_Work_20200603-262956-o_1e9sqf190sg18bc1ftd121nr7pr-uid-2340331.apk 2020-08-07 19:27:35 +08:00
DXL a4f8b60921 Add files via upload 2020-08-07 19:25:56 +08:00
Monster1025 58209fc9f4 Fix timeout while working with russian subway validators. 2020-07-01 17:16:40 +03:00
Willok acdfb6c010 Merge branch 'proxgrind' of https://github.com/RfidResearchGroup/ChameleonMini into proxgrind 2020-06-22 11:22:04 +08:00
Willok 9b0e40f4c5 update hex file 2020-06-22 11:09:48 +08:00
Willok 4ac715463c not allow to write block 0 2020-06-22 11:07:52 +08:00
Iceman 7c8f7dd08f Merge pull request #24 from nieldk/proxgrind
L- and R- button long press options added
2020-05-20 18:39:56 +02:00
Niel Nielsen 2192178dd4 Update Makefile 2020-05-20 16:32:10 +02:00
Niel Nielsen c8718a976c Update Settings.c 2020-05-20 16:29:38 +02:00
Niel Nielsen 9b7b53478d Update Button.h 2020-05-20 16:27:36 +02:00
DXL ba1c451e10 Update README.md 2020-05-10 17:50:38 +08:00
Iceman 76c7ee803f Merge pull request #22 from grspy/proxgrind
Fixed commands list for complete help output
2020-04-20 19:54:45 +02:00
unknown 907fae6fdb Fixed commands list for complete help output 2020-04-19 21:50:36 +03:00
DXL d6b0254bf9 Update README.md 2020-04-20 00:57:42 +08:00
DXL ac12a04d31 Update README.md 2020-04-20 00:56:38 +08:00
DXL ffd0416d18 Add files via upload 2020-03-22 15:41:37 +08:00
DXL 00e3eb8674 Update README.md 2020-03-19 13:21:13 +08:00
DXL 9cb5d37b4e Update README.md 2020-03-19 13:13:36 +08:00
DXL 4a473d6023 Update README.md 2020-03-17 16:52:06 +08:00
DXL 83a27f3917 Update README.md 2020-03-17 12:40:13 +08:00
DXL dd41d79d43 Update README.md 2020-03-17 12:37:08 +08:00
DXL bff753628d Update README.md 2020-03-17 12:36:38 +08:00
DXL 09d065a16b Update README.md 2020-03-17 12:34:11 +08:00
DXL a20dd0f270 Update README.md 2020-03-17 12:30:31 +08:00
DXL 11b94241eb Update README.md 2020-03-17 12:30:06 +08:00
DXL 11633e29e1 Update README.md 2020-03-16 15:52:14 +08:00
DXL 86c837b0ce Update README.md 2020-03-16 15:49:36 +08:00
DXL a08fac39d8 Update README.md 2020-03-16 15:49:22 +08:00
DXL b5126deafd Update README.md 2020-03-16 15:46:29 +08:00
DXL a68ad0fca0 Update README.md 2020-03-16 15:06:05 +08:00
DXL 92981f9f34 Update README.md 2020-03-16 14:55:15 +08:00
DXL 6765b5d2b1 Update README.md 2020-03-16 14:54:00 +08:00
DXL 44838bc178 Update README.md 2020-03-16 14:51:48 +08:00
DXL 6971b02427 Update README.md 2020-03-16 14:50:36 +08:00
DXL 9757d6158c Update README.md 2020-03-16 14:49:46 +08:00
DXL d421dce64e Update README.md 2020-03-16 14:48:32 +08:00
DXL deb4719ce3 Update README.md 2020-03-16 14:33:20 +08:00
DXL a4e0ecd30d Update README.md 2020-03-16 14:31:46 +08:00
DXL e21eba770e Merge pull request #16 from xianglin1998/patch-1
Update README.md
2020-03-16 09:35:31 +08:00
DXL d298f9b816 Update README.md 2020-03-13 20:22:44 +08:00
Willok a83b6feb38 Does not respond to the RATS instruction unless SAK contains 0x20 2020-02-03 17:24:23 +08:00
Willok 11a8cc57ec Fix the UID mode under PM3 2020-01-08 18:39:48 +08:00
Willok 12fadd40d0 Commit new README.md 2019-12-26 20:22:20 +08:00
Willok ff461637ff modify default setting, add default card data 2019-12-24 12:22:11 +08:00
Willok 51ce8fb67c Modify the state on DetectionMode 2019-12-13 17:44:35 +08:00
Willok 6606f8d0ff make style 2019-12-06 10:18:25 +01:00
Willok 1339e6350d Fix:not saving card data when it is smaller than one page(256B) 2019-12-06 10:18:22 +01:00
Willok 5dcf851734 upload the missing file 2019-12-06 10:18:20 +01:00
Willok 414960f733 Fix uidmode function
Adjust the serial communication buffer size
2019-12-06 10:18:18 +01:00
Willok 0cf47594ef RevG rebooted initial release 2019-12-06 10:18:01 +01:00
68 changed files with 12926 additions and 7990 deletions

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
name: Firmware Build (Pull Request, Firmware Modified, Artifact in build job)
on:
pull_request:
paths:
- "Firmware/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Make a firmware build folder
run: mkdir FirmwareBuild
- name: Print Kernel Ver
run: uname -a
- name: Update APT
run: sudo apt-get update -yqq
- name: Install AVR GCC Suite
run: sudo apt-get install -yqq make autoconf build-essential ca-certificates pkg-config libreadline-dev gcc-avr binutils-avr gdb-avr avr-libc avrdude
- name: Make Firmware
run: make
working-directory: Firmware/Chameleon-Mini/
- name: Move hex file to FirmwareBuild
run: mv Chameleon*.hex $GITHUB_WORKSPACE/FirmwareBuild/
working-directory: Firmware/Chameleon-Mini/
- name: Move eep file to FirmwareBuild
run: mv Chameleon*.eep $GITHUB_WORKSPACE/FirmwareBuild/
working-directory: Firmware/Chameleon-Mini/
- name: Upload Build Artifact to Action
uses: actions/upload-artifact@v3
with:
name: "ChameleonBuild"
path: "FirmwareBuild/**"
+52
View File
@@ -0,0 +1,52 @@
name: Firmware Build (proxgrind Branch Push, Pre-release with Artifacts)
on:
push:
branches: [ proxgrind ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Make a firmware build folder
run: mkdir FirmwareBuild
- name: Print Kernel Ver
run: uname -a
- name: Update APT
run: sudo apt-get update -yqq
- name: Install AVR GCC Suite
run: sudo apt-get install -yqq make autoconf build-essential ca-certificates pkg-config libreadline-dev gcc-avr binutils-avr gdb-avr avr-libc avrdude
- name: Make Firmware
run: make
working-directory: Firmware/Chameleon-Mini/
- name: Move hex file to FirmwareBuild
run: mv Chameleon*.hex $GITHUB_WORKSPACE/FirmwareBuild/
working-directory: Firmware/Chameleon-Mini/
- name: Move eep file to FirmwareBuild
run: mv Chameleon*.eep $GITHUB_WORKSPACE/FirmwareBuild/
working-directory: Firmware/Chameleon-Mini/
- name: Upload Build Artifact to Action
uses: actions/upload-artifact@v3
with:
name: "ChameleonBuild"
path: "FirmwareBuild/**"
- name: Create a Pre-release
uses: DonghaoFeng-Moloco/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "${{ format('Build-{0}', github.sha) }}"
release_name: Firmware Build ${{ github.sha }}
body: Built at commit ${{ github.sha }} from ${{ github.actor }}
draft: false
prerelease: true
- name: Upload Pre-release Artifacts
uses: linuxgemini/github-upload-release-artifacts-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
created_tag: "${{ format('Build-{0}', github.sha) }}"
args: "FirmwareBuild/"
+3
View File
@@ -0,0 +1,3 @@
.DS_Store
*.pyc
+9 -7
View File
@@ -1,8 +1,10 @@
/Chameleon-Mini.eep
/Chameleon-Mini.hex
/Chameleon-Mini.elf
/Chameleon-Mini.map
/Chameleon-Mini.bin
/Chameleon-Mini.lss
/Chameleon-Mini.sym
/Chameleon-*.eep
/Chameleon-*.hex
/Chameleon-*.elf
/Chameleon-*.map
/Chameleon-*.bin
/Chameleon-*.lss
/Chameleon-*.sym
/Bin/
dfu-programmer
dfu-programmer.exe
+1
View File
@@ -24,6 +24,7 @@
static inline
void AntennaLevelInit(void) {
ADCA.CAL = (PRODSIGNATURES_ADCACAL1 << 8) | PRODSIGNATURES_ADCACAL0; /* Load calibration data, source: https://www.avrfreaks.net/comment/2080211#comment-2080211 */
ADCA.CTRLA = ADC_ENABLE_bm;
ADCA.CTRLB = ADC_RESOLUTION_12BIT_gc;
ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_BANDGAP_bm;
@@ -21,6 +21,9 @@
#include "TITagitstandard.h"
#include "Sniff14443A.h"
#include "EM4233.h"
#include "NTAG21x.h"
#include "Sniff15693.h"
#include "IClass.h"
/* Function wrappers */
INLINE void ApplicationInit(void) {
@@ -53,4 +56,20 @@ INLINE void ApplicationSetUid(ConfigurationUidType Uid) {
LogEntry(LOG_INFO_UID_SET, Uid, ActiveConfiguration.UidSize);
}
INLINE void ApplicationGetSak(uint8_t * Sak) {
ActiveConfiguration.ApplicationGetSakFunc(Sak);
}
INLINE void ApplicationSetSak(uint8_t Sak) {
ActiveConfiguration.ApplicationSetSakFunc(Sak);
}
INLINE void ApplicationGetAtqa(uint16_t * Atqa) {
ActiveConfiguration.ApplicationGetAtqaFunc(Atqa);
}
INLINE void ApplicationSetAtqa(uint16_t Atqa) {
ActiveConfiguration.ApplicationSetAtqaFunc(Atqa);
}
#endif /* APPLICATION_H_ */
+14 -14
View File
@@ -293,26 +293,26 @@ static const uint8_t TableC0[32] = {
static const uint8_t TableC7[32] = {
/* fc with Input {4,3,2,1,0} = (0,0,0,0,0) to (1,1,1,1,1) */
FC(0, 0, 0, 0, 0) << 7, FC(0, 0, 0, 0, 1) << 7, FC(0, 0, 0, 1, 0) << 7, FC(0, 0, 0, 1, 1) << 7,
FC(0, 0, 1, 0, 0) << 7, FC(0, 0, 1, 0, 1) << 7, FC(0, 0, 1, 1, 0) << 7, FC(0, 0, 1, 1, 1) << 7,
FC(0, 1, 0, 0, 0) << 7, FC(0, 1, 0, 0, 1) << 7, FC(0, 1, 0, 1, 0) << 7, FC(0, 1, 0, 1, 1) << 7,
FC(0, 1, 1, 0, 0) << 7, FC(0, 1, 1, 0, 1) << 7, FC(0, 1, 1, 1, 0) << 7, FC(0, 1, 1, 1, 1) << 7,
FC(1, 0, 0, 0, 0) << 7, FC(1, 0, 0, 0, 1) << 7, FC(1, 0, 0, 1, 0) << 7, FC(1, 0, 0, 1, 1) << 7,
FC(1, 0, 1, 0, 0) << 7, FC(1, 0, 1, 0, 1) << 7, FC(1, 0, 1, 1, 0) << 7, FC(1, 0, 1, 1, 1) << 7,
FC(1, 1, 0, 0, 0) << 7, FC(1, 1, 0, 0, 1) << 7, FC(1, 1, 0, 1, 0) << 7, FC(1, 1, 0, 1, 1) << 7,
FC(1, 1, 1, 0, 0) << 7, FC(1, 1, 1, 0, 1) << 7, FC(1, 1, 1, 1, 0) << 7, FC(1, 1, 1, 1, 1) << 7
FC(0, 0, 1, 0, 0) << 7, FC(0, 0, 1, 0, 1) << 7, FC(0, 0, 1, 1, 0) << 7, FC(0, 0, 1, 1, 1) << 7,
FC(0, 1, 0, 0, 0) << 7, FC(0, 1, 0, 0, 1) << 7, FC(0, 1, 0, 1, 0) << 7, FC(0, 1, 0, 1, 1) << 7,
FC(0, 1, 1, 0, 0) << 7, FC(0, 1, 1, 0, 1) << 7, FC(0, 1, 1, 1, 0) << 7, FC(0, 1, 1, 1, 1) << 7,
FC(1, 0, 0, 0, 0) << 7, FC(1, 0, 0, 0, 1) << 7, FC(1, 0, 0, 1, 0) << 7, FC(1, 0, 0, 1, 1) << 7,
FC(1, 0, 1, 0, 0) << 7, FC(1, 0, 1, 0, 1) << 7, FC(1, 0, 1, 1, 0) << 7, FC(1, 0, 1, 1, 1) << 7,
FC(1, 1, 0, 0, 0) << 7, FC(1, 1, 0, 0, 1) << 7, FC(1, 1, 0, 1, 0) << 7, FC(1, 1, 0, 1, 1) << 7,
FC(1, 1, 1, 0, 0) << 7, FC(1, 1, 1, 0, 1) << 7, FC(1, 1, 1, 1, 0) << 7, FC(1, 1, 1, 1, 1) << 7
};
/* Special table for nibble processing (e.g. ack), feedback at bit 3 */
static const uint8_t TableC3[32] = {
/* fc with Input {4,3,2,1,0} = (0,0,0,0,0) to (1,1,1,1,1) */
FC(0, 0, 0, 0, 0) << 3, FC(0, 0, 0, 0, 1) << 3, FC(0, 0, 0, 1, 0) << 3, FC(0, 0, 0, 1, 1) << 3,
FC(0, 0, 1, 0, 0) << 3, FC(0, 0, 1, 0, 1) << 3, FC(0, 0, 1, 1, 0) << 3, FC(0, 0, 1, 1, 1) << 3,
FC(0, 1, 0, 0, 0) << 3, FC(0, 1, 0, 0, 1) << 3, FC(0, 1, 0, 1, 0) << 3, FC(0, 1, 0, 1, 1) << 3,
FC(0, 1, 1, 0, 0) << 3, FC(0, 1, 1, 0, 1) << 3, FC(0, 1, 1, 1, 0) << 3, FC(0, 1, 1, 1, 1) << 3,
FC(1, 0, 0, 0, 0) << 3, FC(1, 0, 0, 0, 1) << 3, FC(1, 0, 0, 1, 0) << 3, FC(1, 0, 0, 1, 1) << 3,
FC(1, 0, 1, 0, 0) << 3, FC(1, 0, 1, 0, 1) << 3, FC(1, 0, 1, 1, 0) << 3, FC(1, 0, 1, 1, 1) << 3,
FC(1, 1, 0, 0, 0) << 3, FC(1, 1, 0, 0, 1) << 3, FC(1, 1, 0, 1, 0) << 3, FC(1, 1, 0, 1, 1) << 3,
FC(1, 1, 1, 0, 0) << 3, FC(1, 1, 1, 0, 1) << 3, FC(1, 1, 1, 1, 0) << 3, FC(1, 1, 1, 1, 1) << 3
FC(0, 0, 1, 0, 0) << 3, FC(0, 0, 1, 0, 1) << 3, FC(0, 0, 1, 1, 0) << 3, FC(0, 0, 1, 1, 1) << 3,
FC(0, 1, 0, 0, 0) << 3, FC(0, 1, 0, 0, 1) << 3, FC(0, 1, 0, 1, 0) << 3, FC(0, 1, 0, 1, 1) << 3,
FC(0, 1, 1, 0, 0) << 3, FC(0, 1, 1, 0, 1) << 3, FC(0, 1, 1, 1, 0) << 3, FC(0, 1, 1, 1, 1) << 3,
FC(1, 0, 0, 0, 0) << 3, FC(1, 0, 0, 0, 1) << 3, FC(1, 0, 0, 1, 0) << 3, FC(1, 0, 0, 1, 1) << 3,
FC(1, 0, 1, 0, 0) << 3, FC(1, 0, 1, 0, 1) << 3, FC(1, 0, 1, 1, 0) << 3, FC(1, 0, 1, 1, 1) << 3,
FC(1, 1, 0, 0, 0) << 3, FC(1, 1, 0, 0, 1) << 3, FC(1, 1, 0, 1, 0) << 3, FC(1, 1, 0, 1, 1) << 3,
FC(1, 1, 1, 0, 0) << 3, FC(1, 1, 1, 0, 1) << 3, FC(1, 1, 1, 1, 0) << 3, FC(1, 1, 1, 1, 1) << 3
};
/* Filter Output Macros */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,26 @@
/*
* IClass.c
*
* Created on: 17-05-2020
* Author: NVX
*/
#ifndef ICLASS_H_
#define ICLASS_H_
#include "Application.h"
#define ICLASS_BLOCK_SIZE 8
#define ICLASS_CSN_SIZE ICLASS_BLOCK_SIZE
#define ICLASS_BLOCK_NUM 32
#define ICLASS_MEM_SIZE ( ICLASS_BLOCK_SIZE * ICLASS_BLOCK_NUM )
#define ICLASS_READ4_SIZE ( ICLASS_BLOCK_SIZE * 4 )
void IClassAppInit(void);
void IClassAppReset(void);
void IClassDetectionInit(void);
uint16_t IClassAppProcess(uint8_t *FrameBuf, uint16_t FrameBytes);
void IClassGetCsn(ConfigurationUidType Uid);
void IClassSetCsn(const ConfigurationUidType Uid);
#endif /* ICLASS_H_ */
@@ -133,7 +133,7 @@ bool ISO14443AWakeUp(void *Buffer, uint16_t *BitCount, uint16_t ATQAValue, bool
return true;
} else {
*BitCount = 0;
// *BitCount = 0;
return false;
}
File diff suppressed because it is too large. Load diff
@@ -16,6 +16,13 @@
#define MIFARE_CLASSIC_1K_MEM_SIZE 1024
#define MIFARE_CLASSIC_4K_MEM_SIZE 4096
extern bool DetectionMode;
void DetectionLogToFlash(uint8_t Entry, const void *Data, uint8_t Length);
void DetectionInit(void);
void DetectionLogClear(void);
void MifareDetectionInit1K(void);
void MifareDetectionInit4K(void);
void MifareClassicAppInitMini4B(void);
void MifareClassicAppInit1K(void);
void MifareClassicAppInit4K(void);
@@ -29,5 +36,9 @@ uint16_t MifareClassicAppProcess(uint8_t *Buffer, uint16_t BitCount);
void MifareClassicGetUid(ConfigurationUidType Uid);
void MifareClassicSetUid(ConfigurationUidType Uid);
void MifareClassicGetAtqa(uint16_t * Atqa);
void MifareClassicSetAtqa(uint16_t Atqa);
void MifareClassicGetSak(uint8_t * Sak);
void MifareClassicSetSak(uint8_t Sak);
#endif /* MIFARECLASSIC_H_ */
@@ -112,6 +112,8 @@ static uint8_t CompatWritePageAddress;
static bool Authenticated;
static uint8_t FirstAuthenticatedPage;
static bool ReadAccessProtected;
static uint16_t CardATQAValue;
static uint8_t CardSAKValue;
static uint8_t RNDBBuff [8];
static uint8_t InitialVector[8] = {0};
static uint8_t TripleDesKey [16];
@@ -153,6 +155,8 @@ static void AppInitCommon(void) {
FromHalt = false;
Authenticated = false;
ArmedForCompatWrite = false;
CardATQAValue = ATQA_VALUE;
CardSAKValue = SAK_CL1_VALUE;
}
void MifareUltralightCAppInit(void) {
Flavor = UL_C;
@@ -285,7 +289,7 @@ static uint16_t AppProcess(uint8_t *const Buffer, uint16_t ByteCount) {
//Handle MF ULC counter
if (CompatWritePageAddress == MF_ULC_COUNTER_ADDRESS && Flavor == UL_C) {
if (IncrementCounter(&Buffer[2])) {
if (IncrementCounter(&Buffer[0])) {
Buffer[0] = ACK_VALUE;
return ACK_FRAME_SIZE;
} else {
@@ -294,7 +298,7 @@ static uint16_t AppProcess(uint8_t *const Buffer, uint16_t ByteCount) {
}
}
AppWritePage(CompatWritePageAddress, &Buffer[2]);
AppWritePage(CompatWritePageAddress, &Buffer[0]);
Buffer[0] = ACK_VALUE;
return ACK_FRAME_SIZE;
}
@@ -673,3 +677,22 @@ void MifareUltralightSetUid(ConfigurationUidType Uid) {
MemoryWriteBlock(&BCC2, UID_BCC2_ADDRESS, ISO14443A_CL_BCC_SIZE);
}
void MifareUltralightGetAtqa(uint16_t * Atqa)
{
*Atqa = CardATQAValue;
}
void MifareUltralightSetAtqa(uint16_t Atqa)
{
CardATQAValue = Atqa;
}
void MifareUltralightGetSak(uint8_t * Sak)
{
*Sak = CardSAKValue;
}
void MifareUltralightSetSak(uint8_t Sak)
{
CardSAKValue = Sak;
}
@@ -39,6 +39,9 @@ uint16_t MifareUltralightAppProcess(uint8_t *Buffer, uint16_t BitCount);
void MifareUltralightGetUid(ConfigurationUidType Uid);
void MifareUltralightSetUid(ConfigurationUidType Uid);
void MifareUltralightGetAtqa(uint16_t * Atqa);
void MifareUltralightSetAtqa(uint16_t Atqa);
void MifareUltralightGetSak(uint8_t * Sak);
void MifareUltralightSetSak(uint8_t Sak);
#endif /* MIFAREULTRALIGHT_H_ */
@@ -0,0 +1,499 @@
/*
* NTAG21x.c
*
* Created on: 20.02.2019
* Author: Giovanni Cammisa (gcammisa)
* Still missing support for:
* - The management of both static and dynamic lock bytes
* - Bruteforce protection (AUTHLIM COUNTER)
* Thanks to skuser for the MifareUltralight code used as a starting point
*/
#include "ISO14443-3A.h"
#include "../Codec/ISO14443-2A.h"
#include "../Memory.h"
#include "NTAG21x.h"
// DEFINE ATQA and SAK
#define ATQA_VALUE 0x0044
#define SAK_VALUE 0x00
#define SAK_CL1_VALUE ISO14443A_SAK_INCOMPLETE
#define SAK_CL2_VALUE ISO14443A_SAK_COMPLETE_NOT_COMPLIANT
// ACK and NACK
#define ACK_VALUE 0x0A
#define ACK_FRAME_SIZE 4 /* Bits */
#define NAK_INVALID_ARG 0x00
#define NAK_CRC_ERROR 0x01
#define NAK_NOT_AUTHED 0x04
#define NAK_EEPROM_ERROR 0x05
#define NAK_FRAME_SIZE 4
// DEFINING COMMANDS
/* ISO commands */
#define CMD_HALT 0x50
// NTAG COMMANDS
#define CMD_GET_VERSION 0x60
#define CMD_READ 0x30
#define CMD_FAST_READ 0x3A
#define CMD_WRITE 0xA2
#define CMD_COMPAT_WRITE 0xA0
#define CMD_READ_CNT 0x39
#define CMD_PWD_AUTH 0x1B
#define CMD_READ_SIG 0x3C
// MEMORY LAYOUT STUFF, addresses and sizes in bytes
// UID stuff
#define UID_CL1_ADDRESS 0x00
#define UID_CL1_SIZE 3
#define UID_BCC1_ADDRESS 0x03
#define UID_CL2_ADDRESS 0x04
#define UID_CL2_SIZE 4
#define UID_BCC2_ADDRESS 0x08
// LockBytes stuff
#define STATIC_LOCKBYTE_0_ADDRESS 0x0A
#define STATIC_LOCKBYTE_1_ADDRESS 0x0B
// CONFIG stuff
#define NTAG213_CONFIG_AREA_START_ADDRESS NTAG21x_PAGE_SIZE * 0x29
#define NTAG215_CONFIG_AREA_START_ADDRESS NTAG21x_PAGE_SIZE * 0x83
#define NTAG216_CONFIG_AREA_START_ADDRESS NTAG21x_PAGE_SIZE * 0xE3
#define CONFIG_AREA_SIZE 8
// CONFIG offsets, relative to config start address
#define CONF_AUTH0_OFFSET 0x03
#define CONF_ACCESS_OFFSET 0x04
#define CONF_PASSWORD_OFFSET 0x08
#define CONF_PACK_OFFSET 0x0C
// WRITE STUFF
#define BYTES_PER_WRITE 4
#define PAGE_WRITE_MIN 0x02
// CONFIG masks to check individual needed bits
#define CONF_ACCESS_PROT 0x80
#define VERSION_INFO_LENGTH 8 //8 bytes info lenght + crc
#define BYTES_PER_READ NTAG21x_PAGE_SIZE * 4
// SIGNATURE Lenght
#define SIGNATURE_LENGTH 32
static enum {
TYPE_NTAG213,
TYPE_NTAG215,
TYPE_NTAG216
} Ntag_Type;
static enum {
STATE_HALT,
STATE_IDLE,
STATE_READY1,
STATE_READY2,
STATE_ACTIVE
} State;
static uint32_t ConfigStartAddr = NTAG213_CONFIG_AREA_START_ADDRESS;
static bool FromHalt = false;
static uint8_t PageCount;
static bool ArmedForCompatWrite;
static uint8_t CompatWritePageAddress;
static bool Authenticated;
static uint8_t FirstAuthenticatedPage;
static bool ReadAccessProtected;
static uint8_t Access;
void NTAG21xAppInit(void)
{
State = STATE_IDLE;
FromHalt = false;
ArmedForCompatWrite = false;
Authenticated = false;
//PageCount = NTAG215_PAGES;
switch (Ntag_Type)
{
case TYPE_NTAG213:
PageCount = NTAG213_PAGES;
break;
case TYPE_NTAG215:
PageCount = NTAG215_PAGES;
break;
case TYPE_NTAG216:
PageCount = NTAG216_PAGES;
break;
}
/* Fetch some of the configuration into RAM */
MemoryReadBlock(&FirstAuthenticatedPage, ConfigStartAddr + CONF_AUTH0_OFFSET, 1);
MemoryReadBlock(&Access, ConfigStartAddr + CONF_ACCESS_OFFSET, 1);
ReadAccessProtected = !!(Access & CONF_ACCESS_PROT);
}
#if defined(CONFIG_NTAG213_SUPPORT)
void NTAG213AppInit(void)
{
Ntag_Type = TYPE_NTAG213;
PageCount = NTAG213_PAGES;
ConfigStartAddr = NTAG213_CONFIG_AREA_START_ADDRESS;
NTAG21xAppInit();
}
#endif // CONIFG_NTAG213_SUPPORT
#ifdef CONFIG_NTAG215_SUPPORT
void NTAG215AppInit(void)
{
Ntag_Type = TYPE_NTAG215;
PageCount = NTAG215_PAGES;
ConfigStartAddr = NTAG215_CONFIG_AREA_START_ADDRESS;
NTAG21xAppInit();
}
#endif // CONFIG_NTAG215_SUPPORT
#ifdef CONFIG_NTAG216_SUPPORT
void NTAG216AppInit(void)
{
Ntag_Type = TYPE_NTAG216;
PageCount = NTAG216_PAGES;
ConfigStartAddr = NTAG216_CONFIG_AREA_START_ADDRESS;
NTAG21xAppInit();
}
#endif // CONFIG_NTAG216_SUPPORT
void NTAG21xAppReset(void)
{
State = STATE_IDLE;
}
void NTAG21xAppTask(void)
{
}
// Verify authentication
static bool VerifyAuthentication(uint8_t PageAddress)
{
/* If authenticated, no verification needed */
if (Authenticated) {
return true;
}
/* Otherwise, verify the accessed page is below the limit */
return PageAddress < FirstAuthenticatedPage;
}
// Writes a page
static uint8_t AppWritePage(uint8_t PageAddress, uint8_t* const Buffer)
{
if (!ActiveConfiguration.ReadOnly) {
MemoryWriteBlock(Buffer, PageAddress * NTAG21x_PAGE_SIZE, NTAG21x_PAGE_SIZE);
} else {
/* If the chameleon is in read only mode, it silently
* ignores any attempt to write data. */
}
return 0;
}
// Basic sketch of the command handling stuff
static uint16_t AppProcess(uint8_t* const Buffer, uint16_t ByteCount)
{
uint8_t Cmd = Buffer[0];
/* Handle the compatibility write command */
if (ArmedForCompatWrite) {
ArmedForCompatWrite = false;
AppWritePage(CompatWritePageAddress, &Buffer[2]);
Buffer[0] = ACK_VALUE;
return ACK_FRAME_SIZE;
}
switch (Cmd) {
case CMD_GET_VERSION: {
/* Provide hardcoded version response */ //VERSION RESPONSE FOR NTAG 215
Buffer[0] = 0x00;
Buffer[1] = 0x04;
Buffer[2] = 0x04;
Buffer[3] = 0x02;
Buffer[4] = 0x01;
Buffer[5] = 0x00;
switch (Ntag_Type) {
case TYPE_NTAG213:
Buffer[6] = 0x0F;
break;
case TYPE_NTAG215:
Buffer[6] = 0x11;
break;
case TYPE_NTAG216:
Buffer[6] = 0x13;
break;
}
Buffer[7] = 0x03;
ISO14443AAppendCRCA(Buffer, VERSION_INFO_LENGTH);
return (VERSION_INFO_LENGTH + ISO14443A_CRCA_SIZE) * 8;
}
case CMD_READ: {
uint8_t PageAddress = Buffer[1];
uint8_t PageLimit;
uint8_t Offset;
PageLimit = PageCount;
/* if protected and not autenticated, ensure the wraparound is at the first protected page */
if (ReadAccessProtected && !Authenticated) {
PageLimit = FirstAuthenticatedPage;
}
else {
PageLimit = PageCount;
}
/* Validation */
if (PageAddress >= PageLimit) {
Buffer[0] = NAK_INVALID_ARG;
return NAK_FRAME_SIZE;
}
/* Read out, emulating the wraparound */
for (Offset = 0; Offset < BYTES_PER_READ; Offset += 4) {
MemoryReadBlock(&Buffer[Offset], PageAddress * NTAG21x_PAGE_SIZE, NTAG21x_PAGE_SIZE);
PageAddress++;
if (PageAddress == PageLimit) { // if arrived ad the last page, start reading from page 0
PageAddress = 0;
}
}
ISO14443AAppendCRCA(Buffer, BYTES_PER_READ);
return (BYTES_PER_READ + ISO14443A_CRCA_SIZE) * 8;
}
case CMD_FAST_READ: {
uint8_t StartPageAddress = Buffer[1];
uint8_t EndPageAddress = Buffer[2];
/* Validation */
if ((StartPageAddress > EndPageAddress) || (StartPageAddress >= PageCount) || (EndPageAddress >= PageCount)) {
Buffer[0] = NAK_INVALID_ARG;
return NAK_FRAME_SIZE;
}
/* Check authentication only if protection is read&write (instead of only write protection) */
if (ReadAccessProtected) {
if (!VerifyAuthentication(StartPageAddress) || !VerifyAuthentication(EndPageAddress)) {
Buffer[0] = NAK_NOT_AUTHED;
return NAK_FRAME_SIZE;
}
}
ByteCount = (EndPageAddress - StartPageAddress + 1) * NTAG21x_PAGE_SIZE;
MemoryReadBlock(Buffer, StartPageAddress * NTAG21x_PAGE_SIZE, ByteCount);
ISO14443AAppendCRCA(Buffer, ByteCount);
return (ByteCount + ISO14443A_CRCA_SIZE) * 8;
}
case CMD_PWD_AUTH: {
uint8_t Password[4];
/* For now I don't care about bruteforce protection, so: */
/* TODO: IMPLEMENT COUNTER AUTHLIM */
/* Read and compare the password */
MemoryReadBlock(Password, ConfigStartAddr + CONF_PASSWORD_OFFSET, 4);
if (Password[0] != Buffer[1] || Password[1] != Buffer[2] || Password[2] != Buffer[3] || Password[3] != Buffer[4]) {
Buffer[0] = NAK_NOT_AUTHED;
return NAK_FRAME_SIZE;
}
/* Authenticate the user */
//RESET AUTHLIM COUNTER, CURRENTLY NOT IMPLEMENTED
Authenticated = 1;
/* Send the PACK value back */
MemoryReadBlock(Buffer, ConfigStartAddr + CONF_PACK_OFFSET, 2);
ISO14443AAppendCRCA(Buffer, 2);
return (2 + ISO14443A_CRCA_SIZE) * 8;
}
case CMD_WRITE: {
/* This is a write command containing 4 bytes of data that
* should be written to the given page address. */
uint8_t PageAddress = Buffer[1];
/* Validation */
if ((PageAddress < PAGE_WRITE_MIN) || (PageAddress >= PageCount)) {
Buffer[0] = NAK_INVALID_ARG;
return NAK_FRAME_SIZE;
}
if (!VerifyAuthentication(PageAddress)) {
Buffer[0] = NAK_NOT_AUTHED;
return NAK_FRAME_SIZE;
}
AppWritePage(PageAddress, &Buffer[2]);
Buffer[0] = ACK_VALUE;
return ACK_FRAME_SIZE;
}
case CMD_COMPAT_WRITE: {
uint8_t PageAddress = Buffer[1];
/* Validation */
if ((PageAddress < PAGE_WRITE_MIN) || (PageAddress >= PageCount)) {
Buffer[0] = NAK_INVALID_ARG;
return NAK_FRAME_SIZE;
}
if (!VerifyAuthentication(PageAddress)) {
Buffer[0] = NAK_NOT_AUTHED;
return NAK_FRAME_SIZE;
}
/* CRC check passed and page-address is within bounds.
* Store address and proceed to receiving the data. */
CompatWritePageAddress = PageAddress;
ArmedForCompatWrite = true; //TODO:IMPLEMENT ARMED COMPAT WRITE
Buffer[0] = ACK_VALUE;
return ACK_FRAME_SIZE;
}
case CMD_READ_SIG: {
/* Hardcoded response */
memset(Buffer, 0xCA, SIGNATURE_LENGTH);
ISO14443AAppendCRCA(Buffer, SIGNATURE_LENGTH);
return (SIGNATURE_LENGTH + ISO14443A_CRCA_SIZE) * 8;
}
//PART OF ISO STANDARD, NOT OF NTAG DATASHEET
case CMD_HALT: {
/* Halts the tag. According to the ISO14443, the second
* byte is supposed to be 0. */
if (Buffer[1] == 0) {
/* According to ISO14443, we must not send anything
* in order to acknowledge the HALT command. */
State = STATE_HALT;
return ISO14443A_APP_NO_RESPONSE;
} else {
Buffer[0] = NAK_INVALID_ARG;
return NAK_FRAME_SIZE;
}
}
default: {
break;
}
}
/* Command not handled. Switch to idle. */
State = STATE_IDLE;
return ISO14443A_APP_NO_RESPONSE;
}
// FINITE STATE MACHINE STUFF, SHOULD BE THE VERY SIMILAR TO Mifare Ultralight
uint16_t NTAG21xAppProcess(uint8_t* Buffer, uint16_t BitCount)
{
uint8_t Cmd = Buffer[0];
uint16_t ByteCount;
switch(State) {
case STATE_IDLE:
case STATE_HALT:
FromHalt = State == STATE_HALT;
if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE, FromHalt)) {
/* We received a REQA or WUPA command, so wake up. */
State = STATE_READY1;
return BitCount;
}
break;
case STATE_READY1:
if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE, FromHalt)) {
State = FromHalt ? STATE_HALT : STATE_IDLE;
return ISO14443A_APP_NO_RESPONSE;
} else if (Cmd == ISO14443A_CMD_SELECT_CL1) {
/* Load UID CL1 and perform anticollision. Since
* MF Ultralight use a double-sized UID, the first byte
* of CL1 has to be the cascade-tag byte. */
uint8_t UidCL1[ISO14443A_CL_UID_SIZE] = { [0] = ISO14443A_UID0_CT };
MemoryReadBlock(&UidCL1[1], UID_CL1_ADDRESS, UID_CL1_SIZE);
if (ISO14443ASelect(Buffer, &BitCount, UidCL1, SAK_CL1_VALUE)) {
/* CL1 stage has ended successfully */
State = STATE_READY2;
}
return BitCount;
} else {
/* Unknown command. Enter halt state */
State = STATE_IDLE;
}
break;
case STATE_READY2:
if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE, FromHalt)) {
State = FromHalt ? STATE_HALT : STATE_IDLE;
return ISO14443A_APP_NO_RESPONSE;
} else if (Cmd == ISO14443A_CMD_SELECT_CL2) {
/* Load UID CL2 and perform anticollision */
uint8_t UidCL2[ISO14443A_CL_UID_SIZE];
MemoryReadBlock(UidCL2, UID_CL2_ADDRESS, UID_CL2_SIZE);
if (ISO14443ASelect(Buffer, &BitCount, UidCL2, SAK_CL2_VALUE)) {
/* CL2 stage has ended successfully. This means
* our complete UID has been sent to the reader. */
State = STATE_ACTIVE;
}
return BitCount;
} else {
/* Unknown command. Enter halt state */
State = STATE_IDLE;
}
break;
// Only ACTIVE state, no AUTHENTICATED state, PWD_AUTH is handled in commands.
case STATE_ACTIVE:
/* Preserve incoming data length */
ByteCount = (BitCount + 7) >> 3;
if (ISO14443AWakeUp(Buffer, &BitCount, ATQA_VALUE, FromHalt)) {
State = FromHalt ? STATE_HALT : STATE_IDLE;
return ISO14443A_APP_NO_RESPONSE;
}
/* At the very least, there should be 3 bytes in the buffer. */
if (ByteCount < (1 + ISO14443A_CRCA_SIZE)) {
State = STATE_IDLE;
return ISO14443A_APP_NO_RESPONSE;
}
/* All commands here have CRCA appended; verify it right away */
ByteCount -= 2;
if (!ISO14443ACheckCRCA(Buffer, ByteCount)) {
Buffer[0] = NAK_CRC_ERROR;
return NAK_FRAME_SIZE;
}
return AppProcess(Buffer, ByteCount);
default:
/* Unknown state? Should never happen. */
break;
}
/* No response has been sent, when we reach here */
return ISO14443A_APP_NO_RESPONSE;
}
// HELPER FUNCTIONS
void NTAG21xGetUid(ConfigurationUidType Uid)
{
/* Read UID from memory */
MemoryReadBlock(&Uid[0], UID_CL1_ADDRESS, UID_CL1_SIZE);
MemoryReadBlock(&Uid[UID_CL1_SIZE], UID_CL2_ADDRESS, UID_CL2_SIZE);
}
void NTAG21xSetUid(ConfigurationUidType Uid)
{
/* Calculate check bytes and write everything into memory */
uint8_t BCC1 = ISO14443A_UID0_CT ^ Uid[0] ^ Uid[1] ^ Uid[2];
uint8_t BCC2 = Uid[3] ^ Uid[4] ^ Uid[5] ^ Uid[6];
MemoryWriteBlock(&Uid[0], UID_CL1_ADDRESS, UID_CL1_SIZE);
MemoryWriteBlock(&BCC1, UID_BCC1_ADDRESS, ISO14443A_CL_BCC_SIZE);
MemoryWriteBlock(&Uid[UID_CL1_SIZE], UID_CL2_ADDRESS, UID_CL2_SIZE);
MemoryWriteBlock(&BCC2, UID_BCC2_ADDRESS, ISO14443A_CL_BCC_SIZE);
}
@@ -0,0 +1,34 @@
/*
* NTAG21x.h
*
* Created on: 20.02.2019
* Author: gcammisa
*/
#ifndef NTAG21x_H_
#define NTAG21x_H_
#include "Application.h"
#include "ISO14443-3A.h"
#define NTAG21x_UID_SIZE ISO14443A_UID_SIZE_DOUBLE // 7 bytes UID
#define NTAG21x_PAGE_SIZE 4 // bytes per page
#define NTAG213_PAGES 45 //45 pages total for ntag213, from 0 to 44
#define NTAG215_PAGES 135 //135 pages total for ntag215, from 0 to 134
#define NTAG216_PAGES 231 //231 pages total for ntag216, from 0 to 230
#define NTAG213_MEM_SIZE ( NTAG21x_PAGE_SIZE * NTAG213_PAGES )
#define NTAG215_MEM_SIZE ( NTAG21x_PAGE_SIZE * NTAG215_PAGES )
#define NTAG216_MEM_SIZE ( NTAG21x_PAGE_SIZE * NTAG216_PAGES )
void NTAG213AppInit(void);
void NTAG215AppInit(void);
void NTAG216AppInit(void);
void NTAG21xAppReset(void);
void NTAG21xAppTask(void);
uint16_t NTAG21xAppProcess(uint8_t* Buffer, uint16_t BitCount);
void NTAG21xGetUid(ConfigurationUidType Uid);
void NTAG21xSetUid(ConfigurationUidType Uid);
#endif
@@ -4,6 +4,7 @@
#include "../Codec/Reader14443-2A.h"
#include "Crypto1.h"
#include "../System.h"
#include "../uartcmd.h"
#include "../Terminal/Terminal.h"
@@ -141,8 +142,8 @@ uint16_t addParityBits(uint8_t *Buffer, uint16_t BitCount) {
uint16_t removeParityBits(uint8_t *Buffer, uint16_t BitCount) {
// Short frame, no parity bit is added
if (BitCount == 7)
return 7;
if (BitCount <= 7)
return BitCount;
uint16_t i;
for (i = 0; i < (BitCount / 9); i++) {
@@ -150,7 +151,7 @@ uint16_t removeParityBits(uint8_t *Buffer, uint16_t BitCount) {
if (i % 8)
Buffer[i] |= (Buffer[i + i / 8 + 1] << (8 - (i % 8)));
}
return BitCount / 9 * 8;
return (BitCount / 9) * 8;
}
bool checkParityBits(uint8_t *Buffer, uint16_t BitCount) {
@@ -229,7 +230,7 @@ static uint16_t Reader14443A_Select(uint8_t *Buffer, uint16_t BitCount) {
switch (ReaderState) {
case STATE_IDLE:
case STATE_HALT:
Reader_FWT = 4;
Reader_FWT = ISO14443A_RX_PENDING_TIMEOUT;
/* Send a REQA */
Buffer[0] = ISO14443A_CMD_WUPA; // whenever REQA works, WUPA also works, so we choose WUPA always
ReaderState = STATE_READY;
@@ -817,9 +818,7 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
int cfgid = -1;
switch (CardCandidates[0]) {
case CardType_NXP_MIFARE_Ultralight: {
#ifdef CONFIG_MF_ULTRALIGHT_SUPPORT
cfgid = CONFIG_MF_ULTRALIGHT;
#endif
// TODO: enter MFU clone mdoe
break;
}
@@ -829,8 +828,8 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
#ifdef CONFIG_MF_CLASSIC_1K_SUPPORT
cfgid = CONFIG_MF_CLASSIC_1K;
#endif
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
#ifdef CONFIG_MF_CLASSIC_1K_7B_SUPPORT
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
cfgid = CONFIG_MF_CLASSIC_1K_7B;
#endif
}
@@ -843,8 +842,8 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
#ifdef CONFIG_MF_CLASSIC_4K_SUPPORT
cfgid = CONFIG_MF_CLASSIC_4K;
#endif
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
#ifdef CONFIG_MF_CLASSIC_4K_7B_SUPPORT
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
cfgid = CONFIG_MF_CLASSIC_4K_7B;
#endif
}
@@ -11,7 +11,6 @@
extern bool checkParityBits(uint8_t *Buffer, uint16_t BitCount);
Sniff14443Command Sniff14443CurrentCommand = Sniff14443_Do_Nothing;
//bool selected = false;
static enum {
STATE_IDLE,
STATE_REQA,
@@ -23,8 +22,7 @@ static enum {
} SniffState = STATE_IDLE;
static uint16_t tmp_th = CODEC_THRESHOLD_CALIBRATE_MIN;
static uint8_t Thresholds[(CODEC_THRESHOLD_CALIBRATE_MAX - CODEC_THRESHOLD_CALIBRATE_MIN) /
CODEC_THRESHOLD_CALIBRATE_STEPS] = {0};
static uint8_t Thresholds[(CODEC_THRESHOLD_CALIBRATE_MAX - CODEC_THRESHOLD_CALIBRATE_MIN) / CODEC_THRESHOLD_CALIBRATE_STEPS] = {0};
void Sniff14443AAppInit(void) {
SniffState = STATE_REQA;
@@ -69,7 +67,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
case STATE_REQA:
LED_PORT.OUTCLR = LED_RED;
// If received Reader REQA or WUPA
if (TrafficSource == TRAFFIC_READER &&
if (SniffTrafficSource == TRAFFIC_READER &&
(Buffer[0] == 0x26 || Buffer[0] == 0x52)) {
SniffState = STATE_ATQA;
} else {
@@ -78,7 +76,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
break;
case STATE_ATQA:
// ATQA: P RRRR XXXX P XXRX XXXX
if (TrafficSource == TRAFFIC_CARD &&
if (SniffTrafficSource == TRAFFIC_CARD &&
BitCount == 2 * 9 &&
(Buffer[0] & 0x20) == 0x00 && // Bit6 RFU shall be 0
(Buffer[1] & 0xE0) == 0x00 && // bit13-16 RFU shall be 0
@@ -89,7 +87,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
} else {
// If not ATQA, but REQA, then stay on this state,
// Reset to REQA, save the counter and reset the counter
if (TrafficSource == TRAFFIC_READER &&
if (SniffTrafficSource == TRAFFIC_READER &&
(Buffer[0] == 0x26 || Buffer[0] == 0x52)) {
} else {
// If not ATQA and not REQA then reset to REQA
@@ -99,7 +97,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
break;
case STATE_ANTICOLLI:
// SEL: 93/95/97
if (TrafficSource == TRAFFIC_READER &&
if (SniffTrafficSource == TRAFFIC_READER &&
BitCount == 2 * 8 &&
(Buffer[0] & 0xf0) == 0x90 &&
(Buffer[0] & 0x09) == 0x01) {
@@ -110,7 +108,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
}
break;
case STATE_UID:
if (TrafficSource == TRAFFIC_CARD &&
if (SniffTrafficSource == TRAFFIC_CARD &&
BitCount == 5 * 9 &&
checkParityBits(Buffer, BitCount)) {
SniffState = STATE_SELECT;
@@ -121,7 +119,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
case STATE_SELECT:
// SELECT: 9 bytes, SEL = 93/95/97, NVB=70
if (TrafficSource == TRAFFIC_READER &&
if (SniffTrafficSource == TRAFFIC_READER &&
BitCount == 9 * 8 &&
(Buffer[0] & 0xf0) == 0x90 &&
(Buffer[0] & 0x09) == 0x01 &&
@@ -134,7 +132,7 @@ uint16_t Sniff14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
break;
case STATE_SAK:
// SAK: 1Byte SAK + CRC
if (TrafficSource == TRAFFIC_CARD &&
if (SniffTrafficSource == TRAFFIC_CARD &&
BitCount == 3 * 9 &&
checkParityBits(Buffer, BitCount)) {
if ((Buffer[0] & 0x04) == 0x00) {
@@ -0,0 +1,38 @@
/*
* SniffISO15693.h
*
* Created on: 05.11.2019
* Author: ceres-c
*/
#ifdef CONFIG_ISO15693_SNIFF_SUPPORT
#include "../Codec/SniffISO15693.h"
#include "Sniff15693.h"
void SniffISO15693AppInit(void)
{
}
void SniffISO15693AppReset(void)
{
}
void SniffISO15693AppTask(void)
{
}
void SniffISO15693AppTick(void)
{
}
uint16_t SniffISO15693AppProcess(uint8_t* FrameBuf, uint16_t FrameBytes)
{
return 0;
}
#endif /* CONFIG_ISO15693_SNIFF_SUPPORT */
Loaded 20 of 68 files, more files were not shown because too many files have changed in this diff. Show more