mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
util_hdsio: extract getSioMediaTypeInfo
This commit is contained in:
parent
b8d5daa77b
commit
2ae2388cef
6 changed files with 80 additions and 33 deletions
|
@ -425,6 +425,7 @@ set (TARGET_SOURCES
|
||||||
${PM3_ROOT}/client/src/scripting.c
|
${PM3_ROOT}/client/src/scripting.c
|
||||||
${PM3_ROOT}/client/src/ui.c
|
${PM3_ROOT}/client/src/ui.c
|
||||||
${PM3_ROOT}/client/src/util.c
|
${PM3_ROOT}/client/src/util.c
|
||||||
|
${PM3_ROOT}/client/src/util_hidsio.c
|
||||||
${PM3_ROOT}/client/src/wiegand_formats.c
|
${PM3_ROOT}/client/src/wiegand_formats.c
|
||||||
${PM3_ROOT}/client/src/wiegand_formatutils.c
|
${PM3_ROOT}/client/src/wiegand_formatutils.c
|
||||||
${CMAKE_BINARY_DIR}/version_pm3.c
|
${CMAKE_BINARY_DIR}/version_pm3.c
|
||||||
|
|
|
@ -759,6 +759,7 @@ SRCS = mifare/aiddesfire.c \
|
||||||
scripting.c \
|
scripting.c \
|
||||||
ui.c \
|
ui.c \
|
||||||
util.c \
|
util.c \
|
||||||
|
util_hidsio.c \
|
||||||
version_pm3.c \
|
version_pm3.c \
|
||||||
wiegand_formats.c \
|
wiegand_formats.c \
|
||||||
wiegand_formatutils.c
|
wiegand_formatutils.c
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "crypto/libpcrypto.h" // AES decrypt
|
#include "crypto/libpcrypto.h" // AES decrypt
|
||||||
#include "commonutil.h" // get_sw
|
#include "commonutil.h" // get_sw
|
||||||
#include "protocols.h" // ISO7816 APDU return codes
|
#include "protocols.h" // ISO7816 APDU return codes
|
||||||
|
#include "util_hidsio.h"
|
||||||
|
|
||||||
static uint8_t zeros[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
static uint8_t zeros[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
|
@ -100,17 +101,6 @@ static const known_algo_t known_algorithm_map[] = {
|
||||||
{9, "AES-128_CBC_MODE"},
|
{9, "AES-128_CBC_MODE"},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const sioMediaTypeName_t sioMediaTypeMapping[] = {
|
|
||||||
{ 0x00, "Unknown"},
|
|
||||||
{ 0x01, "DESFire"},
|
|
||||||
{ 0x02, "MIFARE"},
|
|
||||||
{ 0x03, "iCLASS (PicoPass)"},
|
|
||||||
{ 0x04, "ISO14443AL4"},
|
|
||||||
{ 0x06, "MIFARE Plus"},
|
|
||||||
{ 0x07, "Seos"},
|
|
||||||
{ 0xFF, "INVALID VALUE"}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int create_cmac(uint8_t *key, uint8_t *input, uint8_t *out, int input_len, int encryption_algorithm) {
|
static int create_cmac(uint8_t *key, uint8_t *input, uint8_t *out, int input_len, int encryption_algorithm) {
|
||||||
uint8_t iv[16] = {0x00};
|
uint8_t iv[16] = {0x00};
|
||||||
|
|
||||||
|
@ -1638,22 +1628,6 @@ static int CmdHfSeosList(const char *Cmd) {
|
||||||
return CmdTraceListAlias(Cmd, "hf seos", "seos -c");
|
return CmdTraceListAlias(Cmd, "hf seos", "seos -c");
|
||||||
}
|
}
|
||||||
|
|
||||||
// get a SIO media type based on the UID
|
|
||||||
// uid[8] tag uid
|
|
||||||
// returns description of the best match
|
|
||||||
static const char *getSioMediaTypeInfo(uint8_t uid) {
|
|
||||||
|
|
||||||
for (int i = 0; i < ARRAYLEN(sioMediaTypeMapping); ++i) {
|
|
||||||
if (uid == sioMediaTypeMapping[i].uid) {
|
|
||||||
return sioMediaTypeMapping[i].desc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//No match, return default
|
|
||||||
return sioMediaTypeMapping[ARRAYLEN(sioMediaTypeMapping) - 1].desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int CmdHfSeosSAM(const char *Cmd) {
|
static int CmdHfSeosSAM(const char *Cmd) {
|
||||||
CLIParserContext *ctx;
|
CLIParserContext *ctx;
|
||||||
CLIParserInit(&ctx, "hf seos sam",
|
CLIParserInit(&ctx, "hf seos sam",
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
// structure and database for uid -> tagtype lookups
|
|
||||||
typedef struct {
|
|
||||||
uint8_t uid;
|
|
||||||
const char *desc;
|
|
||||||
} sioMediaTypeName_t;
|
|
||||||
|
|
||||||
int infoSeos(bool verbose);
|
int infoSeos(bool verbose);
|
||||||
int CmdHFSeos(const char *Cmd);
|
int CmdHFSeos(const char *Cmd);
|
||||||
int seos_kdf(bool encryption, uint8_t *masterKey, uint8_t keyslot,
|
int seos_kdf(bool encryption, uint8_t *masterKey, uint8_t keyslot,
|
||||||
|
|
51
client/src/util_hidsio.c
Normal file
51
client/src/util_hidsio.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// See LICENSE.txt for the text of the license.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// HID Global SIO utilities
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "commonutil.h"
|
||||||
|
#include "util_hidsio.h"
|
||||||
|
|
||||||
|
// structure and database for uid -> tagtype lookups
|
||||||
|
typedef struct {
|
||||||
|
uint8_t uid;
|
||||||
|
const char *desc;
|
||||||
|
} sioMediaTypeName_t;
|
||||||
|
|
||||||
|
static const sioMediaTypeName_t sioMediaTypeMapping[] = {
|
||||||
|
{ 0x00, "Unknown"},
|
||||||
|
{ 0x01, "DESFire"},
|
||||||
|
{ 0x02, "MIFARE"},
|
||||||
|
{ 0x03, "iCLASS (PicoPass)"},
|
||||||
|
{ 0x04, "ISO14443AL4"},
|
||||||
|
{ 0x06, "MIFARE Plus"},
|
||||||
|
{ 0x07, "Seos"},
|
||||||
|
{ 0xFF, "INVALID VALUE"}
|
||||||
|
};
|
||||||
|
|
||||||
|
// get a SIO media type based on the UID
|
||||||
|
// uid[8] tag uid
|
||||||
|
// returns description of the best match
|
||||||
|
const char *getSioMediaTypeInfo(uint8_t uid) {
|
||||||
|
|
||||||
|
for (int i = 0; i < ARRAYLEN(sioMediaTypeMapping); ++i) {
|
||||||
|
if (uid == sioMediaTypeMapping[i].uid) {
|
||||||
|
return sioMediaTypeMapping[i].desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//No match, return default
|
||||||
|
return sioMediaTypeMapping[ARRAYLEN(sioMediaTypeMapping) - 1].desc;
|
||||||
|
}
|
26
client/src/util_hidsio.h
Normal file
26
client/src/util_hidsio.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// See LICENSE.txt for the text of the license.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// HID Global SIO utilities
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifndef __UTIL_HIDSIO_H_
|
||||||
|
#define __UTIL_HIDSIO_H_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
const char *getSioMediaTypeInfo(uint8_t uid);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue