Skip to content

Commit

Permalink
sc-hsm: fixed accessing version info (#1252)
Browse files Browse the repository at this point in the history
fixes #1244
  • Loading branch information
frankmorgner committed Feb 7, 2018
1 parent 88175e3 commit 36894c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/libopensc/card-sc-hsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,14 +1610,17 @@ static int sc_hsm_init(struct sc_card *card)

sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
if (sc_hsm_select_file_ex(card, &path, 0, &file) == SC_SUCCESS
&& file && file->prop_attr && file->prop_attr_len >= 5) {
&& file && file->prop_attr && file->prop_attr_len >= 2) {
static char card_name[SC_MAX_APDU_BUFFER_SIZE];
u8 type = file->prop_attr[2];
u8 major = file->prop_attr[3];
u8 minor = file->prop_attr[4];
u8 type = 0xFF;
u8 major = file->prop_attr[file->prop_attr_len - 2];
u8 minor = file->prop_attr[file->prop_attr_len - 1];
char p00[] = "SmartCard-HSM Applet for JCOP";
char p01[] = "SmartCard-HSM Demo Applet for JCOP";
char *p = "SmartCard-HSM";
if (file->prop_attr_len >= 3) {
type = file->prop_attr[file->prop_attr_len - 3];
}
switch (type) {
case 0x00:
p = p00;
Expand Down
6 changes: 4 additions & 2 deletions src/libopensc/pkcs15-sc-hsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,10 @@ static int sc_pkcs15emu_sc_hsm_init (sc_pkcs15_card_t * p15card)

p15card->card->version.hw_major = 24; /* JCOP 2.4.1r3 */
p15card->card->version.hw_minor = 13;
p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
if (file && file->prop_attr && file->prop_attr_len >= 2) {
p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
}

sc_file_free(file);

Expand Down

0 comments on commit 36894c8

Please sign in to comment.