Allow specifying application name for data objects at pkcs15-init.

[[The change from memcmp to strcmp is valid as in this case the
data is not oid]]

Alon Bar-Lev

svn diff -r 3280:3282 
https://www.opensc-project.org/svn/opensc/branches/alonbl/opensc-data

---

Index: opensc-data/src/tools/pkcs15-tool.c
===================================================================
--- opensc-data/src/tools/pkcs15-tool.c (revision 3280)
+++ opensc-data/src/tools/pkcs15-tool.c (revision 3282)
@@ -106,7 +106,7 @@
        "Stores card info to cache",
        "Reads certificate with ID <arg>",
        "Lists certificates",
-       "Reads data object with applicationName or OID <arg>",
+       "Reads data object with OID, applicationName or label <arg>",
        "Lists data objects",
        "Lists PIN codes",
        "Dump card objects",
@@ -317,7 +317,7 @@
                        if (memcmp(oid.value, cinfo->app_oid.value, sizeof(int) 
* oid_len))
                                continue;
                } else {
-                       if (memcmp(opt_data, &cinfo->app_label, 
strlen(opt_data)))
+                       if (strcmp(opt_data, cinfo->app_label) && 
strcmp(opt_data, objs[i]->label))
                                continue;
                }
                        
@@ -361,6 +361,7 @@
 
                printf("Reading data object <%i>\n", i);
                printf("applicationName: %s\n", cinfo->app_label);
+               printf("Label:           %s\n", objs[i]->label);
                printf("applicationOID:  ");
                if (cinfo->app_oid.value[0] >= 0) {
                        printf("%i", cinfo->app_oid.value[0]);
Index: opensc-data/src/tools/pkcs15-init.c
===================================================================
--- opensc-data/src/tools/pkcs15-init.c (revision 3280)
+++ opensc-data/src/tools/pkcs15-init.c (revision 3282)
@@ -122,6 +122,7 @@
        OPT_SECRET,
        OPT_PUBKEY_LABEL,
        OPT_CERT_LABEL,
+       OPT_APPLICATION_NAME,
        OPT_APPLICATION_ID,
 
        OPT_PIN1     = 0x10000, /* don't touch these values */
@@ -158,6 +159,7 @@
        { "label",              required_argument, NULL,        'l' },
        { "public-key-label",   required_argument, NULL,        
OPT_PUBKEY_LABEL },
        { "cert-label",         required_argument, NULL,        OPT_CERT_LABEL 
},
+       { "application-name",   required_argument, NULL,        
OPT_APPLICATION_NAME },
        { "application-id",     required_argument, NULL,        
OPT_APPLICATION_ID },
        { "output-file",        required_argument, NULL,        'o' },
        { "format",             required_argument, NULL,        'f' },
@@ -211,6 +213,7 @@
        "Specify label of PIN/key",
        "Specify public key label (use with --generate-key)",
        "Specify user cert label (use with --store-private-key)",
+       "Specify application name of data object (use with 
--store-data-object)",
        "Specify application id of data object (use with --store-data-object)",
        "Output public portion of generated key to file",
        "Specify key/cert file format: PEM (=default), DER or PKCS12",
@@ -318,6 +321,7 @@
 static char *                  opt_newkey = NULL;
 static char *                  opt_outkey = NULL;
 static char *                  opt_application_id = NULL;
+static char *                  opt_application_name = NULL;
 static unsigned int            opt_x509_usage = 0;
 static unsigned int            opt_delete_flags = 0;
 static unsigned int            opt_type = 0;
@@ -1070,7 +1074,7 @@
        if (opt_authid)
                sc_pkcs15_format_id(opt_authid, &args.auth_id);
        args.label = opt_label;
-       args.app_label = "pkcs15-init";
+       args.app_label = opt_application_name ? opt_application_name : 
"pkcs15-init";
 
        sc_format_oid(&args.app_oid, opt_application_id);
 
@@ -2425,6 +2429,9 @@
        case OPT_SOFT_KEYGEN:
                opt_softkeygen = 1;
                break;
+       case OPT_APPLICATION_NAME:
+               opt_application_name = optarg;
+               break;
        case OPT_APPLICATION_ID:
                opt_application_id = optarg;
                break;
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to