added PACE (--can) support to emrtd commands.

This commit is contained in:
iceman1001 committed 2026-08-21 22:32:06 +02:00
1 parent 122637f26f
commit f6e0119f5f
10 files changed
+1305 -447

No files matched your search

+2
View File
@@ -358,6 +358,8 @@ set (TARGET_SOURCES
${PM3_ROOT}/client/src/cipurse/cipursecrypto.c
${PM3_ROOT}/client/src/cipurse/cipursecore.c
${PM3_ROOT}/client/src/cipurse/cipursetest.c
${PM3_ROOT}/client/src/emrtd/emrtd_pace.c
${PM3_ROOT}/client/src/emrtd/emrtd_pacetest.c
${PM3_ROOT}/client/src/loclass/cipher.c
${PM3_ROOT}/client/src/loclass/cipher_bs.c
${PM3_ROOT}/client/src/loclass/cipher_bs_avx2.c
+2
View File
@@ -860,6 +860,8 @@ SRCS = mifare/aiddesfire.c \
cipurse/cipursecore.c \
cipurse/cipursecrypto.c \
cipurse/cipursetest.c \
emrtd/emrtd_pace.c \
emrtd/emrtd_pacetest.c \
fileutils.c \
flash.c \
frame_progress.c \
+1063 -387
View File
File diff suppressed because it is too large. Load diff
+13 -14
View File
@@ -47,23 +47,22 @@ typedef struct emrtd_hashalg_s {
const uint8_t descriptor[15];
} emrtd_hashalg_t;
typedef struct emrtd_pacealg_s {
const char *name;
int (*keygenerator)(uint8_t *datain, int datainlen, uint8_t *dataout);
const uint8_t descriptor[10];
} emrtd_pacealg_t;
// Standardized Domain Parameters
typedef struct emrtd_pacesdp_s {
uint8_t id;
const char *name;
size_t size;
} emrtd_pacesdp_t;
// Everything needed to authenticate to a document, either with BAC or with PACE
typedef struct emrtd_auth_s {
char documentnumber[10];
char dob[7];
char expiry[7];
char can[15];
bool mrz_available;
bool can_available;
bool force_pace; // fail rather than falling back to BAC
bool force_bac; // skip PACE even when EF_CardAccess is present
} emrtd_auth_t;
int CmdHFeMRTD(const char *Cmd);
int dumpHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, const char *path);
int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_available, bool only_fast);
int dumpHF_EMRTD(const emrtd_auth_t *auth, const char *path);
int infoHF_EMRTD(const emrtd_auth_t *auth, bool only_fast);
int infoHF_EMRTD_offline(const char *path);
#ifdef __cplusplus
+8 -1
View File
@@ -222,6 +222,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf 15 writeafi" },
{ 0, "hf 15 writedsfid" },
{ 0, "hf 15 csetuid" },
{ 0, "hf 15 cfinalize" },
{ 1, "hf aliro help" },
{ 1, "hf aliro list" },
{ 0, "hf aliro info" },
@@ -254,15 +255,16 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf emrtd dump" },
{ 1, "hf emrtd info" },
{ 1, "hf emrtd list" },
{ 1, "hf emrtd test" },
{ 1, "hf felica help" },
{ 1, "hf felica list" },
{ 0, "hf felica info" },
{ 0, "hf felica seacauth1" },
{ 0, "hf felica raw" },
{ 0, "hf felica rdbl" },
{ 0, "hf felica reader" },
{ 0, "hf felica sniff" },
{ 0, "hf felica wrbl" },
{ 0, "hf felica seacauth1" },
{ 0, "hf felica dump" },
{ 0, "hf felica discnodes" },
{ 0, "hf felica sim" },
@@ -676,7 +678,11 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hw bootloader" },
{ 1, "hw connect" },
{ 0, "hw dbg" },
{ 0, "hw fpga" },
{ 0, "hw fpgaoff" },
{ 0, "hw ant_pm5" },
{ 0, "hw qc_pm5" },
{ 0, "hw factorydata" },
{ 0, "hw lcd" },
{ 0, "hw lcdreset" },
{ 0, "hw ping" },
@@ -1117,6 +1123,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "script run lf_em_tearoff_protect.lua" },
{ 0, "script run lf_hid_bulkclone.lua" },
{ 0, "script run lf_hid_bulkclone_v2.lua" },
{ 0, "script run lf_ht2_paxton.lua" },
{ 0, "script run lf_ident_json.lua" },
{ 0, "script run lf_ioprox_bulkclone.lua" },
{ 0, "script run lf_t55xx_chk.lua" },
+36 -11
View File
@@ -270,6 +270,40 @@ const PictureItem *PictureWidget::pictureAt(int i) const {
return &m_images.at(i);
}
ScaledPictureLabel::ScaledPictureLabel(const QImage &img, QWidget *parent)
: QLabel(parent), m_image(img) {
setAlignment(Qt::AlignCenter);
setMinimumSize(1, 1);
// let the layout hand us whatever is going, we adapt to it
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
rescale();
}
QSize ScaledPictureLabel::sizeHint(void) const {
return m_image.size();
}
void ScaledPictureLabel::resizeEvent(QResizeEvent *event) {
QLabel::resizeEvent(event);
rescale();
}
void ScaledPictureLabel::rescale(void) {
if (m_image.isNull())
return;
QSize room = size();
if (room.width() < 1 || room.height() < 1)
return;
// Qt::KeepAspectRatio fits the image inside the box without distorting it.
// Scaling up is wanted here, a 240x320 portrait in a 400x400 window should
// fill the window rather than sit in the middle of it.
setPixmap(QPixmap::fromImage(m_image.scaled(room, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
}
// Append one image to the array and give it its own tab
void PictureWidget::addPicture(const QString &title, const QImage &img) {
@@ -281,17 +315,8 @@ void PictureWidget::addPicture(const QString &title, const QImage &img) {
QWidget *page = new QWidget();
QVBoxLayout *layout = new QVBoxLayout(page);
QLabel *lbl_pm = new QLabel();
lbl_pm->setPixmap(QPixmap::fromImage(img));
lbl_pm->setScaledContents(false);
lbl_pm->setAlignment(Qt::AlignCenter);
// large images (fingerprints, high res portraits) shouldn't blow up the window
QScrollArea *scroll = new QScrollArea(page);
scroll->setWidget(lbl_pm);
scroll->setWidgetResizable(true);
scroll->setAlignment(Qt::AlignCenter);
layout->addWidget(scroll);
ScaledPictureLabel *lbl_pm = new ScaledPictureLabel(img, page);
layout->addWidget(lbl_pm, 1);
QLabel *lbl_sz = new QLabel(page);
lbl_sz->setText(QString("w: %1 h: %2")
+22
View File
@@ -27,6 +27,7 @@
#include <QObject>
#include <QWidget>
#include <QPainter>
#include <QLabel>
#include <QtGui>
#include "proxgui.h"
@@ -101,6 +102,27 @@ class PictureItem {
QImage image;
};
/**
* @brief A label that keeps its image scaled to whatever room it is given
*
* Portraits in EF_DG2 are small (often 240x320) and signatures in EF_DG7 are
* wide and short. Painting either one at native size in a fixed window leaves
* it stranded in a corner, so the pixmap is rebuilt from the original image on
* every resize, fitted to the widget and keeping the aspect ratio.
*/
class ScaledPictureLabel : public QLabel {
public:
explicit ScaledPictureLabel(const QImage &img, QWidget *parent = nullptr);
QSize sizeHint(void) const override;
protected:
void resizeEvent(QResizeEvent *event) override;
private:
void rescale(void);
QImage m_image;
};
// Picture viewer window. Holds an array of images, one tab per image, so that
// several pictures of the same document (portrait, signature, other biometrics)
// can be shown side by side