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

sc-hsm-tool: Add options for public key authentication #1711

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
sc-hsm: use memcpy() instead of strncpy()
  • Loading branch information
Frank Braun committed Oct 29, 2019
commit ad357886c54acd0563c8a4683f9bf0948633641f
2 changes: 1 addition & 1 deletion src/libopensc/card-sc-hsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ static int get_CAR(u8 *carstr, sc_context_t *ctx, const u8 *buf, size_t buflen)
}

/* return CAR */
strncpy((char*) carstr, (const char*) car, taglen);
memcpy(carstr, car, taglen);
frankbraun marked this conversation as resolved.
Show resolved Hide resolved
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you also want to look at OpenPACE for more extended parsing/verification of CVCs. If you want to keep this self sustained within OpenSC, you should use sc_pkcs15emu_sc_hsm_decode_cvc()

Copy link
Author

Choose a reason for hiding this comment

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

I tried to parse this with sc_pkcs15emu_sc_hsm_decode_cvc(), but wasn't able to. I got the following error:

Required ASN.1 object not found

Copy link
Member

Choose a reason for hiding this comment

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

The idea is not to parse ASN.1 by hand. Please check what object is missing and why.


Expand Down
2 changes: 1 addition & 1 deletion src/tools/sc-hsm-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ static void get_CHR(char *chrstr, int is_cvc, sc_context_t *ctx, const u8 *buf,
}

/* return CHR */
strncpy(chrstr, (const char*) chr, taglen);
memcpy(chrstr, chr, taglen);
}


Expand Down