(crypto-available): add --type

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19154 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-11-27 12:15:00 +00:00
parent cbcc5adfc3
commit 4fd7cabf44
2 changed files with 19 additions and 3 deletions

View File

@@ -384,6 +384,11 @@ command = {
help = "Generates random bytes and prints them to standard output" help = "Generates random bytes and prints them to standard output"
} }
command = { command = {
option = {
long = "type"
type = "string"
help = "type of CMS algorithm"
}
name = "crypto-available" name = "crypto-available"
min_args="0" min_args="0"
help = "Print available CMS crypto types" help = "Print available CMS crypto types"

View File

@@ -991,14 +991,25 @@ random_data(void *opt, int argc, char **argv)
} }
int int
crypto_available(void *opt, int argc, char **argv) crypto_available(struct crypto_available_options *opt, int argc, char **argv)
{ {
int ret; int ret;
size_t len, i; size_t len, i;
AlgorithmIdentifier *val; AlgorithmIdentifier *val;
int type = HX509_SELECT_ALL;
ret = hx509_crypto_available(context, HX509_SELECT_ALL, if (opt->type_string) {
NULL, &val, &len); 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) if (ret)
errx(1, "hx509_crypto_available"); errx(1, "hx509_crypto_available");