-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiso14443.go
41 lines (40 loc) · 953 Bytes
/
iso14443.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gonfc
// ISO14443CascadeUID Add cascade tags (0x88) in UID. ISO/IEC 14443-3 (6.4.4 UID contents and cascade levels)
func ISO14443CascadeUID(abtUID []byte, pbtCascadedUID []byte) int {
szUID := len(abtUID)
switch szUID {
case 7:
pbtCascadedUID[0] = 0x88
// memcpy(pbtCascadedUID+1, abtUID, 7)
for i := 0; i < 7; i++ {
pbtCascadedUID[i+1] = abtUID[i]
}
// *pszCascadedUID = 8
// break
return 8
case 10:
pbtCascadedUID[0] = 0x88
// memcpy(pbtCascadedUID+1, abtUID, 3)
for i := 0; i < 3; i++ {
pbtCascadedUID[i+1] = abtUID[i]
}
pbtCascadedUID[4] = 0x88
// memcpy(pbtCascadedUID+5, abtUID+3, 7)
for i := 0; i < 7; i++ {
pbtCascadedUID[i+5] = abtUID[i]
}
// *pszCascadedUID = 12
// break
return 12
case 4:
fallthrough
default:
//memcpy(pbtCascadedUID, abtUID, szUID)
for i := 0; i < szUID; i++ {
pbtCascadedUID[i] = abtUID[i]
}
// *pszCascadedUID = szUID
// break
return szUID
}
}