make style

This commit is contained in:
Philippe Teuwen
2026-02-06 13:43:41 +01:00
parent 9648c078c1
commit c00e4801b7
48 changed files with 1479 additions and 1490 deletions
+4 -4
View File
@@ -1786,10 +1786,10 @@ static void PacketReceived(PacketCommandNG *packet) {
} PACKED;
struct p *payload = (struct p *) packet->data.asBytes;
SimulateIso14443aTagEx(payload->tagtype, payload->flags, payload->uid,
payload->exitAfter, payload->rats, sizeof(payload->rats),
payload->ulauth_1a1, payload->ulauth_1a1_len,
payload->ulauth_1a2, payload->ulauth_1a2_len
); // ## Simulate iso14443a tag - pass tag type & UID
payload->exitAfter, payload->rats, sizeof(payload->rats),
payload->ulauth_1a1, payload->ulauth_1a1_len,
payload->ulauth_1a2, payload->ulauth_1a2_len
); // ## Simulate iso14443a tag - pass tag type & UID
break;
}
case CMD_HF_ISO14443A_SIM_AID: {
+1 -1
View File
@@ -541,7 +541,7 @@ static int b64dec(const char *src, int n, char *dst) {
int len = 0;
while (src + 3 < end) {
int a = b64rev(src[0]), b = b64rev(src[1]), c = b64rev(src[2]),
d = b64rev(src[3]);
d = b64rev(src[3]);
dst[len++] = (a << 2) | (b >> 4);
if (src[2] != '=') {
dst[len++] = (b << 4) | (c >> 2);
+7 -7
View File
@@ -1881,13 +1881,13 @@ void SimulateIso14443aTagEx(uint8_t tagType, uint16_t flags, uint8_t *useruid, u
emlGet(emdata, start, MIFARE_BLOCK_SIZE);
// mask key pages if needed
if ((tagType == 13) && (block >= 0x29) && (block <= 0x2F)) {
uint8_t offset = block >= 0x2C ? 0 : 0x2C - block;
uint8_t length = block >= 0x2C ? 0x30 - block : block - 0x28;
memset(emdata + offset * 4, 0x00, length * 4);
uint8_t offset = block >= 0x2C ? 0 : 0x2C - block;
uint8_t length = block >= 0x2C ? 0x30 - block : block - 0x28;
memset(emdata + offset * 4, 0x00, length * 4);
} else if ((tagType == 14) && (block >= 0x2D) && (block <= 0x37)) {
uint8_t offset = block >= 0x30 ? 0 : 0x30 - block;
uint8_t length = block >= 0x30 ? (0x37 - block > 4 ? 4 : 0x37 - block) : block - 0x2C;
memset(emdata + offset * 4, 0x00, length * 4);
uint8_t offset = block >= 0x30 ? 0 : 0x30 - block;
uint8_t length = block >= 0x30 ? (0x37 - block > 4 ? 4 : 0x37 - block) : block - 0x2C;
memset(emdata + offset * 4, 0x00, length * 4);
}
// TODO: implement cyclic memory if we reach AUTH0 and AUTH1=0 and unauth on ULC/ULAES, or if we reach end of memory
AddCrc14A(emdata, MIFARE_BLOCK_SIZE);
@@ -1987,7 +1987,7 @@ void SimulateIso14443aTagEx(uint8_t tagType, uint16_t flags, uint8_t *useruid, u
if (wrblock > pages) {
// send NACK 0x0 == invalid argument
EmSend4bit(CARD_NACK_IV);
// TODO: check if wrblock >= AUTH0 and unauth on ULC/ULAES -> NACK
// TODO: check if wrblock >= AUTH0 and unauth on ULC/ULAES -> NACK
} else {
// send ACK
EmSend4bit(CARD_ACK);
+1 -1
View File
@@ -1797,7 +1797,7 @@ void MifareStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo,
// NT1 is any:
// NT2 case: random, but is static(static encrypted nested).
// pre-generate nonces: the distance value is related to the key type, so if the key type is the same,
// pre-generate nonces: the distance value is related to the key type, so if the key type is the same,
// we can directly use the measured distance value. (Experience)
if (targetKeyType == 1 && nt1 == 0x009080A2 && forceDetectDist == 0) {
target_nt[0] = prng_successor(nt1, 161);
+34 -34
View File
@@ -123,7 +123,7 @@ static bool generate_cmac(const uint8_t *key, const uint8_t *input, size_t lengt
}
static void seos_kdf(bool forEncryption, uint8_t *masterKey, uint8_t keyslot, uint8_t *work_buffer,
uint8_t *adfOid, size_t adfoid_len, uint8_t *diversifier, uint8_t diversifier_len, uint8_t *out, int encryption_algorithm, int hash_algorithm) {
uint8_t *adfOid, size_t adfoid_len, uint8_t *diversifier, uint8_t diversifier_len, uint8_t *out, int encryption_algorithm, int hash_algorithm) {
// Encryption key = 04
// KEK Encryption key = 05
@@ -142,8 +142,8 @@ static void seos_kdf(bool forEncryption, uint8_t *masterKey, uint8_t keyslot, ui
work_buffer[16] = encryption_algorithm;
work_buffer[17] = hash_algorithm;
work_buffer[18] = keyslot;
memcpy(work_buffer+19, adfOid, adfoid_len);
memcpy(work_buffer+19+adfoid_len, diversifier, diversifier_len);
memcpy(work_buffer + 19, adfOid, adfoid_len);
memcpy(work_buffer + 19 + adfoid_len, diversifier, diversifier_len);
// This CMAC always uses AES, regardless of the main encryption algorithm in use.
generate_cmac(masterKey, work_buffer, 19 + adfoid_len + diversifier_len, out, SEOS_ENCRYPTION_AES);
@@ -370,7 +370,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
while (tlv_offset < received_tlv_len) {
uint8_t tag = received_tlv[tlv_offset++];
uint8_t length = received_tlv[tlv_offset++];
uint8_t* value = &received_tlv[tlv_offset];
uint8_t *value = &received_tlv[tlv_offset];
if (tag == 0x06) {
if (length == msg->oid_len && memcmp(value, msg->oid, length) == 0) {
selected_oid = true;
@@ -383,7 +383,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
if (selected_oid) {
// Synthesized IV: half a block of random data followed by half of the CMAC of that data
memset(cryptogram_iv, 0, half_bs); // TODO: Maybe actually use random data?
if (!generate_cmac(msg->privmac, cryptogram_iv, half_bs, cryptogram_iv+half_bs, msg->encr_alg)) {
if (!generate_cmac(msg->privmac, cryptogram_iv, half_bs, cryptogram_iv + half_bs, msg->encr_alg)) {
Dbprintf(_RED_("Select ADF failed") ": Failed to create IV CMAC.");
break;
}
@@ -396,12 +396,12 @@ void SimulateSeos(seos_emulate_req_t *msg) {
reply[reply_idx++] = 0x06; // Tag: selected OID
reply[reply_idx++] = msg->oid_len;
memcpy(reply+reply_idx, msg->oid, msg->oid_len);
memcpy(reply + reply_idx, msg->oid, msg->oid_len);
reply_idx += msg->oid_len;
reply[reply_idx++] = 0xCF; // Tag: diversifier
reply[reply_idx++] = msg->diversifier_len;
memcpy(reply+reply_idx, msg->diversifier, msg->diversifier_len);
memcpy(reply + reply_idx, msg->diversifier, msg->diversifier_len);
reply_idx += msg->diversifier_len;
uint8_t tlv_base = 1 + offset;
@@ -414,11 +414,11 @@ void SimulateSeos(seos_emulate_req_t *msg) {
dynamic_response_info.response[tlv_idx++] = 0x85; // Tag: cryptogram
dynamic_response_info.response[tlv_idx++] = reply_len + bs; // Length
memcpy(dynamic_response_info.response+tlv_idx, cryptogram_iv, bs);
memcpy(dynamic_response_info.response + tlv_idx, cryptogram_iv, bs);
tlv_idx += bs;
// Generate cryptogram directly into response buffer
if (!generate_cryptogram(msg->privenc, true, reply, reply_len, dynamic_response_info.response+tlv_idx, msg->encr_alg)) {
if (!generate_cryptogram(msg->privenc, true, reply, reply_len, dynamic_response_info.response + tlv_idx, msg->encr_alg)) {
Dbprintf(_RED_("Select ADF failed") ": Failed to create reply cryptogram.");
break;
}
@@ -427,14 +427,14 @@ void SimulateSeos(seos_emulate_req_t *msg) {
// Always an 8-byte CMAC
const uint8_t cmac_size = 8;
uint8_t *cmac = work_buffer_a;
if (!generate_cmac(msg->privmac, dynamic_response_info.response+tlv_base, tlv_idx-tlv_base, cmac, msg->encr_alg)) {
if (!generate_cmac(msg->privmac, dynamic_response_info.response + tlv_base, tlv_idx - tlv_base, cmac, msg->encr_alg)) {
Dbprintf(_RED_("Select ADF failed") ": Failed to create reply CMAC.");
break;
}
dynamic_response_info.response[tlv_idx++] = 0x8E; // Tag: CMAC
dynamic_response_info.response[tlv_idx++] = cmac_size; // Length
memcpy(dynamic_response_info.response+tlv_idx, cmac, cmac_size);
memcpy(dynamic_response_info.response + tlv_idx, cmac, cmac_size);
tlv_idx += cmac_size;
dynamic_response_info.response_n = tlv_idx;
@@ -463,10 +463,10 @@ void SimulateSeos(seos_emulate_req_t *msg) {
uint8_t tlv_idx = 1 + offset;
dynamic_response_info.response[tlv_idx++] = 0x7C; // Tag: mutual auth
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC)+2; // Length
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC) +2; // Length
dynamic_response_info.response[tlv_idx++] = 0x81; // Tag: request for RND.ICC
dynamic_response_info.response[tlv_idx++] = sizeof(RND_ICC); // Length
memcpy(dynamic_response_info.response+tlv_idx, RND_ICC, sizeof(RND_ICC));
memcpy(dynamic_response_info.response + tlv_idx, RND_ICC, sizeof(RND_ICC));
tlv_idx += sizeof(RND_ICC);
dynamic_response_info.response_n = tlv_idx;
@@ -534,7 +534,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
const uint8_t reply_len = reply_plain_len + 8;
uint8_t *reply = work_buffer_b;
generate_cryptogram(diver_encr_key, false, reply_plain, reply_plain_len, reply, msg->encr_alg);
if (!generate_cmac(diver_cmac_key, reply, reply_plain_len, reply+reply_plain_len, msg->encr_alg)) {
if (!generate_cmac(diver_cmac_key, reply, reply_plain_len, reply + reply_plain_len, msg->encr_alg)) {
Dbprintf(_RED_("Mutual auth failed") ": Failed to create reply CMAC.");
break;
}
@@ -542,10 +542,10 @@ void SimulateSeos(seos_emulate_req_t *msg) {
uint8_t tlv_idx = 1 + offset;
dynamic_response_info.response[tlv_idx++] = 0x7C; // Tag: mutual auth
dynamic_response_info.response[tlv_idx++] = reply_len+2; // Length
dynamic_response_info.response[tlv_idx++] = reply_len + 2; // Length
dynamic_response_info.response[tlv_idx++] = 0x82; // Tag: request for challenge
dynamic_response_info.response[tlv_idx++] = reply_len; // Length
memcpy(dynamic_response_info.response+tlv_idx, reply, reply_len);
memcpy(dynamic_response_info.response + tlv_idx, reply, reply_len);
tlv_idx += reply_len;
dynamic_response_info.response_n = tlv_idx;
@@ -564,17 +564,17 @@ void SimulateSeos(seos_emulate_req_t *msg) {
hash_input[hash_idx++] = 0x00;
hash_input[hash_idx++] = 0x01;
// Only copy first 8 bytes of each KEY
memcpy(hash_input+hash_idx, KEY_IFD, 8);
memcpy(hash_input + hash_idx, KEY_IFD, 8);
hash_idx += 8;
memcpy(hash_input+hash_idx, KEY_ICC, 8);
memcpy(hash_input + hash_idx, KEY_ICC, 8);
hash_idx += 8;
// Yes, this is supposed to be the same thing twice
hash_input[hash_idx++] = msg->encr_alg;
hash_input[hash_idx++] = msg->encr_alg;
// Copy full RND values
memcpy(hash_input+hash_idx, RND_ICC, 8);
memcpy(hash_input + hash_idx, RND_ICC, 8);
hash_idx += 8;
memcpy(hash_input+hash_idx, RND_IFD, 8);
memcpy(hash_input + hash_idx, RND_IFD, 8);
hash_idx += 8;
uint8_t *hash_output = work_buffer_b;
@@ -593,9 +593,9 @@ void SimulateSeos(seos_emulate_req_t *msg) {
}
memcpy(diver_encr_key, hash_output, 16);
memcpy(diver_cmac_key, hash_output+16, 16);
memcpy(diver_cmac_key, hash_output + 16, 16);
} else {
Dbprintf( _RED_("Mutual auth failed") ": Incorrect tag %02X found.", received_tlv[0]);
Dbprintf(_RED_("Mutual auth failed") ": Incorrect tag %02X found.", received_tlv[0]);
}
}
break;
@@ -617,8 +617,8 @@ void SimulateSeos(seos_emulate_req_t *msg) {
uint8_t tlv_offset = 0;
while (tlv_offset < received_tlv_len) {
uint8_t tag = received_tlv[tlv_offset];
uint8_t length = received_tlv[tlv_offset+1];
uint8_t* value = &received_tlv[tlv_offset+2];
uint8_t length = received_tlv[tlv_offset + 1];
uint8_t *value = &received_tlv[tlv_offset + 2];
if (tag == 0x85) {
cryptogram = value;
@@ -642,7 +642,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
memcpy(rndCounter, RND_ICC, half_bs);
memcpy(rndCounter + half_bs, RND_IFD, half_bs);
for (int8_t i=bs-1; i>=0; i--) {
for (int8_t i = bs - 1; i >= 0; i--) {
rndCounter[i]++;
if (rndCounter[i] != 0x00) break;
}
@@ -678,7 +678,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
break;
}
if (memcmp(cmac, recvd_cmac, recvd_cmac_length) != 0) {
Dbprintf( _RED_("Get Data failed") ": Invalid CMAC.");
Dbprintf(_RED_("Get Data failed") ": Invalid CMAC.");
break;
}
@@ -699,7 +699,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
break;
}
if (request[1] != msg->data_tag_len || memcmp(request+2, msg->data_tag, msg->data_tag_len) != 0) {
if (request[1] != msg->data_tag_len || memcmp(request + 2, msg->data_tag, msg->data_tag_len) != 0) {
Dbprintf(_RED_("Get Data failed") ": Requested invalid data tag.");
break;
}
@@ -714,10 +714,10 @@ void SimulateSeos(seos_emulate_req_t *msg) {
uint8_t *reply = work_buffer_a;
uint8_t reply_idx = 0;
memcpy(reply+reply_idx, msg->data_tag, msg->data_tag_len); // Tag
memcpy(reply + reply_idx, msg->data_tag, msg->data_tag_len); // Tag
reply_idx += msg->data_tag_len;
reply[reply_idx++] = msg->data_len; // Length
memcpy(reply+reply_idx, msg->data, msg->data_len); // Value
memcpy(reply + reply_idx, msg->data, msg->data_len); // Value
reply_idx += msg->data_len;
if (reply_idx != reply_len) {
@@ -735,7 +735,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
// Only include a cryptogram for GET DATA
dynamic_response_info.response[tlv_idx++] = 0x85; // Tag: cryptogram
dynamic_response_info.response[tlv_idx++] = reply_len; // Length
memcpy(dynamic_response_info.response+tlv_idx, reply_cryptogram, reply_len);
memcpy(dynamic_response_info.response + tlv_idx, reply_cryptogram, reply_len);
tlv_idx += reply_len;
}
@@ -747,7 +747,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
// Unlike every other CMAC, this time we need to prepend
// the same counter from above, but increment it again
for (int8_t i=bs-1; i>=0; i--) {
for (int8_t i = bs - 1; i >= 0; i--) {
rndCounter[i]++;
if (rndCounter[i] != 0x00) break;
}
@@ -774,7 +774,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
dynamic_response_info.response[tlv_idx++] = 0x8E; // Tag: CMAC
dynamic_response_info.response[tlv_idx++] = cmac_size; // Length
memcpy(dynamic_response_info.response+tlv_idx, cmac, cmac_size);
memcpy(dynamic_response_info.response + tlv_idx, cmac, cmac_size);
tlv_idx += cmac_size;
dynamic_response_info.response_n = tlv_idx;
@@ -783,7 +783,7 @@ void SimulateSeos(seos_emulate_req_t *msg) {
apdu_status[0] = 0x90;
apdu_status[1] = 0x00;
} else {
Dbprintf( _RED_("Get Data failed") ": No cryptogram or CMAC found in request.");
Dbprintf(_RED_("Get Data failed") ": No cryptogram or CMAC found in request.");
}
}
break;
@@ -859,4 +859,4 @@ void SimulateSeos(seos_emulate_req_t *msg) {
}
reply_ng(CMD_HF_SEOS_SIMULATE, retval, NULL, 0);
}
}
+5 -5
View File
@@ -31,13 +31,13 @@
#include <string.h>
#include <stdbool.h>
#if defined(NDEBUG)
#define ASSERT(x) ((void)0)
#define ASSERT(x) ((void)0)
#elif defined(ID48_NO_STDIO)
#define ASSERT(x) ((void)0)
#define ASSERT(x) ((void)0)
#else // neither NDEBUG nor ID48_NO_STDIO defined
#include <stdio.h>
#include <assert.h>
#define ASSERT(x) assert((x))
#include <stdio.h>
#include <assert.h>
#define ASSERT(x) assert((x))
#endif
+69 -71
View File
@@ -45,27 +45,25 @@ SOFTWARE.
*/
#ifndef __has_feature
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \
(defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \
__has_feature(cxx_constexpr) /* CLang versions supporting constexp */
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
namespace detail
{
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept
{
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
namespace detail {
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept {
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
#elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \
defined(__INTEL_COMPILER) || \
@@ -75,81 +73,81 @@ SOFTWARE.
(__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
)))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
0 * sizeof(reinterpret_cast<const ::Bad_arg_to_ARRAY_SIZE2*>(arr)) + /*check1*/ \
0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \
sizeof(arr) / sizeof((arr)[0]) /* eval */ \
)
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
#elif !defined(__cplusplus) && defined(__GNUC__)
#include <stdint.h>
#include <stdint.h>
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#else
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
#endif
+2 -2
View File
@@ -13,8 +13,8 @@ int main(void) {
printf("Verifying Espresso Results...\n");
result = verify_espresso_results();
printf("Verifying Espresso Results: %s\n",
result ? "SUCCESS" : "----> FAILURE <----"
);
result ? "SUCCESS" : "----> FAILURE <----"
);
}
// if (result) {
// printf("Hello2...\n");
File diff suppressed because it is too large Load Diff
+69 -71
View File
@@ -45,27 +45,25 @@ SOFTWARE.
*/
#ifndef __has_feature
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \
(defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \
__has_feature(cxx_constexpr) /* CLang versions supporting constexp */
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
namespace detail
{
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept
{
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
namespace detail {
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept {
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
#elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \
defined(__INTEL_COMPILER) || \
@@ -75,81 +73,81 @@ SOFTWARE.
(__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
)))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
0 * sizeof(reinterpret_cast<const ::Bad_arg_to_ARRAY_SIZE2*>(arr)) + /*check1*/ \
0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \
sizeof(arr) / sizeof((arr)[0]) /* eval */ \
)
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
#elif !defined(__cplusplus) && defined(__GNUC__)
#include <stdint.h>
#include <stdint.h>
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#else
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
#endif
+69 -71
View File
@@ -45,27 +45,25 @@ SOFTWARE.
*/
#ifndef __has_feature
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
#endif
#if (defined(__cplusplus) && __cplusplus >= 201103L) || /* any compiler claiming C++11 support */ \
(defined(__cplusplus) && _MSC_VER >= 1900 && __cplusplus != 199711L) || /* Visual C++ 2015 or higher */ \
__has_feature(cxx_constexpr) /* CLang versions supporting constexp */
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using C++11 version" )
#endif
namespace detail
{
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const (&)[N]) noexcept
{
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
namespace detail {
template <typename T, size_t N>
constexpr size_t ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(T const(&)[N]) noexcept {
return N;
}
} /* namespace detail */
#define ARRAY_SIZE2(arr) detail::ARRAY_SIZE2_ARGUMENT_CANNOT_BE_POINTER(arr)
#elif defined(__cplusplus) && __cplusplus >= 199711L && ( /* C++ 98 trick */ \
defined(__INTEL_COMPILER) || \
@@ -75,81 +73,81 @@ SOFTWARE.
(__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
)))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#include <stddef.h> /* required for size_t */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message "ARRAY_SIZE2 -- Using C++98 version"
#endif
template <typename T, size_t N>
char(&_ArraySizeHelperRequiresArray(T(&)[N]))[N];
#define ARRAY_SIZE2(x) sizeof(_ArraySizeHelperRequiresArray(x))
#elif defined(__cplusplus) /* && ((__cplusplus >= 199711L) || defined(__INTEL_COMPILER) || defined(__clang__)) */
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using Ivan J. Johnson's C++ version" )
#endif
/*
Works on older compilers, even Visual C++ 6....
Created by Ivan J. Johnson, March 06, 2007
See http://drdobbs.com/cpp/197800525?pgno=1
Full description is in markdown file array_size2.md
*/
#define ARRAY_SIZE2(arr) ( \
0 * sizeof(reinterpret_cast<const ::Bad_arg_to_ARRAY_SIZE2*>(arr)) + /*check1*/ \
0 * sizeof(::Bad_arg_to_ARRAY_SIZE2::check_type((arr), &(arr))) + /*check2*/ \
sizeof(arr) / sizeof((arr)[0]) /* eval */ \
)
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
struct Bad_arg_to_ARRAY_SIZE2 {
class Is_pointer; /* incomplete */
class Is_array {};
template <typename T>
static Is_pointer check_type(T const *, T const * const *);
static Is_array check_type(void const *, void const *);
};
#elif !defined(__cplusplus) && defined(__GNUC__)
#include <stdint.h>
#include <stdint.h>
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
/**
Even C can have type-safety for equivalent of ARRAY_SIZE() macro,
when using the following two GCC extensions:
typeof()
__builtin_types_compatible_p()
*/
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
#if defined(ARRAYSIZE2_SHOW_VERSION_MESSAGE)
#pragma message( "ARRAY_SIZE2 -- Using GNUC version" )
#endif
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
/**
validated using:
MSP430 gcc 4.5.3
x86-64 icc 16.0.3
x86-64 gcc 4.1.2
x86-64 clang 3.0.0
AVR gcc 4.5.4
ARM gcc 4.5.4
*/
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#define __SIMPLEHACKS_COMPATIBLE_TYPES__(a,b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) /* GCC extensions */
#define __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(x) (sizeof(struct { uint8_t q: (-!!(x)*0x1ee7)+1u;})-1u) /* if x is zero, reports "error: negative width in bit-field '<anonymous>'" */
#define __SIMPLEHACKS_MUST_BE_ARRAY__(x) __SIMPLEHACKS_BUILD_ERROR_ON_NONZERO__(__SIMPLEHACKS_COMPATIBLE_TYPES__((x), &(*x)))
#define ARRAY_SIZE2(_arr) ( (sizeof(_arr) / sizeof((_arr)[0])) + __SIMPLEHACKS_MUST_BE_ARRAY__(_arr) ) /* compile-time error if not an array */
#else
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
/**
The good news is that all compilers (as of 20202-05-08)
on godbolt.org are fully supported. Therefore, if some
other compiler does not support any of the above method,
it's important to force a compile-time error, to avoid
any suggestion that this provides a safe macro.
*/
#error "Unable to provide type-safe ARRAY_SIZE2 macro"
#endif
+55 -55
View File
@@ -56,36 +56,36 @@ static const TEST_VECTOR_T test_vectors[] = {
};
// Comment
/// <summary>
/// Initializes to allow iterative recovery
/// of multiple potential keys. After calling
/// this init() function, can repeatedly call
/// the next() function until it returns false
/// to obtain all potential keys.
/// </summary>
/// <param name="input_partial_key">
/// Top 48 bits of the key, such as those discovered
/// using the proxmark3 command `lf em 4x70 brute`.
/// Only k[0..5] are used from this parameter,
/// corresponding to K₉₅..K₄₈.
/// </param>
/// <param name="input_nonce">
/// The nonce value.
/// Typically from a sniffed authentication.
/// </param>
/// <param name="input_frn">
/// The challenge sent from the reader (e.g., car)
/// to the tag (e.g., key).
/// Typically from a sniffed authentication.
/// </param>
/// <param name="input_grn">
/// The response sent from the tag (e.g., key)
/// to the car (e.g., car).
/// Typically from a sniffed authentication.
/// </param>
/// <remarks>
/// Note: In C++, each parameter would be a reference (not pointer).
/// </remarks>
/// <summary>
/// Initializes to allow iterative recovery
/// of multiple potential keys. After calling
/// this init() function, can repeatedly call
/// the next() function until it returns false
/// to obtain all potential keys.
/// </summary>
/// <param name="input_partial_key">
/// Top 48 bits of the key, such as those discovered
/// using the proxmark3 command `lf em 4x70 brute`.
/// Only k[0..5] are used from this parameter,
/// corresponding to K₉₅..K₄₈.
/// </param>
/// <param name="input_nonce">
/// The nonce value.
/// Typically from a sniffed authentication.
/// </param>
/// <param name="input_frn">
/// The challenge sent from the reader (e.g., car)
/// to the tag (e.g., key).
/// Typically from a sniffed authentication.
/// </param>
/// <param name="input_grn">
/// The response sent from the tag (e.g., key)
/// to the car (e.g., car).
/// Typically from a sniffed authentication.
/// </param>
/// <remarks>
/// Note: In C++, each parameter would be a reference (not pointer).
/// </remarks>
// void id48lib_key_recovery_init(
// const ID48LIB_KEY *input_partial_key,
@@ -95,30 +95,30 @@ static const TEST_VECTOR_T test_vectors[] = {
// );
// Comment
/// <summary>
/// This can be repeated called (after calling init())
/// to find the next potential key for the given
/// partial key + nonce + frn + grn values.
/// I've seen combinations that have up to six
/// potential keys available, although typically
/// there are 1-3 results.
/// Each call to this function will return a single
/// value. Call repeatedly until the function returns
/// false to get all potential keys.
/// </summary>
/// <param name="potential_key_output">
/// When the function returns true, this caller-provided
/// value will be filled with the 96-bit key that, when
/// programmed to the tag, should authenticate against
/// the nonce+frn values, with tag returning the grn value.
/// </param>
/// <returns>
/// true when another potential key has been found.
/// false if no additional potential keys have been found.
/// </returns>
/// <remarks>
/// Note: In C++, each parameter would be a reference (not pointer).
/// </remarks>
/// <summary>
/// This can be repeated called (after calling init())
/// to find the next potential key for the given
/// partial key + nonce + frn + grn values.
/// I've seen combinations that have up to six
/// potential keys available, although typically
/// there are 1-3 results.
/// Each call to this function will return a single
/// value. Call repeatedly until the function returns
/// false to get all potential keys.
/// </summary>
/// <param name="potential_key_output">
/// When the function returns true, this caller-provided
/// value will be filled with the 96-bit key that, when
/// programmed to the tag, should authenticate against
/// the nonce+frn values, with tag returning the grn value.
/// </param>
/// <returns>
/// true when another potential key has been found.
/// false if no additional potential keys have been found.
/// </returns>
/// <remarks>
/// Note: In C++, each parameter would be a reference (not pointer).
/// </remarks>
// bool id48lib_key_recovery_next(
// ID48LIB_KEY *potential_key_output
// );
@@ -144,7 +144,7 @@ bool recovery_succeeds(const TEST_VECTOR_T *test_vector, bool zero_partial_key)
// just verify that the potential key matches the test vector
if (bytes_equal(potential_key.k, test_vector->key.k, sizeof(test_vector->key.k))) {
key_found = true;
}
}
}
return key_found;
}
+6 -6
View File
@@ -73,10 +73,10 @@ main(int argc, char *argv[]) {
setbmp();
if (BMP_BIT != bmpbit || BMP_SUB != bmpsub) {
fprintf(stderr, "reveng: configuration fault. Update "
"reveng/config.h with these definitions and "
"recompile:\n"
"\t#define BMP_BIT %d\n"
"\t#define BMP_SUB %d\n",
"reveng/config.h with these definitions and "
"recompile:\n"
"\t#define BMP_BIT %d\n"
"\t#define BMP_SUB %d\n",
bmpbit, bmpsub);
exit(EXIT_FAILURE);
}
@@ -84,8 +84,8 @@ main(int argc, char *argv[]) {
/* check the bitmap constant macro */
if (~(bmp_t) 0 != ~BMP_C(0)) {
fprintf(stderr, "reveng: configuration fault. Edit "
"the definition of BMP_C() in config.h to "
"match BMP_T and recompile.\n");
"the definition of BMP_C() in config.h to "
"match BMP_T and recompile.\n");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -608,4 +608,4 @@ def delete_file(aid, key_type, key, com_mode, aid_key_type, aid_key):
print(response)
if __name__ == "__main__":
authenticate_and_menu()
authenticate_and_menu()
+1 -1
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# Recover the shared key mask specific to an Ultralight AES card
#
#
# Conditions:
# * key blocks not locked by LOCK_KEYS
#
+1 -1
View File
@@ -467,7 +467,7 @@ static int CmdFlashMemSpiFFSWipe(const char *Cmd) {
CLIParserInit(&ctx, "mem spiffs wipe",
_RED_("* * * Warning * * *") " \n"
_CYAN_("This command wipes all files on the device SPIFFS file system"),
"mem spiffs wipe");
"mem spiffs wipe");
void *argtable[] = {
arg_param_begin,
+2 -2
View File
@@ -2989,7 +2989,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
int16_t fsci = card.ats[1] & 0x0f;
PrintAndLogEx(INFO, " ..." _YELLOW_("%02X") "............ T0 TA1 is%s present, TB1 is%s present, "
"TC1 is%s present, FSCI is %d (FSC = %d)",
"TC1 is%s present, FSCI is %d (FSC = %d)",
card.ats[1],
(ta1 ? "" : _RED_(" NOT")),
(tb1 ? "" : _RED_(" NOT")),
@@ -3011,7 +3011,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
if (strlen(ds) != 0) ds[strlen(ds) - 2] = '\0';
if (strlen(dr) != 0) dr[strlen(dr) - 2] = '\0';
PrintAndLogEx(INFO, " ......" _YELLOW_("%02X") "......... TA1 different divisors are%s supported, "
"DR: [%s], DS: [%s]",
"DR: [%s], DS: [%s]",
card.ats[pos],
((card.ats[pos] & 0x80) ? _RED_(" NOT") : ""),
dr,
+1 -1
View File
@@ -86,7 +86,7 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
PrintAndLogEx(WARNING, "Failed to allocate memory");
return PM3_EMALLOC;
}
// print nonce
PrintAndLogEx(SUCCESS, "Length: %zu, Nonce: %s", nonce_length, sprint_hex_inrow(resp.data.asBytes, nonce_length));
free(nonce);
+19 -19
View File
@@ -64,10 +64,10 @@ static void print_status_flag1_interpretation(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
PrintAndLogEx(INFO, " FF | If an error occurs during the processing of a command that includes no list in the command packet, \n"
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
" | or if an error occurs independently of any list, the card returns a response by setting FFh to Status Flag1.");
PrintAndLogEx(INFO, " XX | If an error occurs while processing a command that includes Service Code List or Block List \n"
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
" | indicating the location of the error.");
" | in the command packet, the card returns a response by setting a number in the list to Status Flag1,\n"
" | indicating the location of the error.");
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
}
@@ -76,28 +76,28 @@ static void print_status_flag2_interpration(void) {
PrintAndLogEx(INFO, "----+--------------------------------------------------------------------------------------------------------------------");
PrintAndLogEx(INFO, " 00 | Indicates the successful completion of a command.");
PrintAndLogEx(INFO, " 01 | The calculated result is either less than zero when the purse data is decremented, or exceeds 4\n"
" | Bytes when the purse data is incremented.");
" | Bytes when the purse data is incremented.");
PrintAndLogEx(INFO, " 02 | The specified data exceeds the value of cashback data at cashback of purse.");
PrintAndLogEx(INFO, " 70 | Memory error (fatal error).");
PrintAndLogEx(INFO, " 71 | The number of memory rewrites exceeds the upper limit (this is only a warning; data writing is performed as normal).\n"
" | The maximum number of rewrites can differ, depending on the product being used.\n"
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
" | The maximum number of rewrites can differ, depending on the product being used.\n"
" | In addition, Status Flag1 is either 00h or FFh depending on the product being used.");
PrintAndLogEx(INFO, " A1 | Illegal Number of Service| Number of Service or Number of Node specified by the command \n"
" | falls outside the range of the prescribed value.");
" | falls outside the range of the prescribed value.");
PrintAndLogEx(INFO, " A2 | Illegal command packet (specified Number of Block) : Number of Block specified by the \n"
" | command falls outside the range of the prescribed values for the product.");
" | command falls outside the range of the prescribed values for the product.");
PrintAndLogEx(INFO, " A3 | Illegal Block List (specified order of Service) : Service Code List Order specified by \n"
" | Block List Element falls outside the Number of Service specified by the command \n"
" | (or the Number of Service specified at the times of mutual authentication).");
" | Block List Element falls outside the Number of Service specified by the command \n"
" | (or the Number of Service specified at the times of mutual authentication).");
PrintAndLogEx(INFO, " A4 | Illegal Service type : Area Attribute specified by the command or Service Attribute of Service Code is incorrect.");
PrintAndLogEx(INFO, " A5 | Access is not allowed : Area or Service specified by the command cannot be accessed.\n"
" | The parameter specified by the command does not satisfy the conditions for success.");
" | The parameter specified by the command does not satisfy the conditions for success.");
PrintAndLogEx(INFO, " A6 | Illegal Service Code List : Target to be accessed, identified by Service Code List Order, specified by Block\n"
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
" | List Element does not exist. Or, Node specified by Node Code List does not exist.");
PrintAndLogEx(INFO, " A7 | Illegal Block List (Access Mode) : Access Mode specified by Block List Element is incorrect.");
PrintAndLogEx(INFO, " A8 | Illegal Block Number Block Number (access to the specified data is inhibited) :\n"
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
" | specified by Block List Element exceeds the number of Blocks assigned to Service.");
PrintAndLogEx(INFO, " A9 | Data write failure : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AA | Key-change failure : Key change failed.");
PrintAndLogEx(INFO, " AB | Illegal Package Parity or illegal Package MAC : This is the error that occurs in issuance commands.");
@@ -105,7 +105,7 @@ static void print_status_flag2_interpration(void) {
PrintAndLogEx(INFO, " AD | Service exists already : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AE | Illegal System Code : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " AF | Too many simultaneous cyclic write operations : Number of simultaneous write Blocks\n"
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
" | specified by the command to Cyclic Service exceeds the number of Blocks assigned to Service.");
PrintAndLogEx(INFO, " C0 | Illegal Package Identifier : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " C1 | Discrepancy of parameters inside and outside Package : This is the error that occurs in issuance commands.");
PrintAndLogEx(INFO, " C2 | Command is disabled already : This is the error that occurs in issuance commands.");
@@ -129,16 +129,16 @@ static void print_number_of_service_constraints(void) {
static void print_number_of_block_constraints(void) {
PrintAndLogEx(INFO, " - Number of Block: shall be less than or equal to the maximum number of Blocks that can be read simultaneously.\n"
" The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n"
" Use as default 01");
" The maximum number of Blocks that can be read simultaneously can differ, depending on the product being used.\n"
" Use as default 01");
}
static void print_service_code_list_constraints(void) {
PrintAndLogEx(INFO, " - Service Code List: For Service Code List, only Service Code existing in the product shall be specified:");
PrintAndLogEx(INFO, " - Even when Service Code exists in the product, Service Code not referenced from Block List shall not \n"
" be specified to Service Code List.");
" be specified to Service Code List.");
PrintAndLogEx(INFO, " - For existence or nonexistence of Service in a product, please check using the Request Service \n"
" (or Request Service v2) command.");
" (or Request Service v2) command.");
}
/*
@@ -565,7 +565,7 @@ int send_rd_plain(uint8_t flags, uint16_t datalen, uint8_t *data, bool verbose,
return PM3_ERFTRANS;
} else {
memcpy(rd_noCry_resp, (felica_read_without_encryption_response_t *)resp.data.asBytes, sizeof(felica_read_without_encryption_response_t));
if (rd_noCry_resp->frame_response.cmd_code[0] != 0x07) {
if (rd_noCry_resp->frame_response.cmd_code[0] != 0x07) {
PrintAndLogEx(FAILED, "Bad response cmd 0x%02X @ 0x%04X.",
rd_noCry_resp->frame_response.cmd_code[0], 0x00);
PrintAndLogEx(INFO, "This is either a normal signal issue, or an issue caused by wrong parameter. Please try again.");

Some files were not shown because too many files have changed in this diff Show More