added mpi print

This commit is contained in:
merlokk 2018-12-28 19:06:51 +02:00
commit 05814fbe75

View file

@ -73,6 +73,15 @@ mbedtls_mpi_uint mpi_get_uint(const mbedtls_mpi *X) {
return 0;
}
void print_mpi(const char *msg, int radix, const mbedtls_mpi *X) {
char Xchar[400] = {0};
size_t len = 0;
mbedtls_mpi_write_string(X, radix, Xchar, sizeof(Xchar), &len);
printf("%s[%d] %s\n", msg, len, Xchar);
}
bool emv_rocacheck(const unsigned char *buf, size_t buflen) {
mbedtls_mpi t_modulus;
@ -83,6 +92,7 @@ bool emv_rocacheck(const unsigned char *buf, size_t buflen) {
rocacheck_init();
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary(&t_modulus, buf, buflen) );
print_mpi("--t_modulus:", 16, &t_modulus);
for (int i = 0; i < ROCA_PRINTS_LENGTH; i++) {