|
|
@ -11,11 +11,11 @@ type. |
|
|
|
src/libopensc/card-openpgp.c | 96 ++++++++++++++++++++++---------------------- |
|
|
|
1 file changed, 49 insertions(+), 47 deletions(-) |
|
|
|
|
|
|
|
diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c
|
|
|
|
index 724fe73..ca3173c 100644
|
|
|
|
--- a/src/libopensc/card-openpgp.c
|
|
|
|
+++ b/src/libopensc/card-openpgp.c
|
|
|
|
@@ -111,9 +111,9 @@ enum _card_state {
|
|
|
|
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 |
|
|
|
}; |
|
|
|
|
|
|
@ -28,7 +28,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
struct do_info *info; |
|
|
|
|
|
|
|
sc_file_t * file; |
|
|
|
@@ -122,8 +122,8 @@ struct blob {
|
|
|
|
@@ -124,8 +124,8 @@ struct blob {
|
|
|
|
|
|
|
|
unsigned char * data; |
|
|
|
unsigned int len; |
|
|
@ -39,7 +39,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
struct do_info { |
|
|
|
unsigned int id; /* ID of the DO in question */ |
|
|
|
@@ -141,12 +141,12 @@ struct do_info {
|
|
|
|
@@ -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); |
|
|
@ -57,7 +57,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
static int pgp_get_pubkey(sc_card_t *, unsigned int, |
|
|
|
u8 *, size_t); |
|
|
|
static int pgp_get_pubkey_pem(sc_card_t *, unsigned int, |
|
|
|
@@ -272,8 +272,8 @@ static struct do_info pgp2_objects[] = { /* OpenPGP card spec 2.0 */
|
|
|
|
@@ -274,8 +274,8 @@ static struct do_info pgp2_objects[] =
|
|
|
|
|
|
|
|
#define DRVDATA(card) ((struct pgp_priv_data *) ((card)->drv_data)) |
|
|
|
struct pgp_priv_data { |
|
|
@ -68,16 +68,16 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
enum _version bcd_version; |
|
|
|
struct do_info *pgp_objects; |
|
|
|
@@ -311,7 +311,7 @@ pgp_init(sc_card_t *card)
|
|
|
|
@@ -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;
|
|
|
|
- struct blob *child = NULL;
|
|
|
|
+ pgp_blob_t *child = NULL;
|
|
|
|
|
|
|
|
LOG_FUNC_CALLED(card->ctx); |
|
|
|
|
|
|
|
@@ -389,7 +389,7 @@ pgp_get_card_features(sc_card_t *card)
|
|
|
|
@@ -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; |
|
|
@ -86,7 +86,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
/* parse card capabilities from historical bytes */ |
|
|
|
while ((i < atr_len) && (hist_bytes[i] != 0x73)) |
|
|
|
@@ -526,7 +526,7 @@ pgp_finish(sc_card_t *card)
|
|
|
|
@@ -534,7 +534,7 @@ pgp_finish(sc_card_t *card)
|
|
|
|
|
|
|
|
/* internal: fill a blob's data */ |
|
|
|
static int |
|
|
@ -95,7 +95,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
{ |
|
|
|
if (blob->data) |
|
|
|
free(blob->data); |
|
|
|
@@ -620,16 +620,16 @@ pgp_attach_acl(sc_card_t *card, sc_file_t *file, struct do_info *info)
|
|
|
|
@@ -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 */ |
|
|
@ -116,7 +116,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
struct pgp_priv_data *priv = DRVDATA (card); |
|
|
|
struct do_info *info; |
|
|
|
|
|
|
|
@@ -643,7 +643,7 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
|
|
|
|
@@ -651,7 +651,7 @@ pgp_new_blob(sc_card_t *card, struct blo
|
|
|
|
blob->parent = parent; |
|
|
|
|
|
|
|
if (parent != NULL) { |
|
|
@ -125,7 +125,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
/* set file's path = parent's path + file's id */ |
|
|
|
blob->file->path = parent->file->path; |
|
|
|
@@ -681,11 +681,11 @@ pgp_new_blob(sc_card_t *card, struct blob *parent, unsigned int file_id,
|
|
|
|
@@ -689,11 +689,11 @@ pgp_new_blob(sc_card_t *card, struct blo
|
|
|
|
|
|
|
|
/* internal: free a blob including its content */ |
|
|
|
static void |
|
|
@ -139,7 +139,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
/* remove blob from list of parent's children */ |
|
|
|
for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next) |
|
|
|
@@ -705,14 +705,14 @@ pgp_free_blob(struct blob *blob)
|
|
|
|
@@ -713,14 +713,14 @@ pgp_free_blob(struct blob *blob)
|
|
|
|
|
|
|
|
/* internal: iterate through the blob tree, calling a function for each blob */ |
|
|
|
static void |
|
|
@ -157,7 +157,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
pgp_iterate_blobs(child, level-1, func); |
|
|
|
child = next; |
|
|
|
@@ -725,7 +725,7 @@ pgp_iterate_blobs(struct blob *blob, int level, void (*func)())
|
|
|
|
@@ -733,7 +733,7 @@ pgp_iterate_blobs(struct blob *blob, int
|
|
|
|
|
|
|
|
/* internal: read a blob's contents from card */ |
|
|
|
static int |
|
|
@ -166,7 +166,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
{ |
|
|
|
struct pgp_priv_data *priv = DRVDATA (card); |
|
|
|
|
|
|
|
@@ -772,7 +772,7 @@ pgp_read_blob(sc_card_t *card, struct blob *blob)
|
|
|
|
@@ -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 |
|
|
@ -175,7 +175,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
{ |
|
|
|
const u8 *in; |
|
|
|
int r; |
|
|
|
@@ -789,7 +789,7 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
|
|
|
|
@@ -797,7 +797,7 @@ pgp_enumerate_blob(sc_card_t *card, stru
|
|
|
|
unsigned int cla, tag, tmptag; |
|
|
|
size_t len; |
|
|
|
const u8 *data = in; |
|
|
@ -184,7 +184,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
|
|
|
|
r = sc_asn1_read_tag(&data, blob->len - (in - blob->data), |
|
|
|
&cla, &tag, &len); |
|
|
|
@@ -819,10 +819,10 @@ pgp_enumerate_blob(sc_card_t *card, struct blob *blob)
|
|
|
|
@@ -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 |
|
|
@ -198,7 +198,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
int r; |
|
|
|
|
|
|
|
if ((r = pgp_enumerate_blob(card, blob)) < 0) |
|
|
|
@@ -858,10 +858,10 @@ pgp_get_blob(sc_card_t *card, struct blob *blob, unsigned int id,
|
|
|
|
@@ -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 |
|
|
@ -212,7 +212,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
int r; |
|
|
|
|
|
|
|
if ((r = pgp_get_blob(card, root, id, ret)) == 0) |
|
|
|
@@ -883,11 +883,11 @@ pgp_seek_blob(sc_card_t *card, struct blob *root, unsigned int id,
|
|
|
|
@@ -891,11 +891,11 @@ pgp_seek_blob(sc_card_t *card, struct bl
|
|
|
|
} |
|
|
|
|
|
|
|
/* internal: find a blob by tag - pgp_seek_blob with optimizations */ |
|
|
@ -226,7 +226,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
int r; |
|
|
|
|
|
|
|
/* Check if current selected blob is which we want to test*/ |
|
|
|
@@ -941,7 +941,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -235,7 +235,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
unsigned int path_start = 0; |
|
|
|
unsigned int n; |
|
|
|
sc_path_t dummy_path; |
|
|
|
@@ -1022,7 +1022,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -244,7 +244,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
unsigned int k; |
|
|
|
int r; |
|
|
|
|
|
|
|
@@ -1058,7 +1058,7 @@ pgp_read_binary(sc_card_t *card, unsigned int idx,
|
|
|
|
@@ -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); |
|
|
@ -253,7 +253,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
int r; |
|
|
|
|
|
|
|
LOG_FUNC_CALLED(card->ctx); |
|
|
|
@@ -1134,7 +1134,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -262,7 +262,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
sc_pkcs15_pubkey_t pubkey; |
|
|
|
u8 *data; |
|
|
|
size_t len; |
|
|
|
@@ -1329,7 +1329,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -271,7 +271,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
struct do_info *dinfo = NULL; |
|
|
|
int r; |
|
|
|
|
|
|
|
@@ -1603,7 +1603,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -280,7 +280,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
unsigned int old_modulus_len; /* Measured in bit */ |
|
|
|
unsigned int old_exponent_len; |
|
|
|
const unsigned int tag = 0x00C0 | key_info->keytype; |
|
|
|
@@ -1708,7 +1708,7 @@ pgp_calculate_and_store_fingerprint(sc_card_t *card, time_t ctime,
|
|
|
|
@@ -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; |
|
|
@ -289,7 +289,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
u8 *newdata; |
|
|
|
int r; |
|
|
|
|
|
|
|
@@ -1797,7 +1797,7 @@ pgp_update_pubkey_blob(sc_card_t *card, u8* modulus, size_t modulus_len,
|
|
|
|
@@ -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); |
|
|
@ -298,7 +298,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
unsigned int blob_id; |
|
|
|
sc_pkcs15_pubkey_t pubkey; |
|
|
|
u8 *data = NULL; |
|
|
|
@@ -1939,6 +1939,8 @@ static int pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen
|
|
|
|
@@ -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) |
|
|
|
{ |
|
|
@ -307,7 +307,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
sc_apdu_t apdu; |
|
|
|
/* Temporary variables to hold APDU params */ |
|
|
|
u8 apdu_case; |
|
|
|
@@ -2132,7 +2134,7 @@ pgp_build_extended_header_list(sc_card_t *card, sc_cardctl_openpgp_keystore_info
|
|
|
|
@@ -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 */ |
|
|
@ -316,7 +316,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
u8 i; |
|
|
|
int r; |
|
|
|
|
|
|
|
@@ -2483,7 +2485,7 @@ static int
|
|
|
|
@@ -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); |
|
|
@ -325,7 +325,7 @@ index 724fe73..ca3173c 100644 |
|
|
|
sc_file_t *file; |
|
|
|
u8 key_id; |
|
|
|
int r; |
|
|
|
@@ -2533,7 +2535,7 @@ pgp_update_binary(sc_card_t *card, unsigned int idx,
|
|
|
|
@@ -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); |
|
|
@ -334,6 +334,3 @@ index 724fe73..ca3173c 100644 |
|
|
|
int r = SC_SUCCESS; |
|
|
|
|
|
|
|
LOG_FUNC_CALLED(card->ctx); |
|
|
|
--
|
|
|
|
2.1.3 |
|
|
|
|