mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
data num didnt properly zero pad binary string outputs. It was cutting starting zeros. Those are now handled. Hex output still doesnt handle zero padding
This commit is contained in:
parent
2932fefd82
commit
8c04d9d0c8
2 changed files with 42 additions and 10 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Changed `data num` - outputed binary strings are now properly zero padded (@iceman1001)
|
||||
- Changed `hf iclass info` - now tries default keys and decode if legacy (@iceman1001)
|
||||
- Changed `hf iclass chk` - now loads dictionary file by default (@iceman1001)
|
||||
- Added an Makefile variable `DONT_BUILD_NATIVE` in mfd_aes_brute Makefile to easify downstream package
|
||||
|
|
|
@ -3156,11 +3156,20 @@ static int CmdNumCon(const char *Cmd) {
|
|||
|
||||
char s[600] = {0};
|
||||
size_t slen = 0;
|
||||
const char pad[] = "00000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
for (uint8_t i = 0; i < ARRAYLEN(radix); i++) {
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_write_string(&N, radix[i].radix, s, sizeof(s), &slen));
|
||||
if (slen) {
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, s);
|
||||
|
||||
// only pad bin string
|
||||
int pn = 0;
|
||||
if (i==2) {
|
||||
if (slen < blen) {
|
||||
pn = blen - slen + 1;
|
||||
}
|
||||
}
|
||||
PrintAndLogEx(SUCCESS, "%s%.*s%s",radix[i].desc, pn, pad, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3182,10 +3191,20 @@ static int CmdNumCon(const char *Cmd) {
|
|||
for (uint8_t i = 0; i < ARRAYLEN(radix); i++) {
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_write_string(&N, radix[i].radix, s, sizeof(s), &slen));
|
||||
|
||||
str_reverse(s, strlen(s));
|
||||
|
||||
if (slen) {
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, s);
|
||||
|
||||
// only pad bin string
|
||||
char scpy[600] = {0x30};
|
||||
memset(scpy, 0x30, sizeof(scpy));
|
||||
int pn = 0;
|
||||
if (i==2) {
|
||||
if (slen < blen) {
|
||||
pn = blen - slen + 1;
|
||||
}
|
||||
}
|
||||
memcpy(scpy + pn, s, slen);
|
||||
str_reverse(scpy, strlen(scpy));
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, scpy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3213,21 +3232,33 @@ static int CmdNumCon(const char *Cmd) {
|
|||
}
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
case 0: {
|
||||
// MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&N, &N, &base));
|
||||
break;
|
||||
case 1:
|
||||
}
|
||||
case 1: {
|
||||
str_inverse_hex(s, strlen(s));
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, s);
|
||||
break;
|
||||
case 2:
|
||||
str_inverse_bin(s, strlen(s));
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, s);
|
||||
}
|
||||
case 2: {
|
||||
|
||||
char scpy[600] = {0x30};
|
||||
memset(scpy, 0x30, sizeof(scpy));
|
||||
int pn = 0;
|
||||
if (slen < blen) {
|
||||
pn = blen - slen + 1;
|
||||
}
|
||||
memcpy(scpy + pn, s, slen);
|
||||
str_inverse_bin(scpy, strlen(scpy));
|
||||
PrintAndLogEx(SUCCESS, "%s%s", radix[i].desc, scpy);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ascii
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_write_string(&N, 16, s, sizeof(s), &slen));
|
||||
if (slen) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue