diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-07-21 22:11:38 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-07-21 22:11:38 +0200 |
commit | 67b3de5fe34d022593ed9ce216122c10a9c4679d (patch) | |
tree | 05d96fd67e5186fca9e7d6c3a793f995b6d88b45 /src | |
parent | 8dedcd323bd0e93313e5f48cdbcb93115e2da6a8 (diff) | |
download | gnutls-67b3de5fe34d022593ed9ce216122c10a9c4679d.tar.gz |
tpmtool now accepts the --inder and --outder options.
Diffstat (limited to 'src')
-rw-r--r-- | src/tpmtool-args.c | 110 | ||||
-rw-r--r-- | src/tpmtool-args.def | 18 | ||||
-rw-r--r-- | src/tpmtool-args.h | 14 | ||||
-rw-r--r-- | src/tpmtool.c | 28 |
4 files changed, 135 insertions, 35 deletions
diff --git a/src/tpmtool-args.c b/src/tpmtool-args.c index cc50de38f4..886e522e08 100644 --- a/src/tpmtool-args.c +++ b/src/tpmtool-args.c @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (tpmtool-args.c) * - * It has been AutoGen-ed July 20, 2012 at 10:21:17 PM by AutoGen 5.16 + * It has been AutoGen-ed July 21, 2012 at 10:09:08 PM by AutoGen 5.16 * From the definitions tpmtool-args.def * and the template file options * @@ -67,7 +67,7 @@ extern FILE * option_usage_fp; /* * tpmtool option static const strings */ -static char const tpmtool_opt_strs[2031] = +static char const tpmtool_opt_strs[2126] = /* 0 */ "tpmtool @VERSION@\n" "Copyright (C) 2000-2012 Free Software Foundation, all rights reserved.\n" "This is free software. It is licensed for use, modification and\n" @@ -126,21 +126,28 @@ static char const tpmtool_opt_strs[2031] = /* 1553 */ "Specify the number of bits for key generate\0" /* 1597 */ "BITS\0" /* 1602 */ "bits\0" -/* 1607 */ "Display extended usage information and exit\0" -/* 1651 */ "help\0" -/* 1656 */ "Extended usage information passed thru pager\0" -/* 1701 */ "more-help\0" -/* 1711 */ "Output version information and exit\0" -/* 1747 */ "version\0" -/* 1755 */ "TPMTOOL\0" -/* 1763 */ "tpmtool - GnuTLS TPM tool - Ver. @VERSION@\n" +/* 1607 */ "Use the DER format for keys.\0" +/* 1636 */ "INDER\0" +/* 1642 */ "no-inder\0" +/* 1651 */ "no\0" +/* 1654 */ "Use DER format for output keys\0" +/* 1685 */ "OUTDER\0" +/* 1692 */ "no-outder\0" +/* 1702 */ "Display extended usage information and exit\0" +/* 1746 */ "help\0" +/* 1751 */ "Extended usage information passed thru pager\0" +/* 1796 */ "more-help\0" +/* 1806 */ "Output version information and exit\0" +/* 1842 */ "version\0" +/* 1850 */ "TPMTOOL\0" +/* 1858 */ "tpmtool - GnuTLS TPM tool - Ver. @VERSION@\n" "USAGE: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0" -/* 1864 */ "bug-gnutls@gnu.org\0" -/* 1883 */ "\n\n\0" -/* 1886 */ "\n" +/* 1959 */ "bug-gnutls@gnu.org\0" +/* 1978 */ "\n\n\0" +/* 1981 */ "\n" "Program that allows handling cryptographic data from the TPM chip.\n\0" -/* 1955 */ "tpmtool @VERSION@\0" -/* 1973 */ "tpmtool [options]\n" +/* 2050 */ "tpmtool @VERSION@\0" +/* 2068 */ "tpmtool [options]\n" "tpmtool --help for usage instructions.\n"; /* @@ -286,13 +293,33 @@ static int const aSystemCantList[] = { | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* + * inder option description: + */ +#define INDER_DESC (tpmtool_opt_strs+1607) +#define INDER_NAME (tpmtool_opt_strs+1636) +#define NOT_INDER_name (tpmtool_opt_strs+1642) +#define NOT_INDER_PFX (tpmtool_opt_strs+1651) +#define INDER_name (NOT_INDER_name + 3) +#define INDER_FLAGS (OPTST_DISABLED) + +/* + * outder option description: + */ +#define OUTDER_DESC (tpmtool_opt_strs+1654) +#define OUTDER_NAME (tpmtool_opt_strs+1685) +#define NOT_OUTDER_name (tpmtool_opt_strs+1692) +#define NOT_OUTDER_PFX (tpmtool_opt_strs+1651) +#define OUTDER_name (NOT_OUTDER_name + 3) +#define OUTDER_FLAGS (OPTST_DISABLED) + +/* * Help/More_Help/Version option descriptions: */ -#define HELP_DESC (tpmtool_opt_strs+1607) -#define HELP_name (tpmtool_opt_strs+1651) +#define HELP_DESC (tpmtool_opt_strs+1702) +#define HELP_name (tpmtool_opt_strs+1746) #ifdef HAVE_WORKING_FORK -#define MORE_HELP_DESC (tpmtool_opt_strs+1656) -#define MORE_HELP_name (tpmtool_opt_strs+1701) +#define MORE_HELP_DESC (tpmtool_opt_strs+1751) +#define MORE_HELP_name (tpmtool_opt_strs+1796) #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT) #else #define MORE_HELP_DESC NULL @@ -305,8 +332,8 @@ static int const aSystemCantList[] = { # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT) #endif -#define VER_DESC (tpmtool_opt_strs+1711) -#define VER_name (tpmtool_opt_strs+1747) +#define VER_DESC (tpmtool_opt_strs+1806) +#define VER_name (tpmtool_opt_strs+1842) /* * Declare option callback procedures */ @@ -494,6 +521,30 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ BITS_DESC, BITS_NAME, BITS_name, /* disablement strs */ NULL, NULL }, + { /* entry idx, value */ 14, VALUE_OPT_INDER, + /* equiv idx, value */ 14, VALUE_OPT_INDER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INDER_FLAGS, 0, + /* last opt argumnt */ { NULL }, /* --inder */ + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ INDER_DESC, INDER_NAME, INDER_name, + /* disablement strs */ NOT_INDER_name, NOT_INDER_PFX }, + + { /* entry idx, value */ 15, VALUE_OPT_OUTDER, + /* equiv idx, value */ 15, VALUE_OPT_OUTDER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OUTDER_FLAGS, 0, + /* last opt argumnt */ { NULL }, /* --outder */ + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ OUTDER_DESC, OUTDER_NAME, OUTDER_name, + /* disablement strs */ NOT_OUTDER_name, NOT_OUTDER_PFX }, + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION, /* equivalenced to */ NO_EQUIVALENT, @@ -538,14 +589,14 @@ static tOptDesc optDesc[OPTION_CT] = { * * Define the tpmtool Option Environment */ -#define zPROGNAME (tpmtool_opt_strs+1755) -#define zUsageTitle (tpmtool_opt_strs+1763) +#define zPROGNAME (tpmtool_opt_strs+1850) +#define zUsageTitle (tpmtool_opt_strs+1858) #define zRcName NULL #define apzHomeList NULL -#define zBugsAddr (tpmtool_opt_strs+1864) -#define zExplain (tpmtool_opt_strs+1883) -#define zDetail (tpmtool_opt_strs+1886) -#define zFullVersion (tpmtool_opt_strs+1955) +#define zBugsAddr (tpmtool_opt_strs+1959) +#define zExplain (tpmtool_opt_strs+1978) +#define zDetail (tpmtool_opt_strs+1981) +#define zFullVersion (tpmtool_opt_strs+2050) /* extracted from optcode.tlib near line 350 */ #if defined(ENABLE_NLS) @@ -559,7 +610,7 @@ static tOptDesc optDesc[OPTION_CT] = { #define tpmtool_full_usage (NULL) -#define tpmtool_short_usage (tpmtool_opt_strs+1973) +#define tpmtool_short_usage (tpmtool_opt_strs+2068) #endif /* not defined __doxygen__ */ @@ -681,6 +732,7 @@ tOptions tpmtoolOptions = { + OPTPROC_SHORTOPT + OPTPROC_LONGOPT + OPTPROC_NO_REQ_OPT + + OPTPROC_NEGATIONS + OPTPROC_NO_ARGS + OPTPROC_GNUUSAGE + OPTPROC_MISUSE ), @@ -701,7 +753,7 @@ tOptions tpmtoolOptions = { NO_EQUIVALENT, /* '-#' option index */ NO_EQUIVALENT /* index of default opt */ }, - 17 /* full option count */, 14 /* user option count */, + 19 /* full option count */, 16 /* user option count */, tpmtool_full_usage, tpmtool_short_usage, NULL, NULL, PKGDATADIR, tpmtool_packager_info diff --git a/src/tpmtool-args.def b/src/tpmtool-args.def index 5afc0fa370..48b01f6055 100644 --- a/src/tpmtool-args.def +++ b/src/tpmtool-args.def @@ -96,6 +96,24 @@ flag = { doc = ""; }; +flag = { + name = inder; + descrip = "Use the DER format for keys."; + disabled; + disable = "no"; + doc = "The input files will be assumed to be in the portable +DER format of TPM. The default format is a custom format used by various +TPM tools"; +}; + +flag = { + name = outder; + descrip = "Use DER format for output keys"; + disabled; + disable = "no"; + doc = "The output will be in the TPM portable DER format."; +}; + doc-section = { ds-type = 'SEE ALSO'; ds-format = 'texi'; diff --git a/src/tpmtool-args.h b/src/tpmtool-args.h index d268f28493..6666794445 100644 --- a/src/tpmtool-args.h +++ b/src/tpmtool-args.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (tpmtool-args.h) * - * It has been AutoGen-ed July 20, 2012 at 10:21:17 PM by AutoGen 5.16 + * It has been AutoGen-ed July 21, 2012 at 10:09:08 PM by AutoGen 5.16 * From the definitions tpmtool-args.def * and the template file options * @@ -81,12 +81,14 @@ typedef enum { INDEX_OPT_DELETE = 11, INDEX_OPT_SEC_PARAM = 12, INDEX_OPT_BITS = 13, - INDEX_OPT_VERSION = 14, - INDEX_OPT_HELP = 15, - INDEX_OPT_MORE_HELP = 16 + INDEX_OPT_INDER = 14, + INDEX_OPT_OUTDER = 15, + INDEX_OPT_VERSION = 16, + INDEX_OPT_HELP = 17, + INDEX_OPT_MORE_HELP = 18 } teOptIndex; -#define OPTION_CT 17 +#define OPTION_CT 19 #define TPMTOOL_VERSION "@VERSION@" #define TPMTOOL_FULL_VERSION "tpmtool @VERSION@" @@ -142,6 +144,8 @@ typedef enum { #define VALUE_OPT_BITS 13 #define OPT_VALUE_BITS (DESC(BITS).optArg.argInt) +#define VALUE_OPT_INDER 14 +#define VALUE_OPT_OUTDER 15 #define VALUE_OPT_HELP 'h' #define VALUE_OPT_MORE_HELP '!' #define VALUE_OPT_VERSION 'v' diff --git a/src/tpmtool.c b/src/tpmtool.c index edd219a056..25cee8e4c5 100644 --- a/src/tpmtool.c +++ b/src/tpmtool.c @@ -55,6 +55,9 @@ static void tpm_pubkey(const char* url, FILE* outfile); static void tpm_delete(const char* url, FILE* outfile); static void tpm_list(FILE* outfile); +static gnutls_x509_crt_fmt_t incert_format, outcert_format; +static gnutls_tpmkey_fmt_t inkey_format, outkey_format; + static FILE *outfile; static FILE *infile; int batch = 0; @@ -95,6 +98,28 @@ cmd_parser (int argc, char **argv) if (HAVE_OPT(DEBUG)) debug = OPT_VALUE_DEBUG; + if (HAVE_OPT(INDER)) + { + incert_format = GNUTLS_X509_FMT_DER; + inkey_format = GNUTLS_TPMKEY_FMT_DER; + } + else + { + incert_format = GNUTLS_X509_FMT_PEM; + inkey_format = GNUTLS_TPMKEY_FMT_PEM; + } + + if (HAVE_OPT(OUTDER)) + { + outcert_format = GNUTLS_X509_FMT_DER; + outkey_format = GNUTLS_TPMKEY_FMT_DER; + } + else + { + outcert_format = GNUTLS_X509_FMT_PEM; + outkey_format = GNUTLS_TPMKEY_FMT_PEM; + } + if (HAVE_OPT(REGISTER)) genflags |= GNUTLS_TPM_REGISTER_KEY; if (!HAVE_OPT(LEGACY)) @@ -177,7 +202,8 @@ static void tpm_generate(FILE* outfile, unsigned int key_type, unsigned int bits key_pass = strdup(srk_pass); ret = gnutls_tpm_privkey_generate(key_type, bits, srk_pass, key_pass, - GNUTLS_X509_FMT_PEM, &privkey, &pubkey, + outkey_format, outcert_format, + &privkey, &pubkey, flags); free(key_pass); |