From 737ebf9ab885f4ba3bd87f021d407ee20dec4618 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Tue, 31 Mar 2020 19:26:09 +0300 Subject: [PATCH] ndef signature1 length fix --- client/mifare/ndef.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/mifare/ndef.c b/client/mifare/ndef.c index e2399b0fd..f1b3e42bd 100644 --- a/client/mifare/ndef.c +++ b/client/mifare/ndef.c @@ -171,16 +171,19 @@ static int ndefDecodeSig1(uint8_t *sig, size_t siglen) { size_t intsiglen = (sig[indx + 1] << 8) + sig[indx + 2]; // ecdsa 0x04 - if (sigType == stECDSA_P192) { + if (sigType == stECDSA_P192 || sigType == stECDSA_P256) { indx += 3; + int slen = 24; + if (sigType == stECDSA_P256) + slen = 32; PrintAndLogEx(NORMAL, "\tsignature [%zu]: %s", intsiglen, sprint_hex_inrow(&sig[indx], intsiglen)); uint8_t rval[300] = {0}; uint8_t sval[300] = {0}; int res = ecdsa_asn1_get_signature(&sig[indx], intsiglen, rval, sval); if (!res) { - PrintAndLogEx(NORMAL, "\t\tr: %s", sprint_hex(rval, 32)); - PrintAndLogEx(NORMAL, "\t\ts: %s", sprint_hex(sval, 32)); + PrintAndLogEx(NORMAL, "\t\tr: %s", sprint_hex(rval + 32 - slen, slen)); + PrintAndLogEx(NORMAL, "\t\ts: %s", sprint_hex(sval + 32 - slen, slen)); } } indx += intsiglen;