Verification infrastructure
Similar model to enrollment.
This commit is contained in:
parent
39271b4fe5
commit
68bdfc7868
4 changed files with 100 additions and 2 deletions
|
@ -85,10 +85,45 @@ struct fp_print_data *enroll(struct fp_dev *dev) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Enrollment completed!\n");
|
printf("Enrollment completed!\n\n");
|
||||||
return enrolled_print;
|
return enrolled_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int verify(struct fp_dev *dev, struct fp_print_data *data)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
|
||||||
|
do {
|
||||||
|
sleep(1);
|
||||||
|
printf("\nScan your finger now.\n");
|
||||||
|
r = fp_verify_finger(dev, data);
|
||||||
|
if (r < 0) {
|
||||||
|
printf("verification failed with error %d :(\n", r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
switch (r) {
|
||||||
|
case FP_VERIFY_NO_MATCH:
|
||||||
|
printf("NO MATCH!\n");
|
||||||
|
return 0;
|
||||||
|
case FP_VERIFY_MATCH:
|
||||||
|
printf("MATCH!\n");
|
||||||
|
return 0;
|
||||||
|
case FP_VERIFY_RETRY:
|
||||||
|
printf("Scan didn't quite work. Please try again.\n");
|
||||||
|
break;
|
||||||
|
case FP_VERIFY_RETRY_TOO_SHORT:
|
||||||
|
printf("Swipe was too short, please try again.\n");
|
||||||
|
break;
|
||||||
|
case FP_VERIFY_RETRY_CENTER_FINGER:
|
||||||
|
printf("Please center your finger on the sensor and try again.\n");
|
||||||
|
break;
|
||||||
|
case FP_VERIFY_RETRY_REMOVE_FINGER:
|
||||||
|
printf("Please remove finger from the sensor and try again.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (1);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
@ -128,7 +163,24 @@ int main(void)
|
||||||
if (!data)
|
if (!data)
|
||||||
goto out_close;
|
goto out_close;
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
printf("Normally we'd save that print to disk, and recall it at some "
|
||||||
|
"point later when we want to authenticate the user who just "
|
||||||
|
"enrolled. In the interests of demonstration, we'll authenticate "
|
||||||
|
"that user immediately.\n");
|
||||||
|
|
||||||
|
do {
|
||||||
|
char buffer[20];
|
||||||
|
|
||||||
|
verify(dev, data);
|
||||||
|
printf("Verify again? [Y/n]? ");
|
||||||
|
fgets(buffer, sizeof(buffer), stdin);
|
||||||
|
buffer[sizeof(buffer) - 1] = 0; /* null-terminate */
|
||||||
|
if (buffer[0] != '\n' && buffer[0] != 'y' && buffer[0] != 'Y')
|
||||||
|
break;
|
||||||
|
} while (1);
|
||||||
|
|
||||||
|
fp_print_data_free(data);
|
||||||
out_close:
|
out_close:
|
||||||
fp_dev_close(dev);
|
fp_dev_close(dev);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -295,6 +295,39 @@ API_EXPORTED int fp_enroll_finger(struct fp_dev *dev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORTED int fp_verify_finger(struct fp_dev *dev,
|
||||||
|
struct fp_print_data *enrolled_print)
|
||||||
|
{
|
||||||
|
const struct fp_driver *drv = dev->drv;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (!enrolled_print) {
|
||||||
|
fp_err("no print given");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!drv->verify) {
|
||||||
|
fp_err("driver %s has no verify func", drv->name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fpi_print_data_compatible(dev, enrolled_print)) {
|
||||||
|
fp_err("print is not compatible with device");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fp_dbg("to be handled by %s", drv->name);
|
||||||
|
r = drv->verify(dev, enrolled_print);
|
||||||
|
if (r < 0)
|
||||||
|
fp_dbg("verify error %d", r);
|
||||||
|
else if (r == 0)
|
||||||
|
fp_dbg("result: no match");
|
||||||
|
else
|
||||||
|
fp_dbg("result: match");
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORTED int fp_init(void)
|
API_EXPORTED int fp_init(void)
|
||||||
{
|
{
|
||||||
fp_dbg("");
|
fp_dbg("");
|
||||||
|
|
|
@ -98,6 +98,7 @@ struct fp_driver {
|
||||||
void (*exit)(struct fp_dev *dev);
|
void (*exit)(struct fp_dev *dev);
|
||||||
int (*enroll)(struct fp_dev *dev, gboolean initial, int stage,
|
int (*enroll)(struct fp_dev *dev, gboolean initial, int stage,
|
||||||
struct fp_print_data **print_data);
|
struct fp_print_data **print_data);
|
||||||
|
int (*verify)(struct fp_dev *dev, struct fp_print_data *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct fp_driver upekts_driver;
|
extern const struct fp_driver upekts_driver;
|
||||||
|
|
|
@ -54,6 +54,18 @@ enum fp_enroll_result {
|
||||||
|
|
||||||
int fp_enroll_finger(struct fp_dev *dev, struct fp_print_data **print_data);
|
int fp_enroll_finger(struct fp_dev *dev, struct fp_print_data **print_data);
|
||||||
|
|
||||||
|
/* Verification */
|
||||||
|
enum fp_verify_result {
|
||||||
|
FP_VERIFY_NO_MATCH = 0,
|
||||||
|
FP_VERIFY_MATCH = 1,
|
||||||
|
FP_VERIFY_RETRY = FP_ENROLL_RETRY,
|
||||||
|
FP_VERIFY_RETRY_TOO_SHORT = FP_ENROLL_RETRY_TOO_SHORT,
|
||||||
|
FP_VERIFY_RETRY_CENTER_FINGER = FP_ENROLL_RETRY_CENTER_FINGER,
|
||||||
|
FP_VERIFY_RETRY_REMOVE_FINGER = FP_ENROLL_RETRY_REMOVE_FINGER,
|
||||||
|
};
|
||||||
|
|
||||||
|
int fp_verify_finger(struct fp_dev *dev, struct fp_print_data *enrolled_print);
|
||||||
|
|
||||||
/* Data handling */
|
/* Data handling */
|
||||||
void fp_print_data_free(struct fp_print_data *data);
|
void fp_print_data_free(struct fp_print_data *data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue