version 1.14.2.3, 2002/03/08 17:04:42 |
version 1.15, 2001/09/28 09:49:31 |
|
|
|
|
/* interface to libsectok */ |
/* interface to libsectok */ |
|
|
static int |
static int |
sc_open(void) |
sc_open(void) |
{ |
{ |
int sw; |
int sw; |
|
|
return sc_fd; |
return sc_fd; |
} |
} |
|
|
static int |
static int |
sc_enable_applet(void) |
sc_enable_applet(void) |
{ |
{ |
static u_char aid[] = {0xfc, 0x53, 0x73, 0x68, 0x2e, 0x62, 0x69, 0x6e}; |
static u_char aid[] = {0xfc, 0x53, 0x73, 0x68, 0x2e, 0x62, 0x69, 0x6e}; |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
sc_init(void) |
sc_init(void) |
{ |
{ |
int status; |
int status; |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
sc_read_pubkey(Key * k) |
sc_read_pubkey(Key * k) |
{ |
{ |
u_char buf[2], *n; |
u_char buf[2], *n; |
|
|
|
|
/* get key size */ |
/* get key size */ |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_KEYLENGTH, 0, 0, 0, NULL, |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_KEYLENGTH, 0, 0, 0, NULL, |
sizeof(buf), buf, &sw); |
sizeof(buf), buf, &sw); |
if (!sectok_swOK(sw)) { |
if (!sectok_swOK(sw)) { |
error("could not obtain key length: %s", sectok_get_sw(sw)); |
error("could not obtain key length: %s", sectok_get_sw(sw)); |
goto err; |
goto err; |
|
|
goto err; |
goto err; |
} |
} |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_RESPONSE, 0, 0, 0, NULL, |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_RESPONSE, 0, 0, 0, NULL, |
len, padded, &sw); |
len, padded, &sw); |
if (!sectok_swOK(sw)) { |
if (!sectok_swOK(sw)) { |
error("sc_private_decrypt: INS_GET_RESPONSE failed: %s", |
error("sc_private_decrypt: INS_GET_RESPONSE failed: %s", |
sectok_get_sw(sw)); |
sectok_get_sw(sw)); |
|
|
goto err; |
goto err; |
} |
} |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_RESPONSE, 0, 0, 0, NULL, |
sectok_apdu(sc_fd, CLA_SSH, INS_GET_RESPONSE, 0, 0, 0, NULL, |
len, to, &sw); |
len, to, &sw); |
if (!sectok_swOK(sw)) { |
if (!sectok_swOK(sw)) { |
error("sc_private_decrypt: INS_GET_RESPONSE failed: %s", |
error("sc_private_decrypt: INS_GET_RESPONSE failed: %s", |
sectok_get_sw(sw)); |
sectok_get_sw(sw)); |
|
|
smart_rsa.rsa_sign = def->rsa_sign; |
smart_rsa.rsa_sign = def->rsa_sign; |
smart_rsa.rsa_verify = def->rsa_verify; |
smart_rsa.rsa_verify = def->rsa_verify; |
|
|
if ((smart_engine = ENGINE_new()) == NULL) |
smart_engine = ENGINE_new(); |
fatal("ENGINE_new failed"); |
|
|
|
ENGINE_set_id(smart_engine, "sectok"); |
ENGINE_set_id(smart_engine, "sectok"); |
ENGINE_set_name(smart_engine, "libsectok"); |
ENGINE_set_name(smart_engine, "libsectok"); |