1 From 6f56ea4cfc52323002d818731a50a31e863b6843 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Nguy=E1=BB=85n=20H=E1=BB=93ng=20Qu=C3=A2n?=
3 <ng.hong.quan@gmail.com>
4 Date: Sun, 13 Jul 2014 19:41:36 +0800
5 Subject: [PATCH 23/26] OpenPGP: Rename private "blob" type to avoid confusing
8 This name has been used for both data type and variable name of that
11 src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++----------------------
12 1 file changed, 49 insertions(+), 47 deletions(-)
14 diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
15 index 724fe73..ca3173c 100644
16 --- a/src/libopensc/card-openpgp.c
17 +++ b/src/libopensc/card-openpgp.c
18 @@ -111,9 +111,9 @@ enum _card_state {
19 CARD_STATE_ACTIVATED = 0x05
23 - struct blob * next; /* pointer to next sibling */
24 - struct blob * parent; /* pointer to parent */
25 +typedef struct pgp_blob {
26 + struct pgp_blob * next; /* pointer to next sibling */
27 + struct pgp_blob * parent; /* pointer to parent */
31 @@ -122,8 +122,8 @@ struct blob {
35 - struct blob * files; /* pointer to 1st child */
37 + struct pgp_blob * files; /* pointer to 1st child */
41 unsigned int id; /* ID of the DO in question */
42 @@ -141,12 +141,12 @@ struct do_info {
44 static int pgp_get_card_features(sc_card_t *card);
45 static int pgp_finish(sc_card_t *card);
46 -static void pgp_iterate_blobs(struct blob *, int, void (*func)());
47 +static void pgp_iterate_blobs(pgp_blob_t *, int, void (*func)());
49 -static int pgp_get_blob(sc_card_t *card, struct blob *blob,
50 - unsigned int id, struct blob **ret);
51 -static struct blob * pgp_new_blob(sc_card_t *, struct blob *, unsigned int, sc_file_t *);
52 -static void pgp_free_blob(struct blob *);
53 +static int pgp_get_blob(sc_card_t *card, pgp_blob_t *blob,
54 + unsigned int id, pgp_blob_t **ret);
55 +static pgp_blob_t * pgp_new_blob(sc_card_t *, pgp_blob_t *, unsigned int, sc_file_t *);
56 +static void pgp_free_blob(pgp_blob_t *);
57 static int pgp_get_pubkey(sc_card_t *, unsigned int,
59 static int pgp_get_pubkey_pem(sc_card_t *, unsigned int,
60 @@ -272,8 +272,8 @@ static struct do_info pgp2_objects[] = { /* OpenPGP card spec 2.0 */
62 #define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data))
63 struct pgp_priv_data {
65 - struct blob * current; /* currently selected file */
67 + pgp_blob_t * current; /* currently selected file */
69 enum _version bcd_version;
70 struct do_info *pgp_objects;
71 @@ -311,7 +311,7 @@ pgp_init(sc_card_t *card)
72 sc_file_t *file = NULL;
75 - struct blob *child = NULL;
76 + pgp_blob_t *child = NULL;
78 LOG_FUNC_CALLED(card->ctx);
80 @@ -389,7 +389,7 @@ pgp_get_card_features(sc_card_t *card)
81 unsigned char *hist_bytes = card->atr.value;
82 size_t atr_len = card->atr.len;
84 - struct blob *blob, *blob6e, *blob73;
85 + pgp_blob_t *blob, *blob6e, *blob73;
87 /* parse card capabilities from historical bytes */
88 while ((i < atr_len) && (hist_bytes[i] != 0x73))
89 @@ -526,7 +526,7 @@ pgp_finish(sc_card_t *card)
91 /* internal: fill a blob's data */
93 -pgp_set_blob(struct blob *blob, const u8 *data, size_t len)
94 +pgp_set_blob(pgp_blob_t *blob, const u8 *data, size_t len)
98 @@ -620,16 +620,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info)
101 /* internal: append a blob to the list of children of a given parent blob */
102 -static struct blob *
103 -pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
105 +pgp_new_blob(sc_card_t *card, pgp_blob_t *parent, unsigned int file_id,
108 - struct blob *blob = NULL;
109 + pgp_blob_t *blob = NULL;
114 - if ((blob = calloc(1, sizeof(struct blob))) != NULL) {
115 + if ((blob = calloc(1, sizeof(pgp_blob_t))) != NULL) {
116 struct pgp_priv_data *priv = DRVDATA (card);
117 struct do_info *info;
119 @@ -643,7 +643,7 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
120 blob->parent = parent;
122 if (parent != NULL) {
126 /* set file's path = parent's path + file's id */
127 blob->file->path = parent->file->path;
128 @@ -681,11 +681,11 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
130 /* internal: free a blob including its content */
132 -pgp_free_blob(struct blob *blob)
133 +pgp_free_blob(pgp_blob_t *blob)
140 /* remove blob from list of parent's children */
141 for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
142 @@ -705,14 +705,14 @@ pgp_free_blob(struct blob *blob)
144 /* internal: iterate through the blob tree, calling a function for each blob */
146 -pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
147 +pgp_iterate_blobs(pgp_blob_t *blob, int level, void (*func)())
151 - struct blob *child = blob->files;
152 + pgp_blob_t *child = blob->files;
154 while (child != NULL) {
155 - struct blob *next = child->next;
156 + pgp_blob_t *next = child->next;
158 pgp_iterate_blobs(child, level-1, func);
160 @@ -725,7 +725,7 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
162 /* internal: read a blob's contents from card */
164 -pgp_read_blob(sc_card_t *card, struct blob *blob)
165 +pgp_read_blob(sc_card_t *card, pgp_blob_t *blob)
167 struct pgp_priv_data *priv = DRVDATA (card);
169 @@ -772,7 +772,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
170 * The OpenPGP card has a TLV encoding according ASN.1 BER-encoding rules.
173 -pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
174 +pgp_enumerate_blob(sc_card_t *card, pgp_blob_t *blob)
178 @@ -789,7 +789,7 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
179 unsigned int cla, tag, tmptag;
185 r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
187 @@ -819,10 +819,10 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
189 /* internal: find a blob by ID below a given parent, filling its contents when necessary */
191 -pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
193 +pgp_get_blob(sc_card_t *card, pgp_blob_t *blob, unsigned int id,
196 - struct blob *child;
200 if ((r = pgp_enumerate_blob(card, blob)) < 0)
201 @@ -858,10 +858,10 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
203 /* Internal: search recursively for a blob by ID below a given root */
205 -pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
207 +pgp_seek_blob(sc_card_t *card, pgp_blob_t *root, unsigned int id,
210 - struct blob *child;
214 if ((r = pgp_get_blob(card, root, id, ret)) == 0)
215 @@ -883,11 +883,11 @@ pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
218 /* internal: find a blob by tag - pgp_seek_blob with optimizations */
219 -static struct blob *
221 pgp_find_blob(sc_card_t *card, unsigned int tag)
223 struct pgp_priv_data *priv = DRVDATA(card);
224 - struct blob *blob = NULL;
225 + pgp_blob_t *blob = NULL;
228 /* Check if current selected blob is which we want to test*/
229 @@ -941,7 +941,7 @@ static int
230 pgp_select_file(sc_card_t *card, const sc_path_t *path, sc_file_t **ret)
232 struct pgp_priv_data *priv = DRVDATA(card);
235 unsigned int path_start = 0;
237 sc_path_t dummy_path;
238 @@ -1022,7 +1022,7 @@ static int
239 pgp_list_files(sc_card_t *card, u8 *buf, size_t buflen)
241 struct pgp_priv_data *priv = DRVDATA(card);
247 @@ -1058,7 +1058,7 @@ pgp_read_binary(sc_card_t *card, unsigned int idx,
248 u8 *buf, size_t count, unsigned long flags)
250 struct pgp_priv_data *priv = DRVDATA(card);
255 LOG_FUNC_CALLED(card->ctx);
256 @@ -1134,7 +1134,7 @@ static int
257 pgp_get_pubkey_pem(sc_card_t *card, unsigned int tag, u8 *buf, size_t buf_len)
259 struct pgp_priv_data *priv = DRVDATA(card);
260 - struct blob *blob, *mod_blob, *exp_blob;
261 + pgp_blob_t *blob, *mod_blob, *exp_blob;
262 sc_pkcs15_pubkey_t pubkey;
265 @@ -1329,7 +1329,7 @@ static int
266 pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len)
268 struct pgp_priv_data *priv = DRVDATA(card);
269 - struct blob *affected_blob = NULL;
270 + pgp_blob_t *affected_blob = NULL;
271 struct do_info *dinfo = NULL;
274 @@ -1603,7 +1603,7 @@ static int
275 pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
277 struct pgp_priv_data *priv = DRVDATA(card);
278 - struct blob *algo_blob;
279 + pgp_blob_t *algo_blob;
280 unsigned int old_modulus_len; /* Measured in bit */
281 unsigned int old_exponent_len;
282 const unsigned int tag = 0x00C0 | key_info->keytype;
283 @@ -1708,7 +1708,7 @@ pgp_calculate_and_store_fingerprint(sc_card_t *card, time_t ctime,
284 u8 *p; /* Use this pointer to set fp_buffer content */
285 size_t pk_packet_len;
287 - struct blob *fpseq_blob;
288 + pgp_blob_t *fpseq_blob;
292 @@ -1797,7 +1797,7 @@ pgp_update_pubkey_blob(sc_card_t *card, u8* modulus, size_t modulus_len,
293 u8* exponent, size_t exponent_len, u8 key_id)
295 struct pgp_priv_data *priv = DRVDATA(card);
296 - struct blob *pk_blob;
297 + pgp_blob_t *pk_blob;
298 unsigned int blob_id;
299 sc_pkcs15_pubkey_t pubkey;
301 @@ -1939,6 +1939,8 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen
303 static int pgp_gen_key(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_info)
305 + struct pgp_priv_data *priv = DRVDATA(card);
306 + pgp_blob_t *algo_blob;
308 /* Temporary variables to hold APDU params */
310 @@ -2132,7 +2134,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
312 size_t comp_to_add = 3;
313 size_t req_e_len = 0; /* The exponent length specified in Algorithm Attributes */
314 - struct blob *alat_blob;
315 + pgp_blob_t *alat_blob;
319 @@ -2483,7 +2485,7 @@ static int
320 pgp_delete_file(sc_card_t *card, const sc_path_t *path)
322 struct pgp_priv_data *priv = DRVDATA(card);
328 @@ -2533,7 +2535,7 @@ pgp_update_binary(sc_card_t *card, unsigned int idx,
329 const u8 *buf, size_t count, unsigned long flags)
331 struct pgp_priv_data *priv = DRVDATA(card);
332 - struct blob *blob = priv->current;
333 + pgp_blob_t *blob = priv->current;
336 LOG_FUNC_CALLED(card->ctx);