Skip to content

Commit e275160

Browse files
authored
Merge pull request #3004 from henrygab/id48_update_202510
Update id48lib
2 parents bf0330d + 563abf6 commit e275160

33 files changed

+2284
-75
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ Makefile.platform.*
4545

4646
# cmake
4747
CMakeFiles/
48-
deps/
4948
client/CMakeFiles/
50-
client/deps/
49+
client/deps/**
50+
!client/deps/id48/
51+
!client/deps/id48/**
5152
client/build/
5253
client/android/build/
5354
CMakeCache.txt
5455
*.cmake
56+
.cache
5557

5658
# Coverity
5759
cov-int/

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
33
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
44

55
## [unreleased][unreleased]
6+
- Updated id48lib (adds unit tests, better build management)
67
- Added two trace files for Ultralight AES (@iceman1001)
78
- Added support for Ultralight AES secure messaing in `hf 14a raw` (@iceman1001)
89
- Added support for Ultralight AES secure messaging in `hf mfu info/rdbl/wrbl/dump/ndefread/wipe/setkey` (@iceman1001)

Makefile.host

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ endif
2626
ifeq ($(DEFSBEENHERE),)
2727
-include ../../../Makefile.defs
2828
endif
29+
ifeq ($(DEFSBEENHERE),)
30+
-include ../../../../Makefile.defs
31+
endif
2932
ifeq ($(DEFSBEENHERE),)
3033
$(error Can't find Makefile.defs)
3134
endif

client/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
7474
HARDNESTEDLIBLD =
7575

7676
## ID48
77-
ID48LIBPATH = ./deps/id48
78-
ID48LIBINC = -I$(ID48LIBPATH)
77+
## must be manually kept in sync with updates to deps/id48/CMakeLists.txt
78+
ID48LIBPATH = ./deps/id48/src
79+
ID48LIBINC = -I$(ID48LIBPATH)/../public
7980
ID48LIB = $(ID48LIBPATH)/libid48.a
8081
ID48LIBLD =
8182

client/deps/id48/.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Now ignore any "build" directory anywhere under this directory
2+
build/
3+
**/build/
4+
5+
*.log
6+
*.eml
7+
*.html
8+
*.o
9+
*.a
10+
*.d
11+
*.elf
12+
*.s19
13+
*.map
14+
*.bin
15+
*.dll
16+
*.moc.cpp
17+
*.z
18+
*.gz
19+
*.Td
20+
*.DS_Store
21+
*.exe
22+
*.dsym
23+
*.json
24+
*.old
25+
*.swp
26+
*.json.bak
27+
*.pyc
28+
*.bmp
29+
30+
31+
# cmake
32+
CMakeFiles/
33+
client/CMakeFiles/
34+
client/deps/**
35+
!client/deps/id48/
36+
!client/deps/id48/**
37+
client/build/
38+
client/android/build/
39+
CMakeCache.txt
40+
*.cmake
41+
.cache
42+
43+
# Coverity
44+
cov-int/
45+
.coverity.conf
46+
47+
# .tmp files are created during compilation
48+
*.tmp
49+
50+
# local codeql
51+
_codeql*
52+
/codeql

client/deps/id48/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
3+
project(id48_project LANGUAGES C CXX ASM)
4+
5+
# Project-wide language standards (subdirectories inherit if not overridden)
6+
set(CMAKE_C_STANDARD 11)
7+
set(CMAKE_C_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_STANDARD 14)
9+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
10+
11+
add_subdirectory(src)
12+
add_subdirectory(tests)
13+

client/deps/id48/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,25 @@ provided the first half of the key, and at least one successful
4848
authentication trio of nonce, challenge, and response, then
4949
the library can recover all potentially valid values for the
5050
second half of the key.
51+
52+
## Building
53+
54+
This project uses CMake, and thus should be easy to integrate
55+
into any existing project using CMake.
56+
57+
The following commands can be run from the root of this depot,
58+
and places all build artifacts into `./build`:
59+
60+
```bash
61+
# Configure cmake for the current environment
62+
# -S: explicitly specify the source directory
63+
# -B: explicitly specify the directory for build artifacts
64+
cmake -S . -B build
65+
66+
# Optionally (recommended) do a clean build each time
67+
cmake --build ./build --parallel --target clean
68+
69+
# build everything
70+
cmake --build ./build --parallel --target all
71+
```
72+

client/deps/id48/TECHNICAL.md

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -160,63 +160,63 @@ of the key influences a given output bit.
160160
Start state + key bit --> output
161161

162162

163-
| Start state | Key bit | Output |
164-
|-------|-------|----------------|
165-
| `s₀₀` | `K₃₉` | << hidden >> |
166-
| `s₀₁` | `K₃₈` | << hidden >> |
167-
| `s₀₂` | `K₃₇` | << hidden >> |
168-
| `s₀₃` | `K₃₆` | << hidden >> |
169-
| `s₀₄` | `K₃₅` | << hidden >> |
170-
| `s₀₅` | `K₃₄` | << hidden >> |
171-
| `s₀₆` | `K₃₃` | << hidden >> |
172-
| `s₀₇` | `K₃₂` | `O₀₀ == frn₀₀` |
173-
| `s₀₈` | `K₃₁` | `O₀₁ == frn₀₁` |
174-
| `s₀₉` | `K₃₀` | `O₀₂ == frn₀₂` |
175-
| `s₁₀` | `K₂₉` | `O₀₃ == frn₀₃` |
176-
| `s₁₁` | `K₂₈` | `O₀₄ == frn₀₄` |
177-
| `s₁₂` | `K₂₇` | `O₀₅ == frn₀₅` |
178-
| `s₁₃` | `K₂₆` | `O₀₆ == frn₀₆` |
179-
| `s₁₄` | `K₂₅` | `O₀₇ == frn₀₇` |
180-
| `s₁₅` | `K₂₄` | `O₀₈ == frn₀₈` |
181-
| `s₁₆` | `K₂₃` | `O₀₉ == frn₀₉` |
182-
| `s₁₇` | `K₂₂` | `O₁₀ == frn₁₀` |
183-
| `s₁₈` | `K₂₁` | `O₁₁ == frn₁₁` |
184-
| `s₁₉` | `K₂₀` | `O₁₂ == frn₁₂` |
185-
| `s₂₀` | `K₁₉` | `O₁₃ == frn₁₃` |
186-
| `s₂₁` | `K₁₈` | `O₁₄ == frn₁₄` |
187-
| `s₂₂` | `K₁₇` | `O₁₅ == frn₁₅` |
188-
| `s₂₃` | `K₁₆` | `O₁₆ == frn₁₆` |
189-
| `s₂₄` | `K₁₅` | `O₁₇ == frn₁₇` |
190-
| `s₂₅` | `K₁₄` | `O₁₈ == frn₁₈` |
191-
| `s₂₆` | `K₁₃` | `O₁₉ == frn₁₉` |
192-
| `s₂₇` | `K₁₂` | `O₂₀ == frn₂₀` |
193-
| `s₂₈` | `K₁₁` | `O₂₁ == frn₂₁` |
194-
| `s₂₉` | `K₁₀` | `O₂₂ == frn₂₂` |
195-
| `s₃₀` | `K₀₉` | `O₂₃ == frn₂₃` |
196-
| `s₃₁` | `K₀₈` | `O₂₄ == frn₂₄` |
197-
| `s₃₂` | `K₀₇` | `O₂₅ == frn₂₅` |
198-
| `s₃₃` | `K₀₆` | `O₂₆ == frn₂₆` |
199-
| `s₃₄` | `K₀₅` | `O₂₇ == frn₂₇` |
200-
| `s₃₅` | `K₀₄` | `O₂₈ == grn₀₀` |
201-
| `s₃₆` | `K₀₃` | `O₂₉ == grn₀₁` |
202-
| `s₃₇` | `K₀₂` | `O₃₀ == grn₀₂` |
203-
| `s₃₈` | `K₀₁` | `O₃₁ == grn₀₃` |
204-
| `s₃₉` | `K₀₀` | `O₃₂ == grn₀₄` |
205-
| `s₄₀` | `0₁₄` | `O₃₃ == grn₀₅` |
206-
| `s₄₁` | `0₁₃` | `O₃₄ == grn₀₆` |
207-
| `s₄₂` | `0₁₂` | `O₃₅ == grn₀₇` |
208-
| `s₄₃` | `0₁₁` | `O₃₆ == grn₀₈` |
209-
| `s₄₄` | `0₁₀` | `O₃₇ == grn₀₉` |
210-
| `s₄₅` | `0₀₉` | `O₃₈ == grn₁₀` |
211-
| `s₄₆` | `0₀₈` | `O₃₉ == grn₁₁` |
212-
| `s₄₇` | `0₀₇` | `O₄₀ == grn₁₂` |
213-
| `s₄₈` | `0₀₆` | `O₄₁ == grn₁₃` |
214-
| `s₄₉` | `0₀₅` | `O₄₂ == grn₁₄` |
215-
| `s₅₀` | `0₀₄` | `O₄₃ == grn₁₅` |
216-
| `s₅₁` | `0₀₃` | `O₄₄ == grn₁₆` |
217-
| `s₅₂` | `0₀₂` | `O₄₅ == grn₁₇` |
218-
| `s₅₃` | `0₀₁` | `O₄₆ == grn₁₈` |
219-
| `s₅₄` | `0₀₀` | `O₄₇ == grn₁₉` |
163+
| Start state | Key bit | Output | Notes |
164+
|-------|-------|----------------|-------|
165+
| `s₀₀` | `K₃₉` | << hidden >> | Seven ... |
166+
| `s₀₁` | `K₃₈` | << hidden >> | .. iterations ... |
167+
| `s₀₂` | `K₃₇` | << hidden >> | .. before ... |
168+
| `s₀₃` | `K₃₆` | << hidden >> | .. any ... |
169+
| `s₀₄` | `K₃₅` | << hidden >> | .. output ... |
170+
| `s₀₅` | `K₃₄` | << hidden >> | .. bits ... |
171+
| `s₀₆` | `K₃₃` | << hidden >> | .. seen. |
172+
| `s₀₇` | `K₃₂` | `O₀₀ == frn₀₀` | |
173+
| `s₀₈` | `K₃₁` | `O₀₁ == frn₀₁` | |
174+
| `s₀₉` | `K₃₀` | `O₀₂ == frn₀₂` | |
175+
| `s₁₀` | `K₂₉` | `O₀₃ == frn₀₃` | |
176+
| `s₁₁` | `K₂₈` | `O₀₄ == frn₀₄` | |
177+
| `s₁₂` | `K₂₇` | `O₀₅ == frn₀₅` | |
178+
| `s₁₃` | `K₂₆` | `O₀₆ == frn₀₆` | |
179+
| `s₁₄` | `K₂₅` | `O₀₇ == frn₀₇` | |
180+
| `s₁₅` | `K₂₄` | `O₀₈ == frn₀₈` | |
181+
| `s₁₆` | `K₂₃` | `O₀₉ == frn₀₉` | |
182+
| `s₁₇` | `K₂₂` | `O₁₀ == frn₁₀` | |
183+
| `s₁₈` | `K₂₁` | `O₁₁ == frn₁₁` | |
184+
| `s₁₉` | `K₂₀` | `O₁₂ == frn₁₂` | |
185+
| `s₂₀` | `K₁₉` | `O₁₃ == frn₁₃` | |
186+
| `s₂₁` | `K₁₈` | `O₁₄ == frn₁₄` | |
187+
| `s₂₂` | `K₁₇` | `O₁₅ == frn₁₅` | |
188+
| `s₂₃` | `K₁₆` | `O₁₆ == frn₁₆` | |
189+
| `s₂₄` | `K₁₅` | `O₁₇ == frn₁₇` | |
190+
| `s₂₅` | `K₁₄` | `O₁₈ == frn₁₈` | |
191+
| `s₂₆` | `K₁₃` | `O₁₉ == frn₁₉` | |
192+
| `s₂₇` | `K₁₂` | `O₂₀ == frn₂₀` | |
193+
| `s₂₈` | `K₁₁` | `O₂₁ == frn₂₁` | |
194+
| `s₂₉` | `K₁₀` | `O₂₂ == frn₂₂` | |
195+
| `s₃₀` | `K₀₉` | `O₂₃ == frn₂₃` | |
196+
| `s₃₁` | `K₀₈` | `O₂₄ == frn₂₄` | |
197+
| `s₃₂` | `K₀₇` | `O₂₅ == frn₂₅` | |
198+
| `s₃₃` | `K₀₆` | `O₂₆ == frn₂₆` | |
199+
| `s₃₄` | `K₀₅` | `O₂₇ == frn₂₇` | Last key bit that affects `frn` |
200+
| `s₃₅` | `K₀₄` | `O₂₈ == grn₀₀` | Five bits of key affect `grn` |
201+
| `s₃₆` | `K₀₃` | `O₂₉ == grn₀₁` | |
202+
| `s₃₇` | `K₀₂` | `O₃₀ == grn₀₂` | |
203+
| `s₃₈` | `K₀₁` | `O₃₁ == grn₀₃` | |
204+
| `s₃₉` | `K₀₀` | `O₃₂ == grn₀₄` | |
205+
| `s₄₀` | `0₁₄` | `O₃₃ == grn₀₅` | Zero-fill start |
206+
| `s₄₁` | `0₁₃` | `O₃₄ == grn₀₆` | |
207+
| `s₄₂` | `0₁₂` | `O₃₅ == grn₀₇` | |
208+
| `s₄₃` | `0₁₁` | `O₃₆ == grn₀₈` | |
209+
| `s₄₄` | `0₁₀` | `O₃₇ == grn₀₉` | |
210+
| `s₄₅` | `0₀₉` | `O₃₈ == grn₁₀` | |
211+
| `s₄₆` | `0₀₈` | `O₃₉ == grn₁₁` | |
212+
| `s₄₇` | `0₀₇` | `O₄₀ == grn₁₂` | |
213+
| `s₄₈` | `0₀₆` | `O₄₁ == grn₁₃` | |
214+
| `s₄₉` | `0₀₅` | `O₄₂ == grn₁₄` | |
215+
| `s₅₀` | `0₀₄` | `O₄₃ == grn₁₅` | |
216+
| `s₅₁` | `0₀₃` | `O₄₄ == grn₁₆` | |
217+
| `s₅₂` | `0₀₂` | `O₄₅ == grn₁₇` | |
218+
| `s₅₃` | `0₀₁` | `O₄₆ == grn₁₈` | |
219+
| `s₅₄` | `0₀₀` | `O₄₇ == grn₁₉` | |
220220

221221

222222

@@ -525,7 +525,7 @@ FPGA logic if desired.
525525

526526
There are sixteen (`16x`) blocks of memory, each storing a 16-bit value.
527527
Blocks may be protected (`P` column) as read-only (`RO`) or write-only (`WO`).
528-
`Lock₀` === Disable writingPermanent write-prevention when set to 1.
528+
`Lock₀` === Disable writing ... (?) write-prevention when set to 1.
529529
`Lock₁` === Pin-code lock
530530

531531
| `Block` | `P` | `Purpose` | Bits (LSB first) | Bits (MSB first) |
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ###################
2+
# Generating .PLA
3+
# ###################
4+
5+
6+
.i 5
7+
.o 1
8+
.ilb a l2 l3 l0 l6
9+
.ob g1
10+
00000 1
11+
00001 1
12+
00010 1
13+
00011 1
14+
00100 0
15+
00101 0
16+
00110 1
17+
00111 0
18+
01000 0
19+
01001 1
20+
01010 0
21+
01011 0
22+
01100 1
23+
01101 0
24+
01110 0
25+
01111 1
26+
10000 1
27+
10001 0
28+
10010 0
29+
10011 0
30+
10100 0
31+
10101 1
32+
10110 0
33+
10111 1
34+
11000 0
35+
11001 0
36+
11010 1
37+
11011 1
38+
11100 1
39+
11101 1
40+
11110 1
41+
11111 0
42+
.e
43+
44+
# ###################
45+
# END OF .PLA
46+
# ###################
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# ###################
2+
# Generating .PLA
3+
# ###################
4+
5+
6+
.i 5
7+
.o 1
8+
.ilb l5 b m0 l4 m1
9+
.ob g2
10+
00000 1
11+
00001 1
12+
00010 1
13+
00011 1
14+
00100 0
15+
00101 0
16+
00110 0
17+
00111 1
18+
01000 0
19+
01001 1
20+
01010 0
21+
01011 0
22+
01100 1
23+
01101 0
24+
01110 1
25+
01111 0
26+
10000 1
27+
10001 0
28+
10010 0
29+
10011 0
30+
10100 0
31+
10101 1
32+
10110 1
33+
10111 0
34+
11000 0
35+
11001 0
36+
11010 1
37+
11011 1
38+
11100 1
39+
11101 1
40+
11110 0
41+
11111 1
42+
.e
43+
44+
# ###################
45+
# END OF .PLA
46+
# ###################

0 commit comments

Comments
 (0)