51 fprintf(stderr,
"%s (%s) version %s\n",
52 progname, PACKAGE_NAME, PACKAGE_VERSION);
59 "usage: %s [-c config] [-vV] command [options]\n",
62 fprintf(stderr,
" list [repository]\n");
63 fprintf(stderr,
" generate <repository> rsa <keysize>\n");
64 fprintf(stderr,
" remove <id>\n");
65 fprintf(stderr,
" purge <repository>\n");
66 fprintf(stderr,
" dnskey <id> <name>\n");
67 fprintf(stderr,
" test <repository>\n");
68 fprintf(stderr,
" info\n");
70 fprintf(stderr,
" debug\n");
78 char *repository = NULL;
81 size_t key_count_valid = 0;
85 const char *key_info_format =
"%-20s %-32s %-10s\n";
89 repository = strdup(argv[0]);
99 fprintf(stderr,
"Listing keys in repository: %s\n", repository);
102 fprintf(stderr,
"Listing keys in all repositories.\n");
106 fprintf(stderr,
"%u %s found.\n\n", (
unsigned int) key_count,
107 (key_count > 1 || key_count == 0 ?
"keys" :
"key"));
114 fprintf(stderr, key_info_format,
"Repository",
"ID",
"Type");
115 fprintf(stderr, key_info_format,
"----------",
"--",
"----");
117 for (i = 0; i < key_count; i++) {
134 snprintf(key_type,
sizeof(key_type),
"%s/%lu",
136 key_id = key_info->
id;
138 snprintf(key_type,
sizeof(key_type),
"UNKNOWN");
142 printf(key_info_format, key->
module->
name, key_id, key_type);
148 if (key_count != key_count_valid) {
150 invalid_keys = key_count - key_count_valid;
152 fprintf(stderr,
"Warning: %lu %s not usable by OpenDNSSEC was found.\n",
153 (
unsigned long)invalid_keys, invalid_keys > 1 ?
"keys" :
"key");
162 char *repository = NULL;
164 unsigned int keysize = 1024;
174 repository = strdup(argv[0]);
183 algorithm = strdup(argv[1]);
184 keysize = atoi(argv[2]);
186 if (!strcasecmp(algorithm,
"rsa")) {
187 printf(
"Generating %d bit RSA key in repository: %s\n",
188 keysize, repository);
196 printf(
"Key generation successful: %s\n",
197 key_info ? key_info->
id :
"NULL");
202 printf(
"Key generation failed.\n");
207 printf(
"Unknown algorithm: %s\n", algorithm);
227 id = strdup(argv[0]);
232 printf(
"Key not found: %s\n",
id);
239 printf(
"Key remove successful.\n");
241 printf(
"Key remove failed.\n");
253 int final_result = 0;
257 char *repository = NULL;
260 size_t key_count = 0;
269 repository = strdup(argv[0]);
279 printf(
"Purging all keys from repository: %s\n", repository);
282 printf(
"%u %s found.\n\n", (
unsigned int) key_count,
283 (key_count > 1 || key_count == 0 ?
"keys" :
"key"));
289 if (key_count == 0) {
293 printf(
"Are you sure you want to remove ALL keys from repository %s ? (YES/NO) ", repository);
294 fresult = fgets(confirm,
sizeof(confirm) - 1, stdin);
295 if (fresult == NULL || strncasecmp(confirm,
"yes", 3) != 0) {
296 printf(
"\nPurge cancelled.\n");
300 printf(
"\nStarting purge...\n");
303 for (i = 0; i < key_count; i++) {
311 printf(
"Key remove successful: %s\n",
312 key_info ? key_info->
id :
"NULL");
314 printf(
"Key remove failed: %s\n",
315 key_info ? key_info->
id :
"NULL");
323 printf(
"Purge done.\n");
343 id = strdup(argv[0]);
344 name = strdup(argv[1]);
349 printf(
"Key not found: %s\n",
id);
357 sign_params->
owner = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, name);
359 sign_params->
keytag = ldns_calc_keytag(dnskey_rr);
361 ldns_rr_print(stdout, dnskey_rr);
364 ldns_rr_free(dnskey_rr);
375 char *repository = NULL;
378 repository = strdup(argv[0]);
382 printf(
"Testing repository: %s\n\n", repository);
417 while ((ch = getopt(argc, argv,
"c:vVh")) != -1) {
452 openlog(
"hsmutil", LOG_PID, LOG_USER);
454 if (!strcasecmp(argv[0],
"list")) {
458 }
else if (!strcasecmp(argv[0],
"generate")) {
462 }
else if (!strcasecmp(argv[0],
"remove")) {
466 }
else if (!strcasecmp(argv[0],
"purge")) {
470 }
else if (!strcasecmp(argv[0],
"dnskey")) {
474 }
else if (!strcasecmp(argv[0],
"test")) {
478 }
else if (!strcasecmp(argv[0],
"info")) {
482 }
else if (!strcasecmp(argv[0],
"debug")) {
492 if (config) free(config);