|
|
- From 6f56ea4cfc52323002d818731a50a31e863b6843 Mon Sep 17 00:00:00 2001
- From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
- <ng.hong.quan@gmail.com>
- Date: Sun, 13 Jul 2014 19:41:36 +0800
- Subject: [PATCH 23/26] OpenPGP: Rename private "blob" type to avoid confusing
- with variable name.
-
- This name has been used for both data type and variable name of that
- type.
- ---
- src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++----------------------
- 1 file changed, 49 insertions(+), 47 deletions(-)
-
- Index: opensc-20150513/src/libopensc/card-openpgp.c
- ===================================================================
- --- opensc-20150513.orig/src/libopensc/card-openpgp.c
- +++ opensc-20150513/src/libopensc/card-openpgp.c
- @@ -113,9 +113,9 @@ enum _card_state {
- CARD_STATE_ACTIVATED = 0x05
- };
-
- -struct blob {
- - struct blob * next; /* pointer to next sibling */
- - struct blob * parent; /* pointer to parent */
- +typedef struct pgp_blob {
- + struct pgp_blob * next; /* pointer to next sibling */
- + struct pgp_blob * parent; /* pointer to parent */
- struct do_info *info;
-
- sc_file_t * file;
- @@ -124,8 +124,8 @@ struct blob {
-
- unsigned char * data;
- unsigned int len;
- - struct blob * files; /* pointer to 1st child */
- -};
- + struct pgp_blob * files; /* pointer to 1st child */
- +} pgp_blob_t;
-
- struct do_info {
- unsigned int id; /* ID of the DO in question */
- @@ -143,12 +143,12 @@ struct do_info {
-
- static int pgp_get_card_features(sc_card_t *card);
- static int pgp_finish(sc_card_t *card);
- -static void pgp_iterate_blobs(struct blob *, int, void (*func)());
- +static void pgp_iterate_blobs(pgp_blob_t *, int, void (*func)());
-
- -static int pgp_get_blob(sc_card_t *card, struct blob *blob,
- - unsigned int id, struct blob **ret);
- -static struct blob * pgp_new_blob(sc_card_t *, struct blob *, unsigned int, sc_file_t *);
- -static void pgp_free_blob(struct blob *);
- +static int pgp_get_blob(sc_card_t *card, pgp_blob_t *blob,
- + unsigned int id, pgp_blob_t **ret);
- +static pgp_blob_t * pgp_new_blob(sc_card_t *, pgp_blob_t *, unsigned int, sc_file_t *);
- +static void pgp_free_blob(pgp_blob_t *);
- static int pgp_get_pubkey(sc_card_t *, unsigned int,
- u8 *, size_t);
- static int pgp_get_pubkey_pem(sc_card_t *, unsigned int,
- @@ -274,8 +274,8 @@ static struct do_info pgp2_objects[] =
-
- #define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data))
- struct pgp_priv_data {
- - struct blob * mf;
- - struct blob * current; /* currently selected file */
- + pgp_blob_t * mf;
- + pgp_blob_t * current; /* currently selected file */
-
- enum _version bcd_version;
- struct do_info *pgp_objects;
- @@ -313,7 +313,7 @@ pgp_init(sc_card_t *card)
- sc_file_t *file = NULL;
- struct do_info *info;
- int r;
- - struct blob *child = NULL;
- + pgp_blob_t *child = NULL;
-
- LOG_FUNC_CALLED(card->ctx);
-
- @@ -397,7 +397,7 @@ pgp_get_card_features(sc_card_t *card)
- unsigned char *hist_bytes = card->atr.value;
- size_t atr_len = card->atr.len;
- size_t i = 0;
- - struct blob *blob, *blob6e, *blob73;
- + pgp_blob_t *blob, *blob6e, *blob73;
-
- /* parse card capabilities from historical bytes */
- while ((i < atr_len) && (hist_bytes[i] != 0x73))
- @@ -534,7 +534,7 @@ pgp_finish(sc_card_t *card)
-
- /* internal: fill a blob's data */
- static int
- -pgp_set_blob(struct blob *blob, const u8 *data, size_t len)
- +pgp_set_blob(pgp_blob_t *blob, const u8 *data, size_t len)
- {
- if (blob->data)
- free(blob->data);
- @@ -628,16 +628,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_
- }
-
- /* internal: append a blob to the list of children of a given parent blob */
- -static struct blob *
- -pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
- +static pgp_blob_t *
- +pgp_new_blob(sc_card_t *card, pgp_blob_t *parent, unsigned int file_id,
- sc_file_t *file)
- {
- - struct blob *blob = NULL;
- + pgp_blob_t *blob = NULL;
-
- if (file == NULL)
- return NULL;
-
- - if ((blob = calloc(1, sizeof(struct blob))) != NULL) {
- + if ((blob = calloc(1, sizeof(pgp_blob_t))) != NULL) {
- struct pgp_priv_data *priv = DRVDATA (card);
- struct do_info *info;
-
- @@ -651,7 +651,7 @@ pgp_new_blob(sc_card_t *card, struct blo
- blob->parent = parent;
-
- if (parent != NULL) {
- - struct blob **p;
- + pgp_blob_t **p;
-
- /* set file's path = parent's path + file's id */
- blob->file->path = parent->file->path;
- @@ -689,11 +689,11 @@ pgp_new_blob(sc_card_t *card, struct blo
-
- /* internal: free a blob including its content */
- static void
- -pgp_free_blob(struct blob *blob)
- +pgp_free_blob(pgp_blob_t *blob)
- {
- if (blob) {
- if (blob->parent) {
- - struct blob **p;
- + pgp_blob_t **p;
-
- /* remove blob from list of parent's children */
- for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
- @@ -713,14 +713,14 @@ pgp_free_blob(struct blob *blob)
-
- /* internal: iterate through the blob tree, calling a function for each blob */
- static void
- -pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
- +pgp_iterate_blobs(pgp_blob_t *blob, int level, void (*func)())
- {
- if (blob) {
- if (level > 0) {
- - struct blob *child = blob->files;
- + pgp_blob_t *child = blob->files;
-
- while (child != NULL) {
- - struct blob *next = child->next;
- + pgp_blob_t *next = child->next;
-
- pgp_iterate_blobs(child, level-1, func);
- child = next;
- @@ -733,7 +733,7 @@ pgp_iterate_blobs(struct blob *blob, int
-
- /* internal: read a blob's contents from card */
- static int
- -pgp_read_blob(sc_card_t *card, struct blob *blob)
- +pgp_read_blob(sc_card_t *card, pgp_blob_t *blob)
- {
- struct pgp_priv_data *priv = DRVDATA (card);
-
- @@ -780,7 +780,7 @@ pgp_read_blob(sc_card_t *card, struct bl
- * The OpenPGP card has a TLV encoding according ASN.1 BER-encoding rules.
- */
- static int
- -pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
- +pgp_enumerate_blob(sc_card_t *card, pgp_blob_t *blob)
- {
- const u8 *in;
- int r;
- @@ -797,7 +797,7 @@ pgp_enumerate_blob(sc_card_t *card, stru
- unsigned int cla, tag, tmptag;
- size_t len;
- const u8 *data = in;
- - struct blob *new;
- + pgp_blob_t *new;
-
- r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
- &cla, &tag, &len);
- @@ -827,10 +827,10 @@ pgp_enumerate_blob(sc_card_t *card, stru
-
- /* internal: find a blob by ID below a given parent, filling its contents when necessary */
- static int
- -pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
- - struct blob **ret)
- +pgp_get_blob(sc_card_t *card, pgp_blob_t *blob, unsigned int id,
- + pgp_blob_t **ret)
- {
- - struct blob *child;
- + pgp_blob_t *child;
- int r;
-
- if ((r = pgp_enumerate_blob(card, blob)) < 0)
- @@ -866,10 +866,10 @@ pgp_get_blob(sc_card_t *card, struct blo
-
- /* Internal: search recursively for a blob by ID below a given root */
- static int
- -pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
- - struct blob **ret)
- +pgp_seek_blob(sc_card_t *card, pgp_blob_t *root, unsigned int id,
- + pgp_blob_t **ret)
- {
- - struct blob *child;
- + pgp_blob_t *child;
- int r;
-
- if ((r = pgp_get_blob(card, root, id, ret)) == 0)
- @@ -891,11 +891,11 @@ pgp_seek_blob(sc_card_t *card, struct bl
- }
-
- /* internal: find a blob by tag - pgp_seek_blob with optimizations */
- -static struct blob *
- +static pgp_blob_t *
- pgp_find_blob(sc_card_t *card, unsigned int tag)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob = NULL;
- + pgp_blob_t *blob = NULL;
- int r;
-
- /* Check if current selected blob is which we want to test*/
- @@ -949,7 +949,7 @@ static int
- pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob;
- + pgp_blob_t *blob;
- unsigned int path_start = 0;
- unsigned int n;
- sc_path_t dummy_path;
- @@ -1030,7 +1030,7 @@ static int
- pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob;
- + pgp_blob_t *blob;
- unsigned int k;
- int r;
-
- @@ -1066,7 +1066,7 @@ pgp_read_binary(sc_card_t *card, unsigne
- u8 *buf, size_t count, unsigned long flags)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob;
- + pgp_blob_t *blob;
- int r;
-
- LOG_FUNC_CALLED(card->ctx);
- @@ -1142,7 +1142,7 @@ static int
- pgp_get_pubkey_pem(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob, *mod_blob, *exp_blob;
- + pgp_blob_t *blob, *mod_blob, *exp_blob;
- sc_pkcs15_pubkey_t pubkey;
- u8 *data;
- size_t len;
- @@ -1337,7 +1337,7 @@ static int
- pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *affected_blob = NULL;
- + pgp_blob_t *affected_blob = NULL;
- struct do_info *dinfo = NULL;
- int r;
-
- @@ -1611,7 +1611,7 @@ static int
- pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *algo_blob;
- + pgp_blob_t *algo_blob;
- unsigned int old_modulus_len; /* Measured in bit */
- unsigned int old_exponent_len;
- const unsigned int tag = 0x00C0 | key_info->keytype;
- @@ -1716,7 +1716,7 @@ pgp_calculate_and_store_fingerprint(sc_c
- u8 *p; /* Use this pointer to set fp_buffer content */
- size_t pk_packet_len;
- unsigned int tag;
- - struct blob *fpseq_blob;
- + pgp_blob_t *fpseq_blob;
- u8 *newdata;
- int r;
-
- @@ -1805,7 +1805,7 @@ pgp_update_pubkey_blob(sc_card_t *card,
- u8* exponent, size_t exponent_len, u8 key_id)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *pk_blob;
- + pgp_blob_t *pk_blob;
- unsigned int blob_id;
- sc_pkcs15_pubkey_t pubkey;
- u8 *data = NULL;
- @@ -1947,6 +1947,8 @@ static int pgp_update_card_algorithms(sc
- **/
- static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
- {
- + struct pgp_priv_data *priv = DRVDATA(card);
- + pgp_blob_t *algo_blob;
- sc_apdu_t apdu;
- /* Temporary variables to hold APDU params */
- u8 apdu_case;
- @@ -2143,7 +2145,7 @@ pgp_build_extended_header_list(sc_card_t
- };
- size_t comp_to_add = 3;
- size_t req_e_len = 0; /* The exponent length specified in Algorithm Attributes */
- - struct blob *alat_blob;
- + pgp_blob_t *alat_blob;
- u8 i;
- int r;
-
- @@ -2496,7 +2498,7 @@ static int
- pgp_delete_file(sc_card_t *card, const sc_path_t *path)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob;
- + pgp_blob_t *blob;
- sc_file_t *file;
- u8 key_id;
- int r;
- @@ -2546,7 +2548,7 @@ pgp_update_binary(sc_card_t *card, unsig
- const u8 *buf, size_t count, unsigned long flags)
- {
- struct pgp_priv_data *priv = DRVDATA(card);
- - struct blob *blob = priv->current;
- + pgp_blob_t *blob = priv->current;
- int r = SC_SUCCESS;
-
- LOG_FUNC_CALLED(card->ctx);
|