added switch to disable apdu checking for TA/CA
This commit is contained in:
@@ -157,6 +157,7 @@ IMPLEMENT_ASN1_FUNCTIONS(NPA_GEN_AUTH_R)
|
|||||||
|
|
||||||
#define maxresp SC_MAX_APDU_BUFFER_SIZE - 2
|
#define maxresp SC_MAX_APDU_BUFFER_SIZE - 2
|
||||||
|
|
||||||
|
#define NPA_FLAG_DISABLE_CHECKS 1
|
||||||
/** NPA secure messaging context */
|
/** NPA secure messaging context */
|
||||||
struct npa_sm_ctx {
|
struct npa_sm_ctx {
|
||||||
/** Send sequence counter */
|
/** Send sequence counter */
|
||||||
@@ -171,6 +172,7 @@ struct npa_sm_ctx {
|
|||||||
BUF_MEM *eph_pub_key;
|
BUF_MEM *eph_pub_key;
|
||||||
/** Auxiliary Data */
|
/** Auxiliary Data */
|
||||||
BUF_MEM *auxiliary_data;
|
BUF_MEM *auxiliary_data;
|
||||||
|
char flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -230,6 +232,8 @@ npa_sm_ctx_create(EAC_CTX *ctx, const unsigned char *certificate_description,
|
|||||||
out->eph_pub_key = NULL;
|
out->eph_pub_key = NULL;
|
||||||
out->auxiliary_data = NULL;
|
out->auxiliary_data = NULL;
|
||||||
|
|
||||||
|
out->flags = NPA_FLAG_DISABLE_CHECKS;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@@ -1601,6 +1605,7 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
|||||||
}
|
}
|
||||||
struct npa_sm_ctx *eacsmctx = ctx->priv_data;
|
struct npa_sm_ctx *eacsmctx = ctx->priv_data;
|
||||||
|
|
||||||
|
if (eacsmctx->flags & NPA_FLAG_DISABLE_CHECKS) {
|
||||||
if (apdu->ins == 0x2a && apdu->p1 == 0x00 && apdu->p2 == 0xbe) {
|
if (apdu->ins == 0x2a && apdu->p1 == 0x00 && apdu->p2 == 0xbe) {
|
||||||
/* PSO:Verify Certificate
|
/* PSO:Verify Certificate
|
||||||
* check certificate description to match given certificate */
|
* check certificate description to match given certificate */
|
||||||
@@ -1780,6 +1785,7 @@ npa_sm_pre_transmit(sc_card_t *card, const struct sm_ctx *ctx,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r = increment_ssc(ctx->priv_data);
|
r = increment_ssc(ctx->priv_data);
|
||||||
|
|
||||||
@@ -1817,6 +1823,7 @@ npa_sm_finish(sc_card_t *card, const struct sm_ctx *ctx,
|
|||||||
SC_ERROR_INVALID_ARGUMENTS);
|
SC_ERROR_INVALID_ARGUMENTS);
|
||||||
struct npa_sm_ctx *eacsmctx = ctx->priv_data;
|
struct npa_sm_ctx *eacsmctx = ctx->priv_data;
|
||||||
|
|
||||||
|
if (eacsmctx->flags & NPA_FLAG_DISABLE_CHECKS) {
|
||||||
if (apdu->sw1 == 0x90 && apdu->sw2 == 0x00) {
|
if (apdu->sw1 == 0x90 && apdu->sw2 == 0x00) {
|
||||||
if (apdu->ins == 0x84 && apdu->p1 == 0x00 && apdu->p2 == 0x00
|
if (apdu->ins == 0x84 && apdu->p1 == 0x00 && apdu->p2 == 0x00
|
||||||
&& apdu->le == 8 && apdu->resplen == 8) {
|
&& apdu->le == 8 && apdu->resplen == 8) {
|
||||||
@@ -1836,6 +1843,7 @@ npa_sm_finish(sc_card_t *card, const struct sm_ctx *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user