replace SC_FUNC_CALLED with LOG_FUNC_CALLED
This commit is contained in:
parent
18dc38a618
commit
cf55cdc637
@ -267,7 +267,7 @@ static int asepcos_select_file(sc_card_t *card, const sc_path_t *in_path,
|
|||||||
int r;
|
int r;
|
||||||
sc_path_t npath = *in_path;
|
sc_path_t npath = *in_path;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (in_path->type == SC_PATH_TYPE_PATH) {
|
if (in_path->type == SC_PATH_TYPE_PATH) {
|
||||||
/* check the current DF to avoid unnecessary re-selection of
|
/* check the current DF to avoid unnecessary re-selection of
|
||||||
@ -436,7 +436,7 @@ static int asepcos_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_le
|
|||||||
int r;
|
int r;
|
||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
/* call RSA ENCRYPT DECRYPT for the decipher operation */
|
/* call RSA ENCRYPT DECRYPT for the decipher operation */
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x14, 0x01, 0x00);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x14, 0x01, 0x00);
|
||||||
@ -469,7 +469,7 @@ static int asepcos_compute_signature(sc_card_t *card, const u8 *data, size_t dat
|
|||||||
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (datalen >= 256)
|
if (datalen >= 256)
|
||||||
atype = SC_APDU_CASE_4_EXT;
|
atype = SC_APDU_CASE_4_EXT;
|
||||||
|
@ -767,7 +767,7 @@ static int atrust_acos_decipher(struct sc_card *card,
|
|||||||
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
|
|
||||||
assert(card != NULL && crgram != NULL && out != NULL);
|
assert(card != NULL && crgram != NULL && out != NULL);
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (crgram_len > 255)
|
if (crgram_len > 255)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ static int cac_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t* seri
|
|||||||
{
|
{
|
||||||
cac_private_data_t * priv = CAC_DATA(card);
|
cac_private_data_t * priv = CAC_DATA(card);
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->serialnr.len) {
|
if (card->serialnr.len) {
|
||||||
*serial = card->serialnr;
|
*serial = card->serialnr;
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
@ -684,7 +684,7 @@ static int cac_get_ACA_path(sc_card_t *card, sc_path_t *path)
|
|||||||
{
|
{
|
||||||
cac_private_data_t * priv = CAC_DATA(card);
|
cac_private_data_t * priv = CAC_DATA(card);
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (priv->aca_path) {
|
if (priv->aca_path) {
|
||||||
*path = *priv->aca_path;
|
*path = *priv->aca_path;
|
||||||
}
|
}
|
||||||
|
@ -595,7 +595,7 @@ static int cardos_construct_fcp(sc_card_t *card, const sc_file_t *file,
|
|||||||
size_t inlen = *outlen, len;
|
size_t inlen = *outlen, len;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (out == NULL || inlen < 64)
|
if (out == NULL || inlen < 64)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
|
@ -1359,7 +1359,7 @@ static int coolkey_get_token_info(sc_card_t *card, sc_pkcs15_tokeninfo_t * token
|
|||||||
char *manufacturer_id = NULL;
|
char *manufacturer_id = NULL;
|
||||||
char *serial_number = NULL;
|
char *serial_number = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
label = strdup((char *)priv->token_name);
|
label = strdup((char *)priv->token_name);
|
||||||
manufacturer_id = coolkey_get_manufacturer(&priv->cuid);
|
manufacturer_id = coolkey_get_manufacturer(&priv->cuid);
|
||||||
serial_number = coolkey_cuid_to_string(&priv->cuid);
|
serial_number = coolkey_cuid_to_string(&priv->cuid);
|
||||||
@ -1380,7 +1380,7 @@ static int coolkey_get_serial_nr_from_CUID(sc_card_t* card, sc_serial_number_t*
|
|||||||
{
|
{
|
||||||
coolkey_private_data_t * priv = COOLKEY_DATA(card);
|
coolkey_private_data_t * priv = COOLKEY_DATA(card);
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
memcpy(serial->value, &priv->cuid, sizeof(priv->cuid));
|
memcpy(serial->value, &priv->cuid, sizeof(priv->cuid));
|
||||||
serial->len = sizeof(priv->cuid);
|
serial->len = sizeof(priv->cuid);
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
|
@ -745,7 +745,7 @@ static int gids_set_security_env(sc_card_t *card,
|
|||||||
|
|
||||||
assert(card != NULL && env != NULL);
|
assert(card != NULL && env != NULL);
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
memset(sbuf, 0, sizeof(sbuf));
|
memset(sbuf, 0, sizeof(sbuf));
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_MANAGE_SECURITY_ENVIRONMENT, P1_DECIPHERMENT_INTERNAL_AUTHENTICATE_KEY_AGREEMENT, 0);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_MANAGE_SECURITY_ENVIRONMENT, P1_DECIPHERMENT_INTERNAL_AUTHENTICATE_KEY_AGREEMENT, 0);
|
||||||
@ -827,7 +827,7 @@ static int gids_logout(sc_card_t *card)
|
|||||||
int r;
|
int r;
|
||||||
assert(card && card->ctx);
|
assert(card && card->ctx);
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
// use the special PIN to deauthenticate
|
// use the special PIN to deauthenticate
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, INS_VERIFY, 0x00, P2_PIN_DEAUTHENTICATE);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, INS_VERIFY, 0x00, P2_PIN_DEAUTHENTICATE);
|
||||||
@ -917,7 +917,7 @@ static int gids_select_file(sc_card_t *card, const struct sc_path *in_path,
|
|||||||
struct sc_context *ctx = card->ctx;
|
struct sc_context *ctx = card->ctx;
|
||||||
struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
|
struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
data->state = GIDS_STATE_NONE;
|
data->state = GIDS_STATE_NONE;
|
||||||
data->currentDO = 0;
|
data->currentDO = 0;
|
||||||
@ -985,7 +985,7 @@ static int gids_read_binary(sc_card_t *card, unsigned int offset,
|
|||||||
int r;
|
int r;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (! data->currentDO || ! data->currentEFID) {
|
if (! data->currentDO || ! data->currentEFID) {
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
|
||||||
@ -2016,7 +2016,7 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) {
|
|||||||
|
|
||||||
static int gids_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr)
|
static int gids_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr)
|
||||||
{
|
{
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SC_CARDCTL_GET_SERIALNR:
|
case SC_CARDCTL_GET_SERIALNR:
|
||||||
return gids_get_serialnr(card, (sc_serial_number_t *) ptr);
|
return gids_get_serialnr(card, (sc_serial_number_t *) ptr);
|
||||||
|
@ -756,7 +756,7 @@ static int jcop_decipher(sc_card_t *card,
|
|||||||
struct jcop_private_data *drvdata=DRVDATA(card);
|
struct jcop_private_data *drvdata=DRVDATA(card);
|
||||||
|
|
||||||
assert(card != NULL && crgram != NULL && out != NULL);
|
assert(card != NULL && crgram != NULL && out != NULL);
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (crgram_len > 256)
|
if (crgram_len > 256)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
if (drvdata->invalid_senv)
|
if (drvdata->invalid_senv)
|
||||||
|
@ -1169,7 +1169,7 @@ static int mcrd_set_security_env(sc_card_t * card,
|
|||||||
|
|
||||||
if (!(card != NULL && env != NULL))
|
if (!(card != NULL && env != NULL))
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
priv = DRVDATA(card);
|
priv = DRVDATA(card);
|
||||||
|
|
||||||
/* special environment handling for esteid, stolen from openpgp */
|
/* special environment handling for esteid, stolen from openpgp */
|
||||||
@ -1341,7 +1341,7 @@ static int mcrd_compute_signature(sc_card_t * card,
|
|||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
env = &priv->sec_env;
|
env = &priv->sec_env;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (env->operation != SC_SEC_OPERATION_SIGN)
|
if (env->operation != SC_SEC_OPERATION_SIGN)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
if (datalen > 255)
|
if (datalen > 255)
|
||||||
@ -1437,7 +1437,7 @@ static int mcrd_pin_cmd(sc_card_t * card, struct sc_pin_cmd_data *data,
|
|||||||
int *tries_left)
|
int *tries_left)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
data->pin1.offset = 5;
|
data->pin1.offset = 5;
|
||||||
data->pin1.length_offset = 4;
|
data->pin1.length_offset = 4;
|
||||||
data->pin2.offset = 5;
|
data->pin2.offset = 5;
|
||||||
|
@ -1172,7 +1172,6 @@ static int myeid_decipher(struct sc_card *card, const u8 * crgram,
|
|||||||
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
|
||||||
|
|
||||||
assert(card != NULL && crgram != NULL && out != NULL);
|
assert(card != NULL && crgram != NULL && out != NULL);
|
||||||
|
|
||||||
@ -1307,7 +1306,7 @@ static int myeid_unwrap_key(struct sc_card *card, const u8 *crgram, size_t crgra
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (crgram_len > MYEID_MAX_RSA_KEY_LEN / 8)
|
if (crgram_len > MYEID_MAX_RSA_KEY_LEN / 8)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
@ -111,7 +111,7 @@ static int rutoken_match_card(sc_card_t *card)
|
|||||||
|
|
||||||
static int token_init(sc_card_t *card, const char *card_name)
|
static int token_init(sc_card_t *card, const char *card_name)
|
||||||
{
|
{
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
card->name = card_name;
|
card->name = card_name;
|
||||||
card->caps |= SC_CARD_CAP_RNG;
|
card->caps |= SC_CARD_CAP_RNG;
|
||||||
@ -479,7 +479,7 @@ static int rutoken_construct_fci(sc_card_t *card, const sc_file_t *file,
|
|||||||
u8 buf[64], *p = out;
|
u8 buf[64], *p = out;
|
||||||
|
|
||||||
assert(card && card->ctx);
|
assert(card && card->ctx);
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
assert(file && out && outlen);
|
assert(file && out && outlen);
|
||||||
assert(*outlen >= (size_t)(p - out) + 2);
|
assert(*outlen >= (size_t)(p - out) + 2);
|
||||||
@ -548,7 +548,7 @@ static int set_sec_attr_from_acl(sc_card_t *card, sc_file_t *file)
|
|||||||
sc_SecAttrV2_t attr = { 0 };
|
sc_SecAttrV2_t attr = { 0 };
|
||||||
int ret = SC_SUCCESS;
|
int ret = SC_SUCCESS;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (file->type == SC_FILE_TYPE_DF)
|
if (file->type == SC_FILE_TYPE_DF)
|
||||||
{
|
{
|
||||||
@ -850,7 +850,7 @@ static int rutoken_key_gen(sc_card_t *card, sc_DOHdrV2_t *pHdr)
|
|||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (
|
if (
|
||||||
(pHdr->wDOBodyLen != SC_RUTOKEN_DEF_LEN_DO_GOST) ||
|
(pHdr->wDOBodyLen != SC_RUTOKEN_DEF_LEN_DO_GOST) ||
|
||||||
(pHdr->OTID.byObjectType != SC_RUTOKEN_TYPE_KEY) ||
|
(pHdr->OTID.byObjectType != SC_RUTOKEN_TYPE_KEY) ||
|
||||||
@ -883,7 +883,7 @@ static int rutoken_create_do(sc_card_t *card, sc_DO_V2_t * pDO)
|
|||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (
|
if (
|
||||||
((pDO->HDR.OTID.byObjectType & SC_RUTOKEN_TYPE_CHV) &&
|
((pDO->HDR.OTID.byObjectType & SC_RUTOKEN_TYPE_CHV) &&
|
||||||
(pDO->HDR.OTID.byObjectID != SC_RUTOKEN_DEF_ID_GCHV_USER) &&
|
(pDO->HDR.OTID.byObjectID != SC_RUTOKEN_DEF_ID_GCHV_USER) &&
|
||||||
@ -925,7 +925,7 @@ static int rutoken_get_do_info(sc_card_t *card, sc_DO_INFO_t * pInfo)
|
|||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if ((pInfo->SelType != select_first) &&
|
if ((pInfo->SelType != select_first) &&
|
||||||
((pInfo->DoId < SC_RUTOKEN_DO_ALL_MIN_ID) ||
|
((pInfo->DoId < SC_RUTOKEN_DO_ALL_MIN_ID) ||
|
||||||
(pInfo->DoId > SC_RUTOKEN_DO_NOCHV_MAX_ID_V2)))
|
(pInfo->DoId > SC_RUTOKEN_DO_NOCHV_MAX_ID_V2)))
|
||||||
@ -971,7 +971,7 @@ static int rutoken_delete_do(sc_card_t *card, u8 *pId)
|
|||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if ((*pId < SC_RUTOKEN_DO_ALL_MIN_ID) ||
|
if ((*pId < SC_RUTOKEN_DO_ALL_MIN_ID) ||
|
||||||
(*pId > SC_RUTOKEN_DO_NOCHV_MAX_ID_V2))
|
(*pId > SC_RUTOKEN_DO_NOCHV_MAX_ID_V2))
|
||||||
{
|
{
|
||||||
@ -1001,7 +1001,7 @@ static int rutoken_cipher_p(sc_card_t *card, const u8 * crgram, size_t crgram_le
|
|||||||
int ret;
|
int ret;
|
||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
": crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u",
|
": crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
crgram_len, outlen);
|
crgram_len, outlen);
|
||||||
@ -1088,7 +1088,7 @@ static int rutoken_compute_mac_gost(sc_card_t *card,
|
|||||||
int ret;
|
int ret;
|
||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (!in || !out || olen != 4 || ilen == 0)
|
if (!in || !out || olen != 4 || ilen == 0)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
do
|
do
|
||||||
@ -1163,7 +1163,7 @@ static int rutoken_get_serial(sc_card_t *card, sc_serial_number_t *serial)
|
|||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x81);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x81);
|
||||||
apdu.resp = serial->value;
|
apdu.resp = serial->value;
|
||||||
apdu.resplen = sizeof(serial->value);
|
apdu.resplen = sizeof(serial->value);
|
||||||
@ -1182,7 +1182,7 @@ static int rutoken_get_info(sc_card_t *card, void *buff)
|
|||||||
u8 rbuf[8];
|
u8 rbuf[8];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x89);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x89);
|
||||||
apdu.resp = rbuf;
|
apdu.resp = rbuf;
|
||||||
apdu.resplen = sizeof(rbuf);
|
apdu.resplen = sizeof(rbuf);
|
||||||
@ -1200,7 +1200,7 @@ static int rutoken_format(sc_card_t *card, int apdu_ins)
|
|||||||
int ret;
|
int ret;
|
||||||
sc_apdu_t apdu;
|
sc_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, apdu_ins, 0x00, 0x00);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, apdu_ins, 0x00, 0x00);
|
||||||
apdu.cla = 0x80;
|
apdu.cla = 0x80;
|
||||||
ret = sc_transmit_apdu(card, &apdu);
|
ret = sc_transmit_apdu(card, &apdu);
|
||||||
|
@ -1854,7 +1854,7 @@ static int starcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
switch (card->type) {
|
switch (card->type) {
|
||||||
case SC_CARD_TYPE_STARCOS_V3_4:
|
case SC_CARD_TYPE_STARCOS_V3_4:
|
||||||
case SC_CARD_TYPE_STARCOS_V3_5:
|
case SC_CARD_TYPE_STARCOS_V3_5:
|
||||||
|
@ -615,7 +615,7 @@ static int tcos_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len,
|
|||||||
tcos3=(card->type==SC_CARD_TYPE_TCOS_V3);
|
tcos3=(card->type==SC_CARD_TYPE_TCOS_V3);
|
||||||
data=(tcos_data *)card->drv_data;
|
data=(tcos_data *)card->drv_data;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"TCOS3:%d PKCS1:%d\n",tcos3,
|
"TCOS3:%d PKCS1:%d\n",tcos3,
|
||||||
!!(data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1));
|
!!(data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1));
|
||||||
|
@ -1362,7 +1362,7 @@ sc_card_sm_load(struct sc_card *card, const char *module_path, const char *in_mo
|
|||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
ctx = card->ctx;
|
ctx = card->ctx;
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (!in_module)
|
if (!in_module)
|
||||||
return sc_card_sm_unload(card);
|
return sc_card_sm_unload(card);
|
||||||
|
|
||||||
@ -1459,7 +1459,7 @@ sc_card_sm_check(struct sc_card *card)
|
|||||||
scconf_block *atrblock = NULL, *sm_conf_block = NULL;
|
scconf_block *atrblock = NULL, *sm_conf_block = NULL;
|
||||||
int rv, ii;
|
int rv, ii;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "card->sm_ctx.ops.open %p", card->sm_ctx.ops.open);
|
sc_log(ctx, "card->sm_ctx.ops.open %p", card->sm_ctx.ops.open);
|
||||||
|
|
||||||
/* get the name of card specific SM configuration section */
|
/* get the name of card specific SM configuration section */
|
||||||
|
@ -906,7 +906,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
|
|||||||
/* Used by minidriver to pass in provided handles to reader-pcsc */
|
/* Used by minidriver to pass in provided handles to reader-pcsc */
|
||||||
int sc_ctx_use_reader(sc_context_t *ctx, void *pcsc_context_handle, void *pcsc_card_handle)
|
int sc_ctx_use_reader(sc_context_t *ctx, void *pcsc_context_handle, void *pcsc_card_handle)
|
||||||
{
|
{
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (ctx->reader_driver->ops->use_reader != NULL)
|
if (ctx->reader_driver->ops->use_reader != NULL)
|
||||||
return ctx->reader_driver->ops->use_reader(ctx, pcsc_context_handle, pcsc_card_handle);
|
return ctx->reader_driver->ops->use_reader(ctx, pcsc_context_handle, pcsc_card_handle);
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ int sc_ctx_use_reader(sc_context_t *ctx, void *pcsc_context_handle, void *pcsc_c
|
|||||||
/* Following two are only implemented with internal PC/SC and don't consume a reader object */
|
/* Following two are only implemented with internal PC/SC and don't consume a reader object */
|
||||||
int sc_cancel(sc_context_t *ctx)
|
int sc_cancel(sc_context_t *ctx)
|
||||||
{
|
{
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (ctx->reader_driver->ops->cancel != NULL)
|
if (ctx->reader_driver->ops->cancel != NULL)
|
||||||
return ctx->reader_driver->ops->cancel(ctx);
|
return ctx->reader_driver->ops->cancel(ctx);
|
||||||
|
|
||||||
@ -926,7 +926,7 @@ int sc_cancel(sc_context_t *ctx)
|
|||||||
|
|
||||||
int sc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_reader_t **event_reader, unsigned int *event, int timeout, void **reader_states)
|
int sc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_reader_t **event_reader, unsigned int *event, int timeout, void **reader_states)
|
||||||
{
|
{
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (ctx->reader_driver->ops->wait_for_event != NULL)
|
if (ctx->reader_driver->ops->wait_for_event != NULL)
|
||||||
return ctx->reader_driver->ops->wait_for_event(ctx, event_mask, event_reader, event, timeout, reader_states);
|
return ctx->reader_driver->ops->wait_for_event(ctx, event_mask, event_reader, event, timeout, reader_states);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ enum {
|
|||||||
SC_LOG_DEBUG_VERBOSE, /* helps users */
|
SC_LOG_DEBUG_VERBOSE, /* helps users */
|
||||||
SC_LOG_DEBUG_NORMAL, /* helps developers */
|
SC_LOG_DEBUG_NORMAL, /* helps developers */
|
||||||
SC_LOG_DEBUG_RFU1, /* RFU */
|
SC_LOG_DEBUG_RFU1, /* RFU */
|
||||||
SC_LOG_DEBUG_RFU2, /* RFU */
|
SC_LOG_DEBUG_SM, /* secure messaging */
|
||||||
SC_LOG_DEBUG_ASN1, /* asn1.c */
|
SC_LOG_DEBUG_ASN1, /* asn1.c */
|
||||||
SC_LOG_DEBUG_MATCH, /* card matching */
|
SC_LOG_DEBUG_MATCH, /* card matching */
|
||||||
};
|
};
|
||||||
|
@ -106,7 +106,7 @@ static int my_pin_cmd(sc_card_t * card, struct sc_pin_cmd_data * data,
|
|||||||
int saved_len = 0;
|
int saved_len = 0;
|
||||||
u8 newpin[8];
|
u8 newpin[8];
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
memset(newpin, 0xff, sizeof(newpin));
|
memset(newpin, 0xff, sizeof(newpin));
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ void sc_pkcs15_pincache_clear(struct sc_pkcs15_card *p15card)
|
|||||||
struct sc_pkcs15_object *objs[32];
|
struct sc_pkcs15_object *objs[32];
|
||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(p15card->card->ctx);
|
||||||
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
|
r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
|
||||||
for (i = 0; i < r; i++)
|
for (i = 0; i < r; i++)
|
||||||
sc_pkcs15_free_object_content(objs[i]);
|
sc_pkcs15_free_object_content(objs[i]);
|
||||||
|
@ -40,7 +40,7 @@ int sc_decipher(sc_card_t *card,
|
|||||||
if (card == NULL || crgram == NULL || out == NULL) {
|
if (card == NULL || crgram == NULL || out == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->decipher == NULL)
|
if (card->ops->decipher == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->decipher(card, crgram, crgram_len, out, outlen);
|
r = card->ops->decipher(card, crgram, crgram_len, out, outlen);
|
||||||
@ -56,7 +56,7 @@ int sc_compute_signature(sc_card_t *card,
|
|||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->compute_signature == NULL)
|
if (card->ops->compute_signature == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->compute_signature(card, data, datalen, out, outlen);
|
r = card->ops->compute_signature(card, data, datalen, out, outlen);
|
||||||
@ -71,7 +71,7 @@ int sc_unwrap(sc_card_t *card,
|
|||||||
if (card == NULL || crgram == NULL) {
|
if (card == NULL || crgram == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->unwrap == NULL)
|
if (card->ops->unwrap == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->unwrap(card, crgram, crgram_len);
|
r = card->ops->unwrap(card, crgram, crgram_len);
|
||||||
@ -86,7 +86,7 @@ int sc_wrap(sc_card_t *card,
|
|||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->wrap == NULL)
|
if (card->ops->wrap == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->wrap(card, out, outlen);
|
r = card->ops->wrap(card, out, outlen);
|
||||||
@ -102,7 +102,7 @@ int sc_set_security_env(sc_card_t *card,
|
|||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->set_security_env == NULL)
|
if (card->ops->set_security_env == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->set_security_env(card, env, se_num);
|
r = card->ops->set_security_env(card, env, se_num);
|
||||||
@ -116,7 +116,7 @@ int sc_restore_security_env(sc_card_t *card, int se_num)
|
|||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->restore_security_env == NULL)
|
if (card->ops->restore_security_env == NULL)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
|
||||||
r = card->ops->restore_security_env(card, se_num);
|
r = card->ops->restore_security_env(card, se_num);
|
||||||
@ -197,7 +197,7 @@ int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
|
|||||||
if (card == NULL) {
|
if (card == NULL) {
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
if (card->ops->pin_cmd) {
|
if (card->ops->pin_cmd) {
|
||||||
r = card->ops->pin_cmd(card, data, tries_left);
|
r = card->ops->pin_cmd(card, data, tries_left);
|
||||||
} else if (!(data->flags & SC_PIN_CMD_USE_PINPAD)) {
|
} else if (!(data->flags & SC_PIN_CMD_USE_PINPAD)) {
|
||||||
|
@ -136,7 +136,7 @@ static int asepcos_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
|||||||
sc_file_t *tfile;
|
sc_file_t *tfile;
|
||||||
sc_context_t *ctx = p15card->card->ctx;
|
sc_context_t *ctx = p15card->card->ctx;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
/* Check whether a transport exists and verify it if present */
|
/* Check whether a transport exists and verify it if present */
|
||||||
r = asepcos_check_verify_tpin(profile, p15card);
|
r = asepcos_check_verify_tpin(profile, p15card);
|
||||||
if (r != SC_SUCCESS)
|
if (r != SC_SUCCESS)
|
||||||
@ -350,7 +350,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
|||||||
sc_file_t *tfile = NULL;
|
sc_file_t *tfile = NULL;
|
||||||
sc_context_t *ctx = p15card->card->ctx;
|
sc_context_t *ctx = p15card->card->ctx;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (!pin || !pin_len)
|
if (!pin || !pin_len)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ static int cflex_erase_card(struct sc_profile *profile, sc_pkcs15_card_t *p15car
|
|||||||
sc_file_t *df = profile->df_info->file, *dir, *userpinfile = NULL;
|
sc_file_t *df = profile->df_info->file, *dir, *userpinfile = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
/* Delete EF(DIR). This may not be very nice
|
/* Delete EF(DIR). This may not be very nice
|
||||||
* against other applications that use this file, but
|
* against other applications that use this file, but
|
||||||
* extremely useful for testing :)
|
* extremely useful for testing :)
|
||||||
@ -225,7 +225,7 @@ cflex_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df
|
|||||||
int ndummies, pin_type, puk_type, r;
|
int ndummies, pin_type, puk_type, r;
|
||||||
sc_file_t *file = NULL;
|
sc_file_t *file = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
|
if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
|
||||||
return SC_ERROR_OBJECT_NOT_VALID;
|
return SC_ERROR_OBJECT_NOT_VALID;
|
||||||
@ -439,7 +439,7 @@ cflex_create_dummy_chvs(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
|||||||
const sc_acl_entry_t *acl;
|
const sc_acl_entry_t *acl;
|
||||||
int r = 0, ndummies = 0;
|
int r = 0, ndummies = 0;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
/* See if the DF is supposed to be PIN protected, and if
|
/* See if the DF is supposed to be PIN protected, and if
|
||||||
* it is, whether that CHV file actually exists. If it doesn't,
|
* it is, whether that CHV file actually exists. If it doesn't,
|
||||||
* create it.
|
* create it.
|
||||||
@ -530,7 +530,7 @@ cflex_create_pin_file(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
|||||||
sc_file_t *dummies[2], *file;
|
sc_file_t *dummies[2], *file;
|
||||||
int r, ndummies;
|
int r, ndummies;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (file_ret)
|
if (file_ret)
|
||||||
*file_ret = NULL;
|
*file_ret = NULL;
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ cflex_create_empty_pin_file(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(p15card->card->ctx);
|
||||||
*file_ret = NULL;
|
*file_ret = NULL;
|
||||||
r = cflex_create_pin_file(profile, p15card, path, ref,
|
r = cflex_create_pin_file(profile, p15card, path, ref,
|
||||||
dummy_pin_value, sizeof(dummy_pin_value), 8,
|
dummy_pin_value, sizeof(dummy_pin_value), 8,
|
||||||
|
@ -94,7 +94,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
char name[NAME_MAX_LEN];
|
char name[NAME_MAX_LEN];
|
||||||
const char *itag=NULL, *otag=NULL;
|
const char *itag=NULL, *otag=NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type 0x%X; num %i; info %p; obj %p", type, num, info_out, obj_out);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type 0x%X; num %i; info %p; obj %p", type, num, info_out, obj_out);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SC_PKCS15_TYPE_CERT_X509:
|
case SC_PKCS15_TYPE_CERT_X509:
|
||||||
@ -201,7 +201,7 @@ awp_update_blob(struct sc_context *ctx,
|
|||||||
{
|
{
|
||||||
unsigned char *pp;
|
unsigned char *pp;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TLV_TYPE_LLV :
|
case TLV_TYPE_LLV :
|
||||||
if (!(pp = realloc(*blob, *blob_size + 2 + lv->len)))
|
if (!(pp = realloc(*blob, *blob_size + 2 + lv->len)))
|
||||||
@ -243,7 +243,7 @@ awp_new_container_entry(struct sc_pkcs15_card *p15card, unsigned char *buff, int
|
|||||||
unsigned ii, marks[5] = {4,6,8,10,0};
|
unsigned ii, marks[5] = {4,6,8,10,0};
|
||||||
unsigned char rand_buf[0x10];
|
unsigned char rand_buf[0x10];
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (len<0x34)
|
if (len<0x34)
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS, "Invalid container update size");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS, "Invalid container update size");
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile *
|
|||||||
int rv;
|
int rv;
|
||||||
unsigned char *buff = NULL;
|
unsigned char *buff = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)",
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)",
|
||||||
list_file->id, list_file->record_length, list_file->record_count);
|
list_file->id, list_file->record_length, list_file->record_count);
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
struct sc_file *clist = NULL, *file = NULL;
|
struct sc_file *clist = NULL, *file = NULL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
|
||||||
|
|
||||||
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
|
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
|
||||||
@ -349,7 +349,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
|
|||||||
int rv;
|
int rv;
|
||||||
unsigned char *buff = NULL;
|
unsigned char *buff = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"update container entry(type:%X,id %i,rec %i,offs %i",
|
"update container entry(type:%X,id %i,rec %i,offs %i",
|
||||||
type, file_id, rec, offs);
|
type, file_id, rec, offs);
|
||||||
@ -430,7 +430,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
int rv = 0, rec, rec_offs;
|
int rv = 0, rec, rec_offs;
|
||||||
unsigned char *list = NULL;
|
unsigned char *list = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container(type:%X,obj_id:%X)", type, obj_id);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container(type:%X,obj_id:%X)", type, obj_id);
|
||||||
|
|
||||||
if (prkey_id)
|
if (prkey_id)
|
||||||
@ -565,7 +565,7 @@ awp_set_certificate_info (struct sc_pkcs15_card *p15card,
|
|||||||
unsigned char *blob;
|
unsigned char *blob;
|
||||||
const char *default_cert_label = "Certificate";
|
const char *default_cert_label = "Certificate";
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
blob_size = 2;
|
blob_size = 2;
|
||||||
if (!(blob = malloc(blob_size))) {
|
if (!(blob = malloc(blob_size))) {
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
r = SC_ERROR_OUT_OF_MEMORY;
|
||||||
@ -640,7 +640,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
|
|||||||
int rv;
|
int rv;
|
||||||
unsigned ii;
|
unsigned ii;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %i, num %i", type, num);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %i, num %i", type, num);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SC_PKCS15_TYPE_CERT_X509:
|
case SC_PKCS15_TYPE_CERT_X509:
|
||||||
@ -764,7 +764,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
|
|||||||
struct sc_pkcs15_prkey_info *key_info;
|
struct sc_pkcs15_prkey_info *key_info;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
ERR_load_ERR_strings();
|
ERR_load_ERR_strings();
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
|
|||||||
int r = 0, blob_size;
|
int r = 0, blob_size;
|
||||||
unsigned char *blob;
|
unsigned char *blob;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file:%p, kinfo:%p, cinfo:%p", file, ki, ci);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file:%p, kinfo:%p, cinfo:%p", file, ki, ci);
|
||||||
blob_size = 2;
|
blob_size = 2;
|
||||||
blob = malloc(blob_size);
|
blob = malloc(blob_size);
|
||||||
@ -927,7 +927,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
|
|||||||
BIO *mem = NULL;
|
BIO *mem = NULL;
|
||||||
X509 *x = NULL;
|
X509 *x = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
ERR_load_ERR_strings();
|
ERR_load_ERR_strings();
|
||||||
ERR_load_crypto_strings();
|
ERR_load_crypto_strings();
|
||||||
@ -1101,7 +1101,7 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
|
|||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
if (!obj || !di)
|
if (!obj || !di)
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "AWP encode data failed: invalid parameters");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "AWP encode data failed: invalid parameters");
|
||||||
@ -1168,7 +1168,7 @@ awp_set_data_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
int r = 0, blob_size;
|
int r = 0, blob_size;
|
||||||
unsigned char *blob;
|
unsigned char *blob;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug (ctx, SC_LOG_DEBUG_NORMAL, "Set 'DATA' info %p", di);
|
sc_debug (ctx, SC_LOG_DEBUG_NORMAL, "Set 'DATA' info %p", di);
|
||||||
blob_size = 2;
|
blob_size = 2;
|
||||||
if (!(blob = malloc(blob_size))) {
|
if (!(blob = malloc(blob_size))) {
|
||||||
@ -1249,7 +1249,7 @@ awp_parse_key_info(struct sc_context *ctx, unsigned char *buf, size_t buf_len,
|
|||||||
size_t offs;
|
size_t offs;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
offs = 0;
|
offs = 0;
|
||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
@ -1315,7 +1315,7 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
size_t buf_len;
|
size_t buf_len;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
rv = awp_new_file(p15card, profile, SC_PKCS15_TYPE_PRKEY_RSA, prvkey_id & 0xFF, &info_file, &key_file);
|
rv = awp_new_file(p15card, profile, SC_PKCS15_TYPE_PRKEY_RSA, prvkey_id & 0xFF, &info_file, &key_file);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update key info failed: instantiation error");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update key info failed: instantiation error");
|
||||||
@ -1375,7 +1375,7 @@ awp_update_df_create_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
|||||||
unsigned prvkey_id, obj_id;
|
unsigned prvkey_id, obj_id;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
der = obj->content;
|
der = obj->content;
|
||||||
path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
|
path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
|
||||||
@ -1432,7 +1432,7 @@ awp_update_df_create_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
|||||||
struct sc_pkcs15_cert *p15cert = NULL;
|
struct sc_pkcs15_cert *p15cert = NULL;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
memset(&ikey, 0, sizeof(ikey));
|
memset(&ikey, 0, sizeof(ikey));
|
||||||
memset(&icert, 0, sizeof(icert));
|
memset(&icert, 0, sizeof(icert));
|
||||||
@ -1516,7 +1516,7 @@ awp_update_df_create_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
|||||||
unsigned obj_id;
|
unsigned obj_id;
|
||||||
int index, rv;
|
int index, rv;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
|
path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
|
||||||
der = obj->content;
|
der = obj->content;
|
||||||
@ -1565,7 +1565,7 @@ awp_update_df_create_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
|||||||
unsigned obj_id, obj_type = obj->auth_id.len ? COSM_TYPE_PRIVDATA_OBJECT : SC_PKCS15_TYPE_DATA_OBJECT;
|
unsigned obj_id, obj_type = obj->auth_id.len ? COSM_TYPE_PRIVDATA_OBJECT : SC_PKCS15_TYPE_DATA_OBJECT;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
der = obj->content;
|
der = obj->content;
|
||||||
path = ((struct sc_pkcs15_data_info *)obj->data)->path;
|
path = ((struct sc_pkcs15_data_info *)obj->data)->path;
|
||||||
@ -1602,7 +1602,7 @@ awp_update_df_create(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
int rv = SC_ERROR_INTERNAL;
|
int rv = SC_ERROR_INTERNAL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (!object)
|
if (!object)
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
|
|
||||||
@ -1640,7 +1640,7 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
|
|||||||
int rv = 0, ii;
|
int rv = 0, ii;
|
||||||
unsigned char *buff=NULL;
|
unsigned char *buff=NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry (type:%X,file-id:%X)", type, file_id);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry (type:%X,file-id:%X)", type, file_id);
|
||||||
|
|
||||||
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
|
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
|
||||||
@ -1723,7 +1723,7 @@ awp_remove_from_object_list( struct sc_pkcs15_card *p15card, struct sc_profile *
|
|||||||
unsigned char *buff=NULL;
|
unsigned char *buff=NULL;
|
||||||
unsigned char id[2];
|
unsigned char id[2];
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %X; obj_id %X",type, obj_id);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %X; obj_id %X",type, obj_id);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -1796,7 +1796,7 @@ awp_update_df_delete_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
|||||||
int rv = SC_ERROR_NOT_SUPPORTED;
|
int rv = SC_ERROR_NOT_SUPPORTED;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
path = ((struct sc_pkcs15_cert_info *) obj->data)->path;
|
path = ((struct sc_pkcs15_cert_info *) obj->data)->path;
|
||||||
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
||||||
@ -1830,7 +1830,7 @@ awp_update_df_delete_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
|||||||
int rv = SC_ERROR_NOT_SUPPORTED;
|
int rv = SC_ERROR_NOT_SUPPORTED;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
path = ((struct sc_pkcs15_prkey_info *) obj->data)->path;
|
path = ((struct sc_pkcs15_prkey_info *) obj->data)->path;
|
||||||
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
||||||
@ -1864,7 +1864,7 @@ awp_update_df_delete_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
|||||||
int rv = SC_ERROR_NOT_SUPPORTED;
|
int rv = SC_ERROR_NOT_SUPPORTED;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
path = ((struct sc_pkcs15_pubkey_info *) obj->data)->path;
|
path = ((struct sc_pkcs15_pubkey_info *) obj->data)->path;
|
||||||
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
||||||
@ -1898,7 +1898,7 @@ awp_update_df_delete_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
|||||||
int rv = SC_ERROR_NOT_SUPPORTED;
|
int rv = SC_ERROR_NOT_SUPPORTED;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
path = ((struct sc_pkcs15_data_info *) obj->data)->path;
|
path = ((struct sc_pkcs15_data_info *) obj->data)->path;
|
||||||
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
|
||||||
@ -1926,7 +1926,7 @@ awp_update_df_delete(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
|||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
int rv = SC_ERROR_INTERNAL;
|
int rv = SC_ERROR_INTERNAL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (!object)
|
if (!object)
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ sm_encrypt_des_cbc3(struct sc_context *ctx, unsigned char *key,
|
|||||||
size_t data_len, st;
|
size_t data_len, st;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM encrypt_des_cbc3: not_force_pad:%i,in_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
"SM encrypt_des_cbc3: not_force_pad:%i,in_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
not_force_pad, in_len);
|
not_force_pad, in_len);
|
||||||
if (!out || !out_len)
|
if (!out || !out_len)
|
||||||
@ -337,7 +337,7 @@ sm_encrypt_des_cbc3(struct sc_context *ctx, unsigned char *key,
|
|||||||
memcpy(data + in_len, "\x80\0\0\0\0\0\0\0", 8);
|
memcpy(data + in_len, "\x80\0\0\0\0\0\0\0", 8);
|
||||||
data_len = in_len + (not_force_pad ? 7 : 8);
|
data_len = in_len + (not_force_pad ? 7 : 8);
|
||||||
data_len -= (data_len%8);
|
data_len -= (data_len%8);
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM encrypt_des_cbc3: data to encrypt (len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
"SM encrypt_des_cbc3: data to encrypt (len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
||||||
data_len, sc_dump_hex(data, data_len));
|
data_len, sc_dump_hex(data, data_len));
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ static int format_mse_cdata(struct sc_context *ctx, int protocol,
|
|||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, "MSE command data", data_no_sequence, length);
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "MSE command data", data_no_sequence, length);
|
||||||
|
|
||||||
|
|
||||||
p = realloc(*cdata, length);
|
p = realloc(*cdata, length);
|
||||||
@ -639,7 +639,7 @@ static int eac_gen_auth_1_encrypted_nonce(sc_card_t *card,
|
|||||||
apdu.datalen = r;
|
apdu.datalen = r;
|
||||||
apdu.lc = r;
|
apdu.lc = r;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Encrypted Nonce) command data", apdu.data, apdu.datalen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Encrypted Nonce) command data", apdu.data, apdu.datalen);
|
||||||
|
|
||||||
apdu.resplen = sizeof resp;
|
apdu.resplen = sizeof resp;
|
||||||
apdu.resp = resp;
|
apdu.resp = resp;
|
||||||
@ -651,7 +651,7 @@ static int eac_gen_auth_1_encrypted_nonce(sc_card_t *card,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Encrypted Nonce) response data", apdu.resp, apdu.resplen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Encrypted Nonce) response data", apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
||||||
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
||||||
@ -731,7 +731,7 @@ static int eac_gen_auth_2_map_nonce(sc_card_t *card,
|
|||||||
apdu.datalen = r;
|
apdu.datalen = r;
|
||||||
apdu.lc = r;
|
apdu.lc = r;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Map Nonce) command data", apdu.data, apdu.datalen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Map Nonce) command data", apdu.data, apdu.datalen);
|
||||||
|
|
||||||
apdu.resplen = sizeof resp;
|
apdu.resplen = sizeof resp;
|
||||||
apdu.resp = resp;
|
apdu.resp = resp;
|
||||||
@ -743,7 +743,7 @@ static int eac_gen_auth_2_map_nonce(sc_card_t *card,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Map Nonce) response data", apdu.resp, apdu.resplen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Map Nonce) response data", apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
||||||
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
||||||
@ -823,7 +823,7 @@ static int eac_gen_auth_3_perform_key_agreement(sc_card_t *card,
|
|||||||
apdu.datalen = r;
|
apdu.datalen = r;
|
||||||
apdu.lc = r;
|
apdu.lc = r;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
||||||
|
|
||||||
apdu.resplen = sizeof resp;
|
apdu.resplen = sizeof resp;
|
||||||
apdu.resp = resp;
|
apdu.resp = resp;
|
||||||
@ -835,7 +835,7 @@ static int eac_gen_auth_3_perform_key_agreement(sc_card_t *card,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
||||||
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
||||||
@ -916,7 +916,7 @@ static int eac_gen_auth_4_mutual_authentication(sc_card_t *card,
|
|||||||
apdu.datalen = r;
|
apdu.datalen = r;
|
||||||
apdu.lc = r;
|
apdu.lc = r;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
||||||
|
|
||||||
apdu.resplen = sizeof resp;
|
apdu.resplen = sizeof resp;
|
||||||
apdu.resp = resp;
|
apdu.resp = resp;
|
||||||
@ -928,7 +928,7 @@ static int eac_gen_auth_4_mutual_authentication(sc_card_t *card,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
if (!d2i_EAC_GEN_AUTH_PACE_R(&r_data,
|
||||||
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
||||||
@ -950,7 +950,7 @@ static int eac_gen_auth_4_mutual_authentication(sc_card_t *card,
|
|||||||
p = r_data->auth_token->data;
|
p = r_data->auth_token->data;
|
||||||
l = r_data->auth_token->length;
|
l = r_data->auth_token->length;
|
||||||
if (r_data->cur_car) {
|
if (r_data->cur_car) {
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Most recent Certificate Authority Reference",
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "Most recent Certificate Authority Reference",
|
||||||
r_data->cur_car->data, r_data->cur_car->length);
|
r_data->cur_car->data, r_data->cur_car->length);
|
||||||
*recent_car = malloc(r_data->cur_car->length);
|
*recent_car = malloc(r_data->cur_car->length);
|
||||||
if (!*recent_car) {
|
if (!*recent_car) {
|
||||||
@ -963,7 +963,7 @@ static int eac_gen_auth_4_mutual_authentication(sc_card_t *card,
|
|||||||
} else
|
} else
|
||||||
*recent_car_len = 0;
|
*recent_car_len = 0;
|
||||||
if (r_data->prev_car) {
|
if (r_data->prev_car) {
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Previous Certificate Authority Reference",
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "Previous Certificate Authority Reference",
|
||||||
r_data->prev_car->data, r_data->prev_car->length);
|
r_data->prev_car->data, r_data->prev_car->length);
|
||||||
*prev_car = malloc(r_data->prev_car->length);
|
*prev_car = malloc(r_data->prev_car->length);
|
||||||
if (!*prev_car) {
|
if (!*prev_car) {
|
||||||
@ -1161,7 +1161,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "EF.CardAccess", pace_output->ef_cardaccess,
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "EF.CardAccess", pace_output->ef_cardaccess,
|
||||||
pace_output->ef_cardaccess_length);
|
pace_output->ef_cardaccess_length);
|
||||||
|
|
||||||
/* XXX Card capabilities should be determined by the OpenSC card driver. We
|
/* XXX Card capabilities should be determined by the OpenSC card driver. We
|
||||||
@ -1205,7 +1205,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
"(General Authenticate step 1 failed).");
|
"(General Authenticate step 1 failed).");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Encrypted nonce from MRTD", (u8 *)enc_nonce->data, enc_nonce->length);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "Encrypted nonce from MRTD", (u8 *)enc_nonce->data, enc_nonce->length);
|
||||||
enc_nonce->max = enc_nonce->length;
|
enc_nonce->max = enc_nonce->length;
|
||||||
|
|
||||||
sec = get_psec(card, (char *) pace_input.pin, pace_input.pin_length,
|
sec = get_psec(card, (char *) pace_input.pin, pace_input.pin_length,
|
||||||
@ -1240,7 +1240,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
mdata_opp->max = mdata_opp->length;
|
mdata_opp->max = mdata_opp->length;
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Mapping data from MRTD", (u8 *) mdata_opp->data, mdata_opp->length);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "Mapping data from MRTD", (u8 *) mdata_opp->data, mdata_opp->length);
|
||||||
|
|
||||||
if (!PACE_STEP3A_map_generator(eac_ctx, mdata_opp)) {
|
if (!PACE_STEP3A_map_generator(eac_ctx, mdata_opp)) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not map generator.");
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not map generator.");
|
||||||
@ -1266,7 +1266,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
pub_opp->max = pub_opp->length;
|
pub_opp->max = pub_opp->length;
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Ephemeral public key from MRTD", (u8 *) pub_opp->data, pub_opp->length);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "Ephemeral public key from MRTD", (u8 *) pub_opp->data, pub_opp->length);
|
||||||
|
|
||||||
|
|
||||||
if (!PACE_STEP3B_compute_shared_secret(eac_ctx, pub_opp)
|
if (!PACE_STEP3B_compute_shared_secret(eac_ctx, pub_opp)
|
||||||
@ -1331,7 +1331,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
pace_output->id_icc_length = comp_pub_opp->length;
|
pace_output->id_icc_length = comp_pub_opp->length;
|
||||||
/* Flawfinder: ignore */
|
/* Flawfinder: ignore */
|
||||||
memcpy(pace_output->id_icc, comp_pub_opp->data, comp_pub_opp->length);
|
memcpy(pace_output->id_icc, comp_pub_opp->data, comp_pub_opp->length);
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "ID ICC", pace_output->id_icc,
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "ID ICC", pace_output->id_icc,
|
||||||
pace_output->id_icc_length);
|
pace_output->id_icc_length);
|
||||||
p = realloc(pace_output->id_pcd, comp_pub->length);
|
p = realloc(pace_output->id_pcd, comp_pub->length);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -1343,7 +1343,7 @@ int perform_pace(sc_card_t *card,
|
|||||||
pace_output->id_pcd_length = comp_pub->length;
|
pace_output->id_pcd_length = comp_pub->length;
|
||||||
/* Flawfinder: ignore */
|
/* Flawfinder: ignore */
|
||||||
memcpy(pace_output->id_pcd, comp_pub->data, comp_pub->length);
|
memcpy(pace_output->id_pcd, comp_pub->data, comp_pub->length);
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "ID PCD", pace_output->id_pcd,
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "ID PCD", pace_output->id_pcd,
|
||||||
pace_output->id_pcd_length);
|
pace_output->id_pcd_length);
|
||||||
|
|
||||||
r = eac_sm_start(card, eac_ctx, pace_input.certificate_description,
|
r = eac_sm_start(card, eac_ctx, pace_input.certificate_description,
|
||||||
@ -1527,7 +1527,7 @@ int perform_terminal_authentication(sc_card_t *card,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "EF.CardAccess", ef_cardaccess,
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "EF.CardAccess", ef_cardaccess,
|
||||||
ef_cardaccess_length);
|
ef_cardaccess_length);
|
||||||
|
|
||||||
/* XXX Card capabilities should be determined by the OpenSC card driver. We
|
/* XXX Card capabilities should be determined by the OpenSC card driver. We
|
||||||
@ -1706,7 +1706,7 @@ static int eac_gen_auth_ca(sc_card_t *card, const BUF_MEM *eph_pub_key,
|
|||||||
apdu.datalen = r;
|
apdu.datalen = r;
|
||||||
apdu.lc = r;
|
apdu.lc = r;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) command data", apdu.data, apdu.datalen);
|
||||||
|
|
||||||
apdu.resplen = sizeof resp;
|
apdu.resplen = sizeof resp;
|
||||||
apdu.resp = resp;
|
apdu.resp = resp;
|
||||||
@ -1718,7 +1718,7 @@ static int eac_gen_auth_ca(sc_card_t *card, const BUF_MEM *eph_pub_key,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_SM, "General authenticate (Perform Key Agreement) response data", apdu.resp, apdu.resplen);
|
||||||
|
|
||||||
if (!d2i_EAC_GEN_AUTH_CA_R(&r_data,
|
if (!d2i_EAC_GEN_AUTH_CA_R(&r_data,
|
||||||
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
(const unsigned char **) &apdu.resp, apdu.resplen)) {
|
||||||
@ -2079,7 +2079,7 @@ eac_sm_verify_authentication(sc_card_t *card, const struct iso_sm_ctx *ctx,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Authentication data verified");
|
sc_debug(card->ctx, SC_LOG_DEBUG_SM, "Authentication data verified");
|
||||||
|
|
||||||
r = SC_SUCCESS;
|
r = SC_SUCCESS;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ sm_oberthur_diversify_keyset(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
else if (gp_keyset->kmc_len == 16 || gp_keyset->kmc_len == 0) {
|
else if (gp_keyset->kmc_len == 16 || gp_keyset->kmc_len == 0) {
|
||||||
if (gp_keyset->kmc_len == 16)
|
if (gp_keyset->kmc_len == 16)
|
||||||
memcpy(master_key, gp_keyset->kmc, 16);
|
memcpy(master_key, gp_keyset->kmc, 16);
|
||||||
sc_log(ctx, "KMC: %s", sc_dump_hex(master_key, sizeof(master_key)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "KMC: %s", sc_dump_hex(master_key, sizeof(master_key)));
|
||||||
for (ii=0; ii<3; ii++) {
|
for (ii=0; ii<3; ii++) {
|
||||||
key_buff[0] = key_buff[8] = 0;
|
key_buff[0] = key_buff[8] = 0;
|
||||||
key_buff[1] = key_buff[9] = 0;
|
key_buff[1] = key_buff[9] = 0;
|
||||||
@ -77,7 +77,7 @@ sm_oberthur_diversify_keyset(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
key_buff[6] = 0xF0, key_buff[14] = 0x0F;
|
key_buff[6] = 0xF0, key_buff[14] = 0x0F;
|
||||||
key_buff[7] = key_buff[15] = ii+1;
|
key_buff[7] = key_buff[15] = ii+1;
|
||||||
|
|
||||||
sc_log(ctx, "key_buf:%s", sc_dump_hex(key_buff, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "key_buf:%s", sc_dump_hex(key_buff, 16));
|
||||||
|
|
||||||
rv = sm_encrypt_des_ecb3(master_key, key_buff, sizeof(key_buff), &tmp, &tmp_len);
|
rv = sm_encrypt_des_ecb3(master_key, key_buff, sizeof(key_buff), &tmp, &tmp_len);
|
||||||
LOG_TEST_RET(ctx, rv, "GP init session: cannot derive key");
|
LOG_TEST_RET(ctx, rv, "GP init session: cannot derive key");
|
||||||
@ -91,11 +91,11 @@ sm_oberthur_diversify_keyset(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!rv && ctx) {
|
if (!rv && ctx) {
|
||||||
sc_log_hex(ctx, "Card challenge", gp_session->card_challenge, sizeof(gp_session->card_challenge));
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "Card challenge", gp_session->card_challenge, sizeof(gp_session->card_challenge));
|
||||||
sc_log_hex(ctx, "Host challenge", gp_session->host_challenge, sizeof(gp_session->host_challenge));
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "Host challenge", gp_session->host_challenge, sizeof(gp_session->host_challenge));
|
||||||
sc_log_hex(ctx, "ENC", gp_keyset->enc, sizeof(gp_keyset->enc));
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "ENC", gp_keyset->enc, sizeof(gp_keyset->enc));
|
||||||
sc_log_hex(ctx, "MAC", gp_keyset->mac, sizeof(gp_keyset->mac));
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "MAC", gp_keyset->mac, sizeof(gp_keyset->mac));
|
||||||
sc_log_hex(ctx, "KEK", gp_keyset->kek, sizeof(gp_keyset->kek));
|
sc_debug_hex(ctx, SC_LOG_DEBUG_SM, "KEK", gp_keyset->kek, sizeof(gp_keyset->kek));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
@ -110,7 +110,7 @@ sm_authentic_encode_apdu(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
int rv = SC_ERROR_INVALID_ARGUMENTS;
|
int rv = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM encode APDU: offset:");
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM encode APDU: offset:");
|
||||||
|
|
||||||
rv = sm_gp_securize_apdu(ctx, sm_info, NULL, apdu);
|
rv = sm_gp_securize_apdu(ctx, sm_info, NULL, apdu);
|
||||||
LOG_TEST_RET(ctx, rv, "SM encode APDU: securize error");
|
LOG_TEST_RET(ctx, rv, "SM encode APDU: securize error");
|
||||||
@ -130,9 +130,9 @@ sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM get APDUs: rdata:%p, init_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get APDUs: rdata:%p, init_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
rdata, init_len);
|
rdata, init_len);
|
||||||
sc_log(ctx, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
||||||
|
|
||||||
if (init_data) {
|
if (init_data) {
|
||||||
rv = sm_gp_external_authentication(ctx, sm_info, init_data, init_len, rdata, sm_oberthur_diversify_keyset);
|
rv = sm_gp_external_authentication(ctx, sm_info, init_data, init_len, rdata, sm_oberthur_diversify_keyset);
|
||||||
|
@ -67,7 +67,7 @@ sm_iasecc_get_apdu_read_binary(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM get 'READ BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u",
|
"SM get 'READ BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
cmd_data->offs, cmd_data->count);
|
cmd_data->offs, cmd_data->count);
|
||||||
offs = cmd_data->offs;
|
offs = cmd_data->offs;
|
||||||
@ -113,7 +113,7 @@ sm_iasecc_get_apdu_update_binary(struct sc_context *ctx, struct sm_info *sm_info
|
|||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM get 'UPDATE BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u",
|
"SM get 'UPDATE BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
cmd_data->offs, cmd_data->count);
|
cmd_data->offs, cmd_data->count);
|
||||||
offs = cmd_data->offs;
|
offs = cmd_data->offs;
|
||||||
@ -161,7 +161,7 @@ sm_iasecc_get_apdu_create_file(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
if (!cmd_data || !cmd_data->data || !rdata || !rdata->alloc)
|
if (!cmd_data || !cmd_data->data || !rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM get 'CREATE FILE' APDU: FCP(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
"SM get 'CREATE FILE' APDU: FCP(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
||||||
cmd_data->size, sc_dump_hex(cmd_data->data,cmd_data->size));
|
cmd_data->size, sc_dump_hex(cmd_data->data,cmd_data->size));
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ sm_iasecc_get_apdu_delete_file(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM get 'DELETE FILE' APDU: file-id %04X", file_id);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'DELETE FILE' APDU: file-id %04X", file_id);
|
||||||
|
|
||||||
if (!file_id)
|
if (!file_id)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
@ -237,7 +237,7 @@ sm_iasecc_get_apdu_verify_pin(struct sc_context *ctx, struct sm_info *sm_info, s
|
|||||||
if (!pin_data || !rdata || !rdata->alloc)
|
if (!pin_data || !rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM get 'VERIFY PIN' APDU: %u", pin_data->pin_reference);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'VERIFY PIN' APDU: %u", pin_data->pin_reference);
|
||||||
|
|
||||||
rv = rdata->alloc(rdata, &rapdu);
|
rv = rdata->alloc(rdata, &rapdu);
|
||||||
LOG_TEST_RET(ctx, rv, "SM get 'VERIFY PIN' APDUs: cannot allocate remote APDU");
|
LOG_TEST_RET(ctx, rv, "SM get 'VERIFY PIN' APDUs: cannot allocate remote APDU");
|
||||||
@ -278,7 +278,7 @@ sm_iasecc_get_apdu_reset_pin(struct sc_context *ctx, struct sm_info *sm_info, st
|
|||||||
if (!pin_data || !rdata || !rdata->alloc)
|
if (!pin_data || !rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM get 'RESET PIN' APDU; reference %i", pin_data->pin_reference);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'RESET PIN' APDU; reference %i", pin_data->pin_reference);
|
||||||
|
|
||||||
rv = rdata->alloc(rdata, &rapdu);
|
rv = rdata->alloc(rdata, &rapdu);
|
||||||
LOG_TEST_RET(ctx, rv, "SM get 'RESET PIN' APDUs: cannot allocate remote APDU");
|
LOG_TEST_RET(ctx, rv, "SM get 'RESET PIN' APDUs: cannot allocate remote APDU");
|
||||||
@ -324,7 +324,7 @@ sm_iasecc_get_apdu_sdo_update(struct sc_context *ctx, struct sm_info *sm_info, s
|
|||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM get 'SDO UPDATE' APDU, SDO(class:0x%X,ref:%i)", update->sdo_class, update->sdo_ref);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'SDO UPDATE' APDU, SDO(class:0x%X,ref:%i)", update->sdo_class, update->sdo_ref);
|
||||||
for (ii=0; update->fields[ii].tag && ii < IASECC_SDO_TAGS_UPDATE_MAX; ii++) {
|
for (ii=0; update->fields[ii].tag && ii < IASECC_SDO_TAGS_UPDATE_MAX; ii++) {
|
||||||
unsigned char *encoded = NULL;
|
unsigned char *encoded = NULL;
|
||||||
size_t encoded_len, offs;
|
size_t encoded_len, offs;
|
||||||
@ -332,7 +332,7 @@ sm_iasecc_get_apdu_sdo_update(struct sc_context *ctx, struct sm_info *sm_info, s
|
|||||||
encoded_len = iasecc_sdo_encode_update_field(ctx, update->sdo_class, update->sdo_ref, &update->fields[ii], &encoded);
|
encoded_len = iasecc_sdo_encode_update_field(ctx, update->sdo_class, update->sdo_ref, &update->fields[ii], &encoded);
|
||||||
LOG_TEST_RET(ctx, encoded_len, "SM get 'SDO UPDATE' APDU: encode component error");
|
LOG_TEST_RET(ctx, encoded_len, "SM get 'SDO UPDATE' APDU: encode component error");
|
||||||
|
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: encoded component '%s'", sc_dump_hex(encoded, encoded_len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: encoded component '%s'", sc_dump_hex(encoded, encoded_len));
|
||||||
|
|
||||||
for (offs = 0; offs < encoded_len; ) {
|
for (offs = 0; offs < encoded_len; ) {
|
||||||
int len = (encoded_len - offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (encoded_len - offs);
|
int len = (encoded_len - offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (encoded_len - offs);
|
||||||
@ -383,7 +383,7 @@ sm_iasecc_get_apdu_generate_rsa(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM get 'GENERATE RSA' APDU: SDO(class:%X,reference:%X)", sdo->sdo_class, sdo->sdo_ref);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'GENERATE RSA' APDU: SDO(class:%X,reference:%X)", sdo->sdo_class, sdo->sdo_ref);
|
||||||
|
|
||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
@ -443,12 +443,12 @@ sm_iasecc_get_apdu_update_rsa(struct sc_context *ctx, struct sm_info *sm_info, s
|
|||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (cmd_data->update_prv.sdo_class) {
|
if (cmd_data->update_prv.sdo_class) {
|
||||||
to_update[ii++] = &cmd_data->update_prv;
|
to_update[ii++] = &cmd_data->update_prv;
|
||||||
sc_log(ctx, "SM get 'UPDATE RSA' APDU: SDO(class:%X,ref:%X)", cmd_data->update_prv.sdo_class, cmd_data->update_prv.sdo_ref);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'UPDATE RSA' APDU: SDO(class:%X,ref:%X)", cmd_data->update_prv.sdo_class, cmd_data->update_prv.sdo_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd_data->update_pub.sdo_class) {
|
if (cmd_data->update_pub.sdo_class) {
|
||||||
to_update[ii++] = &cmd_data->update_pub;
|
to_update[ii++] = &cmd_data->update_pub;
|
||||||
sc_log(ctx, "SM get 'UPDATE RSA' APDU: SDO(class:%X,ref:%X)", cmd_data->update_pub.sdo_class, cmd_data->update_pub.sdo_ref);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get 'UPDATE RSA' APDU: SDO(class:%X,ref:%X)", cmd_data->update_pub.sdo_class, cmd_data->update_pub.sdo_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (jj=0;jj<2 && to_update[jj];jj++) {
|
for (jj=0;jj<2 && to_update[jj];jj++) {
|
||||||
@ -456,14 +456,14 @@ sm_iasecc_get_apdu_update_rsa(struct sc_context *ctx, struct sm_info *sm_info, s
|
|||||||
unsigned char *encoded = NULL;
|
unsigned char *encoded = NULL;
|
||||||
size_t encoded_len, offs;
|
size_t encoded_len, offs;
|
||||||
|
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: component(num %i:%i) class:%X, ref:%X", jj, ii,
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: component(num %i:%i) class:%X, ref:%X", jj, ii,
|
||||||
to_update[jj]->sdo_class, to_update[jj]->sdo_ref);
|
to_update[jj]->sdo_class, to_update[jj]->sdo_ref);
|
||||||
|
|
||||||
encoded_len = iasecc_sdo_encode_update_field(ctx, to_update[jj]->sdo_class, to_update[jj]->sdo_ref,
|
encoded_len = iasecc_sdo_encode_update_field(ctx, to_update[jj]->sdo_class, to_update[jj]->sdo_ref,
|
||||||
&to_update[jj]->fields[ii], &encoded);
|
&to_update[jj]->fields[ii], &encoded);
|
||||||
LOG_TEST_RET(ctx, encoded_len, "SM get 'UPDATE RSA' APDU: cannot encode key component");
|
LOG_TEST_RET(ctx, encoded_len, "SM get 'UPDATE RSA' APDU: cannot encode key component");
|
||||||
|
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: component encoded %s", sc_dump_hex(encoded, encoded_len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: component encoded %s", sc_dump_hex(encoded, encoded_len));
|
||||||
|
|
||||||
for (offs = 0; offs < encoded_len; ) {
|
for (offs = 0; offs < encoded_len; ) {
|
||||||
int len = (encoded_len - offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (encoded_len - offs);
|
int len = (encoded_len - offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (encoded_len - offs);
|
||||||
@ -511,10 +511,10 @@ sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: init_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: init_len:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
init_len);
|
init_len);
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: rdata:%p", rdata);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: rdata:%p", rdata);
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
||||||
|
|
||||||
rv = sm_cwa_decode_authentication_data(ctx, cwa_keyset, cwa_session, init_data);
|
rv = sm_cwa_decode_authentication_data(ctx, cwa_keyset, cwa_session, init_data);
|
||||||
LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: decode authentication data error");
|
LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: decode authentication data error");
|
||||||
@ -522,9 +522,9 @@ sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
rv = sm_cwa_init_session_keys(ctx, cwa_session, cwa_session->params.crt_at.algo);
|
rv = sm_cwa_init_session_keys(ctx, cwa_session, cwa_session->params.crt_at.algo);
|
||||||
LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: cannot get session keys");
|
LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: cannot get session keys");
|
||||||
|
|
||||||
sc_log(ctx, "SKENC %s", sc_dump_hex(cwa_session->session_enc, sizeof(cwa_session->session_enc)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SKENC %s", sc_dump_hex(cwa_session->session_enc, sizeof(cwa_session->session_enc)));
|
||||||
sc_log(ctx, "SKMAC %s", sc_dump_hex(cwa_session->session_mac, sizeof(cwa_session->session_mac)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SKMAC %s", sc_dump_hex(cwa_session->session_mac, sizeof(cwa_session->session_mac)));
|
||||||
sc_log(ctx, "SSC %s", sc_dump_hex(cwa_session->ssc, sizeof(cwa_session->ssc)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SSC %s", sc_dump_hex(cwa_session->ssc, sizeof(cwa_session->ssc)));
|
||||||
|
|
||||||
switch (sm_info->cmd) {
|
switch (sm_info->cmd) {
|
||||||
case SM_CMD_FILE_READ:
|
case SM_CMD_FILE_READ:
|
||||||
@ -586,7 +586,7 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru
|
|||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"IAS/ECC decode answer() rdata length %i, out length %"SC_FORMAT_LEN_SIZE_T"u",
|
"IAS/ECC decode answer() rdata length %i, out length %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
rdata->length, out_len);
|
rdata->length, out_len);
|
||||||
for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) {
|
for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) {
|
||||||
@ -599,7 +599,7 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru
|
|||||||
unsigned char ticket[8];
|
unsigned char ticket[8];
|
||||||
size_t ticket_len = sizeof(ticket);
|
size_t ticket_len = sizeof(ticket);
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"IAS/ECC decode response(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
"IAS/ECC decode response(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
||||||
rapdu->apdu.resplen, sc_dump_hex(rapdu->apdu.resp, rapdu->apdu.resplen));
|
rapdu->apdu.resplen, sc_dump_hex(rapdu->apdu.resp, rapdu->apdu.resplen));
|
||||||
|
|
||||||
@ -611,12 +611,12 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru
|
|||||||
rv = sc_asn1_decode(ctx, asn1_iasecc_sm_data_object, rapdu->apdu.resp, rapdu->apdu.resplen, NULL, NULL);
|
rv = sc_asn1_decode(ctx, asn1_iasecc_sm_data_object, rapdu->apdu.resp, rapdu->apdu.resplen, NULL, NULL);
|
||||||
LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): ASN1 decode error");
|
LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): ASN1 decode error");
|
||||||
|
|
||||||
sc_log(ctx, "IAS/ECC decode response() SW:%02X%02X, MAC:%s", status[0], status[1], sc_dump_hex(ticket, ticket_len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IAS/ECC decode response() SW:%02X%02X, MAC:%s", status[0], status[1], sc_dump_hex(ticket, ticket_len));
|
||||||
if (status[0] != 0x90 || status[1] != 0x00)
|
if (status[0] != 0x90 || status[1] != 0x00)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (asn1_iasecc_sm_data_object[0].flags & SC_ASN1_PRESENT) {
|
if (asn1_iasecc_sm_data_object[0].flags & SC_ASN1_PRESENT) {
|
||||||
sc_log(ctx, "IAS/ECC decode answer() object present");
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IAS/ECC decode answer() object present");
|
||||||
if (resp_data[0] != 0x01)
|
if (resp_data[0] != 0x01)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "IAS/ECC decode answer(s): invalid encrypted data format");
|
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "IAS/ECC decode answer(s): invalid encrypted data format");
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru
|
|||||||
&decrypted, &decrypted_len);
|
&decrypted, &decrypted_len);
|
||||||
LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): cannot decrypt card answer data");
|
LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): cannot decrypt card answer data");
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"IAS/ECC decrypted data(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
"IAS/ECC decrypted data(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
||||||
decrypted_len,
|
decrypted_len,
|
||||||
sc_dump_hex(decrypted, decrypted_len));
|
sc_dump_hex(decrypted, decrypted_len));
|
||||||
@ -642,7 +642,7 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru
|
|||||||
memcpy(out + offs, decrypted, decrypted_len);
|
memcpy(out + offs, decrypted, decrypted_len);
|
||||||
|
|
||||||
offs += decrypted_len;
|
offs += decrypted_len;
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"IAS/ECC decode card answer(s): out_len/offs %"SC_FORMAT_LEN_SIZE_T"u/%i",
|
"IAS/ECC decode card answer(s): out_len/offs %"SC_FORMAT_LEN_SIZE_T"u/%i",
|
||||||
out_len, offs);
|
out_len, offs);
|
||||||
}
|
}
|
||||||
|
@ -55,13 +55,13 @@ sm_cwa_get_mac(struct sc_context *ctx, unsigned char *key, DES_cblock *icv,
|
|||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "sm_cwa_get_mac() data length %i", in_len);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "sm_cwa_get_mac() data length %i", in_len);
|
||||||
|
|
||||||
buf = malloc(in_len + 8);
|
buf = malloc(in_len + 8);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
sc_log(ctx, "sm_cwa_get_mac() in_data(%i) %s", in_len, sc_dump_hex(in, in_len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "sm_cwa_get_mac() in_data(%i) %s", in_len, sc_dump_hex(in, in_len));
|
||||||
memcpy(buf, in, in_len);
|
memcpy(buf, in, in_len);
|
||||||
memcpy(buf + in_len, padding, 8);
|
memcpy(buf + in_len, padding, 8);
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ sm_cwa_get_mac(struct sc_context *ctx, unsigned char *key, DES_cblock *icv,
|
|||||||
else
|
else
|
||||||
in_len = ((in_len + 7) / 8) * 8;
|
in_len = ((in_len + 7) / 8) * 8;
|
||||||
|
|
||||||
sc_log(ctx, "sm_cwa_get_mac() data to MAC(%i) %s", in_len, sc_dump_hex(buf, in_len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "sm_cwa_get_mac() data to MAC(%i) %s", in_len, sc_dump_hex(buf, in_len));
|
||||||
sc_log(ctx, "sm_cwa_get_mac() ICV %s", sc_dump_hex((unsigned char *)icv, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "sm_cwa_get_mac() ICV %s", sc_dump_hex((unsigned char *)icv, 8));
|
||||||
|
|
||||||
memcpy(&kk, key, 8);
|
memcpy(&kk, key, 8);
|
||||||
memcpy(&k2, key + 8, 8);
|
memcpy(&k2, key + 8, 8);
|
||||||
@ -91,8 +91,8 @@ sm_cwa_encode_external_auth_data(struct sc_context *ctx, struct sm_cwa_session *
|
|||||||
if (out_len < 16)
|
if (out_len < 16)
|
||||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||||
|
|
||||||
sc_log(ctx, "IFD.RND %s", sc_dump_hex(session_data->ifd.rnd, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.RND %s", sc_dump_hex(session_data->ifd.rnd, 8));
|
||||||
sc_log(ctx, "IFD.SN %s", sc_dump_hex(session_data->ifd.sn, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.SN %s", sc_dump_hex(session_data->ifd.sn, 8));
|
||||||
|
|
||||||
memcpy(out + 0, session_data->icc.rnd, 8);
|
memcpy(out + 0, session_data->icc.rnd, 8);
|
||||||
memcpy(out + 8, session_data->icc.sn, 8);
|
memcpy(out + 8, session_data->icc.sn, 8);
|
||||||
@ -108,11 +108,11 @@ sm_cwa_encode_mutual_auth_data(struct sc_context *ctx, struct sm_cwa_session *se
|
|||||||
if (out_len < 64)
|
if (out_len < 64)
|
||||||
return SC_ERROR_BUFFER_TOO_SMALL;
|
return SC_ERROR_BUFFER_TOO_SMALL;
|
||||||
|
|
||||||
sc_log(ctx, "IFD.RND %s", sc_dump_hex(session_data->ifd.rnd, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.RND %s", sc_dump_hex(session_data->ifd.rnd, 8));
|
||||||
sc_log(ctx, "IFD.SN %s", sc_dump_hex(session_data->ifd.sn, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.SN %s", sc_dump_hex(session_data->ifd.sn, 8));
|
||||||
sc_log(ctx, "IFD.K %s", sc_dump_hex(session_data->ifd.k, 32));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.K %s", sc_dump_hex(session_data->ifd.k, 32));
|
||||||
sc_log(ctx, "ICC.RND %s", sc_dump_hex(session_data->icc.rnd, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "ICC.RND %s", sc_dump_hex(session_data->icc.rnd, 8));
|
||||||
sc_log(ctx, "ICC.SN %s", sc_dump_hex(session_data->icc.sn, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "ICC.SN %s", sc_dump_hex(session_data->icc.sn, 8));
|
||||||
|
|
||||||
memcpy(out + 0, session_data->ifd.rnd, 8);
|
memcpy(out + 0, session_data->ifd.rnd, 8);
|
||||||
memcpy(out + 8, session_data->ifd.sn, 8);
|
memcpy(out + 8, session_data->ifd.sn, 8);
|
||||||
@ -139,7 +139,7 @@ sm_cwa_decode_authentication_data(struct sc_context *ctx, struct sm_cwa_keyset *
|
|||||||
memset(icv, 0, sizeof(icv));
|
memset(icv, 0, sizeof(icv));
|
||||||
rv = sm_cwa_get_mac(ctx, keyset->mac, &icv, session_data->mdata, 0x40, &cblock, 1);
|
rv = sm_cwa_get_mac(ctx, keyset->mac, &icv, session_data->mdata, 0x40, &cblock, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "Decode authentication data: sm_ecc_get_mac failed");
|
LOG_TEST_RET(ctx, rv, "Decode authentication data: sm_ecc_get_mac failed");
|
||||||
sc_log(ctx, "MAC:%s", sc_dump_hex(cblock, sizeof(cblock)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "MAC:%s", sc_dump_hex(cblock, sizeof(cblock)));
|
||||||
|
|
||||||
if(memcmp(session_data->mdata + 0x40, cblock, 8))
|
if(memcmp(session_data->mdata + 0x40, cblock, 8))
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_SM_AUTHENTICATION_FAILED);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_SM_AUTHENTICATION_FAILED);
|
||||||
@ -147,7 +147,7 @@ sm_cwa_decode_authentication_data(struct sc_context *ctx, struct sm_cwa_keyset *
|
|||||||
rv = sm_decrypt_des_cbc3(ctx, keyset->enc, session_data->mdata, session_data->mdata_len, &decrypted, &decrypted_len);
|
rv = sm_decrypt_des_cbc3(ctx, keyset->enc, session_data->mdata, session_data->mdata_len, &decrypted, &decrypted_len);
|
||||||
LOG_TEST_RET(ctx, rv, "sm_ecc_decode_auth_data() DES CBC3 decrypt error");
|
LOG_TEST_RET(ctx, rv, "sm_ecc_decode_auth_data() DES CBC3 decrypt error");
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"sm_ecc_decode_auth_data() decrypted(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
"sm_ecc_decode_auth_data() decrypted(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
||||||
decrypted_len, sc_dump_hex(decrypted, decrypted_len));
|
decrypted_len, sc_dump_hex(decrypted, decrypted_len));
|
||||||
|
|
||||||
@ -191,17 +191,17 @@ sm_cwa_init_session_keys(struct sc_context *ctx, struct sm_cwa_session *session_
|
|||||||
for (ii=0; ii<32; ii++)
|
for (ii=0; ii<32; ii++)
|
||||||
xored[ii] = session_data->ifd.k[ii] ^ session_data->icc.k[ii];
|
xored[ii] = session_data->ifd.k[ii] ^ session_data->icc.k[ii];
|
||||||
|
|
||||||
sc_log(ctx, "K_IFD %s", sc_dump_hex(session_data->ifd.k, 32));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "K_IFD %s", sc_dump_hex(session_data->ifd.k, 32));
|
||||||
sc_log(ctx, "K_ICC %s", sc_dump_hex(session_data->icc.k, 32));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "K_ICC %s", sc_dump_hex(session_data->icc.k, 32));
|
||||||
|
|
||||||
if (mechanism == IASECC_ALGORITHM_SYMMETRIC_SHA1) {
|
if (mechanism == IASECC_ALGORITHM_SYMMETRIC_SHA1) {
|
||||||
xored[35] = 0x01;
|
xored[35] = 0x01;
|
||||||
sc_log(ctx, "XOR for SkEnc %s", sc_dump_hex(xored, 36));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "XOR for SkEnc %s", sc_dump_hex(xored, 36));
|
||||||
SHA1(xored, 36, buff);
|
SHA1(xored, 36, buff);
|
||||||
memcpy(&session_data->session_enc[0], buff, sizeof(session_data->session_enc));
|
memcpy(&session_data->session_enc[0], buff, sizeof(session_data->session_enc));
|
||||||
|
|
||||||
xored[35] = 0x02;
|
xored[35] = 0x02;
|
||||||
sc_log(ctx, "XOR for SkMac %s", sc_dump_hex(xored, 36));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "XOR for SkMac %s", sc_dump_hex(xored, 36));
|
||||||
SHA1(xored, 36, buff);
|
SHA1(xored, 36, buff);
|
||||||
memcpy(&session_data->session_mac[0], buff, sizeof(session_data->session_mac));
|
memcpy(&session_data->session_mac[0], buff, sizeof(session_data->session_mac));
|
||||||
}
|
}
|
||||||
@ -240,10 +240,10 @@ sm_cwa_initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_rem
|
|||||||
int rv, offs;
|
int rv, offs;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM IAS/ECC initialize: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC initialize: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
||||||
sc_log(ctx, "SM IAS/ECC initialize: card challenge %s", sc_dump_hex(cwa_session->card_challenge, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC initialize: card challenge %s", sc_dump_hex(cwa_session->card_challenge, 8));
|
||||||
sc_log(ctx, "SM IAS/ECC initialize: current_df_path %s", sc_print_path(&sm_info->current_path_df));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC initialize: current_df_path %s", sc_print_path(&sm_info->current_path_df));
|
||||||
sc_log(ctx, "SM IAS/ECC initialize: CRT_AT reference 0x%X", cwa_session->params.crt_at.refs[0]);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM IAS/ECC initialize: CRT_AT reference 0x%X", cwa_session->params.crt_at.refs[0]);
|
||||||
|
|
||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
@ -270,12 +270,12 @@ sm_cwa_initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_rem
|
|||||||
LOG_FUNC_RETURN(ctx, offs);
|
LOG_FUNC_RETURN(ctx, offs);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "S(%i) %s", offs, sc_dump_hex(buf, offs));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "S(%i) %s", offs, sc_dump_hex(buf, offs));
|
||||||
|
|
||||||
rv = sm_encrypt_des_cbc3(ctx, cwa_keyset->enc, buf, offs, &encrypted, &encrypted_len, 1);
|
rv = sm_encrypt_des_cbc3(ctx, cwa_keyset->enc, buf, offs, &encrypted, &encrypted_len, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "_encrypt_des_cbc3() failed");
|
LOG_TEST_RET(ctx, rv, "_encrypt_des_cbc3() failed");
|
||||||
|
|
||||||
sc_log(ctx, "ENCed(%"SC_FORMAT_LEN_SIZE_T"u) %s", encrypted_len,
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "ENCed(%"SC_FORMAT_LEN_SIZE_T"u) %s", encrypted_len,
|
||||||
sc_dump_hex(encrypted, encrypted_len));
|
sc_dump_hex(encrypted, encrypted_len));
|
||||||
|
|
||||||
memcpy(buf, encrypted, encrypted_len);
|
memcpy(buf, encrypted, encrypted_len);
|
||||||
@ -283,7 +283,7 @@ sm_cwa_initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_rem
|
|||||||
|
|
||||||
rv = sm_cwa_get_mac(ctx, cwa_keyset->mac, &icv, buf, offs, &cblock, 1);
|
rv = sm_cwa_get_mac(ctx, cwa_keyset->mac, &icv, buf, offs, &cblock, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "sm_ecc_get_mac() failed");
|
LOG_TEST_RET(ctx, rv, "sm_ecc_get_mac() failed");
|
||||||
sc_log(ctx, "MACed(%"SC_FORMAT_LEN_SIZE_T"u) %s", sizeof(cblock),
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "MACed(%"SC_FORMAT_LEN_SIZE_T"u) %s", sizeof(cblock),
|
||||||
sc_dump_hex(cblock, sizeof(cblock)));
|
sc_dump_hex(cblock, sizeof(cblock)));
|
||||||
|
|
||||||
apdu->cse = SC_APDU_CASE_4_SHORT;
|
apdu->cse = SC_APDU_CASE_4_SHORT;
|
||||||
@ -314,7 +314,7 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%"SC_FORMAT_LEN_SIZE_T"u):%p)",
|
"securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%"SC_FORMAT_LEN_SIZE_T"u):%p)",
|
||||||
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen,
|
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen,
|
||||||
apdu->data);
|
apdu->data);
|
||||||
@ -323,7 +323,7 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
|||||||
|
|
||||||
rv = sm_encrypt_des_cbc3(ctx, session_data->session_enc, apdu->data, apdu->datalen, &encrypted, &encrypted_len, 0);
|
rv = sm_encrypt_des_cbc3(ctx, session_data->session_enc, apdu->data, apdu->datalen, &encrypted, &encrypted_len, 0);
|
||||||
LOG_TEST_RET(ctx, rv, "securize APDU: DES CBC3 encryption failed");
|
LOG_TEST_RET(ctx, rv, "securize APDU: DES CBC3 encryption failed");
|
||||||
sc_log(ctx, "encrypted data (len:%"SC_FORMAT_LEN_SIZE_T"u, %s)",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "encrypted data (len:%"SC_FORMAT_LEN_SIZE_T"u, %s)",
|
||||||
encrypted_len, sc_dump_hex(encrypted, encrypted_len));
|
encrypted_len, sc_dump_hex(encrypted, encrypted_len));
|
||||||
|
|
||||||
offs = 0;
|
offs = 0;
|
||||||
@ -343,7 +343,7 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
|||||||
memcpy(edfb_data + offs, encrypted, encrypted_len);
|
memcpy(edfb_data + offs, encrypted, encrypted_len);
|
||||||
offs += encrypted_len;
|
offs += encrypted_len;
|
||||||
edfb_len = offs;
|
edfb_len = offs;
|
||||||
sc_log(ctx, "securize APDU: EDFB(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "securize APDU: EDFB(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
||||||
edfb_len, sc_dump_hex(edfb_data, edfb_len));
|
edfb_len, sc_dump_hex(edfb_data, edfb_len));
|
||||||
|
|
||||||
free(encrypted);
|
free(encrypted);
|
||||||
@ -371,13 +371,13 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
|||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
mac_len = offs;
|
mac_len = offs;
|
||||||
sc_log(ctx, "securize APDU: MAC data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "securize APDU: MAC data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
||||||
mac_len, sc_dump_hex(mac_data, mac_len));
|
mac_len, sc_dump_hex(mac_data, mac_len));
|
||||||
|
|
||||||
memset(icv, 0, sizeof(icv));
|
memset(icv, 0, sizeof(icv));
|
||||||
rv = sm_cwa_get_mac(ctx, session_data->session_mac, &icv, mac_data, mac_len, &cblock, 0);
|
rv = sm_cwa_get_mac(ctx, session_data->session_mac, &icv, mac_data, mac_len, &cblock, 0);
|
||||||
LOG_TEST_RET(ctx, rv, "securize APDU: MAC calculation error");
|
LOG_TEST_RET(ctx, rv, "securize APDU: MAC calculation error");
|
||||||
sc_log(ctx, "securize APDU: MAC:%s", sc_dump_hex(cblock, sizeof(cblock)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "securize APDU: MAC:%s", sc_dump_hex(cblock, sizeof(cblock)));
|
||||||
|
|
||||||
offs = 0;
|
offs = 0;
|
||||||
if (edfb_len) {
|
if (edfb_len) {
|
||||||
@ -395,7 +395,7 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
|||||||
sbuf[offs++] = 8;
|
sbuf[offs++] = 8;
|
||||||
memcpy(sbuf + offs, cblock, 8);
|
memcpy(sbuf + offs, cblock, 8);
|
||||||
offs += 8;
|
offs += 8;
|
||||||
sc_log(ctx, "securize APDU: SM data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "securize APDU: SM data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)",
|
||||||
offs, sc_dump_hex(sbuf, offs));
|
offs, sc_dump_hex(sbuf, offs));
|
||||||
|
|
||||||
if (offs > sizeof(rapdu->sbuf))
|
if (offs > sizeof(rapdu->sbuf))
|
||||||
|
@ -63,9 +63,9 @@ sm_gp_initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_rem
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM GP initialize: serial:%s", sc_dump_hex(sn.value, sn.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP initialize: serial:%s", sc_dump_hex(sn.value, sn.len));
|
||||||
sc_log(ctx, "SM GP initialize: current_df_path %s", sc_print_path(&sm_info->current_path_df));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP initialize: current_df_path %s", sc_print_path(&sm_info->current_path_df));
|
||||||
sc_log(ctx, "SM GP initialize: KMC length %i", gp_keyset->kmc_len);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP initialize: KMC length %i", gp_keyset->kmc_len);
|
||||||
|
|
||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
@ -107,13 +107,13 @@ sc_gp_get_session_key(struct sc_context *ctx, struct sm_gp_session *gp_session,
|
|||||||
|
|
||||||
if (sm_encrypt_des_ecb3(key, deriv, 16, &out, &out_len)) {
|
if (sm_encrypt_des_ecb3(key, deriv, 16, &out, &out_len)) {
|
||||||
if (ctx)
|
if (ctx)
|
||||||
sc_log(ctx, "SM GP get session key: des_ecb3 encryption error");
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM GP get session key: des_ecb3 encryption error");
|
||||||
free(out);
|
free(out);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (out==NULL || out_len!=16) {
|
else if (out==NULL || out_len!=16) {
|
||||||
if (ctx)
|
if (ctx)
|
||||||
sc_log(ctx, "SM GP get session key: des_ecb3 encryption error: out(%p,len:%i)", out, out_len);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM GP get session key: des_ecb3 encryption error: out(%p,len:%i)", out, out_len);
|
||||||
if (out)
|
if (out)
|
||||||
free(out);
|
free(out);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -211,7 +211,7 @@ sm_gp_init_session(struct sc_context *ctx, struct sm_gp_session *gp_session,
|
|||||||
if (!adata || adata_len < 8)
|
if (!adata || adata_len < 8)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM GP init session: auth.data %s", sc_dump_hex(adata, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: auth.data %s", sc_dump_hex(adata, 8));
|
||||||
|
|
||||||
gp_session->session_enc = sc_gp_get_session_key(ctx, gp_session, gp_keyset->enc);
|
gp_session->session_enc = sc_gp_get_session_key(ctx, gp_session, gp_keyset->enc);
|
||||||
gp_session->session_mac = sc_gp_get_session_key(ctx, gp_session, gp_keyset->mac);
|
gp_session->session_mac = sc_gp_get_session_key(ctx, gp_session, gp_keyset->mac);
|
||||||
@ -220,19 +220,19 @@ sm_gp_init_session(struct sc_context *ctx, struct sm_gp_session *gp_session,
|
|||||||
LOG_TEST_RET(ctx, SC_ERROR_SM_NO_SESSION_KEYS, "SM GP init session: get session keys error");
|
LOG_TEST_RET(ctx, SC_ERROR_SM_NO_SESSION_KEYS, "SM GP init session: get session keys error");
|
||||||
memcpy(gp_session->session_kek, gp_keyset->kek, 16);
|
memcpy(gp_session->session_kek, gp_keyset->kek, 16);
|
||||||
|
|
||||||
sc_log(ctx, "SM GP init session: session ENC: %s", sc_dump_hex(gp_session->session_enc, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: session ENC: %s", sc_dump_hex(gp_session->session_enc, 16));
|
||||||
sc_log(ctx, "SM GP init session: session MAC: %s", sc_dump_hex(gp_session->session_mac, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: session MAC: %s", sc_dump_hex(gp_session->session_mac, 16));
|
||||||
sc_log(ctx, "SM GP init session: session KEK: %s", sc_dump_hex(gp_session->session_kek, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: session KEK: %s", sc_dump_hex(gp_session->session_kek, 16));
|
||||||
|
|
||||||
memset(cksum, 0, sizeof(cksum));
|
memset(cksum, 0, sizeof(cksum));
|
||||||
rv = sm_gp_get_cryptogram(gp_session->session_enc, gp_session->host_challenge, gp_session->card_challenge, cksum, sizeof(cksum));
|
rv = sm_gp_get_cryptogram(gp_session->session_enc, gp_session->host_challenge, gp_session->card_challenge, cksum, sizeof(cksum));
|
||||||
LOG_TEST_RET(ctx, rv, "SM GP init session: cannot get cryptogram");
|
LOG_TEST_RET(ctx, rv, "SM GP init session: cannot get cryptogram");
|
||||||
|
|
||||||
sc_log(ctx, "SM GP init session: cryptogram: %s", sc_dump_hex(cksum, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: cryptogram: %s", sc_dump_hex(cksum, 8));
|
||||||
if (memcmp(cksum, adata, adata_len))
|
if (memcmp(cksum, adata, adata_len))
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_SM_AUTHENTICATION_FAILED);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_SM_AUTHENTICATION_FAILED);
|
||||||
|
|
||||||
sc_log(ctx, "SM GP init session: card authenticated");
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP init session: card authenticated");
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ sm_gp_external_authentication(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
host_cryptogram, sizeof(host_cryptogram));
|
host_cryptogram, sizeof(host_cryptogram));
|
||||||
LOG_TEST_RET(ctx, rv, "SM GP authentication: get host cryptogram error");
|
LOG_TEST_RET(ctx, rv, "SM GP authentication: get host cryptogram error");
|
||||||
|
|
||||||
sc_log(ctx, "SM GP authentication: host_cryptogram:%s", sc_dump_hex(host_cryptogram, 8));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM GP authentication: host_cryptogram:%s", sc_dump_hex(host_cryptogram, 8));
|
||||||
|
|
||||||
rv = rdata->alloc(rdata, &new_rapdu);
|
rv = rdata->alloc(rdata, &new_rapdu);
|
||||||
LOG_TEST_RET(ctx, rv, "SM GP authentication: cannot allocate remote APDU");
|
LOG_TEST_RET(ctx, rv, "SM GP authentication: cannot allocate remote APDU");
|
||||||
@ -321,7 +321,7 @@ sm_gp_encrypt_command_data(struct sc_context *ctx, unsigned char *session_key,
|
|||||||
if (!out || !out_len)
|
if (!out || !out_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM GP encrypt command data error");
|
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM GP encrypt command data error");
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM GP encrypt command data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p)",
|
"SM GP encrypt command data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p)",
|
||||||
in_len, in);
|
in_len, in);
|
||||||
if (in==NULL || in_len==0) {
|
if (in==NULL || in_len==0) {
|
||||||
@ -365,7 +365,7 @@ sm_gp_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
apdu_data = (unsigned char *)apdu->data;
|
apdu_data = (unsigned char *)apdu->data;
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM GP securize APDU(cse:%X,cla:%X,ins:%X,data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p),lc:%"SC_FORMAT_LEN_SIZE_T"u,GP level:%X,GP index:%X",
|
"SM GP securize APDU(cse:%X,cla:%X,ins:%X,data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p),lc:%"SC_FORMAT_LEN_SIZE_T"u,GP level:%X,GP index:%X",
|
||||||
apdu->cse, apdu->cla, apdu->ins, apdu->datalen, apdu->data,
|
apdu->cse, apdu->cla, apdu->ins, apdu->datalen, apdu->data,
|
||||||
apdu->lc, gp_level, gp_index);
|
apdu->lc, gp_level, gp_index);
|
||||||
@ -387,7 +387,7 @@ sm_gp_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info,
|
|||||||
if (encrypted_len + 8 > SC_MAX_APDU_BUFFER_SIZE)
|
if (encrypted_len + 8 > SC_MAX_APDU_BUFFER_SIZE)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "SM GP securize APDU: not enough place for encrypted data");
|
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "SM GP securize APDU: not enough place for encrypted data");
|
||||||
|
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_SM,
|
||||||
"SM GP securize APDU: encrypted length %"SC_FORMAT_LEN_SIZE_T"u",
|
"SM GP securize APDU: encrypted length %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
encrypted_len);
|
encrypted_len);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ sm_gp_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
size_t hex_len = sizeof(hex);
|
size_t hex_len = sizeof(hex);
|
||||||
int rv, ii;
|
int rv, ii;
|
||||||
|
|
||||||
sc_log(ctx, "SM get KMC from config section '%s'", sm_info->config_section);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get KMC from config section '%s'", sm_info->config_section);
|
||||||
for (ii = 0; ctx->conf_blocks[ii]; ii++) {
|
for (ii = 0; ctx->conf_blocks[ii]; ii++) {
|
||||||
blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[ii], "secure_messaging", sm_info->config_section);
|
blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[ii], "secure_messaging", sm_info->config_section);
|
||||||
if (blocks) {
|
if (blocks) {
|
||||||
@ -83,11 +83,11 @@ sm_gp_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
|
|
||||||
rv = sc_hex_to_bin(kmc, hex, &hex_len);
|
rv = sc_hex_to_bin(kmc, hex, &hex_len);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
sc_log(ctx, "SM get KMC: hex to bin failed for '%s'; error %i", kmc, rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM get KMC: hex to bin failed for '%s'; error %i", kmc, rv);
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "SM type:%X, KMC(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM type:%X, KMC(%"SC_FORMAT_LEN_SIZE_T"u) %s",
|
||||||
sm_info->sm_type, hex_len, sc_dump_hex(hex, hex_len));
|
sm_info->sm_type, hex_len, sc_dump_hex(hex, hex_len));
|
||||||
if (hex_len != 16 && hex_len != 48 )
|
if (hex_len != 16 && hex_len != 48 )
|
||||||
return SC_ERROR_INVALID_DATA;
|
return SC_ERROR_INVALID_DATA;
|
||||||
@ -123,7 +123,7 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "CRT(algo:%X,ref:%X)", crt_at->algo, crt_at->refs[0]);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "CRT(algo:%X,ref:%X)", crt_at->algo, crt_at->refs[0]);
|
||||||
/* Keyset ENC */
|
/* Keyset ENC */
|
||||||
if (sm_info->current_aid.len && (crt_at->refs[0] & IASECC_OBJECT_REF_LOCAL))
|
if (sm_info->current_aid.len && (crt_at->refs[0] & IASECC_OBJECT_REF_LOCAL))
|
||||||
snprintf(name, sizeof(name), "keyset_%s_%02i_enc",
|
snprintf(name, sizeof(name), "keyset_%s_%02i_enc",
|
||||||
@ -132,11 +132,11 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
snprintf(name, sizeof(name), "keyset_%02i_enc", ref);
|
snprintf(name, sizeof(name), "keyset_%02i_enc", ref);
|
||||||
value = scconf_get_str(sm_conf_block, name, NULL);
|
value = scconf_get_str(sm_conf_block, name, NULL);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
sc_log(ctx, "No %s value in OpenSC config", name);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "No %s value in OpenSC config", name);
|
||||||
return SC_ERROR_SM_KEYSET_NOT_FOUND;
|
return SC_ERROR_SM_KEYSET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "keyset::enc(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value),
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "keyset::enc(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value),
|
||||||
value);
|
value);
|
||||||
if (strlen(value) == 16) {
|
if (strlen(value) == 16) {
|
||||||
memcpy(cwa_keyset->enc, value, 16);
|
memcpy(cwa_keyset->enc, value, 16);
|
||||||
@ -145,18 +145,18 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
hex_len = sizeof(hex);
|
hex_len = sizeof(hex);
|
||||||
rv = sc_hex_to_bin(value, hex, &hex_len);
|
rv = sc_hex_to_bin(value, hex, &hex_len);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
sc_log(ctx, "SM get %s: hex to bin failed for '%s'; error %i", name, value, rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM get %s: hex to bin failed for '%s'; error %i", name, value, rv);
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "ENC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len,
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "ENC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len,
|
||||||
sc_dump_hex(hex, hex_len));
|
sc_dump_hex(hex, hex_len));
|
||||||
if (hex_len != 16)
|
if (hex_len != 16)
|
||||||
return SC_ERROR_INVALID_DATA;
|
return SC_ERROR_INVALID_DATA;
|
||||||
|
|
||||||
memcpy(cwa_keyset->enc, hex, hex_len);
|
memcpy(cwa_keyset->enc, hex, hex_len);
|
||||||
}
|
}
|
||||||
sc_log(ctx, "%s %s", name, sc_dump_hex(cwa_keyset->enc, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "%s %s", name, sc_dump_hex(cwa_keyset->enc, 16));
|
||||||
|
|
||||||
/* Keyset MAC */
|
/* Keyset MAC */
|
||||||
if (sm_info->current_aid.len && (crt_at->refs[0] & IASECC_OBJECT_REF_LOCAL))
|
if (sm_info->current_aid.len && (crt_at->refs[0] & IASECC_OBJECT_REF_LOCAL))
|
||||||
@ -166,11 +166,11 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
snprintf(name, sizeof(name), "keyset_%02i_mac", ref);
|
snprintf(name, sizeof(name), "keyset_%02i_mac", ref);
|
||||||
value = scconf_get_str(sm_conf_block, name, NULL);
|
value = scconf_get_str(sm_conf_block, name, NULL);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
sc_log(ctx, "No %s value in OpenSC config", name);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "No %s value in OpenSC config", name);
|
||||||
return SC_ERROR_SM_KEYSET_NOT_FOUND;
|
return SC_ERROR_SM_KEYSET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "keyset::mac(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value),
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "keyset::mac(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value),
|
||||||
value);
|
value);
|
||||||
if (strlen(value) == 16) {
|
if (strlen(value) == 16) {
|
||||||
memcpy(cwa_keyset->mac, value, 16);
|
memcpy(cwa_keyset->mac, value, 16);
|
||||||
@ -179,18 +179,18 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
hex_len = sizeof(hex);
|
hex_len = sizeof(hex);
|
||||||
rv = sc_hex_to_bin(value, hex, &hex_len);
|
rv = sc_hex_to_bin(value, hex, &hex_len);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
sc_log(ctx, "SM get '%s': hex to bin failed for '%s'; error %i", name, value, rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM get '%s': hex to bin failed for '%s'; error %i", name, value, rv);
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "MAC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len,
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "MAC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len,
|
||||||
sc_dump_hex(hex, hex_len));
|
sc_dump_hex(hex, hex_len));
|
||||||
if (hex_len != 16)
|
if (hex_len != 16)
|
||||||
return SC_ERROR_INVALID_DATA;
|
return SC_ERROR_INVALID_DATA;
|
||||||
|
|
||||||
memcpy(cwa_keyset->mac, hex, hex_len);
|
memcpy(cwa_keyset->mac, hex, hex_len);
|
||||||
}
|
}
|
||||||
sc_log(ctx, "%s %s", name, sc_dump_hex(cwa_keyset->mac, 16));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "%s %s", name, sc_dump_hex(cwa_keyset->mac, 16));
|
||||||
|
|
||||||
cwa_keyset->sdo_reference = crt_at->refs[0];
|
cwa_keyset->sdo_reference = crt_at->refs[0];
|
||||||
|
|
||||||
@ -203,12 +203,12 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
hex_len = sizeof(hex);
|
hex_len = sizeof(hex);
|
||||||
rv = sc_hex_to_bin(value, hex, &hex_len);
|
rv = sc_hex_to_bin(value, hex, &hex_len);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
sc_log(ctx, "SM get 'ifd_serial': hex to bin failed for '%s'; error %i", value, rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM get 'ifd_serial': hex to bin failed for '%s'; error %i", value, rv);
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hex_len != sizeof(cwa_session->ifd.sn)) {
|
if (hex_len != sizeof(cwa_session->ifd.sn)) {
|
||||||
sc_log(ctx,
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE,
|
||||||
"SM get 'ifd_serial': invalid IFD serial length: %"SC_FORMAT_LEN_SIZE_T"u",
|
"SM get 'ifd_serial': invalid IFD serial length: %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
hex_len);
|
hex_len);
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
@ -218,18 +218,18 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
|||||||
|
|
||||||
rv = RAND_bytes(cwa_session->ifd.rnd, 8);
|
rv = RAND_bytes(cwa_session->ifd.rnd, 8);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
sc_log(ctx, "Generate random error: %i", rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "Generate random error: %i", rv);
|
||||||
return SC_ERROR_SM_RAND_FAILED;
|
return SC_ERROR_SM_RAND_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = RAND_bytes(cwa_session->ifd.k, 32);
|
rv = RAND_bytes(cwa_session->ifd.k, 32);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
sc_log(ctx, "Generate random error: %i", rv);
|
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "Generate random error: %i", rv);
|
||||||
return SC_ERROR_SM_RAND_FAILED;
|
return SC_ERROR_SM_RAND_FAILED;
|
||||||
}
|
}
|
||||||
sc_log(ctx, "IFD.Serial: %s", sc_dump_hex(cwa_session->ifd.sn, sizeof(cwa_session->ifd.sn)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.Serial: %s", sc_dump_hex(cwa_session->ifd.sn, sizeof(cwa_session->ifd.sn)));
|
||||||
sc_log(ctx, "IFD.Rnd: %s", sc_dump_hex(cwa_session->ifd.rnd, sizeof(cwa_session->ifd.rnd)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.Rnd: %s", sc_dump_hex(cwa_session->ifd.rnd, sizeof(cwa_session->ifd.rnd)));
|
||||||
sc_log(ctx, "IFD.K: %s", sc_dump_hex(cwa_session->ifd.k, sizeof(cwa_session->ifd.k)));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "IFD.K: %s", sc_dump_hex(cwa_session->ifd.k, sizeof(cwa_session->ifd.k)));
|
||||||
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_remote_dat
|
|||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "Current AID: %s", sc_dump_hex(sm_info->current_aid.value, sm_info->current_aid.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "Current AID: %s", sc_dump_hex(sm_info->current_aid.value, sm_info->current_aid.len));
|
||||||
switch (sm_info->sm_type) {
|
switch (sm_info->sm_type) {
|
||||||
case SM_TYPE_GP_SCP01:
|
case SM_TYPE_GP_SCP01:
|
||||||
rv = sm_gp_config_get_keyset(ctx, sm_info);
|
rv = sm_gp_config_get_keyset(ctx, sm_info);
|
||||||
@ -290,8 +290,8 @@ get_apdus(struct sc_context *ctx, struct sm_info *sm_info, unsigned char *init_d
|
|||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_log(ctx, "SM get APDUs: out:%p", out);
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get APDUs: out:%p", out);
|
||||||
sc_log(ctx, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
||||||
|
|
||||||
if (sm_info->card_type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
|
if (sm_info->card_type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
|
||||||
rv = sm_authentic_get_apdus(ctx, sm_info, init_data, init_len, out, 1);
|
rv = sm_authentic_get_apdus(ctx, sm_info, init_data, init_len, out, 1);
|
||||||
@ -320,7 +320,7 @@ finalize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_remote_data
|
|||||||
int rv = SC_ERROR_INTERNAL;
|
int rv = SC_ERROR_INTERNAL;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "SM finalize: out buffer(%"SC_FORMAT_LEN_SIZE_T"u) %p",
|
sc_debug(ctx, SC_LOG_DEBUG_SM, "SM finalize: out buffer(%"SC_FORMAT_LEN_SIZE_T"u) %p",
|
||||||
out_len, out);
|
out_len, out);
|
||||||
if (!sm_info || !rdata)
|
if (!sm_info || !rdata)
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
@ -344,7 +344,6 @@ int
|
|||||||
module_init(struct sc_context *ctx, char *data)
|
module_init(struct sc_context *ctx, char *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
sc_log(ctx, "Module init data '%s'", data);
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -357,7 +356,6 @@ module_init(struct sc_context *ctx, char *data)
|
|||||||
int
|
int
|
||||||
module_cleanup(struct sc_context *ctx)
|
module_cleanup(struct sc_context *ctx)
|
||||||
{
|
{
|
||||||
sc_log(ctx, "Module cleanup: TODO");
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +363,6 @@ module_cleanup(struct sc_context *ctx)
|
|||||||
int
|
int
|
||||||
test(struct sc_context *ctx, struct sm_info *info, char *out, size_t *out_len)
|
test(struct sc_context *ctx, struct sm_info *info, char *out, size_t *out_len)
|
||||||
{
|
{
|
||||||
sc_log(ctx, "Test");
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user