]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/emv/emv_pki.c
Increase threshold to 160, fix for issue 756 (#760)
[proxmark3-svn] / client / emv / emv_pki.c
index 7803060e2e6b33eda5c471d182ed6d65f6708ce4..da102291876fd69a29dcd4a78585dd6074ecb2e5 100644 (file)
 #include <string.h>
 #include <stdarg.h>
 
+static bool strictExecution = true;
+void PKISetStrictExecution(bool se) {
+       strictExecution = se;
+}
+
 static const unsigned char empty_tlv_value[] = {};
 static const struct tlv empty_tlv = {.tag = 0x0, .len = 0, .value = empty_tlv_value};
 
@@ -53,7 +58,7 @@ static unsigned char *emv_pki_decode_message(const struct emv_pk *enc_pk,
        }
 
        if (cert_tlv->len != enc_pk->mlen) {
-               printf("ERROR: Certificate length (%d) not equal key length (%d)\n", cert_tlv->len, enc_pk->mlen);
+               printf("ERROR: Certificate length (%zd) not equal key length (%zd)\n", cert_tlv->len, enc_pk->mlen);
                return NULL;
        }
        kcp = crypto_pk_open(enc_pk->pk_algo,
@@ -108,9 +113,12 @@ static unsigned char *emv_pki_decode_message(const struct emv_pk *enc_pk,
                printf("ERROR: Calculated wrong hash\n");
                printf("decoded:    %s\n",sprint_hex(data + data_len - 1 - hash_len, hash_len));
                printf("calculated: %s\n",sprint_hex(crypto_hash_read(ch), hash_len));
-               crypto_hash_close(ch);
-               free(data);
-               return NULL;
+               
+               if (strictExecution) {
+                       crypto_hash_close(ch);
+                       free(data);
+                       return NULL;
+               }
        }
 
        crypto_hash_close(ch);
@@ -451,7 +459,7 @@ struct tlvdb *emv_pki_perform_cda_ex(const struct emv_pk *enc_pk, const struct t
                        un_tlv,
                        NULL);
        if (!data || data_len < 3) {
-               printf("ERROR: can't decode message. len %d\n", data_len);
+               printf("ERROR: can't decode message. len %zd\n", data_len);
                return NULL;
        }
 
Impressum, Datenschutz