From: Nikos Mavrogiannopoulos Date: Sat, 14 Jul 2012 08:42:25 +0000 (+0200) Subject: Allow generation of system and user keys. X-Git-Tag: gnutls_3_1_0pre0~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5b4b1eee98c4e03ee45c59f23bb625a1d9f38c2;p=thirdparty%2Fgnutls.git Allow generation of system and user keys. --- diff --git a/src/tpmtool-args.c b/src/tpmtool-args.c index 57fd7d7818..a2474b1572 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 14, 2012 at 09:24:04 AM by AutoGen 5.16 + * It has been AutoGen-ed July 14, 2012 at 10:40:19 AM 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[1930] = +static char const tpmtool_opt_strs[2031] = /* 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" @@ -102,39 +102,45 @@ static char const tpmtool_opt_strs[1930] = /* 1096 */ "Any generated key will be a signing key\0" /* 1136 */ "SIGNING\0" /* 1144 */ "signing\0" -/* 1152 */ "Any generated key will be a legacy key\0" -/* 1191 */ "LEGACY\0" -/* 1198 */ "legacy\0" -/* 1205 */ "Prints the public key of the provided key\0" -/* 1247 */ "PUBKEY\0" -/* 1254 */ "pubkey\0" -/* 1261 */ "Lists all stored keys in the TPM\0" -/* 1294 */ "LIST\0" -/* 1299 */ "list\0" -/* 1304 */ "Delete the key identified by the given URL (UUID).\0" -/* 1355 */ "DELETE\0" -/* 1362 */ "delete\0" -/* 1369 */ "Specify the security level [low, legacy, normal, high, ultra].\0" -/* 1432 */ "SEC_PARAM\0" -/* 1442 */ "sec-param\0" -/* 1452 */ "Specify the number of bits for key generate\0" -/* 1496 */ "BITS\0" -/* 1501 */ "bits\0" -/* 1506 */ "Display extended usage information and exit\0" -/* 1550 */ "help\0" -/* 1555 */ "Extended usage information passed thru pager\0" -/* 1600 */ "more-help\0" -/* 1610 */ "Output version information and exit\0" -/* 1646 */ "version\0" -/* 1654 */ "TPMTOOL\0" -/* 1662 */ "tpmtool - GnuTLS TPM tool - Ver. @VERSION@\n" +/* 1152 */ "Any registered key will be a user key\0" +/* 1190 */ "USER\0" +/* 1195 */ "user\0" +/* 1200 */ "Any registred key will be a system key\0" +/* 1239 */ "SYSTEM\0" +/* 1246 */ "system\0" +/* 1253 */ "Any generated key will be a legacy key\0" +/* 1292 */ "LEGACY\0" +/* 1299 */ "legacy\0" +/* 1306 */ "Prints the public key of the provided key\0" +/* 1348 */ "PUBKEY\0" +/* 1355 */ "pubkey\0" +/* 1362 */ "Lists all stored keys in the TPM\0" +/* 1395 */ "LIST\0" +/* 1400 */ "list\0" +/* 1405 */ "Delete the key identified by the given URL (UUID).\0" +/* 1456 */ "DELETE\0" +/* 1463 */ "delete\0" +/* 1470 */ "Specify the security level [low, legacy, normal, high, ultra].\0" +/* 1533 */ "SEC_PARAM\0" +/* 1543 */ "sec-param\0" +/* 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" "USAGE: %s [ - [] | --[{=| }] ]...\n\0" -/* 1763 */ "bug-gnutls@gnu.org\0" -/* 1782 */ "\n\n\0" -/* 1785 */ "\n" +/* 1864 */ "bug-gnutls@gnu.org\0" +/* 1883 */ "\n\n\0" +/* 1886 */ "\n" "Program that allows handling cryptographic data from the TPM chip.\n\0" -/* 1854 */ "tpmtool @VERSION@\0" -/* 1872 */ "tpmtool [options]\n" +/* 1955 */ "tpmtool @VERSION@\0" +/* 1973 */ "tpmtool [options]\n" "tpmtool --help for usage instructions.\n"; /* @@ -196,13 +202,39 @@ static int const aSigningCantList[] = { INDEX_OPT_LEGACY, NO_EQUIVALENT }; #define SIGNING_FLAGS (OPTST_DISABLED) +/* + * user option description with + * "Must also have options" and "Incompatible options": + */ +#define USER_DESC (tpmtool_opt_strs+1152) +#define USER_NAME (tpmtool_opt_strs+1190) +#define USER_name (tpmtool_opt_strs+1195) +static int const aUserMustList[] = { + INDEX_OPT_REGISTER, NO_EQUIVALENT }; +static int const aUserCantList[] = { + INDEX_OPT_SYSTEM, NO_EQUIVALENT }; +#define USER_FLAGS (OPTST_DISABLED) + +/* + * system option description with + * "Must also have options" and "Incompatible options": + */ +#define SYSTEM_DESC (tpmtool_opt_strs+1200) +#define SYSTEM_NAME (tpmtool_opt_strs+1239) +#define SYSTEM_name (tpmtool_opt_strs+1246) +static int const aSystemMustList[] = { + INDEX_OPT_REGISTER, NO_EQUIVALENT }; +static int const aSystemCantList[] = { + INDEX_OPT_USER, NO_EQUIVALENT }; +#define SYSTEM_FLAGS (OPTST_DISABLED) + /* * legacy option description with * "Must also have options" and "Incompatible options": */ -#define LEGACY_DESC (tpmtool_opt_strs+1152) -#define LEGACY_NAME (tpmtool_opt_strs+1191) -#define LEGACY_name (tpmtool_opt_strs+1198) +#define LEGACY_DESC (tpmtool_opt_strs+1253) +#define LEGACY_NAME (tpmtool_opt_strs+1292) +#define LEGACY_name (tpmtool_opt_strs+1299) static int const aLegacyMustList[] = { INDEX_OPT_GENERATE_RSA, NO_EQUIVALENT }; static int const aLegacyCantList[] = { @@ -212,55 +244,55 @@ static int const aLegacyCantList[] = { /* * pubkey option description: */ -#define PUBKEY_DESC (tpmtool_opt_strs+1205) -#define PUBKEY_NAME (tpmtool_opt_strs+1247) -#define PUBKEY_name (tpmtool_opt_strs+1254) +#define PUBKEY_DESC (tpmtool_opt_strs+1306) +#define PUBKEY_NAME (tpmtool_opt_strs+1348) +#define PUBKEY_name (tpmtool_opt_strs+1355) #define PUBKEY_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * list option description: */ -#define LIST_DESC (tpmtool_opt_strs+1261) -#define LIST_NAME (tpmtool_opt_strs+1294) -#define LIST_name (tpmtool_opt_strs+1299) +#define LIST_DESC (tpmtool_opt_strs+1362) +#define LIST_NAME (tpmtool_opt_strs+1395) +#define LIST_name (tpmtool_opt_strs+1400) #define LIST_FLAGS (OPTST_DISABLED) /* * delete option description: */ -#define DELETE_DESC (tpmtool_opt_strs+1304) -#define DELETE_NAME (tpmtool_opt_strs+1355) -#define DELETE_name (tpmtool_opt_strs+1362) +#define DELETE_DESC (tpmtool_opt_strs+1405) +#define DELETE_NAME (tpmtool_opt_strs+1456) +#define DELETE_name (tpmtool_opt_strs+1463) #define DELETE_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * sec-param option description: */ -#define SEC_PARAM_DESC (tpmtool_opt_strs+1369) -#define SEC_PARAM_NAME (tpmtool_opt_strs+1432) -#define SEC_PARAM_name (tpmtool_opt_strs+1442) +#define SEC_PARAM_DESC (tpmtool_opt_strs+1470) +#define SEC_PARAM_NAME (tpmtool_opt_strs+1533) +#define SEC_PARAM_name (tpmtool_opt_strs+1543) #define SEC_PARAM_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) /* * bits option description: */ -#define BITS_DESC (tpmtool_opt_strs+1452) -#define BITS_NAME (tpmtool_opt_strs+1496) -#define BITS_name (tpmtool_opt_strs+1501) +#define BITS_DESC (tpmtool_opt_strs+1553) +#define BITS_NAME (tpmtool_opt_strs+1597) +#define BITS_name (tpmtool_opt_strs+1602) #define BITS_FLAGS (OPTST_DISABLED \ | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) /* * Help/More_Help/Version option descriptions: */ -#define HELP_DESC (tpmtool_opt_strs+1506) -#define HELP_name (tpmtool_opt_strs+1550) +#define HELP_DESC (tpmtool_opt_strs+1607) +#define HELP_name (tpmtool_opt_strs+1651) #ifdef HAVE_WORKING_FORK -#define MORE_HELP_DESC (tpmtool_opt_strs+1555) -#define MORE_HELP_name (tpmtool_opt_strs+1600) +#define MORE_HELP_DESC (tpmtool_opt_strs+1656) +#define MORE_HELP_name (tpmtool_opt_strs+1701) #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT) #else #define MORE_HELP_DESC NULL @@ -273,8 +305,8 @@ static int const aLegacyCantList[] = { # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT) #endif -#define VER_DESC (tpmtool_opt_strs+1610) -#define VER_name (tpmtool_opt_strs+1646) +#define VER_DESC (tpmtool_opt_strs+1711) +#define VER_name (tpmtool_opt_strs+1747) /* * Declare option callback procedures */ @@ -366,8 +398,32 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ SIGNING_DESC, SIGNING_NAME, SIGNING_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 6, VALUE_OPT_LEGACY, - /* equiv idx, value */ 6, VALUE_OPT_LEGACY, + { /* entry idx, value */ 6, VALUE_OPT_USER, + /* equiv idx, value */ 6, VALUE_OPT_USER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ USER_FLAGS, 0, + /* last opt argumnt */ { NULL }, /* --user */ + /* arg list/cookie */ NULL, + /* must/cannot opts */ aUserMustList, aUserCantList, + /* option proc */ NULL, + /* desc, NAME, name */ USER_DESC, USER_NAME, USER_name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_SYSTEM, + /* equiv idx, value */ 7, VALUE_OPT_SYSTEM, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SYSTEM_FLAGS, 0, + /* last opt argumnt */ { NULL }, /* --system */ + /* arg list/cookie */ NULL, + /* must/cannot opts */ aSystemMustList, aSystemCantList, + /* option proc */ NULL, + /* desc, NAME, name */ SYSTEM_DESC, SYSTEM_NAME, SYSTEM_name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_LEGACY, + /* equiv idx, value */ 8, VALUE_OPT_LEGACY, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ LEGACY_FLAGS, 0, @@ -378,8 +434,8 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ LEGACY_DESC, LEGACY_NAME, LEGACY_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 7, VALUE_OPT_PUBKEY, - /* equiv idx, value */ 7, VALUE_OPT_PUBKEY, + { /* entry idx, value */ 9, VALUE_OPT_PUBKEY, + /* equiv idx, value */ 9, VALUE_OPT_PUBKEY, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ PUBKEY_FLAGS, 0, @@ -390,8 +446,8 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ PUBKEY_DESC, PUBKEY_NAME, PUBKEY_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 8, VALUE_OPT_LIST, - /* equiv idx, value */ 8, VALUE_OPT_LIST, + { /* entry idx, value */ 10, VALUE_OPT_LIST, + /* equiv idx, value */ 10, VALUE_OPT_LIST, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ LIST_FLAGS, 0, @@ -402,8 +458,8 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ LIST_DESC, LIST_NAME, LIST_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 9, VALUE_OPT_DELETE, - /* equiv idx, value */ 9, VALUE_OPT_DELETE, + { /* entry idx, value */ 11, VALUE_OPT_DELETE, + /* equiv idx, value */ 11, VALUE_OPT_DELETE, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ DELETE_FLAGS, 0, @@ -414,8 +470,8 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ DELETE_DESC, DELETE_NAME, DELETE_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 10, VALUE_OPT_SEC_PARAM, - /* equiv idx, value */ 10, VALUE_OPT_SEC_PARAM, + { /* entry idx, value */ 12, VALUE_OPT_SEC_PARAM, + /* equiv idx, value */ 12, VALUE_OPT_SEC_PARAM, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SEC_PARAM_FLAGS, 0, @@ -426,8 +482,8 @@ static tOptDesc optDesc[OPTION_CT] = { /* desc, NAME, name */ SEC_PARAM_DESC, SEC_PARAM_NAME, SEC_PARAM_name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 11, VALUE_OPT_BITS, - /* equiv idx, value */ 11, VALUE_OPT_BITS, + { /* entry idx, value */ 13, VALUE_OPT_BITS, + /* equiv idx, value */ 13, VALUE_OPT_BITS, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ BITS_FLAGS, 0, @@ -482,14 +538,14 @@ static tOptDesc optDesc[OPTION_CT] = { * * Define the tpmtool Option Environment */ -#define zPROGNAME (tpmtool_opt_strs+1654) -#define zUsageTitle (tpmtool_opt_strs+1662) +#define zPROGNAME (tpmtool_opt_strs+1755) +#define zUsageTitle (tpmtool_opt_strs+1763) #define zRcName NULL #define apzHomeList NULL -#define zBugsAddr (tpmtool_opt_strs+1763) -#define zExplain (tpmtool_opt_strs+1782) -#define zDetail (tpmtool_opt_strs+1785) -#define zFullVersion (tpmtool_opt_strs+1854) +#define zBugsAddr (tpmtool_opt_strs+1864) +#define zExplain (tpmtool_opt_strs+1883) +#define zDetail (tpmtool_opt_strs+1886) +#define zFullVersion (tpmtool_opt_strs+1955) /* extracted from optcode.tlib near line 350 */ #if defined(ENABLE_NLS) @@ -503,7 +559,7 @@ static tOptDesc optDesc[OPTION_CT] = { #define tpmtool_full_usage (NULL) -#define tpmtool_short_usage (tpmtool_opt_strs+1872) +#define tpmtool_short_usage (tpmtool_opt_strs+1973) #endif /* not defined __doxygen__ */ @@ -645,7 +701,7 @@ tOptions tpmtoolOptions = { NO_EQUIVALENT, /* '-#' option index */ NO_EQUIVALENT /* index of default opt */ }, - 15 /* full option count */, 12 /* user option count */, + 17 /* full option count */, 14 /* 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 d44aaaf085..59bb846cb0 100644 --- a/src/tpmtool-args.def +++ b/src/tpmtool-args.def @@ -31,6 +31,22 @@ flag = { doc = ""; }; +flag = { + name = user; + descrip = "Any registered key will be a user key"; + flags_must = register; + flags_cant = system; + doc = "The generated key will be stored in a user specific persistent storage."; +}; + +flag = { + name = system; + descrip = "Any registred key will be a system key"; + flags_must = register; + flags_cant = user; + doc = "The generated key will be stored in system persistent storage."; +}; + flag = { name = legacy; descrip = "Any generated key will be a legacy key"; diff --git a/src/tpmtool-args.h b/src/tpmtool-args.h index 08aa055305..f4d98ae048 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 14, 2012 at 09:24:04 AM by AutoGen 5.16 + * It has been AutoGen-ed July 14, 2012 at 10:40:19 AM by AutoGen 5.16 * From the definitions tpmtool-args.def * and the template file options * @@ -73,18 +73,20 @@ typedef enum { INDEX_OPT_GENERATE_RSA = 3, INDEX_OPT_REGISTER = 4, INDEX_OPT_SIGNING = 5, - INDEX_OPT_LEGACY = 6, - INDEX_OPT_PUBKEY = 7, - INDEX_OPT_LIST = 8, - INDEX_OPT_DELETE = 9, - INDEX_OPT_SEC_PARAM = 10, - INDEX_OPT_BITS = 11, - INDEX_OPT_VERSION = 12, - INDEX_OPT_HELP = 13, - INDEX_OPT_MORE_HELP = 14 + INDEX_OPT_USER = 6, + INDEX_OPT_SYSTEM = 7, + INDEX_OPT_LEGACY = 8, + INDEX_OPT_PUBKEY = 9, + INDEX_OPT_LIST = 10, + 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 } teOptIndex; -#define OPTION_CT 15 +#define OPTION_CT 17 #define TPMTOOL_VERSION "@VERSION@" #define TPMTOOL_FULL_VERSION "tpmtool @VERSION@" @@ -130,12 +132,14 @@ typedef enum { #define VALUE_OPT_GENERATE_RSA 3 #define VALUE_OPT_REGISTER 4 #define VALUE_OPT_SIGNING 5 -#define VALUE_OPT_LEGACY 6 -#define VALUE_OPT_PUBKEY 7 -#define VALUE_OPT_LIST 8 -#define VALUE_OPT_DELETE 9 -#define VALUE_OPT_SEC_PARAM 10 -#define VALUE_OPT_BITS 11 +#define VALUE_OPT_USER 6 +#define VALUE_OPT_SYSTEM 7 +#define VALUE_OPT_LEGACY 8 +#define VALUE_OPT_PUBKEY 9 +#define VALUE_OPT_LIST 10 +#define VALUE_OPT_DELETE 11 +#define VALUE_OPT_SEC_PARAM 12 +#define VALUE_OPT_BITS 13 #define OPT_VALUE_BITS (DESC(BITS).optArg.argInt) #define VALUE_OPT_HELP 'h' diff --git a/src/tpmtool.c b/src/tpmtool.c index 074e6653c5..1a84e1cabd 100644 --- a/src/tpmtool.c +++ b/src/tpmtool.c @@ -99,6 +99,8 @@ cmd_parser (int argc, char **argv) genflags |= GNUTLS_TPM_REGISTER_KEY; if (HAVE_OPT(SIGNING)) genflags |= GNUTLS_TPM_KEY_SIGNING; + if (HAVE_OPT(USER)) + genflags |= GNUTLS_TPM_KEY_USER; gnutls_global_set_log_function (tls_log_func); gnutls_global_set_log_level (debug);