Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openssl error info #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion prototype/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

#define err(x) res_err(x, xstr(x))
#define errb(x) res_errb(x, xstr(x))
#define errssl(x) openssl_res_err(x, xstr(x))
#define byte guint8

typedef struct DeviceInfo {
Expand Down Expand Up @@ -153,6 +154,13 @@ bool compare(byte * data1, int data_len, dword * expected, int exp_len) {
return data_len == exp_len;
}

void openssl_res_err(int result, char* where) {
if (result != 0) {
printf("Failed '%s': %d - %s\n", where, result, ERR_reason_error_string(ERR_get_error()));
exit(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to exit here?
Maybe it's useful to proceed and see what happens afterwards.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my 0094, it can reach the menu:
1 - Scan fingerprint
2 - Test leds
0 - Exit
But none of them works. The device replies with 0404.

I think the exit may still be necessary to guarantee a proper process.

Copy link
Author

@Inokinoki Inokinoki Jan 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's necessary to have a EC_KEY_check_key there and fail it if the private key not suitable, because I did a workaround during the parse of private key, which may lead some errors...
Before doing that, the header check and the padding check for the private key always failed.

}
}

void res_err(int result, char* where) {
if (result != 0) {
printf("Failed '%s': %d - %s\n", where, result, libusb_error_name(result));
Expand Down Expand Up @@ -421,7 +429,7 @@ EC_KEY * load_key(byte *data, bool is_private) {
goto err;
}
}
err(EC_KEY_check_key(key) - 1);
errssl(EC_KEY_check_key(key) - 1);

goto clean;

Expand Down