From b1145ba57771237d5a7b8223f2f5746863b5f418 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Fri, 28 Dec 2018 14:50:23 +0200 Subject: [PATCH] mpi_get_uint --- client/emv/emv_roca.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/emv/emv_roca.c b/client/emv/emv_roca.c index 0dfaa1339..2843cb2c1 100644 --- a/client/emv/emv_roca.c +++ b/client/emv/emv_roca.c @@ -64,6 +64,15 @@ int bitand_is_zero( mbedtls_mpi* a, mbedtls_mpi* b ) { } +mbedtls_mpi_uint mpi_get_uint(const mbedtls_mpi *X) { + + if (X->n == 1) { + return X->p[0]; + } + + return 0; +} + bool emv_rocacheck(char *modulus) { mbedtls_mpi *t_modulus = NULL; @@ -93,7 +102,7 @@ bool emv_rocacheck(char *modulus) { MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi(t_temp, t_modulus, t_prime) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l(g_one, t_temp) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l(g_one, mpi_get_uint(t_temp)) ); if (bitand_is_zero(t_temp, g_prints[i])) { PrintAndLogEx(FAILED, "No fingerprint found\n");