fixed some compiler warnings
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <npa/iso-sm.h>
|
||||
#include <npa/npa.h>
|
||||
#include <npa/scutil.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -51,7 +51,7 @@ static ssize_t getline(char **lineptr, size_t *n, FILE *stream)
|
||||
}
|
||||
#endif
|
||||
|
||||
int fread_to_eof(const unsigned char *file, unsigned char **buf, size_t *buflen)
|
||||
int fread_to_eof(const char *file, unsigned char **buf, size_t *buflen)
|
||||
{
|
||||
FILE *input;
|
||||
int r = 0;
|
||||
@@ -123,7 +123,7 @@ static void write_dg(sc_card_t *card, unsigned char sfid, const char *dg_str,
|
||||
|
||||
#define ISO_VERIFY 0x20
|
||||
static void verify(sc_card_t *card, const char *verify_str,
|
||||
const unsigned char *data, size_t data_len)
|
||||
unsigned char *data, size_t data_len)
|
||||
{
|
||||
sc_apdu_t apdu;
|
||||
int r;
|
||||
@@ -283,12 +283,6 @@ main (int argc, char **argv)
|
||||
size_t privkey_len = 0;
|
||||
unsigned char auxiliary_data[0xff];
|
||||
size_t auxiliary_data_len = 0;
|
||||
unsigned char *verify_age_data = NULL;
|
||||
size_t verify_age_len = 0;
|
||||
unsigned char *verify_community_data = NULL;
|
||||
size_t verify_community_len = 0;
|
||||
unsigned char *verify_validity_data = NULL;
|
||||
size_t verify_validity_len = 0;
|
||||
|
||||
sc_context_t *ctx = NULL;
|
||||
sc_card_t *card = NULL;
|
||||
@@ -584,7 +578,8 @@ main (int argc, char **argv)
|
||||
} else {
|
||||
if (cmdline.older_than_given) {
|
||||
r = add_to_CVC_DISCRETIONARY_DATA_TEMPLATES(&templates,
|
||||
NID_id_DateOfBirth, cmdline.older_than_arg,
|
||||
NID_id_DateOfBirth,
|
||||
(unsigned char *) cmdline.older_than_arg,
|
||||
strlen(cmdline.older_than_arg));
|
||||
if (r < 0)
|
||||
goto err;
|
||||
@@ -597,7 +592,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
if (cmdline.verify_community_given) {
|
||||
r = add_to_CVC_DISCRETIONARY_DATA_TEMPLATES(&templates,
|
||||
NID_id_CommunityID, cmdline.verify_community_arg,
|
||||
NID_id_CommunityID,
|
||||
(unsigned char *) cmdline.verify_community_arg,
|
||||
strlen(cmdline.verify_community_arg));
|
||||
if (r < 0)
|
||||
goto err;
|
||||
|
||||
@@ -632,7 +632,7 @@ static int npa_mse_set_at_pace(sc_card_t *card, int protocol,
|
||||
enum s_type secret_key, const CVC_CHAT *chat, u8 *sw1, u8 *sw2)
|
||||
{
|
||||
int r, tries;
|
||||
char key = secret_key;
|
||||
unsigned char key = secret_key;
|
||||
|
||||
r = npa_mse_set_at(card, 0xC1, protocol, &key, sizeof key, NULL,
|
||||
0, NULL, 0, NULL, 0, chat, sw1, sw2);
|
||||
@@ -690,7 +690,7 @@ static int npa_gen_auth_1_encrypted_nonce(sc_card_t *card,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
apdu.data = (const u8 *) d;
|
||||
apdu.data = d;
|
||||
apdu.datalen = r;
|
||||
apdu.lc = r;
|
||||
|
||||
@@ -782,7 +782,7 @@ static int npa_gen_auth_2_map_nonce(sc_card_t *card,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
apdu.data = (const u8 *) d;
|
||||
apdu.data = d;
|
||||
apdu.datalen = r;
|
||||
apdu.lc = r;
|
||||
|
||||
@@ -874,7 +874,7 @@ static int npa_gen_auth_3_perform_key_agreement(sc_card_t *card,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
apdu.data = (const u8 *) d;
|
||||
apdu.data = d;
|
||||
apdu.datalen = r;
|
||||
apdu.lc = r;
|
||||
|
||||
@@ -967,7 +967,7 @@ static int npa_gen_auth_4_mutual_authentication(sc_card_t *card,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
apdu.data = (const u8 *) d;
|
||||
apdu.data = d;
|
||||
apdu.datalen = r;
|
||||
apdu.lc = r;
|
||||
|
||||
@@ -1595,8 +1595,7 @@ static int npa_verify(sc_card_t *card,
|
||||
apdu.cse = SC_APDU_CASE_3_EXT;
|
||||
|
||||
apdu.data = cert;
|
||||
if (0x80 & ASN1_get_object(&apdu.data, &length, &tag,
|
||||
&class, cert_len)) {
|
||||
if (0x80 & ASN1_get_object(&apdu.data, &length, &tag, &class, cert_len)) {
|
||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Error decoding Certificate");
|
||||
ssl_error(card->ctx);
|
||||
r = SC_ERROR_INTERNAL;
|
||||
@@ -1616,7 +1615,7 @@ err:
|
||||
}
|
||||
|
||||
static int npa_external_authenticate(sc_card_t *card,
|
||||
const unsigned char *signature, size_t signature_len)
|
||||
unsigned char *signature, size_t signature_len)
|
||||
{
|
||||
int r;
|
||||
sc_apdu_t apdu;
|
||||
@@ -1644,6 +1643,7 @@ err:
|
||||
return r;
|
||||
}
|
||||
|
||||
#define TA_NONCE_LENGTH 8
|
||||
int perform_terminal_authentication(sc_card_t *card,
|
||||
const unsigned char **certs, const size_t *certs_lens,
|
||||
const unsigned char *privkey, size_t privkey_len,
|
||||
@@ -1719,7 +1719,7 @@ int perform_terminal_authentication(sc_card_t *card,
|
||||
r = npa_mse_set_at_ta(card, eacsmctx->ctx->ta_ctx->protocol,
|
||||
cvc_cert->body->certificate_holder_reference->data,
|
||||
cvc_cert->body->certificate_holder_reference->length,
|
||||
eacsmctx->eph_pub_key->data, eacsmctx->eph_pub_key->length,
|
||||
(unsigned char *) eacsmctx->eph_pub_key->data, eacsmctx->eph_pub_key->length,
|
||||
auxiliary_data, auxiliary_data_len);
|
||||
if (r < 0) {
|
||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not select protocol proberties "
|
||||
@@ -1727,13 +1727,13 @@ int perform_terminal_authentication(sc_card_t *card,
|
||||
goto err;
|
||||
}
|
||||
|
||||
nonce = BUF_MEM_create(8);
|
||||
nonce = BUF_MEM_create(TA_NONCE_LENGTH);
|
||||
if (!nonce) {
|
||||
ssl_error(card->ctx);
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
r = npa_get_challenge(card, nonce->data, nonce->length);
|
||||
r = npa_get_challenge(card, (unsigned char *) nonce->data, nonce->length);
|
||||
if (r < 0) {
|
||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Could not get nonce for TA.");
|
||||
goto err;
|
||||
@@ -1761,7 +1761,8 @@ int perform_terminal_authentication(sc_card_t *card,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
r = npa_external_authenticate(card, signature->data, signature->length);
|
||||
r = npa_external_authenticate(card, (unsigned char *) signature->data,
|
||||
signature->length);
|
||||
|
||||
err:
|
||||
if (cvc_cert)
|
||||
@@ -1810,7 +1811,7 @@ static int npa_gen_auth_ca(sc_card_t *card, const BUF_MEM *eph_pub_key,
|
||||
r = SC_ERROR_INTERNAL;
|
||||
goto err;
|
||||
}
|
||||
apdu.data = (const u8 *) d;
|
||||
apdu.data = d;
|
||||
apdu.datalen = r;
|
||||
apdu.lc = r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user