From 570fc56c47524b9a23beddc0ab7426a31491c4ff Mon Sep 17 00:00:00 2001 From: Anton Logachev Date: Thu, 8 Apr 2021 18:00:30 +0300 Subject: [PATCH] Remove the SC_SEC_ENV_FILE_REF_PRESENT flag for Rutoken ECP cards Rutoken ECP cards have no default SE file. Previous cards ignored MSE with restoring default SE, but new cards don't. This requires SC_SEC_ENV_FILE_REF_PRESENT to be removed from env flags. --- src/libopensc/card-rtecp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libopensc/card-rtecp.c b/src/libopensc/card-rtecp.c index 81a2d959..db70fba8 100644 --- a/src/libopensc/card-rtecp.c +++ b/src/libopensc/card-rtecp.c @@ -366,6 +366,19 @@ static int rtecp_logout(sc_card_t *card) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r); } +static int rtecp_set_security_env( struct sc_card *card, + const struct sc_security_env *env, + int se_num) +{ + struct sc_security_env se_env; + if(!env) + return SC_ERROR_INVALID_ARGUMENTS; + + se_env= *env; + se_env.flags &= ~SC_SEC_ENV_FILE_REF_PRESENT; + return iso_ops->set_security_env(card, &se_env, se_num); +} + static int rtecp_cipher(sc_card_t *card, const u8 *data, size_t data_len, u8 *out, size_t out_len, int sign) { @@ -824,7 +837,7 @@ struct sc_card_driver * sc_get_rtecp_driver(void) rtecp_ops.verify = rtecp_verify; rtecp_ops.logout = rtecp_logout; /* restore_security_env */ - /* set_security_env */ + rtecp_ops.set_security_env = rtecp_set_security_env; rtecp_ops.decipher = rtecp_decipher; rtecp_ops.compute_signature = rtecp_compute_signature; rtecp_ops.change_reference_data = rtecp_change_reference_data;