You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DesfireCrypto is a C++ class that provides cryptographic functionalities for DESFire cards. It includes encryption, decryption, initialization of the Cipher-based Message Authentication Code (CMAC), and other utility functions.
4
+
5
+
## Functions
6
+
7
+
### generateSubkeys
8
+
```cpp
9
+
voidgenerateSubkeys();
10
+
```
11
+
This function generates key0, key1, and key2 for DESFire. It performs the following steps:
12
+
1. Generate key0, key1, and key2.
13
+
2. Encrypt 16 bytes of 0x00 with the key.
14
+
3. Left shift key0 by 1 bit and store it in key1.
15
+
4. If the Most Significant Bit (MSB) of key0 is 0x80, then key1 = (key0 << 1) ^ 0x87.
16
+
5. Left shift key1 by 1 bit and store it in key2.
17
+
6. If the MSB of key1 is 0x80, then key2 = (key1 << 1) ^ 0x87.
18
+
19
+
### setIv
20
+
```cpp
21
+
voidsetIv(const vector<uint8_t> &_iv);
22
+
```
23
+
This function sets the Initialization Vector (IV) for encryption and decryption. The IV is obtained during authentication.
This function encrypts the provided data using AES-128 algorithm. It takes the data, encryption key, and IV as inputs and returns the encrypted data as a vector of bytes.
This function decrypts the provided data using AES-128 algorithm. It takes the data, decryption key, and IV as inputs and returns the decrypted data as a vector of bytes.
This function initializes the Cipher-based Message Authentication Code (CMAC) with the provided key and IV. It is called during the authentication process.
0 commit comments