From e0a99a740d60a7ffa39391560bc8d49a798bc272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 27 Nov 2006 10:40:06 +0000 Subject: [PATCH] Add crypto-select and crypto-available. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19141 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/hxtool-commands.in | 10 ++++++++ lib/hx509/hxtool.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/lib/hx509/hxtool-commands.in b/lib/hx509/hxtool-commands.in index 7af98c05c..e5d4b9923 100644 --- a/lib/hx509/hxtool-commands.in +++ b/lib/hx509/hxtool-commands.in @@ -383,6 +383,16 @@ command = { argument="bytes" help = "Generates random bytes and prints them to standard output" } +command = { + name = "crypto-available" + min_args="0" + help = "Print available CMS crypto types" +} +command = { + name = "crypto-select" + min_args="0" + help = "Print available CMS crypto types" +} command = { name = "help" name = "?" diff --git a/lib/hx509/hxtool.c b/lib/hx509/hxtool.c index a8a2e4ddc..fe38619f4 100644 --- a/lib/hx509/hxtool.c +++ b/lib/hx509/hxtool.c @@ -990,6 +990,50 @@ random_data(void *opt, int argc, char **argv) return 0; } +int +crypto_available(void *opt, int argc, char **argv) +{ + int ret; + size_t len, i; + AlgorithmIdentifier *val; + + ret = hx509_crypto_available(context, HX509_SELECT_ALL, + NULL, &val, &len); + if (ret) + errx(1, "hx509_crypto_available"); + + for (i = 0; i < len; i++) { + char *s; + der_print_heim_oid (&val[i].algorithm, '.', &s); + printf("%s\n", s); + free(s); + } + + hx509_crypto_free_algs(val, len); + + return 0; +} + +int +crypto_select(void *opt, int argc, char **argv) +{ + int ret; + char *s; + AlgorithmIdentifier val; + + ret = hx509_crypto_select(context, HX509_SELECT_DIGEST, + NULL, NULL, &val); + if (ret) + errx(1, "hx509_crypto_available"); + + der_print_heim_oid (&val.algorithm, '.', &s); + printf("%s\n", s); + free(s); + free_AlgorithmIdentifier(&val); + + return 0; +} + int help(void *opt, int argc, char **argv) {