OpenPGP: Added support for PIN logout and status
This commit is contained in:
parent
995845b002
commit
449f6c2b94
|
@ -84,7 +84,8 @@ enum _version { /* 2-byte BCD-alike encoded version number */
|
|||
OPENPGP_CARD_1_1 = 0x0101,
|
||||
OPENPGP_CARD_2_0 = 0x0200,
|
||||
OPENPGP_CARD_2_1 = 0x0201,
|
||||
OPENPGP_CARD_3_0 = 0x0300
|
||||
OPENPGP_CARD_3_0 = 0x0300,
|
||||
OPENPGP_CARD_3_1 = 0x0301,
|
||||
};
|
||||
|
||||
enum _access { /* access flags for the respective DO/file */
|
||||
|
@ -536,6 +537,10 @@ pgp_get_card_features(sc_card_t *card)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->bcd_version >= OPENPGP_CARD_3_1) {
|
||||
card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
|
||||
}
|
||||
|
||||
if ((pgp_get_blob(card, priv->mf, 0x006e, &blob6e) >= 0) &&
|
||||
(pgp_get_blob(card, blob6e, 0x0073, &blob73) >= 0)) {
|
||||
|
||||
|
@ -1617,6 +1622,36 @@ pgp_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)
|
|||
}
|
||||
|
||||
|
||||
int pgp_logout(struct sc_card *card)
|
||||
{
|
||||
int r = SC_SUCCESS;
|
||||
struct pgp_priv_data *priv = DRVDATA(card);
|
||||
|
||||
LOG_FUNC_CALLED(card->ctx);
|
||||
|
||||
if (priv->bcd_version >= OPENPGP_CARD_3_1) {
|
||||
unsigned char pin_reference;
|
||||
for (pin_reference = 0x81; pin_reference <= 0x83; pin_reference++) {
|
||||
int tmp = iso7816_logout(card, pin_reference);
|
||||
if (r == SC_SUCCESS) {
|
||||
r = tmp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sc_path_t path;
|
||||
sc_file_t *file = NULL;
|
||||
|
||||
/* select application "OpenPGP" */
|
||||
sc_format_path("D276:0001:2401", &path);
|
||||
path.type = SC_PATH_TYPE_DF_NAME;
|
||||
r = iso_ops->select_file(card, &path, &file);
|
||||
sc_file_free(file);
|
||||
}
|
||||
|
||||
LOG_FUNC_RETURN(card->ctx, r);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ABI: set security environment.
|
||||
*/
|
||||
|
@ -2834,6 +2869,7 @@ sc_get_driver(void)
|
|||
pgp_ops.read_binary = pgp_read_binary;
|
||||
pgp_ops.write_binary = pgp_write_binary;
|
||||
pgp_ops.pin_cmd = pgp_pin_cmd;
|
||||
pgp_ops.logout = pgp_logout;
|
||||
pgp_ops.get_data = pgp_get_data;
|
||||
pgp_ops.put_data = pgp_put_data;
|
||||
pgp_ops.set_security_env= pgp_set_security_env;
|
||||
|
|
|
@ -1417,3 +1417,19 @@ int iso7816_write_binary_sfid(sc_card_t *card, unsigned char sfid,
|
|||
err:
|
||||
return r;
|
||||
}
|
||||
|
||||
int iso7816_logout(sc_card_t *card, unsigned char pin_reference)
|
||||
{
|
||||
int r;
|
||||
sc_apdu_t apdu;
|
||||
|
||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0xFF, pin_reference);
|
||||
|
||||
r = sc_transmit_apdu(card, &apdu);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1418,6 +1418,16 @@ int iso7816_read_binary_sfid(sc_card_t *card, unsigned char sfid,
|
|||
int iso7816_write_binary_sfid(sc_card_t *card, unsigned char sfid,
|
||||
u8 *ef, size_t ef_len);
|
||||
|
||||
/**
|
||||
* @brief Set verification status of a specific PIN to “not verified”
|
||||
*
|
||||
* @param[in] card
|
||||
* @param[in] pin_reference PIN reference written to P2
|
||||
*
|
||||
* @note The appropriate directory must be selected before calling this function.
|
||||
* */
|
||||
int iso7816_logout(sc_card_t *card, unsigned char pin_reference);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue