From d8ababbf965d65f91aa7d782c0fa587c1299042a Mon Sep 17 00:00:00 2001 From: frankmorgner Date: Mon, 12 Apr 2010 14:26:23 +0000 Subject: [PATCH] - protocol nid in pace_sm_ctx is not needed any longer due to the changes of OpenPACE git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@69 96b47cad-a561-4643-ad3b-153ac7d7599c --- ccid/pace.c | 29 ++++++++--------------------- ccid/pace.h | 3 +-- ccid/pace_lib.c | 3 +-- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/ccid/pace.c b/ccid/pace.c index 1332914..d501842 100644 --- a/ccid/pace.c +++ b/ccid/pace.c @@ -743,7 +743,7 @@ int EstablishPACEChannel(sc_card_t *card, const __u8 *in, sctx->decrypt = pace_sm_decrypt; sctx->padding_indicator = SM_ISO_PADDING; sctx->block_length = EVP_CIPHER_block_size(pctx->cipher); - sctx->authentication_ctx = pace_sm_ctx_create(info->protocol, k_mac, + sctx->authentication_ctx = pace_sm_ctx_create(k_mac, k_enc, pctx); sctx->cipher_ctx = sctx->authentication_ctx; if (!sctx->authentication_ctx) { @@ -907,31 +907,22 @@ update_iv(struct sm_ctx *ctx) return SC_ERROR_INVALID_ARGUMENTS; BUF_MEM *sscbuf = NULL, *ivbuf = NULL; - EVP_CIPHER *ivcipher = NULL; + const EVP_CIPHER *ivcipher = NULL, *oldcipher; u8 *ssc = NULL; unsigned char *p; struct pace_sm_ctx *psmctx = ctx->cipher_ctx; int r; - switch (psmctx->protocol) { - case NID_id_PACE_DH_GM_AES_CBC_CMAC_128: - case NID_id_PACE_DH_IM_AES_CBC_CMAC_128: - case NID_id_PACE_ECDH_GM_AES_CBC_CMAC_128: - case NID_id_PACE_ECDH_IM_AES_CBC_CMAC_128: + switch (EVP_CIPHER_nid(psmctx->ctx->cipher)) { + case NID_aes_128_cbc: if (!ivcipher) ivcipher = EVP_aes_128_ecb(); /* fall through */ - case NID_id_PACE_DH_GM_AES_CBC_CMAC_192: - case NID_id_PACE_DH_IM_AES_CBC_CMAC_192: - case NID_id_PACE_ECDH_GM_AES_CBC_CMAC_192: - case NID_id_PACE_ECDH_IM_AES_CBC_CMAC_192: + case NID_aes_192_cbc: if (!ivcipher) ivcipher = EVP_aes_192_ecb(); /* fall through */ - case NID_id_PACE_DH_GM_AES_CBC_CMAC_256: - case NID_id_PACE_DH_IM_AES_CBC_CMAC_256: - case NID_id_PACE_ECDH_GM_AES_CBC_CMAC_256: - case NID_id_PACE_ECDH_IM_AES_CBC_CMAC_256: + case NID_aes_256_cbc: if (!ivcipher) ivcipher = EVP_aes_256_ecb(); @@ -961,10 +952,7 @@ update_iv(struct sm_ctx *ctx) psmctx->ctx->iv = p; memcpy(psmctx->ctx->iv, ivbuf->data, ivbuf->length); break; - case NID_id_PACE_DH_GM_3DES_CBC_CBC: - case NID_id_PACE_DH_IM_3DES_CBC_CBC: - case NID_id_PACE_ECDH_GM_3DES_CBC_CBC: - case NID_id_PACE_ECDH_IM_3DES_CBC_CBC: + case NID_des_ede_cbc: /* For 3DES encryption or decryption the IV is always NULL */ free(psmctx->ctx->iv); psmctx->ctx->iv = NULL; @@ -1129,8 +1117,7 @@ int pace_sm_authenticate(sc_card_t *card, const struct sm_ctx *ctx, bin_log(card->ctx, "Data to authenticate (PACE)", (u8 *) databuf->data, databuf->length); - macbuf = PACE_authenticate(psmctx->ctx, psmctx->protocol, - psmctx->key_mac, databuf); + macbuf = PACE_authenticate(psmctx->ctx, psmctx->key_mac, databuf); if (!macbuf) { sc_error(card->ctx, "Could not get MAC\n"); r = SC_ERROR_INTERNAL; diff --git a/ccid/pace.h b/ccid/pace.h index d4f69d7..e34e30e 100644 --- a/ccid/pace.h +++ b/ccid/pace.h @@ -43,7 +43,6 @@ extern "C" { #define MAX_EF_CARDACCESS 2048 struct pace_sm_ctx { - int protocol; /* XXX SSC is up to 16 Bytes long, not only 16 Bits */ BIGNUM *ssc; const BUF_MEM *key_mac; @@ -52,7 +51,7 @@ struct pace_sm_ctx { }; struct pace_sm_ctx * -pace_sm_ctx_create(int protocol, const BUF_MEM *key_mac, +pace_sm_ctx_create(const BUF_MEM *key_mac, const BUF_MEM *key_enc, PACE_CTX *ctx); void pace_sm_ctx_free(struct pace_sm_ctx *ctx); diff --git a/ccid/pace_lib.c b/ccid/pace_lib.c index ab85e33..654a92b 100644 --- a/ccid/pace_lib.c +++ b/ccid/pace_lib.c @@ -21,7 +21,7 @@ #include struct pace_sm_ctx * -pace_sm_ctx_create(int protocol, const BUF_MEM *key_mac, +pace_sm_ctx_create(const BUF_MEM *key_mac, const BUF_MEM *key_enc, PACE_CTX *ctx) { struct pace_sm_ctx *out = malloc(sizeof *out); @@ -36,7 +36,6 @@ pace_sm_ctx_create(int protocol, const BUF_MEM *key_mac, out->key_enc = key_enc; out->key_mac = key_mac; - out->protocol = protocol; out->ctx = ctx; return out;