From 4fd7cabf4436c4aad9b5bedfd88a740bb19b1a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 27 Nov 2006 12:15:00 +0000 Subject: [PATCH] (crypto-available): add --type git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19154 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/hxtool-commands.in | 5 +++++ lib/hx509/hxtool.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/hx509/hxtool-commands.in b/lib/hx509/hxtool-commands.in index 368f2c8dc..33191b812 100644 --- a/lib/hx509/hxtool-commands.in +++ b/lib/hx509/hxtool-commands.in @@ -384,6 +384,11 @@ command = { help = "Generates random bytes and prints them to standard output" } command = { + option = { + long = "type" + type = "string" + help = "type of CMS algorithm" + } name = "crypto-available" min_args="0" help = "Print available CMS crypto types" diff --git a/lib/hx509/hxtool.c b/lib/hx509/hxtool.c index a953a050d..dd8f080ba 100644 --- a/lib/hx509/hxtool.c +++ b/lib/hx509/hxtool.c @@ -991,14 +991,25 @@ random_data(void *opt, int argc, char **argv) } int -crypto_available(void *opt, int argc, char **argv) +crypto_available(struct crypto_available_options *opt, int argc, char **argv) { int ret; size_t len, i; AlgorithmIdentifier *val; + int type = HX509_SELECT_ALL; - ret = hx509_crypto_available(context, HX509_SELECT_ALL, - NULL, &val, &len); + if (opt->type_string) { + if (strcmp(opt->type_string, "all") == 0) + type = HX509_SELECT_ALL; + else if (strcmp(opt->type_string, "digest") == 0) + type = HX509_SELECT_DIGEST; + else if (strcmp(opt->type_string, "public-sig") == 0) + type = HX509_SELECT_PUBLIC_SIG; + else + errx(1, "unknown type: %s", opt->type_string); + } + + ret = hx509_crypto_available(context, type, NULL, &val, &len); if (ret) errx(1, "hx509_crypto_available");