Add MAVAI tool: Advanced MyKey/SRIX4K NFC management with WebGUI API #7
+2,437
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Implements MAVAI (MyKey Advanced Vendor Authenticator Interface), a comprehensive NFC tool for SRIX4K MyKey card management. Built on the existing SRIX Tool foundation (PR BruceDevices#1983) with complete MyKey cryptographic operations, credit management, vendor authentication, and REST API.
Core Implementation (
mavai.cpp,mavai.h- 1,672 lines):SK = UID × Vendor × OTP.mavaifile format with metadata (KeyID, EncryptionKey, ProductionDate)Menu Integration (
RFIDMenu.cpp):bruceConfigPins.rfidModule == PN532_I2C_MODULEWebGUI API (
webInterface.cpp- 7 endpoints):MyKey Block Structure:
0x05: Lock ID (0x7F = locked)0x06: OTP (byte-swapped two's complement)0x07: Key ID0x08: Production date (BCD)0x18-0x19: Vendor (encoded, mirrored to 0x1C-0x1D)0x21: Current credit + timestamp (upper 16b = cents, lower 16b = days since 1995-01-01)0x34-0x3B: Transaction history (8 slots, circular buffer)0x3C: Transaction pointerTypes of Changes
New Feature - Adds complete SRIX4K MyKey management capabilities
Verification
.mavaifile → verify metadata preservedcurl /api/mavai/info→ returns version 1.0Requires PN532 module (I2C) and SRIX4K/ST25TB04K tags for hardware testing.
Testing
Not covered by automated tests - requires physical hardware (PN532 + SRIX4K tags). Code follows existing SRIX Tool patterns and has been structurally validated.
User-Facing Change
Further Comments
Security safeguards implemented:
Documentation: See
MAVAI_TOOL.mdfor complete API reference andMAVAI_IMPLEMENTATION_SUMMARY.mdfor technical details.WebGUI endpoints are placeholder implementations - full hardware integration requires extending with actual tag read/write context from device state.
Original prompt
Feature Request: MAVAI - Advanced MyKey/SRIX4K NFC Tool
Overview
Create a new comprehensive NFC tool called MAVAI (based on the existing SRIX Tool from PR BruceDevices#1983 in BruceDevices/firmware) that implements full MyKey/SRIX4K chip analysis, including encryption key calculation, credit management, vendor operations, and WebGUI integration.
Background
This implementation is based on:
Requirements
1. New Files to Create
src/modules/rfid/mavai.cppandsrc/modules/rfid/mavai.hThe main application files implementing:
Core SRIX4K Functions (from srix_tool.cpp):
MyKey Analysis Functions (from mikai.c/mykey.c):
Encryption Key Calculation: Calculate the MyKey encryption key using:
Block Encode/Decode Function: XOR swap operations for MyKey blocks
Credit Management:
getCurrentCredit()- Read current credit from block 0x21 (XOR decrypted)addCents()- Add credits with transaction history (blocks 0x34-0x3C)setCents()- Set absolute credit valueVendor Operations:
exportVendor()- Extract vendor ID from blocks 0x18/0x19importVendor()- Write new vendor ID with proper checksum recalculationKey Information Display:
Checksum Calculation:
Reset Key Function: Reset MyKey to factory state with proper block initialization
2. Data Display Layout
The screen should show (when a tag is read):
3. Menu Structure
4. WebGUI Integration
Add API endpoints in
src/core/wifi/webInterface.cpp:Add WebUI component in
embedded_resources/web_interface/for MAVAI control panel.5. File Format (.mavai)
6. Integration Points
RFIDMenu.cpp - Add MAVAI entry:
7. Constants and Definitions