in src/tools/import_pub_key.c [41:103]
static int get_import_args(int argc, char **argv, struct import_args *args) {
if (!args || !argv) {
return -1;
}
int c;
char *pin = NULL;
char *library = NULL;
char *pem_file = NULL;
while (1) {
static struct option long_options[] =
{
{"pin", required_argument, 0, 0},
{"library", required_argument, 0, 0},
{"pem", required_argument, 0, 0},
{0, 0, 0, 0}
};
int option_index = 0;
c = getopt_long(argc, argv, "",
long_options, &option_index);
if (c == -1)
break;
switch (option_index) {
case 0:
pin = optarg;
break;
case 1:
library = optarg;
break;
case 2:
pem_file = optarg;
break;
default:
printf("Unknown arguments");
show_help();
return -1;
}
}
if (!pin || !pem_file ) {
show_help();
return -1;
}
args->pin = pin;
args->library = library;
args->pem_file = pem_file;
// Default to the standard CloudHSM PKCS#11 library location.
if (!args->library) {
args->library = "/opt/cloudhsm/lib/libcloudhsm_pkcs11.so";
}
return 0;
}