Skip to content

Commit 29b3bab

Browse files
authored
Merge branch 'dev' into patch-1
2 parents c745cbb + a0d1d3f commit 29b3bab

File tree

5 files changed

+85
-64
lines changed

5 files changed

+85
-64
lines changed

.github/workflows/docs.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ jobs:
5555
fi
5656
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
5757
58-
- name: 'Generate documentation'
59-
uses: mattnotmitt/doxygen-action@edge
60-
env:
61-
DOXY_SRC_ROOT: "${{ github.workspace }}"
62-
DOXY_CONFIG_DIR: "${{ github.workspace }}/documentation/doxygen"
63-
DOXY_OUTPUT_DIR: "${{ github.workspace }}/documentation/doxygen/build"
58+
- name: install-doxygen
59+
uses: AdarshRawat1/Install-Doxygen@v1.0
6460
with:
65-
working-directory: 'documentation/'
66-
doxyfile-path: './doxygen/Doxyfile-awesome.cfg'
61+
version: "1.12.0"
62+
63+
- name: 'Generate documentation'
64+
run: ./fbt doxygen
6765

6866
- name: 'Upload documentation'
6967
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/dev' && needs.check-secret.outputs.s3-valid-config == 'true' }}

applications/main/u2f/u2f.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ static uint16_t u2f_register(U2fData* U2F, uint8_t* buf) {
280280
MCHECK(mbedtls_md_hmac_update(&hmac_ctx, private, sizeof(private)));
281281
MCHECK(mbedtls_md_hmac_update(&hmac_ctx, req->app_id, sizeof(req->app_id)));
282282
MCHECK(mbedtls_md_hmac_finish(&hmac_ctx, handle.hash));
283+
284+
mbedtls_md_free(&hmac_ctx);
283285
}
284286

285287
// Generate public key
@@ -387,6 +389,8 @@ static uint16_t u2f_authenticate(U2fData* U2F, uint8_t* buf) {
387389
MCHECK(mbedtls_md_hmac_update(&hmac_ctx, priv_key, sizeof(priv_key)));
388390
MCHECK(mbedtls_md_hmac_update(&hmac_ctx, req->app_id, sizeof(req->app_id)));
389391
MCHECK(mbedtls_md_hmac_finish(&hmac_ctx, mac_control));
392+
393+
mbedtls_md_free(&hmac_ctx);
390394
}
391395

392396
if(memcmp(req->key_handle.hash, mac_control, sizeof(mac_control)) != 0) {

lib/nfc/protocols/mf_plus/mf_plus_i.c

Lines changed: 71 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -27,65 +27,51 @@ MfPlusError mf_plus_get_type_from_version(
2727

2828
MfPlusError error = MfPlusErrorProtocol;
2929

30-
if(mf_plus_data->version.hw_major == 0x02 || mf_plus_data->version.hw_major == 0x82) {
30+
if(mf_plus_data->version.hw_type == 0x02 || mf_plus_data->version.hw_type == 0x82) {
3131
error = MfPlusErrorNone;
32-
if(iso14443_4a_data->iso14443_3a_data->sak == 0x10) {
33-
// Mifare Plus 2K SL2
34-
mf_plus_data->type = MfPlusTypePlus;
32+
// Mifare Plus EV1/EV2
33+
34+
// Revision
35+
switch(mf_plus_data->version.hw_major) {
36+
case 0x11:
37+
mf_plus_data->type = MfPlusTypeEV1;
38+
FURI_LOG_D(TAG, "Mifare Plus EV1");
39+
break;
40+
case 0x22:
41+
mf_plus_data->type = MfPlusTypeEV2;
42+
FURI_LOG_D(TAG, "Mifare Plus EV2");
43+
break;
44+
default:
45+
mf_plus_data->type = MfPlusTypeUnknown;
46+
FURI_LOG_D(TAG, "Unknown Mifare Plus EV type");
47+
break;
48+
}
49+
50+
// Storage size
51+
switch(mf_plus_data->version.hw_storage) {
52+
case 0x16:
3553
mf_plus_data->size = MfPlusSize2K;
36-
mf_plus_data->security_level = MfPlusSecurityLevel2;
37-
FURI_LOG_D(TAG, "Mifare Plus 2K SL2");
38-
} else if(iso14443_4a_data->iso14443_3a_data->sak == 0x11) {
39-
// Mifare Plus 4K SL3
40-
mf_plus_data->type = MfPlusTypePlus;
54+
FURI_LOG_D(TAG, "2K");
55+
break;
56+
case 0x18:
4157
mf_plus_data->size = MfPlusSize4K;
58+
FURI_LOG_D(TAG, "4K");
59+
break;
60+
default:
61+
mf_plus_data->size = MfPlusSizeUnknown;
62+
FURI_LOG_D(TAG, "Unknown storage size");
63+
break;
64+
}
65+
66+
// Security level
67+
if(iso14443_4a_data->iso14443_3a_data->sak == 0x20) {
68+
// Mifare Plus EV1/2 SL3
4269
mf_plus_data->security_level = MfPlusSecurityLevel3;
43-
FURI_LOG_D(TAG, "Mifare Plus 4K SL3");
70+
FURI_LOG_D(TAG, "Mifare Plus EV1/2 SL3");
4471
} else {
45-
// Mifare Plus EV1/EV2
46-
47-
// Revision
48-
switch(mf_plus_data->version.hw_major) {
49-
case 0x11:
50-
mf_plus_data->type = MfPlusTypeEV1;
51-
FURI_LOG_D(TAG, "Mifare Plus EV1");
52-
break;
53-
case 0x22:
54-
mf_plus_data->type = MfPlusTypeEV2;
55-
FURI_LOG_D(TAG, "Mifare Plus EV2");
56-
break;
57-
default:
58-
mf_plus_data->type = MfPlusTypeUnknown;
59-
FURI_LOG_D(TAG, "Unknown Mifare Plus EV type");
60-
break;
61-
}
62-
63-
// Storage size
64-
switch(mf_plus_data->version.hw_storage) {
65-
case 0x16:
66-
mf_plus_data->size = MfPlusSize2K;
67-
FURI_LOG_D(TAG, "2K");
68-
break;
69-
case 0x18:
70-
mf_plus_data->size = MfPlusSize4K;
71-
FURI_LOG_D(TAG, "4K");
72-
break;
73-
default:
74-
mf_plus_data->size = MfPlusSizeUnknown;
75-
FURI_LOG_D(TAG, "Unknown storage size");
76-
break;
77-
}
78-
79-
// Security level
80-
if(iso14443_4a_data->iso14443_3a_data->sak == 0x20) {
81-
// Mifare Plus EV1/2 SL3
82-
mf_plus_data->security_level = MfPlusSecurityLevel3;
83-
FURI_LOG_D(TAG, "Miare Plus EV1/2 SL3");
84-
} else {
85-
// Mifare Plus EV1/2 SL1
86-
mf_plus_data->security_level = MfPlusSecurityLevel1;
87-
FURI_LOG_D(TAG, "Miare Plus EV1/2 SL1");
88-
}
72+
// Mifare Plus EV1/2 SL1
73+
mf_plus_data->security_level = MfPlusSecurityLevel1;
74+
FURI_LOG_D(TAG, "Mifare Plus EV1/2 SL1");
8975
}
9076
}
9177

@@ -148,6 +134,24 @@ MfPlusError
148134
FURI_LOG_D(TAG, "Sak 08 but no known Mifare Plus type");
149135
}
150136

137+
break;
138+
case 0x10:
139+
// Mifare Plus X 2K SL2
140+
mf_plus_data->type = MfPlusTypeX;
141+
mf_plus_data->size = MfPlusSize2K;
142+
mf_plus_data->security_level = MfPlusSecurityLevel2;
143+
FURI_LOG_D(TAG, "Mifare Plus X 2K SL2");
144+
error = MfPlusErrorNone;
145+
146+
break;
147+
case 0x11:
148+
// Mifare Plus X 4K SL2
149+
mf_plus_data->type = MfPlusTypeX;
150+
mf_plus_data->size = MfPlusSize4K;
151+
mf_plus_data->security_level = MfPlusSecurityLevel2;
152+
FURI_LOG_D(TAG, "Mifare Plus X 4K SL2");
153+
error = MfPlusErrorNone;
154+
151155
break;
152156
case 0x18:
153157
if(memcmp(
@@ -234,10 +238,22 @@ MfPlusError
234238
}
235239

236240
MfPlusError mf_plus_version_parse(MfPlusVersion* data, const BitBuffer* buf) {
237-
const bool can_parse = bit_buffer_get_size_bytes(buf) == sizeof(MfPlusVersion);
241+
bool can_parse = bit_buffer_get_size_bytes(buf) == sizeof(MfPlusVersion);
238242

239243
if(can_parse) {
240244
bit_buffer_write_bytes(buf, data, sizeof(MfPlusVersion));
245+
} else if(
246+
bit_buffer_get_size_bytes(buf) == 8 &&
247+
bit_buffer_get_byte(buf, 0) == MF_PLUS_STATUS_ADDITIONAL_FRAME) {
248+
// HACK(-nofl): There are supposed to be three parts to the GetVersion command,
249+
// with the second and third parts fetched by sending the AdditionalFrame
250+
// command. I don't know whether the entire MIFARE Plus line uses status as
251+
// the first byte, so let's just assume we only have the first part of
252+
// the response if it's size 8 and starts with the AF status. The second
253+
// part of the response is the same size and status byte, but so far
254+
// we're only reading one response.
255+
can_parse = true;
256+
bit_buffer_write_bytes_mid(buf, data, 1, bit_buffer_get_size_bytes(buf) - 1);
241257
}
242258

243259
return can_parse ? MfPlusErrorNone : MfPlusErrorProtocol;

lib/nfc/protocols/mf_plus/mf_plus_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
#define MF_PLUS_FFF_PICC_PREFIX "PICC"
66

7+
#define MF_PLUS_STATUS_OPERATION_OK (0x90)
8+
#define MF_PLUS_STATUS_ADDITIONAL_FRAME (0xAF)
9+
710
MfPlusError mf_plus_get_type_from_version(
811
const Iso14443_4aData* iso14443_4a_data,
912
MfPlusData* mf_plus_data);

lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_i.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ MfUltralightError mf_ultralight_poller_auth_pwd(
3737
furi_check(data);
3838

3939
uint8_t auth_cmd[5] = {MF_ULTRALIGHT_CMD_PWD_AUTH}; //-V1009
40-
memccpy(&auth_cmd[1], data->password.data, 0, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE);
40+
memcpy(&auth_cmd[1], data->password.data, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE);
4141
bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd));
4242

4343
MfUltralightError ret = MfUltralightErrorNone;

0 commit comments

Comments
 (0)