mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-10-22 17:32:33 +00:00
make style
This commit is contained in:
1 parent
9648c078c1
commit
c00e4801b7
48 files changed
+1479
-1490
No files matched your search
+4
-4
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -9,78 +9,78 @@
|
||||
#include "verify_espresso.h"
|
||||
|
||||
#if !defined true
|
||||
#define true ((bool)1u)
|
||||
#define true ((bool)1u)
|
||||
#endif
|
||||
#if !defined false
|
||||
#define false ((bool)0u)
|
||||
#define false ((bool)0u)
|
||||
#endif
|
||||
|
||||
#if 1 // constant names for use in LUT_PLA_NAMES_xx
|
||||
static const char * const NAME_A = "a";
|
||||
static const char * const NAME_B = "b";
|
||||
static const char * const NAME_C = "c";
|
||||
static const char * const NAME_L0 = "l0";
|
||||
static const char * const NAME_L2 = "l2";
|
||||
static const char * const NAME_L3 = "l3";
|
||||
static const char * const NAME_L4 = "l4";
|
||||
static const char * const NAME_L5 = "l5";
|
||||
static const char * const NAME_L6 = "l6";
|
||||
static const char * const NAME_M0 = "m0";
|
||||
static const char * const NAME_M1 = "m1";
|
||||
static const char * const NAME_M3 = "m3";
|
||||
static const char * const NAME_M5 = "m5";
|
||||
static const char * const NAME_R0 = "r0";
|
||||
static const char * const NAME_R1 = "r1";
|
||||
static const char * const NAME_R2 = "r2";
|
||||
static const char * const NAME_R3 = "r3";
|
||||
static const char * const NAME_R4 = "r4";
|
||||
static const char * const NAME_R5 = "r5";
|
||||
static const char * const NAME_R6 = "r6";
|
||||
static const char *const NAME_A = "a";
|
||||
static const char *const NAME_B = "b";
|
||||
static const char *const NAME_C = "c";
|
||||
static const char *const NAME_L0 = "l0";
|
||||
static const char *const NAME_L2 = "l2";
|
||||
static const char *const NAME_L3 = "l3";
|
||||
static const char *const NAME_L4 = "l4";
|
||||
static const char *const NAME_L5 = "l5";
|
||||
static const char *const NAME_L6 = "l6";
|
||||
static const char *const NAME_M0 = "m0";
|
||||
static const char *const NAME_M1 = "m1";
|
||||
static const char *const NAME_M3 = "m3";
|
||||
static const char *const NAME_M5 = "m5";
|
||||
static const char *const NAME_R0 = "r0";
|
||||
static const char *const NAME_R1 = "r1";
|
||||
static const char *const NAME_R2 = "r2";
|
||||
static const char *const NAME_R3 = "r3";
|
||||
static const char *const NAME_R4 = "r4";
|
||||
static const char *const NAME_R5 = "r5";
|
||||
static const char *const NAME_R6 = "r6";
|
||||
#endif // constant names for use in LUT_PLA_NAMES_xx
|
||||
#if 1 // LUT_PLA_NAMES_xx -- name arrays for generating espresso input files
|
||||
// NOTE: these arrays are in order of the most significant to least significant bit.
|
||||
// did i get confused by that?
|
||||
const char * const LUT_PLA_NAMES_g1[5] = { NAME_A , NAME_L2, NAME_L3, NAME_L0, NAME_L6, };
|
||||
const char * const LUT_PLA_NAMES_g2[5] = { NAME_L5, NAME_B , NAME_M0, NAME_L4, NAME_M1, };
|
||||
const char * const LUT_PLA_NAMES_g3[5] = { NAME_M5, NAME_C , NAME_R1, NAME_M3, NAME_R3, };
|
||||
const char * const LUT_PLA_NAMES_g4[5] = { NAME_R2, NAME_R4, NAME_R6, NAME_R0, NAME_R5, };
|
||||
const char * const LUT_PLA_NAMES_XX[8] = {
|
||||
NAME_L0, NAME_L4, NAME_L6, NAME_M1,
|
||||
NAME_M3, NAME_R0, NAME_R3, NAME_R5,
|
||||
};
|
||||
// NOTE: these arrays are in order of the most significant to least significant bit.
|
||||
// did i get confused by that?
|
||||
const char *const LUT_PLA_NAMES_g1[5] = { NAME_A, NAME_L2, NAME_L3, NAME_L0, NAME_L6, };
|
||||
const char *const LUT_PLA_NAMES_g2[5] = { NAME_L5, NAME_B, NAME_M0, NAME_L4, NAME_M1, };
|
||||
const char *const LUT_PLA_NAMES_g3[5] = { NAME_M5, NAME_C, NAME_R1, NAME_M3, NAME_R3, };
|
||||
const char *const LUT_PLA_NAMES_g4[5] = { NAME_R2, NAME_R4, NAME_R6, NAME_R0, NAME_R5, };
|
||||
const char *const LUT_PLA_NAMES_XX[8] = {
|
||||
NAME_L0, NAME_L4, NAME_L6, NAME_M1,
|
||||
NAME_M3, NAME_R0, NAME_R3, NAME_R5,
|
||||
};
|
||||
#endif // LUT_PLA_NAMES_xx -- name arrays for generating espresso input files
|
||||
|
||||
#if 1 // actual lookup tables
|
||||
// LUTs were internal-only, and not even exposed to library internals.
|
||||
// so just copy/paste here for now for initial testing
|
||||
/// initial_idx = (l0 << 7) | (l4 << 6) | (l6 << 5) | (m1 << 4) | (m3 << 3) | (r0 << 2) | (r3 << 1) | (r5 << 0)
|
||||
static const uint8_t small_lut_XX[32] = { // aka 256 bits
|
||||
0x44, 0xff, 0x4f, 0x4f, 0x55, 0xff, 0x55, 0x55,
|
||||
0xcc, 0xff, 0xcf, 0x4f, 0xcc, 0xff, 0xcc, 0x44,
|
||||
0x00, 0x00, 0x0f, 0x0f, 0x55, 0x55, 0x55, 0x55,
|
||||
0xcc, 0x00, 0xcf, 0x0f, 0xcc, 0x00, 0xcc, 0x00,
|
||||
};
|
||||
/// g1_idx = (a << 4) | (l2 << 3) | (l3 << 2) | (l0 << 1) | (l6 << 0)
|
||||
static const uint8_t small_lut_group1[4] = { // aka 32 bits
|
||||
0x4f, 0x92, 0xa1, 0x7c,
|
||||
};
|
||||
/// g2_idx = (l5 << 4) | (b << 3) | (m0 << 2) | (l4 << 1) | (m1 << 0)
|
||||
static const uint8_t small_lut_group2[4] = { // aka 32 bits
|
||||
0x8f, 0x52, 0x61, 0xbc,
|
||||
};
|
||||
/// g3_idx = (m5 << 4) | (c << 3) | (r1 << 2) | (m3 << 1) | (r3 << 0)
|
||||
static const uint8_t small_lut_group3[4] = { // aka 32 bits
|
||||
0x8f, 0x34, 0x61, 0xda,
|
||||
};
|
||||
/// g4_idx = (r2 << 4) | (r4 << 3) | (r6 << 2) | (r0 << 1) | (r5 << 0)
|
||||
static const uint8_t small_lut_group4[4] = { // aka 32 bits
|
||||
0x8f, 0x34, 0x52, 0xe9,
|
||||
};
|
||||
static inline bool get_bit(const uint8_t *table_start, uint32_t bit_idx) {
|
||||
const uint32_t byte = bit_idx / 8u;
|
||||
const uint8_t mask = 1u << (bit_idx % 8u);
|
||||
return (table_start[byte] & mask) != 0;
|
||||
}
|
||||
// LUTs were internal-only, and not even exposed to library internals.
|
||||
// so just copy/paste here for now for initial testing
|
||||
/// initial_idx = (l0 << 7) | (l4 << 6) | (l6 << 5) | (m1 << 4) | (m3 << 3) | (r0 << 2) | (r3 << 1) | (r5 << 0)
|
||||
static const uint8_t small_lut_XX[32] = { // aka 256 bits
|
||||
0x44, 0xff, 0x4f, 0x4f, 0x55, 0xff, 0x55, 0x55,
|
||||
0xcc, 0xff, 0xcf, 0x4f, 0xcc, 0xff, 0xcc, 0x44,
|
||||
0x00, 0x00, 0x0f, 0x0f, 0x55, 0x55, 0x55, 0x55,
|
||||
0xcc, 0x00, 0xcf, 0x0f, 0xcc, 0x00, 0xcc, 0x00,
|
||||
};
|
||||
/// g1_idx = (a << 4) | (l2 << 3) | (l3 << 2) | (l0 << 1) | (l6 << 0)
|
||||
static const uint8_t small_lut_group1[4] = { // aka 32 bits
|
||||
0x4f, 0x92, 0xa1, 0x7c,
|
||||
};
|
||||
/// g2_idx = (l5 << 4) | (b << 3) | (m0 << 2) | (l4 << 1) | (m1 << 0)
|
||||
static const uint8_t small_lut_group2[4] = { // aka 32 bits
|
||||
0x8f, 0x52, 0x61, 0xbc,
|
||||
};
|
||||
/// g3_idx = (m5 << 4) | (c << 3) | (r1 << 2) | (m3 << 1) | (r3 << 0)
|
||||
static const uint8_t small_lut_group3[4] = { // aka 32 bits
|
||||
0x8f, 0x34, 0x61, 0xda,
|
||||
};
|
||||
/// g4_idx = (r2 << 4) | (r4 << 3) | (r6 << 2) | (r0 << 1) | (r5 << 0)
|
||||
static const uint8_t small_lut_group4[4] = { // aka 32 bits
|
||||
0x8f, 0x34, 0x52, 0xe9,
|
||||
};
|
||||
static inline bool get_bit(const uint8_t *table_start, uint32_t bit_idx) {
|
||||
const uint32_t byte = bit_idx / 8u;
|
||||
const uint8_t mask = 1u << (bit_idx % 8u);
|
||||
return (table_start[byte] & mask) != 0;
|
||||
}
|
||||
#endif // actual lookup tables
|
||||
|
||||
|
||||
@@ -217,9 +217,9 @@ typedef struct _INDEX_XX {
|
||||
|
||||
typedef struct _ESPRESSO_GENERATOR_ARGUMENTS {
|
||||
uint8_t const input_count;
|
||||
char const * const * names;
|
||||
char const * const output_name;
|
||||
uint8_t const * lut_start;
|
||||
char const *const *names;
|
||||
char const *const output_name;
|
||||
uint8_t const *lut_start;
|
||||
} ESPRESSO_GENERATOR_ARGUMENTS;
|
||||
|
||||
static bool verify_lut_g1(void);
|
||||
@@ -243,16 +243,16 @@ static bool espresso_implementation_g1_alt0(uint8_t idx) {
|
||||
bool l0 = idx & (1u << 1);
|
||||
bool l6 = idx & (1u << 0);
|
||||
return
|
||||
( a && l2 && _ && l0 && !(l6) ) ||
|
||||
( a && _ && l3 && !(l0) && l6 ) ||
|
||||
( !(a) && !(l2) && !(l3) && _ && _ ) ||
|
||||
( _ && !(l2) && !(l3) && !(l0) && !(l6) ) ||
|
||||
( _ && l2 && l3 && !(l0) && !(l6) ) ||
|
||||
( !(a) && !(l2) && _ && l0 && !(l6) ) ||
|
||||
( !(a) && _ && !(l3) && !(l0) && l6 ) ||
|
||||
( a && l2 && !(l3) && l0 && _ ) ||
|
||||
( a && !(l2) && l3 && _ && l6 ) ||
|
||||
( !(a) && l2 && l3 && l0 && l6 ) ;
|
||||
(a && l2 && _ && l0 && !(l6)) ||
|
||||
(a && _ && l3 && !(l0) && l6) ||
|
||||
(!(a) && !(l2) && !(l3) && _ && _) ||
|
||||
(_ && !(l2) && !(l3) && !(l0) && !(l6)) ||
|
||||
(_ && l2 && l3 && !(l0) && !(l6)) ||
|
||||
(!(a) && !(l2) && _ && l0 && !(l6)) ||
|
||||
(!(a) && _ && !(l3) && !(l0) && l6) ||
|
||||
(a && l2 && !(l3) && l0 && _) ||
|
||||
(a && !(l2) && l3 && _ && l6) ||
|
||||
(!(a) && l2 && l3 && l0 && l6) ;
|
||||
}
|
||||
static bool espresso_implementation_g1_alt1(uint8_t idx) {
|
||||
// output_g1 = (a&l2&l0&!l6) | (a&l3&!l0&l6) | (!a&!l2&!l3) | (!l2&!l3&!l0&!l6) | (l2&l3&!l0&!l6) | (!a&!l2&l0&!l6) | (!a&!l3&!l0&l6) | (a&l2&!l3&l0) | (a&!l2&l3&l6) | (!a&l2&l3&l0&l6);
|
||||
@@ -264,16 +264,16 @@ static bool espresso_implementation_g1_alt1(uint8_t idx) {
|
||||
bool l0 = t.l0;
|
||||
bool l6 = t.l6;
|
||||
return
|
||||
( a && l0 && l2 && _ && !(l6) ) ||
|
||||
( a && !(l0) && _ && l3 && l6 ) ||
|
||||
( !(a) && _ && !(l2) && !(l3) && _ ) ||
|
||||
( _ && !(l0) && !(l2) && !(l3) && !(l6) ) ||
|
||||
( _ && !(l0) && l2 && l3 && !(l6) ) ||
|
||||
( !(a) && l0 && !(l2) && _ && !(l6) ) ||
|
||||
( !(a) && !(l0) && _ && !(l3) && l6 ) ||
|
||||
( a && l0 && l2 && !(l3) && _ ) ||
|
||||
( a && _ && !(l2) && l3 && l6 ) ||
|
||||
( !(a) && l0 && l2 && l3 && l6 ) ;
|
||||
(a && l0 && l2 && _ && !(l6)) ||
|
||||
(a && !(l0) && _ && l3 && l6) ||
|
||||
(!(a) && _ && !(l2) && !(l3) && _) ||
|
||||
(_ && !(l0) && !(l2) && !(l3) && !(l6)) ||
|
||||
(_ && !(l0) && l2 && l3 && !(l6)) ||
|
||||
(!(a) && l0 && !(l2) && _ && !(l6)) ||
|
||||
(!(a) && !(l0) && _ && !(l3) && l6) ||
|
||||
(a && l0 && l2 && !(l3) && _) ||
|
||||
(a && _ && !(l2) && l3 && l6) ||
|
||||
(!(a) && l0 && l2 && l3 && l6) ;
|
||||
}
|
||||
static const lookuptable_func_t alt_for_g1[] = {
|
||||
espresso_implementation_g1_alt0,
|
||||
@@ -290,17 +290,17 @@ static bool espresso_implementation_g2_alt0(uint8_t idx) {
|
||||
bool l4 = idx & (1u << 1);
|
||||
bool m1 = idx & (1u << 0);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && b && m0 && !(l4) && !(m1) ) |
|
||||
( l5 && b && _ && l4 && m1 ) |
|
||||
( !(l5) && !(b) && !(m0) && _ && _ ) |
|
||||
( _ && !(b) && !(m0) && !(l4) && !(m1) ) |
|
||||
( l5 && b && !(m0) && l4 && _ ) |
|
||||
( l5 && !(b) && m0 && l4 && !(m1) ) |
|
||||
( !(l5) && b && m0 && _ && !(m1) ) |
|
||||
( !(l5) && _ && !(m0) && !(l4) && m1 ) |
|
||||
( l5 && _ && m0 && !(l4) && m1 ) |
|
||||
( !(l5) && !(b) && _ && l4 && m1 ) ;
|
||||
return
|
||||
(_ && b && m0 && !(l4) && !(m1)) |
|
||||
(l5 && b && _ && l4 && m1) |
|
||||
(!(l5) && !(b) && !(m0) && _ && _) |
|
||||
(_ && !(b) && !(m0) && !(l4) && !(m1)) |
|
||||
(l5 && b && !(m0) && l4 && _) |
|
||||
(l5 && !(b) && m0 && l4 && !(m1)) |
|
||||
(!(l5) && b && m0 && _ && !(m1)) |
|
||||
(!(l5) && _ && !(m0) && !(l4) && m1) |
|
||||
(l5 && _ && m0 && !(l4) && m1) |
|
||||
(!(l5) && !(b) && _ && l4 && m1) ;
|
||||
}
|
||||
static bool espresso_implementation_g2_alt1(uint8_t idx) {
|
||||
// output_g2 = (b&m0&!l4&!m1) | (l5&b&l4&m1) | (!l5&!b&!m0) | (!b&!m0&!l4&!m1) | (l5&b&!m0&l4) | (l5&!b&m0&l4&!m1) | (!l5&b&m0&!m1) | (!l5&!m0&!l4&m1) | (l5&m0&!l4&m1) | (!l5&!b&l4&m1);
|
||||
@@ -311,17 +311,17 @@ static bool espresso_implementation_g2_alt1(uint8_t idx) {
|
||||
bool l4 = t.l4;
|
||||
bool m1 = t.m1;
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && b && m0 && !(l4) && !(m1) ) |
|
||||
( l5 && b && _ && l4 && m1 ) |
|
||||
( !(l5) && !(b) && !(m0) && _ && _ ) |
|
||||
( _ && !(b) && !(m0) && !(l4) && !(m1) ) |
|
||||
( l5 && b && !(m0) && l4 && _ ) |
|
||||
( l5 && !(b) && m0 && l4 && !(m1) ) |
|
||||
( !(l5) && b && m0 && _ && !(m1) ) |
|
||||
( !(l5) && _ && !(m0) && !(l4) && m1 ) |
|
||||
( l5 && _ && m0 && !(l4) && m1 ) |
|
||||
( !(l5) && !(b) && _ && l4 && m1 ) ;
|
||||
return
|
||||
(_ && b && m0 && !(l4) && !(m1)) |
|
||||
(l5 && b && _ && l4 && m1) |
|
||||
(!(l5) && !(b) && !(m0) && _ && _) |
|
||||
(_ && !(b) && !(m0) && !(l4) && !(m1)) |
|
||||
(l5 && b && !(m0) && l4 && _) |
|
||||
(l5 && !(b) && m0 && l4 && !(m1)) |
|
||||
(!(l5) && b && m0 && _ && !(m1)) |
|
||||
(!(l5) && _ && !(m0) && !(l4) && m1) |
|
||||
(l5 && _ && m0 && !(l4) && m1) |
|
||||
(!(l5) && !(b) && _ && l4 && m1) ;
|
||||
}
|
||||
|
||||
static const lookuptable_func_t alt_for_g2[] = {
|
||||
@@ -341,16 +341,16 @@ static bool espresso_implementation_g3_alt0(uint8_t idx) {
|
||||
bool r3 = idx & (1u << 0);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && c && r1 && !(m3) && !(r3) ) ||
|
||||
( m5 && c && _ && m3 && r3 ) ||
|
||||
( !(m5) && !(c) && !(r1) && _ && _ ) ||
|
||||
( _ && !(c) && !(r1) && !(m3) && !(r3) ) ||
|
||||
( !(m5) && _ && !(r1) && m3 && !(r3) ) ||
|
||||
( m5 && _ && r1 && m3 && !(r3) ) ||
|
||||
( m5 && c && !(r1) && _ && r3 ) ||
|
||||
( m5 && !(c) && r1 && !(m3) && r3 ) ||
|
||||
( !(m5) && c && r1 && !(m3) && _ ) ||
|
||||
( !(m5) && !(c) && _ && m3 && r3 ) ;
|
||||
(_ && c && r1 && !(m3) && !(r3)) ||
|
||||
(m5 && c && _ && m3 && r3) ||
|
||||
(!(m5) && !(c) && !(r1) && _ && _) ||
|
||||
(_ && !(c) && !(r1) && !(m3) && !(r3)) ||
|
||||
(!(m5) && _ && !(r1) && m3 && !(r3)) ||
|
||||
(m5 && _ && r1 && m3 && !(r3)) ||
|
||||
(m5 && c && !(r1) && _ && r3) ||
|
||||
(m5 && !(c) && r1 && !(m3) && r3) ||
|
||||
(!(m5) && c && r1 && !(m3) && _) ||
|
||||
(!(m5) && !(c) && _ && m3 && r3) ;
|
||||
}
|
||||
static bool espresso_implementation_g3_alt1(uint8_t idx) {
|
||||
// output_g3 = (c&r1&!m3&!r3) | (m5&c&m3&r3) | (!m5&!c&!r1) | (!c&!r1&!m3&!r3) | (!m5&!r1&m3&!r3) | (m5&r1&m3&!r3) | (m5&c&!r1&r3) | (m5&!c&r1&!m3&r3) | (!m5&c&r1&!m3) | (!m5&!c&m3&r3);
|
||||
@@ -362,16 +362,16 @@ static bool espresso_implementation_g3_alt1(uint8_t idx) {
|
||||
bool m5 = t.m5;
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && c && r1 && !(m3) && !(r3) ) ||
|
||||
( m5 && c && _ && m3 && r3 ) ||
|
||||
( !(m5) && !(c) && !(r1) && _ && _ ) ||
|
||||
( _ && !(c) && !(r1) && !(m3) && !(r3) ) ||
|
||||
( !(m5) && _ && !(r1) && m3 && !(r3) ) ||
|
||||
( m5 && _ && r1 && m3 && !(r3) ) ||
|
||||
( m5 && c && !(r1) && _ && r3 ) ||
|
||||
( m5 && !(c) && r1 && !(m3) && r3 ) ||
|
||||
( !(m5) && c && r1 && !(m3) && _ ) ||
|
||||
( !(m5) && !(c) && _ && m3 && r3 ) ;
|
||||
(_ && c && r1 && !(m3) && !(r3)) ||
|
||||
(m5 && c && _ && m3 && r3) ||
|
||||
(!(m5) && !(c) && !(r1) && _ && _) ||
|
||||
(_ && !(c) && !(r1) && !(m3) && !(r3)) ||
|
||||
(!(m5) && _ && !(r1) && m3 && !(r3)) ||
|
||||
(m5 && _ && r1 && m3 && !(r3)) ||
|
||||
(m5 && c && !(r1) && _ && r3) ||
|
||||
(m5 && !(c) && r1 && !(m3) && r3) ||
|
||||
(!(m5) && c && r1 && !(m3) && _) ||
|
||||
(!(m5) && !(c) && _ && m3 && r3) ;
|
||||
}
|
||||
|
||||
static const lookuptable_func_t alt_for_g3[] = {
|
||||
@@ -389,16 +389,16 @@ static bool espresso_implementation_g4_alt0(uint8_t idx) {
|
||||
bool r5 = idx & (1u << 0);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( r2 && _ && r6 && r0 && !(r5) ) |
|
||||
( _ && r4 && r6 && !(r0) && r5 ) |
|
||||
( !(r2) && !(r4) && !(r6) && _ && _ ) |
|
||||
( r2 && r4 && !(r6) && !(r0) && !(r5) ) |
|
||||
( r2 && !(r4) && r6 && _ && !(r5) ) |
|
||||
( !(r2) && r4 && r6 && !(r0) && _ ) |
|
||||
( !(r2) && _ && !(r6) && r0 && !(r5) ) |
|
||||
( _ && !(r4) && !(r6) && !(r0) && r5 ) |
|
||||
( r2 && r4 && _ && r0 && r5 ) |
|
||||
( !(r2) && !(r4) && _ && r0 && r5 ) ;
|
||||
(r2 && _ && r6 && r0 && !(r5)) |
|
||||
(_ && r4 && r6 && !(r0) && r5) |
|
||||
(!(r2) && !(r4) && !(r6) && _ && _) |
|
||||
(r2 && r4 && !(r6) && !(r0) && !(r5)) |
|
||||
(r2 && !(r4) && r6 && _ && !(r5)) |
|
||||
(!(r2) && r4 && r6 && !(r0) && _) |
|
||||
(!(r2) && _ && !(r6) && r0 && !(r5)) |
|
||||
(_ && !(r4) && !(r6) && !(r0) && r5) |
|
||||
(r2 && r4 && _ && r0 && r5) |
|
||||
(!(r2) && !(r4) && _ && r0 && r5) ;
|
||||
}
|
||||
static bool espresso_implementation_g4_alt1(uint8_t idx) {
|
||||
// output_g4 = (r2&r6&r0&!r5) | (r4&r6&!r0&r5) | (!r2&!r4&!r6) | (r2&r4&!r6&!r0&!r5) | (r2&!r4&r6&!r5) | (!r2&r4&r6&!r0) | (!r2&!r6&r0&!r5) | (!r4&!r6&!r0&r5) | (r2&r4&r0&r5) | (!r2&!r4&r0&r5);
|
||||
@@ -411,16 +411,16 @@ static bool espresso_implementation_g4_alt1(uint8_t idx) {
|
||||
bool r5 = t.r5;
|
||||
static const bool _ = true;
|
||||
return
|
||||
( r2 && _ && r6 && r0 && !(r5) ) |
|
||||
( _ && r4 && r6 && !(r0) && r5 ) |
|
||||
( !(r2) && !(r4) && !(r6) && _ && _ ) |
|
||||
( r2 && r4 && !(r6) && !(r0) && !(r5) ) |
|
||||
( r2 && !(r4) && r6 && _ && !(r5) ) |
|
||||
( !(r2) && r4 && r6 && !(r0) && _ ) |
|
||||
( !(r2) && _ && !(r6) && r0 && !(r5) ) |
|
||||
( _ && !(r4) && !(r6) && !(r0) && r5 ) |
|
||||
( r2 && r4 && _ && r0 && r5 ) |
|
||||
( !(r2) && !(r4) && _ && r0 && r5 ) ;
|
||||
(r2 && _ && r6 && r0 && !(r5)) |
|
||||
(_ && r4 && r6 && !(r0) && r5) |
|
||||
(!(r2) && !(r4) && !(r6) && _ && _) |
|
||||
(r2 && r4 && !(r6) && !(r0) && !(r5)) |
|
||||
(r2 && !(r4) && r6 && _ && !(r5)) |
|
||||
(!(r2) && r4 && r6 && !(r0) && _) |
|
||||
(!(r2) && _ && !(r6) && r0 && !(r5)) |
|
||||
(_ && !(r4) && !(r6) && !(r0) && r5) |
|
||||
(r2 && r4 && _ && r0 && r5) |
|
||||
(!(r2) && !(r4) && _ && r0 && r5) ;
|
||||
}
|
||||
|
||||
static const lookuptable_func_t alt_for_g4[] = {
|
||||
@@ -442,11 +442,11 @@ static bool espresso_implementation_xx_alt0(uint8_t idx) {
|
||||
bool r5 = idx & (1u << 0);
|
||||
|
||||
return
|
||||
( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) ||
|
||||
( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) ||
|
||||
( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) ||
|
||||
( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) ||
|
||||
( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) ) ;
|
||||
(_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) ||
|
||||
(_ && l4 && _ && _ && !(m3) && _ && r3 && _) ||
|
||||
(_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) ||
|
||||
(!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) ||
|
||||
(!(l0) && _ && _ && _ && _ && _ && r3 && !(r5)) ;
|
||||
}
|
||||
static bool espresso_implementation_xx_alt1(uint8_t idx) {
|
||||
// output_XX = (!l6&m1&!r0) | (l4&!m3&r3) | (!l4&l6&!r5) | (!l0&!m1&m3) | (!l0&r3&!r5);
|
||||
@@ -462,11 +462,11 @@ static bool espresso_implementation_xx_alt1(uint8_t idx) {
|
||||
bool r3 = t.r3;
|
||||
bool r5 = t.r5;
|
||||
return
|
||||
( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) ||
|
||||
( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) ||
|
||||
( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) ||
|
||||
( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) ||
|
||||
( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) ) ;
|
||||
(_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) ||
|
||||
(_ && l4 && _ && _ && !(m3) && _ && r3 && _) ||
|
||||
(_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) ||
|
||||
(!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) ||
|
||||
(!(l0) && _ && _ && _ && _ && _ && r3 && !(r5)) ;
|
||||
}
|
||||
|
||||
static const lookuptable_func_t alt_for_xx[] = {
|
||||
@@ -478,10 +478,10 @@ static const lookuptable_func_t alt_for_xx[] = {
|
||||
|
||||
typedef struct _VERIFICATION_T {
|
||||
uint8_t const input_count;
|
||||
char const * const * names;
|
||||
char const * const output_name;
|
||||
uint8_t const * lut_start;
|
||||
lookuptable_func_t const * const altFns;
|
||||
char const *const *names;
|
||||
char const *const output_name;
|
||||
uint8_t const *lut_start;
|
||||
lookuptable_func_t const *const altFns;
|
||||
size_t const altFnCount;
|
||||
} VERIFICATION_T;
|
||||
|
||||
@@ -491,7 +491,7 @@ VERIFICATION_T const verification_table[] = {
|
||||
{ .input_count = 5, .names = LUT_PLA_NAMES_g2, .output_name = "g2", .lut_start = small_lut_group2, .altFns = alt_for_g2, .altFnCount = ARRAY_SIZE2(alt_for_g2) },
|
||||
{ .input_count = 5, .names = LUT_PLA_NAMES_g3, .output_name = "g3", .lut_start = small_lut_group3, .altFns = alt_for_g3, .altFnCount = ARRAY_SIZE2(alt_for_g3) },
|
||||
{ .input_count = 5, .names = LUT_PLA_NAMES_g4, .output_name = "g4", .lut_start = small_lut_group4, .altFns = alt_for_g4, .altFnCount = ARRAY_SIZE2(alt_for_g4) },
|
||||
{ .input_count = 8, .names = LUT_PLA_NAMES_XX, .output_name = "xx", .lut_start = small_lut_XX , .altFns = alt_for_xx, .altFnCount = ARRAY_SIZE2(alt_for_xx) },
|
||||
{ .input_count = 8, .names = LUT_PLA_NAMES_XX, .output_name = "xx", .lut_start = small_lut_XX, .altFns = alt_for_xx, .altFnCount = ARRAY_SIZE2(alt_for_xx) },
|
||||
};
|
||||
|
||||
|
||||
@@ -499,84 +499,83 @@ static bool espresso_implementation_g1(bool a, bool l0, bool l2, bool l3, bool
|
||||
// output_g1 = (a&l2&l0&!l6) | (a&l3&!l0&l6) | (!a&!l2&!l3) | (!l2&!l3&!l0&!l6) | (l2&l3&!l0&!l6) | (!a&!l2&l0&!l6) | (!a&!l3&!l0&l6) | (a&l2&!l3&l0) | (a&!l2&l3&l6) | (!a&l2&l3&l0&l6);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( a && l0 && l2 && _ && !(l6) ) |
|
||||
( a && !(l0) && _ && l3 && l6 ) |
|
||||
( !(a) && _ && !(l2) && !(l3) && _ ) |
|
||||
( _ && !(l0) && !(l2) && !(l3) && !(l6) ) |
|
||||
( _ && !(l0) && l2 && l3 && !(l6) ) |
|
||||
( !(a) && l0 && !(l2) && _ && !(l6) ) |
|
||||
( !(a) && !(l0) && _ && !(l3) && l6 ) |
|
||||
( a && l0 && l2 && !(l3) && _ ) |
|
||||
( a && _ && !(l2) && l3 && l6 ) |
|
||||
( !(a) && l0 && l2 && l3 && l6 ) ;
|
||||
(a && l0 && l2 && _ && !(l6)) |
|
||||
(a && !(l0) && _ && l3 && l6) |
|
||||
(!(a) && _ && !(l2) && !(l3) && _) |
|
||||
(_ && !(l0) && !(l2) && !(l3) && !(l6)) |
|
||||
(_ && !(l0) && l2 && l3 && !(l6)) |
|
||||
(!(a) && l0 && !(l2) && _ && !(l6)) |
|
||||
(!(a) && !(l0) && _ && !(l3) && l6) |
|
||||
(a && l0 && l2 && !(l3) && _) |
|
||||
(a && _ && !(l2) && l3 && l6) |
|
||||
(!(a) && l0 && l2 && l3 && l6) ;
|
||||
}
|
||||
static bool espresso_implementation_g2(bool b, bool l4, bool l5, bool m0, bool m1) {
|
||||
// output_g2 = (b&m0&!l4&!m1) | (l5&b&l4&m1) | (!l5&!b&!m0) | (!b&!m0&!l4&!m1) | (l5&b&!m0&l4) | (l5&!b&m0&l4&!m1) | (!l5&b&m0&!m1) | (!l5&!m0&!l4&m1) | (l5&m0&!l4&m1) | (!l5&!b&l4&m1);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && b && m0 && !(l4) && !(m1) ) |
|
||||
( l5 && b && _ && l4 && m1 ) |
|
||||
( !(l5) && !(b) && !(m0) && _ && _ ) |
|
||||
( _ && !(b) && !(m0) && !(l4) && !(m1) ) |
|
||||
( l5 && b && !(m0) && l4 && _ ) |
|
||||
( l5 && !(b) && m0 && l4 && !(m1) ) |
|
||||
( !(l5) && b && m0 && _ && !(m1) ) |
|
||||
( !(l5) && _ && !(m0) && !(l4) && m1 ) |
|
||||
( l5 && _ && m0 && !(l4) && m1 ) |
|
||||
( !(l5) && !(b) && _ && l4 && m1 ) ;
|
||||
return
|
||||
(_ && b && m0 && !(l4) && !(m1)) |
|
||||
(l5 && b && _ && l4 && m1) |
|
||||
(!(l5) && !(b) && !(m0) && _ && _) |
|
||||
(_ && !(b) && !(m0) && !(l4) && !(m1)) |
|
||||
(l5 && b && !(m0) && l4 && _) |
|
||||
(l5 && !(b) && m0 && l4 && !(m1)) |
|
||||
(!(l5) && b && m0 && _ && !(m1)) |
|
||||
(!(l5) && _ && !(m0) && !(l4) && m1) |
|
||||
(l5 && _ && m0 && !(l4) && m1) |
|
||||
(!(l5) && !(b) && _ && l4 && m1) ;
|
||||
}
|
||||
static bool espresso_implementation_g3(bool c, bool r1, bool r3, bool m3, bool m5) {
|
||||
// output_g3 = (c&r1&!m3&!r3) | (m5&c&m3&r3) | (!m5&!c&!r1) | (!c&!r1&!m3&!r3) | (!m5&!r1&m3&!r3) | (m5&r1&m3&!r3) | (m5&c&!r1&r3) | (m5&!c&r1&!m3&r3) | (!m5&c&r1&!m3) | (!m5&!c&m3&r3);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && c && r1 && !(m3) && !(r3) ) |
|
||||
( m5 && c && _ && m3 && r3 ) |
|
||||
( !(m5) && !(c) && !(r1) && _ && _ ) |
|
||||
( _ && !(c) && !(r1) && !(m3) && !(r3) ) |
|
||||
( !(m5) && _ && !(r1) && m3 && !(r3) ) |
|
||||
( m5 && _ && r1 && m3 && !(r3) ) |
|
||||
( m5 && c && !(r1) && _ && r3 ) |
|
||||
( m5 && !(c) && r1 && !(m3) && r3 ) |
|
||||
( !(m5) && c && r1 && !(m3) && _ ) |
|
||||
( !(m5) && !(c) && _ && m3 && r3 ) ;
|
||||
(_ && c && r1 && !(m3) && !(r3)) |
|
||||
(m5 && c && _ && m3 && r3) |
|
||||
(!(m5) && !(c) && !(r1) && _ && _) |
|
||||
(_ && !(c) && !(r1) && !(m3) && !(r3)) |
|
||||
(!(m5) && _ && !(r1) && m3 && !(r3)) |
|
||||
(m5 && _ && r1 && m3 && !(r3)) |
|
||||
(m5 && c && !(r1) && _ && r3) |
|
||||
(m5 && !(c) && r1 && !(m3) && r3) |
|
||||
(!(m5) && c && r1 && !(m3) && _) |
|
||||
(!(m5) && !(c) && _ && m3 && r3) ;
|
||||
}
|
||||
static bool espresso_implementation_g4(bool r0, bool r2, bool r4, bool r5, bool r6) {
|
||||
// output_g4 = (r2&r6&r0&!r5) | (r4&r6&!r0&r5) | (!r2&!r4&!r6) | (r2&r4&!r6&!r0&!r5) | (r2&!r4&r6&!r5) | (!r2&r4&r6&!r0) | (!r2&!r6&r0&!r5) | (!r4&!r6&!r0&r5) | (r2&r4&r0&r5) | (!r2&!r4&r0&r5);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( r2 && _ && r6 && r0 && !(r5) ) |
|
||||
( _ && r4 && r6 && !(r0) && r5 ) |
|
||||
( !(r2) && !(r4) && !(r6) && _ && _ ) |
|
||||
( r2 && r4 && !(r6) && !(r0) && !(r5) ) |
|
||||
( r2 && !(r4) && r6 && _ && !(r5) ) |
|
||||
( !(r2) && r4 && r6 && !(r0) && _ ) |
|
||||
( !(r2) && _ && !(r6) && r0 && !(r5) ) |
|
||||
( _ && !(r4) && !(r6) && !(r0) && r5 ) |
|
||||
( r2 && r4 && _ && r0 && r5 ) |
|
||||
( !(r2) && !(r4) && _ && r0 && r5 ) ;
|
||||
(r2 && _ && r6 && r0 && !(r5)) |
|
||||
(_ && r4 && r6 && !(r0) && r5) |
|
||||
(!(r2) && !(r4) && !(r6) && _ && _) |
|
||||
(r2 && r4 && !(r6) && !(r0) && !(r5)) |
|
||||
(r2 && !(r4) && r6 && _ && !(r5)) |
|
||||
(!(r2) && r4 && r6 && !(r0) && _) |
|
||||
(!(r2) && _ && !(r6) && r0 && !(r5)) |
|
||||
(_ && !(r4) && !(r6) && !(r0) && r5) |
|
||||
(r2 && r4 && _ && r0 && r5) |
|
||||
(!(r2) && !(r4) && _ && r0 && r5) ;
|
||||
}
|
||||
static bool espresso_implementation_XX(bool l0, bool l4, bool l6, bool m1, bool m3, bool r0, bool r3, bool r5) {
|
||||
// output_XX = (!l6&m1&!r0) | (l4&!m3&r3) | (!l4&l6&!r5) | (!l0&!m1&m3) | (!l0&r3&!r5);
|
||||
static const bool _ = true;
|
||||
return
|
||||
( _ && _ && !(l6) && m1 && _ && !(r0) && _ && _ ) |
|
||||
( _ && l4 && _ && _ && !(m3) && _ && r3 && _ ) |
|
||||
( _ && !(l4) && l6 && _ && _ && _ && _ && !(r5) ) |
|
||||
( !(l0) && _ && _ && !(m1) && m3 && _ && _ && _ ) |
|
||||
( !(l0) && _ && _ && _ && _ && _ && r3 && !(r5) );
|
||||
(_ && _ && !(l6) && m1 && _ && !(r0) && _ && _) |
|
||||
(_ && l4 && _ && _ && !(m3) && _ && r3 && _) |
|
||||
(_ && !(l4) && l6 && _ && _ && _ && _ && !(r5)) |
|
||||
(!(l0) && _ && _ && !(m1) && m3 && _ && _ && _) |
|
||||
(!(l0) && _ && _ && _ && _ && _ && r3 && !(r5));
|
||||
}
|
||||
|
||||
static bool verify_alternatives(void)
|
||||
{
|
||||
static bool verify_alternatives(void) {
|
||||
bool any_failures_overall = false;
|
||||
|
||||
for (uint16_t q = 0; q < ARRAY_SIZE2(verification_table); ++q) {
|
||||
bool any_failures_this_table = false;
|
||||
VERIFICATION_T const * vt = &verification_table[q];
|
||||
const char* fstr = vt->output_name;
|
||||
const char *fstr = vt->output_name;
|
||||
uint16_t limit = 1u << vt->input_count;
|
||||
|
||||
for (uint16_t fn_idx = 0; fn_idx < vt->altFnCount; ++fn_idx ) {
|
||||
for (uint16_t fn_idx = 0; fn_idx < vt->altFnCount; ++fn_idx) {
|
||||
|
||||
bool any_failures_this_table_alts = false;
|
||||
const lookuptable_func_t fn = vt->altFns[fn_idx];
|
||||
@@ -608,7 +607,7 @@ static bool verify_alternatives(void)
|
||||
} else {
|
||||
printf("SUCCESS ---------> All alternate for %s \n", fstr);
|
||||
}
|
||||
|
||||
|
||||
any_failures_overall |= any_failures_this_table;
|
||||
}
|
||||
|
||||
@@ -620,9 +619,8 @@ static bool verify_alternatives(void)
|
||||
return !any_failures_overall;
|
||||
}
|
||||
|
||||
static bool verify_lut_g1(void)
|
||||
{
|
||||
static const char* fstr = "verify_lut_g1";
|
||||
static bool verify_lut_g1(void) {
|
||||
static const char *fstr = "verify_lut_g1";
|
||||
bool any_failures = false;
|
||||
for (uint8_t i = 0; i < 32; ++i) {
|
||||
INDEX_G1 t = { .as_uint8_t = i };
|
||||
@@ -640,13 +638,12 @@ static bool verify_lut_g1(void)
|
||||
}
|
||||
return !any_failures;
|
||||
}
|
||||
static bool verify_lut_g2(void)
|
||||
{
|
||||
static const char* fstr = "verify_lut_g2";
|
||||
static bool verify_lut_g2(void) {
|
||||
static const char *fstr = "verify_lut_g2";
|
||||
bool any_failures = false;
|
||||
for (uint8_t i = 0; i < 32; ++i) {
|
||||
INDEX_G2 t = { .as_uint8_t = i };
|
||||
bool lut_result = get_bit(small_lut_group2, i);
|
||||
bool lut_result = get_bit(small_lut_group2, i);
|
||||
bool other_result = espresso_implementation_g2(t.b, t.l4, t.l5, t.m0, t.m1);
|
||||
if (lut_result != other_result) {
|
||||
printf("%s: verification failed for index %d\n", fstr, t.as_uint8_t);
|
||||
@@ -660,9 +657,8 @@ static bool verify_lut_g2(void)
|
||||
}
|
||||
return !any_failures;
|
||||
}
|
||||
static bool verify_lut_g3(void)
|
||||
{
|
||||
static const char* fstr = "verify_lut_g3";
|
||||
static bool verify_lut_g3(void) {
|
||||
static const char *fstr = "verify_lut_g3";
|
||||
bool any_failures = false;
|
||||
for (uint8_t i = 0; i < 32; ++i) {
|
||||
INDEX_G3 t = { .as_uint8_t = i };
|
||||
@@ -680,9 +676,8 @@ static bool verify_lut_g3(void)
|
||||
}
|
||||
return !any_failures;
|
||||
}
|
||||
static bool verify_lut_g4(void)
|
||||
{
|
||||
static const char* fstr = "verify_lut_g4";
|
||||
static bool verify_lut_g4(void) {
|
||||
static const char *fstr = "verify_lut_g4";
|
||||
bool any_failures = false;
|
||||
for (uint8_t i = 0; i < 32; ++i) {
|
||||
INDEX_G4 t = { .as_uint8_t = i };
|
||||
@@ -700,9 +695,8 @@ static bool verify_lut_g4(void)
|
||||
}
|
||||
return !any_failures;
|
||||
}
|
||||
static bool verify_lut_XX(void)
|
||||
{
|
||||
static const char* fstr = "verify_lut_XX";
|
||||
static bool verify_lut_XX(void) {
|
||||
static const char *fstr = "verify_lut_XX";
|
||||
bool any_failures = false;
|
||||
for (uint16_t ix = 0; ix < 256; ++ix) {
|
||||
uint8_t i = (uint8_t)ix;
|
||||
@@ -737,7 +731,7 @@ static bool generate_espresso_file(uint8_t input_count, const char * const * inp
|
||||
const uint16_t iterations = 1u << input_count;
|
||||
fprintf(f_output, ".ilb");
|
||||
for (uint16_t i = 0; i < input_count; ++i) {
|
||||
const char* name = input_names[i];
|
||||
const char *name = input_names[i];
|
||||
fprintf(f_output, " %s", name);
|
||||
}
|
||||
fprintf(f_output, "\n");
|
||||
@@ -761,8 +755,7 @@ static bool generate_espresso_file(uint8_t input_count, const char * const * inp
|
||||
return true;
|
||||
}
|
||||
|
||||
bool generate_all_lut_espresso_files(void)
|
||||
{
|
||||
bool generate_all_lut_espresso_files(void) {
|
||||
|
||||
bool any_failures = false;
|
||||
|
||||
@@ -784,12 +777,12 @@ bool generate_all_lut_espresso_files(void)
|
||||
}
|
||||
if (file != NULL) {
|
||||
current_result = generate_espresso_file(
|
||||
args->input_count,
|
||||
args->names,
|
||||
args->output_name,
|
||||
args->lut_start,
|
||||
file
|
||||
);
|
||||
args->input_count,
|
||||
args->names,
|
||||
args->output_name,
|
||||
args->lut_start,
|
||||
file
|
||||
);
|
||||
if (!current_result) {
|
||||
printf("Failed to generate espresso file for %s\n", args->output_name);
|
||||
}
|
||||
@@ -803,8 +796,7 @@ bool generate_all_lut_espresso_files(void)
|
||||
|
||||
return !any_failures;
|
||||
}
|
||||
bool verify_espresso_results(void)
|
||||
{
|
||||
bool verify_espresso_results(void) {
|
||||
//generate_all_lut_espresso_files();
|
||||
|
||||
bool unused = verify_alternatives();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
+229
-229
@@ -137,19 +137,19 @@ static const bmp_t b40c[] = {
|
||||
# else /* BMP_BIT */
|
||||
static const bmp_t b40[] = {
|
||||
BMP_C(0x00048200) << (BMP_BIT - 32) | BMP_C(0x04) >> (39 - BMP_BIT),
|
||||
BMP_C(0x09) << (BMP_BIT * 2 - 40),
|
||||
BMP_C(0x09) << (BMP_BIT * 2 - 40),
|
||||
};
|
||||
static const bmp_t b40a[] = {
|
||||
BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT),
|
||||
BMP_C(0xff) << (BMP_BIT * 2 - 40),
|
||||
BMP_C(0xff) << (BMP_BIT * 2 - 40),
|
||||
};
|
||||
static const bmp_t b40b[] = {
|
||||
BMP_C(0xd4164fc6) << (BMP_BIT - 32) | BMP_C(0x23) >> (39 - BMP_BIT),
|
||||
BMP_C(0x46) << (BMP_BIT * 2 - 40),
|
||||
BMP_C(0x46) << (BMP_BIT * 2 - 40),
|
||||
};
|
||||
static const bmp_t b40c[] = {
|
||||
BMP_C(0xc4ff8071) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT),
|
||||
BMP_C(0xff) << (BMP_BIT * 2 - 40),
|
||||
BMP_C(0xff) << (BMP_BIT * 2 - 40),
|
||||
};
|
||||
# endif /* BMP_BIT */
|
||||
|
||||
@@ -187,43 +187,43 @@ static const bmp_t b64i[] = {
|
||||
# else /* BMP_BIT */
|
||||
static const bmp_t b64[] = {
|
||||
BMP_C(0x00000000) << (BMP_BIT - 32) | BMP_C(0x0000000d) >> (63 - BMP_BIT),
|
||||
BMP_C(0x0000001b) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0x0000001b) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64a[] = {
|
||||
BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7fffffff) >> (63 - BMP_BIT),
|
||||
BMP_C(0xffffffff) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0xffffffff) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64b[] = {
|
||||
BMP_C(0xb90956c7) << (BMP_BIT - 32) | BMP_C(0x3ad20800) >> (63 - BMP_BIT),
|
||||
BMP_C(0x75a41001) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0x75a41001) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64c[] = {
|
||||
BMP_C(0x53000000) << (BMP_BIT - 32) | BMP_C(0x00000000) >> (63 - BMP_BIT),
|
||||
BMP_C(0x00000000) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0x00000000) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64d[] = {
|
||||
BMP_C(0x42f0e1eb) << (BMP_BIT - 32) | BMP_C(0x54f51b49) >> (63 - BMP_BIT),
|
||||
BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64e[] = {
|
||||
BMP_C(0x6c40df5f) << (BMP_BIT - 32) | BMP_C(0x05a4b9a3) >> (63 - BMP_BIT),
|
||||
BMP_C(0x0b497347) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0x0b497347) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64f[] = {
|
||||
BMP_C(0x62ec59e3) << (BMP_BIT - 32) | BMP_C(0x78d27805) >> (63 - BMP_BIT),
|
||||
BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64g[] = {
|
||||
BMP_C(0xfcacbebd) << (BMP_BIT - 32) | BMP_C(0x2c98d4c9) >> (63 - BMP_BIT),
|
||||
BMP_C(0x5931a992) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0x5931a992) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64h[] = {
|
||||
BMP_C(0x995dc9bb) << (BMP_BIT - 32) | BMP_C(0x6f8c9cfd) >> (63 - BMP_BIT),
|
||||
BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
static const bmp_t b64i[] = {
|
||||
BMP_C(0x49958c9a) << (BMP_BIT - 32) | BMP_C(0x5ebe9a9f) >> (63 - BMP_BIT),
|
||||
BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64),
|
||||
BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64),
|
||||
};
|
||||
# endif /* BMP_BIT */
|
||||
|
||||
@@ -237,22 +237,22 @@ static const bmp_t b82a[] = {
|
||||
# elif BMP_BIT >= 41
|
||||
static const bmp_t b82[] = {
|
||||
BMP_C(0x01846008880) << (BMP_BIT - 41) | BMP_C(0x08a00a20208) >> (81 - BMP_BIT),
|
||||
BMP_C(0x11401440411) << (BMP_BIT * 2 - 82),
|
||||
BMP_C(0x11401440411) << (BMP_BIT * 2 - 82),
|
||||
};
|
||||
static const bmp_t b82a[] = {
|
||||
BMP_C(0x04f541fb128) << (BMP_BIT - 41) | BMP_C(0x011c00feb09) >> (81 - BMP_BIT),
|
||||
BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82),
|
||||
BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82),
|
||||
};
|
||||
# else /* BMP_BIT */
|
||||
static const bmp_t b82[] = {
|
||||
BMP_C(0x0c230044) << (BMP_BIT - 32) | BMP_C(0x040) >> (40 - BMP_BIT),
|
||||
BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2),
|
||||
BMP_C(0x00411) << (BMP_BIT * 3 - 82),
|
||||
BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2),
|
||||
BMP_C(0x00411) << (BMP_BIT * 3 - 82),
|
||||
};
|
||||
static const bmp_t b82a[] = {
|
||||
BMP_C(0x27aa0fd8) << (BMP_BIT - 32) | BMP_C(0x094) >> (40 - BMP_BIT),
|
||||
BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2),
|
||||
BMP_C(0x3d612) << (BMP_BIT * 3 - 82),
|
||||
BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2),
|
||||
BMP_C(0x3d612) << (BMP_BIT * 3 - 82),
|
||||
};
|
||||
# endif /* BMP_BIT */
|
||||
|
||||
@@ -262,215 +262,215 @@ static const bmp_t b82a[] = {
|
||||
/* Array of the polynomial bitmaps used in the model table. */
|
||||
static const bmp_t b32[] = {
|
||||
BMP_C(0x000000af) << (BMP_BIT - 32), /* 0 -- 32,000000af */
|
||||
BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */
|
||||
BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */
|
||||
BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */
|
||||
BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */
|
||||
BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */
|
||||
BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */
|
||||
BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */
|
||||
BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */
|
||||
BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */
|
||||
BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */
|
||||
BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */
|
||||
BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */
|
||||
BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */
|
||||
BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */
|
||||
BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */
|
||||
BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */
|
||||
BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */
|
||||
BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */
|
||||
BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */
|
||||
BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */
|
||||
BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */
|
||||
BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */
|
||||
BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */
|
||||
BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */
|
||||
BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */
|
||||
BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */
|
||||
BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */
|
||||
BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */
|
||||
BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */
|
||||
BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */
|
||||
BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */
|
||||
BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */
|
||||
BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */
|
||||
BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */
|
||||
BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */
|
||||
BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */
|
||||
BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */
|
||||
BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */
|
||||
BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */
|
||||
BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */
|
||||
BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */
|
||||
BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */
|
||||
BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */
|
||||
BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */
|
||||
BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */
|
||||
BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */
|
||||
BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */
|
||||
BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */
|
||||
BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */
|
||||
BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */
|
||||
BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */
|
||||
BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */
|
||||
BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */
|
||||
BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */
|
||||
BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */
|
||||
BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */
|
||||
BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */
|
||||
BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */
|
||||
BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */
|
||||
BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */
|
||||
BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */
|
||||
BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */
|
||||
BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */
|
||||
BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */
|
||||
BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */
|
||||
BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */
|
||||
BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */
|
||||
BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */
|
||||
BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */
|
||||
BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */
|
||||
BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */
|
||||
BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */
|
||||
BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */
|
||||
BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */
|
||||
BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */
|
||||
BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */
|
||||
BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */
|
||||
BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */
|
||||
BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */
|
||||
BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */
|
||||
BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */
|
||||
BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */
|
||||
BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */
|
||||
BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */
|
||||
BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */
|
||||
BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */
|
||||
BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */
|
||||
BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */
|
||||
BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */
|
||||
BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */
|
||||
BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */
|
||||
BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */
|
||||
BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */
|
||||
BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */
|
||||
BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */
|
||||
BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */
|
||||
BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */
|
||||
BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */
|
||||
BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */
|
||||
BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */
|
||||
BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */
|
||||
BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */
|
||||
BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */
|
||||
BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */
|
||||
BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */
|
||||
BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */
|
||||
BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */
|
||||
BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */
|
||||
BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */
|
||||
BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */
|
||||
BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */
|
||||
BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */
|
||||
BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */
|
||||
BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */
|
||||
BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */
|
||||
BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */
|
||||
BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */
|
||||
BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */
|
||||
BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */
|
||||
BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */
|
||||
BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */
|
||||
BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */
|
||||
BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */
|
||||
BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */
|
||||
BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */
|
||||
BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */
|
||||
BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */
|
||||
BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */
|
||||
BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */
|
||||
BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */
|
||||
BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */
|
||||
BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */
|
||||
BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */
|
||||
BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */
|
||||
BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */
|
||||
BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */
|
||||
BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */
|
||||
BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */
|
||||
BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */
|
||||
BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */
|
||||
BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */
|
||||
BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */
|
||||
BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */
|
||||
BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */
|
||||
BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */
|
||||
BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */
|
||||
BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */
|
||||
BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */
|
||||
BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */
|
||||
BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */
|
||||
BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */
|
||||
BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */
|
||||
BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */
|
||||
BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */
|
||||
BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */
|
||||
BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */
|
||||
BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */
|
||||
BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */
|
||||
BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */
|
||||
BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */
|
||||
BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */
|
||||
BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */
|
||||
BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */
|
||||
BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */
|
||||
BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */
|
||||
BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */
|
||||
BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */
|
||||
BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */
|
||||
BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */
|
||||
BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */
|
||||
BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */
|
||||
BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */
|
||||
BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */
|
||||
BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */
|
||||
BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */
|
||||
BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */
|
||||
BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */
|
||||
BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */
|
||||
BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */
|
||||
BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */
|
||||
BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */
|
||||
BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */
|
||||
BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */
|
||||
BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */
|
||||
BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */
|
||||
BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */
|
||||
BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */
|
||||
BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */
|
||||
BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */
|
||||
BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */
|
||||
BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */
|
||||
BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */
|
||||
BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */
|
||||
BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */
|
||||
BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */
|
||||
BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */
|
||||
BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */
|
||||
BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */
|
||||
BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */
|
||||
BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */
|
||||
BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */
|
||||
BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */
|
||||
BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */
|
||||
BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */
|
||||
BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */
|
||||
BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */
|
||||
BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */
|
||||
BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */
|
||||
BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */
|
||||
BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */
|
||||
BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */
|
||||
BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */
|
||||
BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */
|
||||
BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */
|
||||
BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */
|
||||
BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */
|
||||
BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */
|
||||
BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */
|
||||
BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */
|
||||
BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */
|
||||
BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */
|
||||
BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */
|
||||
BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */
|
||||
BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */
|
||||
BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */
|
||||
BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */
|
||||
BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */
|
||||
BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */
|
||||
BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */
|
||||
BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */
|
||||
BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */
|
||||
BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */
|
||||
BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */
|
||||
BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */
|
||||
BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */
|
||||
BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */
|
||||
BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */
|
||||
BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */
|
||||
BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */
|
||||
BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */
|
||||
BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */
|
||||
BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */
|
||||
BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */
|
||||
BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */
|
||||
BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */
|
||||
BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */
|
||||
BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */
|
||||
BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */
|
||||
BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */
|
||||
BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */
|
||||
BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */
|
||||
BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */
|
||||
BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */
|
||||
BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */
|
||||
BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */
|
||||
BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */
|
||||
BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */
|
||||
BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */
|
||||
BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */
|
||||
BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */
|
||||
BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */
|
||||
BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */
|
||||
BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */
|
||||
BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */
|
||||
BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */
|
||||
BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */
|
||||
BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */
|
||||
BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */
|
||||
BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */
|
||||
BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */
|
||||
BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */
|
||||
BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */
|
||||
BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */
|
||||
BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */
|
||||
BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */
|
||||
BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */
|
||||
BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */
|
||||
BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */
|
||||
BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */
|
||||
BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */
|
||||
BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */
|
||||
BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */
|
||||
BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */
|
||||
BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */
|
||||
BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */
|
||||
BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */
|
||||
BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */
|
||||
BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */
|
||||
BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */
|
||||
BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */
|
||||
BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */
|
||||
BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */
|
||||
BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */
|
||||
BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */
|
||||
BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */
|
||||
BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */
|
||||
BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */
|
||||
BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */
|
||||
BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */
|
||||
BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */
|
||||
BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */
|
||||
BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */
|
||||
BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */
|
||||
BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */
|
||||
BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */
|
||||
BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */
|
||||
BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */
|
||||
BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */
|
||||
BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */
|
||||
BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */
|
||||
BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */
|
||||
BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */
|
||||
BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */
|
||||
BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */
|
||||
BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */
|
||||
BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */
|
||||
BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */
|
||||
BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */
|
||||
BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */
|
||||
BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */
|
||||
BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */
|
||||
BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */
|
||||
BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */
|
||||
BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */
|
||||
BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */
|
||||
BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */
|
||||
BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */
|
||||
BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */
|
||||
BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */
|
||||
BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */
|
||||
BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */
|
||||
BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */
|
||||
BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */
|
||||
BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */
|
||||
BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */
|
||||
BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */
|
||||
BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */
|
||||
BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */
|
||||
BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */
|
||||
BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */
|
||||
BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */
|
||||
BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */
|
||||
BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */
|
||||
BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */
|
||||
BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */
|
||||
BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */
|
||||
BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */
|
||||
BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */
|
||||
BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */
|
||||
BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */
|
||||
BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */
|
||||
BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */
|
||||
BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */
|
||||
BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */
|
||||
BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */
|
||||
BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */
|
||||
BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */
|
||||
BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */
|
||||
BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */
|
||||
BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */
|
||||
BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */
|
||||
BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */
|
||||
BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */
|
||||
BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */
|
||||
BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */
|
||||
BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */
|
||||
BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */
|
||||
BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */
|
||||
BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */
|
||||
BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */
|
||||
BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */
|
||||
BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */
|
||||
BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */
|
||||
BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */
|
||||
BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */
|
||||
BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */
|
||||
BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */
|
||||
BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */
|
||||
BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */
|
||||
BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */
|
||||
BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */
|
||||
BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */
|
||||
BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */
|
||||
BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */
|
||||
BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */
|
||||
BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */
|
||||
BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */
|
||||
BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */
|
||||
BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */
|
||||
BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */
|
||||
BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */
|
||||
BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */
|
||||
BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */
|
||||
BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */
|
||||
BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */
|
||||
BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */
|
||||
BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */
|
||||
BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */
|
||||
BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */
|
||||
BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */
|
||||
BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */
|
||||
BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */
|
||||
BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */
|
||||
BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */
|
||||
BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */
|
||||
BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */
|
||||
BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */
|
||||
BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */
|
||||
BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */
|
||||
BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */
|
||||
BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */
|
||||
BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */
|
||||
BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */
|
||||
BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */
|
||||
BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */
|
||||
BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */
|
||||
BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */
|
||||
BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */
|
||||
};
|
||||
|
||||
static const struct malias aliases[];
|
||||
|
||||
@@ -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,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
|
||||
#
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
@@ -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.");
|
||||
|
||||
@@ -373,7 +373,7 @@ static int hfgal_create_creds_app(DesfireContext_t *ctx, uint8_t *site_key, uint
|
||||
// UID is required for key diversification
|
||||
if (ctx->uidlen == 0) {
|
||||
PM3_RET_ERR(PM3_EINVARG, "UID is required for key diversification. "
|
||||
"Please fetch it before calling `hfgal_create_creds_app`");
|
||||
"Please fetch it before calling `hfgal_create_creds_app`");
|
||||
}
|
||||
|
||||
// Create application
|
||||
@@ -862,11 +862,11 @@ static int hfgal_read_card(uint32_t aid, uint8_t *site_key, bool verbose, bool q
|
||||
PM3_RET_IF_ERR_MAYBE_MSG(res, !quiet, "Failed reading card application credentials");
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Gallagher (AID %06X) - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
current_aid,
|
||||
'A' + creds.region_code,
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
@@ -1299,10 +1299,10 @@ static int CmdGallagherDecode(const char *cmd) {
|
||||
gallagher_decode_creds(data_buf, &creds);
|
||||
|
||||
PrintAndLogEx(SUCCESS, "Gallagher - region: " _GREEN_("%c") " ( " _GREEN_("%u") " )"
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds.region_code,
|
||||
", facility: " _GREEN_("%u")
|
||||
", card number: " _GREEN_("%u")
|
||||
", issue level: " _GREEN_("%u"),
|
||||
'A' + creds.region_code,
|
||||
creds.region_code,
|
||||
creds.facility_code,
|
||||
creds.card_number,
|
||||
|
||||
+14
-14
@@ -1513,26 +1513,26 @@ static void iclass_decode_credentials(uint8_t *data) {
|
||||
char *pbin = binstr;
|
||||
// Strip leading zeros
|
||||
while (strlen(pbin) && *(++pbin) == '0');
|
||||
|
||||
|
||||
size_t binlen = strlen(pbin);
|
||||
|
||||
|
||||
// Check if we have a sentinel bit (leading '1' that makes length one more than common formats)
|
||||
// Common formats: 26, 30, 33, 34, 35, 36, 37, 46, 48
|
||||
// If we have 27, 31, 34, 35, 36, 37, 38, 47, 49 bits and it starts with '1',
|
||||
// it's likely a sentinel bit that should be stripped
|
||||
if (binlen > 0 && pbin[0] == '1' &&
|
||||
(binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 ||
|
||||
binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) {
|
||||
if (binlen > 0 && pbin[0] == '1' &&
|
||||
(binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 ||
|
||||
binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) {
|
||||
// Strip the sentinel bit by recreating u96 from binary string without leading '1'
|
||||
char *corrected_bin = pbin + 1; // Skip the leading '1'
|
||||
size_t corrected_len = strlen(corrected_bin);
|
||||
|
||||
|
||||
// Recreate u96 values from corrected binary string
|
||||
top = 0;
|
||||
mid = 0;
|
||||
bot = 0;
|
||||
binstring_to_u96(&top, &mid, &bot, corrected_bin);
|
||||
|
||||
|
||||
pbin = corrected_bin;
|
||||
binlen = corrected_len;
|
||||
}
|
||||
@@ -2954,26 +2954,26 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) {
|
||||
char *pbin = binstr;
|
||||
// Strip leading zeros
|
||||
while (strlen(pbin) && *(++pbin) == '0');
|
||||
|
||||
|
||||
size_t binlen = strlen(pbin);
|
||||
|
||||
|
||||
// Check if we have a sentinel bit (leading '1' that makes length one more than common formats)
|
||||
// Common formats: 26, 30, 33, 34, 35, 36, 37, 46, 48
|
||||
// If we have 27, 31, 34, 35, 36, 37, 38, 47, 49 bits and it starts with '1',
|
||||
// it's likely a sentinel bit that should be stripped
|
||||
if (binlen > 0 && pbin[0] == '1' &&
|
||||
(binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 ||
|
||||
binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) {
|
||||
if (binlen > 0 && pbin[0] == '1' &&
|
||||
(binlen == 27 || binlen == 31 || binlen == 34 || binlen == 35 ||
|
||||
binlen == 36 || binlen == 37 || binlen == 38 || binlen == 47 || binlen == 49)) {
|
||||
// Strip the sentinel bit by recreating u96 from binary string without leading '1'
|
||||
char *corrected_bin = pbin + 1; // Skip the leading '1'
|
||||
size_t corrected_len = strlen(corrected_bin);
|
||||
|
||||
|
||||
// Recreate u96 values from corrected binary string
|
||||
top = 0;
|
||||
mid = 0;
|
||||
bot = 0;
|
||||
binstring_to_u96(&top, &mid, &bot, corrected_bin);
|
||||
|
||||
|
||||
pbin = corrected_bin;
|
||||
binlen = corrected_len;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff
|
||||
// for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes
|
||||
if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) {
|
||||
PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. "
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
return_value = PM3_EOUTOFBOUND;
|
||||
goto out;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ static int decode_and_print_memory(uint16_t card_size, const uint8_t *input_buff
|
||||
// for printing the complete segment we need at least wrc + wrp_len + remain_seg_payload_len bytes
|
||||
if ((i + wrc + wrp_len + remain_seg_payload_len) > card_size) {
|
||||
PrintAndLogEx(FAILED, "Cannot read segment body, because the input buffer is too small. "
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
"Please check that the data is correct and properly aligned. ");
|
||||
return_value = PM3_EOUTOFBOUND;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -2507,7 +2507,7 @@ static int CmdHF14AMfNestedStatic(const char *Cmd) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
if (e_sector[sectorNo].foundKey[trgKeyType]) continue;
|
||||
|
||||
|
||||
int16_t isOK = mf_static_nested(blockNo, keyType, key, mfFirstBlockOfSector(sectorNo), trgKeyType, keyBlock, forceDetectDist);
|
||||
switch (isOK) {
|
||||
case PM3_ETIMEOUT :
|
||||
@@ -5030,7 +5030,7 @@ void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector
|
||||
_YELLOW_("H") ":Hardnested / "
|
||||
_YELLOW_("C") ":statiCnested / "
|
||||
_YELLOW_("A") ":keyA "
|
||||
" )"
|
||||
" )"
|
||||
);
|
||||
if (sectorscnt == 18) {
|
||||
PrintAndLogEx(INFO, "( " _MAGENTA_("*") " ) These sectors used for signature. Lays outside of user memory");
|
||||
|
||||
@@ -2027,7 +2027,7 @@ static int mfulc_fingerprint(void) {
|
||||
if ((status > 0) && (data[2] == 0x09)) {
|
||||
cmd[1] = 3;
|
||||
status = ul_send_cmd_raw(cmd, sizeof(cmd), data, 4, false);
|
||||
if ((status > 0) && (data[0] == 0xE1) && (data[1] == 0x10) && (data[2] == 0x12) && (data[3] == 0x00) ) {
|
||||
if ((status > 0) && (data[0] == 0xE1) && (data[1] == 0x10) && (data[2] == 0x12) && (data[3] == 0x00)) {
|
||||
PrintAndLogEx(INFO, "MIFARE Hospitality (MF0ICU2(H))");
|
||||
DropField();
|
||||
return PM3_SUCCESS;
|
||||
@@ -5054,7 +5054,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
||||
}
|
||||
|
||||
// block 1.
|
||||
memcpy(packetw.data, uid+3, 4);
|
||||
memcpy(packetw.data, uid + 3, 4);
|
||||
packetw.block_no = 1;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw));
|
||||
@@ -5065,7 +5065,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
||||
|
||||
// block 2.
|
||||
packetw.data[0] = uid[3] ^ uid[4] ^ uid[5] ^ uid[6];
|
||||
memcpy(packetw.data+1, oldblock2+1, 3);
|
||||
memcpy(packetw.data + 1, oldblock2 + 1, 3);
|
||||
packetw.block_no = 2;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw));
|
||||
@@ -5469,7 +5469,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
||||
if (use_data) {
|
||||
SendCommandNG(CMD_HF_MIFAREU_WRITEBL, (uint8_t *)&packetw, sizeof(packetw));
|
||||
if ((WaitForResponseTimeout(CMD_HF_MIFAREU_WRITEBL, &resp, 1500) == false) ||
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(FAILED, "Failed to write block BEFORE");
|
||||
error_retries++;
|
||||
continue; // try again
|
||||
@@ -5478,8 +5478,8 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
||||
|
||||
packetr.block_no = blockno;
|
||||
SendCommandNG(CMD_HF_MIFAREU_READBL, (uint8_t *)&packetr, sizeof(packetr));
|
||||
if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false ) ||
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false) ||
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(FAILED, "Failed to read block BEFORE");
|
||||
error_retries++;
|
||||
continue; // try again
|
||||
@@ -5504,8 +5504,8 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFAREU_READBL, (uint8_t *)&packetr, sizeof(packetr));
|
||||
if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false ) ||
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
if ((WaitForResponseTimeout(CMD_HF_MIFAREU_READBL, &resp, 1500) == false) ||
|
||||
(resp.status != PM3_SUCCESS)) {
|
||||
PrintAndLogEx(FAILED, "Failed to read block BEFORE");
|
||||
error_retries++;
|
||||
continue; // try again
|
||||
|
||||
@@ -723,8 +723,8 @@ static int ntag424_authenticate_ev2_first(uint8_t keyno, uint8_t *key, ntag424_s
|
||||
if (memcmp(response.rnd_a, &rnd_a_clear[1], 15) != 0 ||
|
||||
response.rnd_a[15] != rnd_a_clear[0]) {
|
||||
PrintAndLogEx(ERR, "Incorrect response from card\n"
|
||||
"expected: %s\n"
|
||||
"got: %s"
|
||||
"expected: %s\n"
|
||||
"got: %s"
|
||||
, sprint_hex(rnd_a_clear, 16),
|
||||
sprint_hex(response.rnd_a, 16));
|
||||
return PM3_ESOFT;
|
||||
|
||||
+549
-546
File diff suppressed because it is too large.
Load diff
+14
-14
@@ -159,7 +159,7 @@ static int decrypt_cryptogram(uint8_t *key, uint8_t *input, uint8_t *out, int in
|
||||
|
||||
static void increment_command_wrapper(uint8_t *input, int input_len) {
|
||||
// Increment the end of the header by 1
|
||||
uint8_t* offset = &input[input_len - sizeof(uint32_t)];
|
||||
uint8_t *offset = &input[input_len - sizeof(uint32_t)];
|
||||
uint32_t value = MemBeToUint4byte(offset);
|
||||
value++;
|
||||
Uint4byteToMemBe(offset, value);
|
||||
@@ -192,12 +192,12 @@ static void generate_command_wrapping(uint8_t *command_Header, int command_heade
|
||||
|
||||
// Command Header is for the APDU Command to be sent
|
||||
int padded_Command_Header_len = command_header_len;
|
||||
uint8_t padded_Command_Header[padded_Command_Header_len+block_size];
|
||||
uint8_t padded_Command_Header[padded_Command_Header_len + block_size];
|
||||
padToBlockSize(command_Header, &padded_Command_Header_len, block_size, padded_Command_Header);
|
||||
|
||||
// Unencrypted Command is our actual command data
|
||||
int padded_unencrypted_Command_len = unencrypted_command_len;
|
||||
uint8_t padded_unencrypted_Command[padded_unencrypted_Command_len+block_size];
|
||||
uint8_t padded_unencrypted_Command[padded_unencrypted_Command_len + block_size];
|
||||
padToBlockSize(unencrypted_Command, &padded_unencrypted_Command_len, block_size, padded_unencrypted_Command);
|
||||
|
||||
uint8_t padded_encrypted_Command[padded_unencrypted_Command_len];
|
||||
@@ -216,7 +216,7 @@ static void generate_command_wrapping(uint8_t *command_Header, int command_heade
|
||||
memcpy(toEncrypt + ARRAYLEN(rndCounter) + padded_Command_Header_len + ARRAYLEN(asn1_tag_cryptograph) + ARRAYLEN(padded_encrypted_Command), command_trailer, ARRAYLEN(command_trailer));
|
||||
|
||||
int padded_toEncrypt_len = ARRAYLEN(toEncrypt);
|
||||
uint8_t padded_toEncrypt[padded_toEncrypt_len+block_size];
|
||||
uint8_t padded_toEncrypt[padded_toEncrypt_len + block_size];
|
||||
padToBlockSize(toEncrypt, &padded_toEncrypt_len, block_size, padded_toEncrypt);
|
||||
|
||||
// Breakdown
|
||||
@@ -286,10 +286,10 @@ static int seos_get_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversified_
|
||||
// uint8_t unencrypted_command[4] = {0x5c,0x02,0xff,0x00};
|
||||
// Modification of the tags 2nd place from 00 can return other data
|
||||
|
||||
uint8_t unencrypted_command[data_tag_len+2];
|
||||
uint8_t unencrypted_command[data_tag_len + 2];
|
||||
unencrypted_command[0] = 0x5c;
|
||||
unencrypted_command[1] = data_tag_len;
|
||||
memcpy(unencrypted_command+2, data_tag, data_tag_len);
|
||||
memcpy(unencrypted_command + 2, data_tag, data_tag_len);
|
||||
|
||||
int unencrypted_command_len = ARRAYLEN(unencrypted_command);
|
||||
|
||||
@@ -402,11 +402,11 @@ static int seos_write_data(uint8_t *rndICC, uint8_t *rndIFD, uint8_t *diversifie
|
||||
// ff 00 [04] 12 34 56 78
|
||||
// ff 00 = BER-TLV tag of the data object to be written
|
||||
|
||||
uint8_t unencrypted_command[write_data_tag_len+1+sio_size];
|
||||
uint8_t unencrypted_command[write_data_tag_len + 1 + sio_size];
|
||||
memcpy(unencrypted_command, write_data_tag, write_data_tag_len);
|
||||
|
||||
unencrypted_command[write_data_tag_len] = sio_size;
|
||||
memcpy(unencrypted_command+write_data_tag_len+1, sio, sio_size);
|
||||
memcpy(unencrypted_command + write_data_tag_len + 1, sio, sio_size);
|
||||
|
||||
int unencrypted_command_len = ARRAYLEN(unencrypted_command);
|
||||
|
||||
@@ -650,12 +650,12 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t
|
||||
for (int i = 0; i < response_length - 2;) {
|
||||
// extract MAC
|
||||
if (response[i] == 0x8E) {
|
||||
if (response[i+1] != MAC_value_len) {
|
||||
if (response[i + 1] != MAC_value_len) {
|
||||
goto out;
|
||||
}
|
||||
// Ensure there's enough bytes remaining
|
||||
// in the response for the full MAC
|
||||
if (i+2+MAC_value_len > response_length) {
|
||||
if (i + 2 + MAC_value_len > response_length) {
|
||||
goto out;
|
||||
}
|
||||
input_len = i;
|
||||
@@ -665,7 +665,7 @@ static int select_DF_verify(uint8_t *response, uint8_t response_length, uint8_t
|
||||
break;
|
||||
}
|
||||
// skip to next tag
|
||||
i += 2 + response[i+1];
|
||||
i += 2 + response[i + 1];
|
||||
}
|
||||
if (res != PM3_SUCCESS) {
|
||||
goto out;
|
||||
@@ -821,7 +821,7 @@ static int select_ADF_decrypt(const char *selectADFOID, uint8_t *CRYPTOGRAM_encr
|
||||
uint8_t MAC_key[24] = {0x00};
|
||||
memcpy(MAC_key, keys[key_index].privMacKey, 16);
|
||||
create_cmac(MAC_key, CRYPTOGRAM_encrypted_data_raw, mac, iv_size, sizeof(mac), encryption_algorithm);
|
||||
if (memcmp(CRYPTOGRAM_encrypted_data_raw+iv_size, mac, iv_size) != 0) {
|
||||
if (memcmp(CRYPTOGRAM_encrypted_data_raw + iv_size, mac, iv_size) != 0) {
|
||||
PrintAndLogEx(ERR, "Synthesized IV Verification Failed");
|
||||
PrintAndLogEx(ERR, _YELLOW_("Likely wrong Priv Mac Key"));
|
||||
return PM3_ESOFT;
|
||||
@@ -1234,7 +1234,7 @@ static int seos_pacs_adf_select(char *oid, int oid_len, uint8_t *data_tag, int d
|
||||
return res;
|
||||
}
|
||||
create_mutual_auth_key(KeyIFD, KeyICC, RNDICC, RNDIFD, Diversified_New_EncryptionKey, Diversified_New_MACKey, ALGORITHM_INFO_value1, ALGORITHM_INFO_value2);
|
||||
|
||||
|
||||
if (write == NULL) {
|
||||
uint8_t sio_buffer_out[PM3_CMD_DATA_SIZE];
|
||||
int sio_size = 0;
|
||||
@@ -1819,7 +1819,7 @@ static int CmdHfSeosSim(const char *Cmd) {
|
||||
return PM3_EOPABORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -948,9 +948,9 @@ static int CmdT55xxReadBlock(const char *Cmd) {
|
||||
_CYAN_("Use of read with password on a tag not configured") "\n"
|
||||
_CYAN_("for a password can damage the tag") "\n"
|
||||
_RED_(" * * * * * * * * * *"),
|
||||
"lf t55xx read -b 0 --> read data from block 0\n"
|
||||
"lf t55xx read -b 0 --pwd 01020304 --> read data from block 0, pwd 01020304\n"
|
||||
"lf t55xx read -b 0 --pwd 01020304 -o --> read data from block 0, pwd 01020304, override\n"
|
||||
"lf t55xx read -b 0 --> read data from block 0\n"
|
||||
"lf t55xx read -b 0 --pwd 01020304 --> read data from block 0, pwd 01020304\n"
|
||||
"lf t55xx read -b 0 --pwd 01020304 -o --> read data from block 0, pwd 01020304, override\n"
|
||||
);
|
||||
|
||||
// 1 (help) + 4(four user specified params) + (5 T55XX_DLMODE_SINGLE)
|
||||
|
||||
@@ -1469,7 +1469,7 @@ int CmdTraceList(const char *Cmd) {
|
||||
|
||||
if (protocol == LEGIC)
|
||||
PrintAndLogEx(INFO, _YELLOW_("LEGIC") " - Reader Mode: Timings are in ticks (1us == 1.5ticks)\n"
|
||||
" Tag Mode: Timings are in sub carrier periods (1/212 kHz == 4.7us)");
|
||||
" Tag Mode: Timings are in sub carrier periods (1/212 kHz == 4.7us)");
|
||||
|
||||
if (protocol == ISO_14443B || protocol == PROTO_CRYPTORF) {
|
||||
if (use_us)
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, uint32_t flash_size) {
|
||||
offset);
|
||||
if (filesz != memsz) {
|
||||
PrintAndLogEx(ERR, "Error: PHDR file size does not equal memory size\n"
|
||||
"(DATA+BSS PHDRs do not make sense on ROM platforms!)");
|
||||
"(DATA+BSS PHDRs do not make sense on ROM platforms!)");
|
||||
return PM3_EFILE;
|
||||
}
|
||||
if (paddr < last_end) {
|
||||
|
||||
@@ -2756,9 +2756,9 @@ static int _wrap_new_pm3(lua_State *L) {
|
||||
}
|
||||
|
||||
SWIG_Lua_pusherrstring(L, "Wrong arguments for overloaded function 'new_pm3'\n"
|
||||
" Possible C/C++ prototypes are:\n"
|
||||
" pm3::pm3()\n"
|
||||
" pm3::pm3(char *)\n");
|
||||
" Possible C/C++ prototypes are:\n"
|
||||
" pm3::pm3()\n"
|
||||
" pm3::pm3(char *)\n");
|
||||
lua_error(L);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ static int dumpmem_pm3(char *serial_port_name, const char *filename, uint32_t ad
|
||||
PrintAndLogEx(INFO, "Device is running the bootloader.");
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Device is running the bootloader, but the bootloader"
|
||||
" doesn't understand the READ MEM command.");
|
||||
" doesn't understand the READ MEM command.");
|
||||
goto finish2;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,8 +63,8 @@ typedef struct {
|
||||
uint64_t current_key; // Use 64 bit and truncate when needed.
|
||||
uint8_t mode;
|
||||
uint8_t charset[
|
||||
BF_CHARSET_DIGITS_SIZE
|
||||
+ BF_CHARSET_UPPERCASE_SIZE
|
||||
BF_CHARSET_DIGITS_SIZE
|
||||
+ BF_CHARSET_UPPERCASE_SIZE
|
||||
];
|
||||
uint8_t charset_length;
|
||||
|
||||
|
||||
+12
-12
@@ -73,14 +73,14 @@
|
||||
|
||||
static const int Iso15693FrameSOF[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
-1, -1, -1, -1,
|
||||
-1, -1, -1, -1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1
|
||||
};
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
-1, -1, -1, -1,
|
||||
-1, -1, -1, -1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1
|
||||
};
|
||||
static const int Iso15693Logic0[] = {
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
@@ -89,10 +89,10 @@ static const int Iso15693Logic0[] = {
|
||||
};
|
||||
static const int Iso15693Logic1[] = {
|
||||
-1, -1, -1, -1,
|
||||
-1, -1, -1, -1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1
|
||||
};
|
||||
-1, -1, -1, -1,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1
|
||||
};
|
||||
|
||||
// EOF defined as
|
||||
// 1) logic '0' (8 pulses of 423.75kHz followed by unmodulated for 18.88us)
|
||||
|
||||
+13
-13
@@ -254,7 +254,7 @@ void mbedtls_aesni_inverse_key(unsigned char *invkey,
|
||||
for (fk -= 16, ik += 16; fk > fwdkey; fk -= 16, ik += 16)
|
||||
asm("movdqu (%0), %%xmm0 \n\t"
|
||||
AESIMC xmm0_xmm0 "\n\t"
|
||||
"movdqu %%xmm0, (%1) \n\t"
|
||||
"movdqu %%xmm0, (%1) \n\t"
|
||||
:
|
||||
: "r"(fk), "r"(ik)
|
||||
: "memory", "xmm0");
|
||||
@@ -403,23 +403,23 @@ static void aesni_setkey_enc_256(unsigned char *rk,
|
||||
/* Set xmm2 to stuff:Y:stuff:stuff with Y = subword( r11 )
|
||||
* and proceed to generate next round key from there */
|
||||
AESKEYGENA xmm0_xmm2 ",0x00 \n\t"
|
||||
"pshufd $0xaa, %%xmm2, %%xmm2 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm2, %%xmm1 \n\t"
|
||||
"add $16, %0 \n\t"
|
||||
"movdqu %%xmm1, (%0) \n\t"
|
||||
"ret \n\t"
|
||||
"pshufd $0xaa, %%xmm2, %%xmm2 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm1, %%xmm2 \n\t"
|
||||
"pslldq $4, %%xmm1 \n\t"
|
||||
"pxor %%xmm2, %%xmm1 \n\t"
|
||||
"add $16, %0 \n\t"
|
||||
"movdqu %%xmm1, (%0) \n\t"
|
||||
"ret \n\t"
|
||||
|
||||
/*
|
||||
* Main "loop" - Generating one more key than necessary,
|
||||
* see definition of mbedtls_aes_context.buf
|
||||
*/
|
||||
"2: \n\t"
|
||||
"2: \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x01 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x02 \n\tcall 1b \n\t"
|
||||
AESKEYGENA xmm1_xmm2 ",0x04 \n\tcall 1b \n\t"
|
||||
|
||||
@@ -215,16 +215,16 @@ static const signed char indexes[2][4][20] = {
|
||||
}, /* KL -> RK */
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
}, /* KR -> RK */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
}, /* KR -> RK */
|
||||
{
|
||||
4, 5, 6, 7, 12, 13, 14, 15, 16, 17,
|
||||
18, 19, -1, 24, 25, -1, 31, 28, 29, 30
|
||||
}, /* KA -> RK */
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
} /* KB -> RK */
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
} /* KB -> RK */
|
||||
},
|
||||
{
|
||||
{
|
||||
@@ -233,12 +233,12 @@ static const signed char indexes[2][4][20] = {
|
||||
}, /* KL -> RK */
|
||||
{
|
||||
-1, -1, -1, -1, 8, 9, 10, 11, 16, 17,
|
||||
18, 19, -1, -1, -1, -1, 39, 36, 37, 38
|
||||
}, /* KR -> RK */
|
||||
18, 19, -1, -1, -1, -1, 39, 36, 37, 38
|
||||
}, /* KR -> RK */
|
||||
{
|
||||
-1, -1, -1, -1, 12, 13, 14, 15, 58, 59,
|
||||
56, 57, 31, 28, 29, 30, -1, -1, -1, -1
|
||||
}, /* KA -> RK */
|
||||
56, 57, 31, 28, 29, 30, -1, -1, -1, -1
|
||||
}, /* KA -> RK */
|
||||
{
|
||||
4, 5, 6, 7, 65, 66, 67, 64, 20, 21,
|
||||
22, 23, -1, -1, -1, -1, 43, 40, 41, 42
|
||||
|
||||
@@ -119,7 +119,7 @@ void mbedtls_ctr_drbg_set_reseed_interval(mbedtls_ctr_drbg_context *ctx,
|
||||
static int block_cipher_df(unsigned char *output,
|
||||
const unsigned char *data, size_t data_len) {
|
||||
unsigned char buf[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT +
|
||||
MBEDTLS_CTR_DRBG_BLOCKSIZE + 16];
|
||||
MBEDTLS_CTR_DRBG_BLOCKSIZE + 16];
|
||||
unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN];
|
||||
unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE];
|
||||
unsigned char chain[MBEDTLS_CTR_DRBG_BLOCKSIZE];
|
||||
|
||||
@@ -86,7 +86,7 @@ static void debug_header(memory_header *hdr) {
|
||||
#endif
|
||||
|
||||
mbedtls_fprintf(stderr, "HDR: PTR(%10zu), PREV(%10zu), NEXT(%10zu), "
|
||||
"ALLOC(%zu), SIZE(%10zu)\n",
|
||||
"ALLOC(%zu), SIZE(%10zu)\n",
|
||||
(size_t) hdr, (size_t) hdr->prev, (size_t) hdr->next,
|
||||
hdr->alloc, hdr->size);
|
||||
mbedtls_fprintf(stderr, " FPREV(%10zu), FNEXT(%10zu)\n",
|
||||
@@ -164,7 +164,7 @@ static int verify_chain(void) {
|
||||
if (prv == NULL || verify_header(prv) != 0) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: verification of first header "
|
||||
"failed\n");
|
||||
"failed\n");
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ static int verify_chain(void) {
|
||||
if (heap.first->prev != NULL) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: verification failed: "
|
||||
"first->prev != NULL\n");
|
||||
"first->prev != NULL\n");
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ static int verify_chain(void) {
|
||||
if (verify_header(cur) != 0) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: verification of header "
|
||||
"failed\n");
|
||||
"failed\n");
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ static int verify_chain(void) {
|
||||
if (cur->prev != prv) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: verification failed: "
|
||||
"cur->prev != prv\n");
|
||||
"cur->prev != prv\n");
|
||||
#endif
|
||||
return (1);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ static void *buffer_alloc_calloc(size_t n, size_t size) {
|
||||
if (cur->alloc != 0) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: block in free_list but allocated "
|
||||
"data\n");
|
||||
"data\n");
|
||||
#endif
|
||||
mbedtls_exit(1);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ static void buffer_alloc_free(void *ptr) {
|
||||
if (p < heap.buf || p >= heap.buf + heap.len) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: mbedtls_free() outside of managed "
|
||||
"space\n");
|
||||
"space\n");
|
||||
#endif
|
||||
mbedtls_exit(1);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ static void buffer_alloc_free(void *ptr) {
|
||||
if (hdr->alloc != 1) {
|
||||
#if defined(MBEDTLS_MEMORY_DEBUG)
|
||||
mbedtls_fprintf(stderr, "FATAL: mbedtls_free() on unallocated "
|
||||
"data\n");
|
||||
"data\n");
|
||||
#endif
|
||||
mbedtls_exit(1);
|
||||
}
|
||||
|
||||
@@ -445,14 +445,14 @@ union mbedtls_ssl_premaster_secret {
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
|
||||
unsigned char _pms_dhe_psk[4 + MBEDTLS_MPI_MAX_SIZE
|
||||
+ MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
|
||||
+ MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 3 */
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
|
||||
unsigned char _pms_rsa_psk[52 + MBEDTLS_PSK_MAX_LEN]; /* RFC 4279 4 */
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
|
||||
unsigned char _pms_ecdhe_psk[4 + MBEDTLS_ECP_MAX_BYTES
|
||||
+ MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
|
||||
+ MBEDTLS_PSK_MAX_LEN]; /* RFC 5489 2 */
|
||||
#endif
|
||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
|
||||
unsigned char _pms_ecjpake[32]; /* Thread spec: SHA-256 output */
|
||||
|
||||
@@ -804,7 +804,7 @@ static int ssl_write_use_srtp_ext(mbedtls_ssl_context *ssl,
|
||||
*/
|
||||
MBEDTLS_SSL_DEBUG_MSG(3,
|
||||
("client hello, "
|
||||
"illegal DTLS-SRTP protection profile %d",
|
||||
"illegal DTLS-SRTP protection profile %d",
|
||||
ssl->conf->dtls_srtp_profile_list[protection_profiles_index]
|
||||
));
|
||||
return (MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED);
|
||||
|
||||
@@ -3954,7 +3954,7 @@ static int ssl_buffer_message(mbedtls_ssl_context *ssl) {
|
||||
/* Silently ignore -- message too far in the future */
|
||||
MBEDTLS_SSL_DEBUG_MSG(2,
|
||||
("Ignore future HS message with sequence number %u, "
|
||||
"buffering window %u - %u",
|
||||
"buffering window %u - %u",
|
||||
recv_msg_seq, ssl->handshake->in_msg_seq,
|
||||
ssl->handshake->in_msg_seq + MBEDTLS_SSL_MAX_BUFFERED_HS - 1));
|
||||
|
||||
|
||||
@@ -2101,7 +2101,7 @@ int mbedtls_x509_crt_verify_info(char *buf, size_t size, const char *prefix,
|
||||
|
||||
if (flags != 0) {
|
||||
ret = mbedtls_snprintf(p, n, "%sUnknown reason "
|
||||
"(this should not happen)\n", prefix);
|
||||
"(this should not happen)\n", prefix);
|
||||
MBEDTLS_X509_SAFE_SNPRINTF;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -13793,6 +13793,6 @@
|
||||
"metadata": {
|
||||
"commands_extracted": 790,
|
||||
"extracted_by": "PM3Help2JSON v1.00",
|
||||
"extracted_on": "2026-02-06T12:06:55"
|
||||
"extracted_on": "2026-02-06T12:16:10"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -321,7 +321,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
// 64KB SRAM -> 524288 bits(max sample num) < 2^30
|
||||
uint32_t samples :
|
||||
uint32_t samples :
|
||||
LF_SAMPLES_BITS;
|
||||
bool realtime : 1;
|
||||
bool verbose : 1;
|
||||
|
||||
+3
-3
@@ -42,13 +42,13 @@ typedef struct {
|
||||
|
||||
uint8_t diversifier_len;
|
||||
uint8_t diversifier[16];
|
||||
|
||||
|
||||
uint8_t data_tag_len;
|
||||
uint8_t data_tag[8];
|
||||
|
||||
|
||||
uint8_t data_len;
|
||||
uint8_t data[128];
|
||||
|
||||
|
||||
uint8_t oid_len;
|
||||
uint8_t oid[32];
|
||||
} PACKED seos_emulate_req_t;
|
||||
|
||||
@@ -71,7 +71,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs,
|
||||
offset);
|
||||
if (filesz != memsz) {
|
||||
fprintf(stderr, "Error: PHDR file size does not equal memory size\n"
|
||||
"(DATA+BSS PHDRs do not make sense on ROM platforms!)\n");
|
||||
"(DATA+BSS PHDRs do not make sense on ROM platforms!)\n");
|
||||
return -1;
|
||||
}
|
||||
if (paddr < last_end) {
|
||||
|
||||
@@ -234,13 +234,13 @@ static void *worker(void *arg) {
|
||||
|
||||
static void print_help_and_exit(const char *cmd_name) {
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" * Counterfeit key recovery:\n"
|
||||
" %s -c <null key ERndB (8 hex digits)> <target key ERndB (8 hex digits)> <3DES base key hex (32 hex digits)> <key segment (1-4)> <num threads>\n"
|
||||
" * Reader nonce key recovery:\n"
|
||||
" %s -r <ERndB (8 hex digits)> <ERndARndB' (16 hex digits)> <3DES base key hex (32 hex digits)> <key segment (1-4)> <num threads>\n",
|
||||
cmd_name,
|
||||
cmd_name);
|
||||
"Usage:\n"
|
||||
" * Counterfeit key recovery:\n"
|
||||
" %s -c <null key ERndB (8 hex digits)> <target key ERndB (8 hex digits)> <3DES base key hex (32 hex digits)> <key segment (1-4)> <num threads>\n"
|
||||
" * Reader nonce key recovery:\n"
|
||||
" %s -r <ERndB (8 hex digits)> <ERndARndB' (16 hex digits)> <3DES base key hex (32 hex digits)> <key segment (1-4)> <num threads>\n",
|
||||
cmd_name,
|
||||
cmd_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user