cert_create: update help message

The help message printed by the cert_create tool using the command
line option -h (or --help) does not correctly list all the available
command line options.

This patch reworks the print_help() function to print the help
messages in a data driven approach. For each command line option
registered, an optional help message can be specified, which will
be printed by print_help().

Help messages for the TBBR options (certificates, keys and images)
are also provided.

Fix a small bug in the short options string passed to getopt_long:
the ':' was missing in the '-a' option (this option must take an
argument).

Fixes ARM-software/tf-issues#337

Change-Id: I9d08c2dfd349022808fcc884724f677eefdc1452
diff --git a/tools/cert_create/src/tbbr/tbb_cert.c b/tools/cert_create/src/tbbr/tbb_cert.c
index 20be59f..7a50ab3 100644
--- a/tools/cert_create/src/tbbr/tbb_cert.c
+++ b/tools/cert_create/src/tbbr/tbb_cert.c
@@ -43,6 +43,7 @@
 	[TRUSTED_BOOT_FW_CERT] = {
 		.id = TRUSTED_BOOT_FW_CERT,
 		.opt = "tb-fw-cert",
+		.help_msg = "Trusted Boot FW Certificate (output file)",
 		.fn = NULL,
 		.cn = "Trusted Boot FW Certificate",
 		.key = ROT_KEY,
@@ -55,6 +56,7 @@
 	[TRUSTED_KEY_CERT] = {
 		.id = TRUSTED_KEY_CERT,
 		.opt = "trusted-key-cert",
+		.help_msg = "Trusted Key Certificate (output file)",
 		.fn = NULL,
 		.cn = "Trusted Key Certificate",
 		.key = ROT_KEY,
@@ -68,6 +70,7 @@
 	[SCP_FW_KEY_CERT] = {
 		.id = SCP_FW_KEY_CERT,
 		.opt = "scp-fw-key-cert",
+		.help_msg = "SCP Firmware Key Certificate (output file)",
 		.fn = NULL,
 		.cn = "SCP Firmware Key Certificate",
 		.key = TRUSTED_WORLD_KEY,
@@ -80,6 +83,7 @@
 	[SCP_FW_CONTENT_CERT] = {
 		.id = SCP_FW_CONTENT_CERT,
 		.opt = "scp-fw-cert",
+		.help_msg = "SCP Firmware Content Certificate (output file)",
 		.fn = NULL,
 		.cn = "SCP Firmware Content Certificate",
 		.key = SCP_FW_CONTENT_CERT_KEY,
@@ -92,6 +96,7 @@
 	[SOC_FW_KEY_CERT] = {
 		.id = SOC_FW_KEY_CERT,
 		.opt = "soc-fw-key-cert",
+		.help_msg = "SoC Firmware Key Certificate (output file)",
 		.fn = NULL,
 		.cn = "SoC Firmware Key Certificate",
 		.key = TRUSTED_WORLD_KEY,
@@ -104,6 +109,7 @@
 	[SOC_FW_CONTENT_CERT] = {
 		.id = SOC_FW_CONTENT_CERT,
 		.opt = "soc-fw-cert",
+		.help_msg = "SoC Firmware Content Certificate (output file)",
 		.fn = NULL,
 		.cn = "SoC Firmware Content Certificate",
 		.key = SOC_FW_CONTENT_CERT_KEY,
@@ -116,6 +122,7 @@
 	[TRUSTED_OS_FW_KEY_CERT] = {
 		.id = TRUSTED_OS_FW_KEY_CERT,
 		.opt = "tos-fw-key-cert",
+		.help_msg = "Trusted OS Firmware Key Certificate (output file)",
 		.fn = NULL,
 		.cn = "Trusted OS Firmware Key Certificate",
 		.key = TRUSTED_WORLD_KEY,
@@ -128,6 +135,7 @@
 	[TRUSTED_OS_FW_CONTENT_CERT] = {
 		.id = TRUSTED_OS_FW_CONTENT_CERT,
 		.opt = "tos-fw-cert",
+		.help_msg = "Trusted OS Firmware Content Certificate (output file)",
 		.fn = NULL,
 		.cn = "Trusted OS Firmware Content Certificate",
 		.key = TRUSTED_OS_FW_CONTENT_CERT_KEY,
@@ -140,6 +148,7 @@
 	[NON_TRUSTED_FW_KEY_CERT] = {
 		.id = NON_TRUSTED_FW_KEY_CERT,
 		.opt = "nt-fw-key-cert",
+		.help_msg = "Non-Trusted Firmware Key Certificate (output file)",
 		.fn = NULL,
 		.cn = "Non-Trusted Firmware Key Certificate",
 		.key = NON_TRUSTED_WORLD_KEY,
@@ -152,6 +161,7 @@
 	[NON_TRUSTED_FW_CONTENT_CERT] = {
 		.id = NON_TRUSTED_FW_CONTENT_CERT,
 		.opt = "nt-fw-cert",
+		.help_msg = "Non-Trusted Firmware Content Certificate (output file)",
 		.fn = NULL,
 		.cn = "Non-Trusted Firmware Content Certificate",
 		.key = NON_TRUSTED_FW_CONTENT_CERT_KEY,
@@ -164,8 +174,9 @@
 	[FWU_CERT] = {
 		.id = FWU_CERT,
 		.opt = "fwu-cert",
+		.help_msg = "Firmware Update Certificate (output file)",
 		.fn = NULL,
-		.cn = "FWU Certificate",
+		.cn = "Firmware Update Certificate",
 		.key = ROT_KEY,
 		.issuer = FWU_CERT,
 		.ext = {
diff --git a/tools/cert_create/src/tbbr/tbb_ext.c b/tools/cert_create/src/tbbr/tbb_ext.c
index 1400fbf..8bcb070 100644
--- a/tools/cert_create/src/tbbr/tbb_ext.c
+++ b/tools/cert_create/src/tbbr/tbb_ext.c
@@ -61,6 +61,7 @@
 	[TRUSTED_BOOT_FW_HASH_EXT] = {
 		.oid = TRUSTED_BOOT_FW_HASH_OID,
 		.opt = "tb-fw",
+		.help_msg = "Trusted Boot Firmware image file",
 		.sn = "TrustedBootFirmwareHash",
 		.ln = "Trusted Boot Firmware hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -93,6 +94,7 @@
 	[SCP_FW_HASH_EXT] = {
 		.oid = SCP_FW_HASH_OID,
 		.opt = "scp-fw",
+		.help_msg = "SCP Firmware image file",
 		.sn = "SCPFirmwareHash",
 		.ln = "SCP Firmware hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -109,6 +111,7 @@
 	[SOC_AP_FW_HASH_EXT] = {
 		.oid = SOC_AP_FW_HASH_OID,
 		.opt = "soc-fw",
+		.help_msg = "SoC AP Firmware image file",
 		.sn = "SoCAPFirmwareHash",
 		.ln = "SoC AP Firmware hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -125,6 +128,7 @@
 	[TRUSTED_OS_FW_HASH_EXT] = {
 		.oid = TRUSTED_OS_FW_HASH_OID,
 		.opt = "tos-fw",
+		.help_msg = "Trusted OS image file",
 		.sn = "TrustedOSHash",
 		.ln = "Trusted OS hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -141,6 +145,7 @@
 	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
 		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
 		.opt = "nt-fw",
+		.help_msg = "Non-Trusted World Bootloader image file",
 		.sn = "NonTrustedWorldBootloaderHash",
 		.ln = "Non-Trusted World hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -149,6 +154,7 @@
 	[SCP_FWU_CFG_HASH_EXT] = {
 		.oid = SCP_FWU_CFG_HASH_OID,
 		.opt = "scp-fwu-cfg",
+		.help_msg = "SCP Firmware Update Config image file",
 		.sn = "SCPFWUpdateConfig",
 		.ln = "SCP Firmware Update Config hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -158,6 +164,7 @@
 	[AP_FWU_CFG_HASH_EXT] = {
 		.oid = AP_FWU_CFG_HASH_OID,
 		.opt = "ap-fwu-cfg",
+		.help_msg = "AP Firmware Update Config image file",
 		.sn = "APFWUpdateConfig",
 		.ln = "AP Firmware Update Config hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
@@ -167,6 +174,7 @@
 	[FWU_HASH_EXT] = {
 		.oid = FWU_HASH_OID,
 		.opt = "fwu",
+		.help_msg = "Firmware Updater image file",
 		.sn = "FWUpdaterHash",
 		.ln = "Firmware Updater hash (SHA256)",
 		.asn1_type = V_ASN1_OCTET_STRING,
diff --git a/tools/cert_create/src/tbbr/tbb_key.c b/tools/cert_create/src/tbbr/tbb_key.c
index 089425a..1d2f789 100644
--- a/tools/cert_create/src/tbbr/tbb_key.c
+++ b/tools/cert_create/src/tbbr/tbb_key.c
@@ -39,36 +39,43 @@
 	[ROT_KEY] = {
 		.id = ROT_KEY,
 		.opt = "rot-key",
+		.help_msg = "Root Of Trust key (input/output file)",
 		.desc = "Root Of Trust key"
 	},
 	[TRUSTED_WORLD_KEY] = {
 		.id = TRUSTED_WORLD_KEY,
 		.opt = "trusted-world-key",
+		.help_msg = "Trusted World key (input/output file)",
 		.desc = "Trusted World key"
 	},
 	[NON_TRUSTED_WORLD_KEY] = {
 		.id = NON_TRUSTED_WORLD_KEY,
 		.opt = "non-trusted-world-key",
+		.help_msg = "Non Trusted World key (input/output file)",
 		.desc = "Non Trusted World key"
 	},
 	[SCP_FW_CONTENT_CERT_KEY] = {
 		.id = SCP_FW_CONTENT_CERT_KEY,
 		.opt = "scp-fw-key",
+		.help_msg = "SCP Firmware Content Certificate key (input/output file)",
 		.desc = "SCP Firmware Content Certificate key"
 	},
 	[SOC_FW_CONTENT_CERT_KEY] = {
 		.id = SOC_FW_CONTENT_CERT_KEY,
 		.opt = "soc-fw-key",
+		.help_msg = "SoC Firmware Content Certificate key (input/output file)",
 		.desc = "SoC Firmware Content Certificate key"
 	},
 	[TRUSTED_OS_FW_CONTENT_CERT_KEY] = {
 		.id = TRUSTED_OS_FW_CONTENT_CERT_KEY,
 		.opt = "tos-fw-key",
+		.help_msg = "Trusted OS Firmware Content Certificate key (input/output file)",
 		.desc = "Trusted OS Firmware Content Certificate key"
 	},
 	[NON_TRUSTED_FW_CONTENT_CERT_KEY] = {
 		.id = NON_TRUSTED_FW_CONTENT_CERT_KEY,
 		.opt = "nt-fw-key",
+		.help_msg = "Non Trusted Firmware Content Certificate key (input/output file)",
 		.desc = "Non Trusted Firmware Content Certificate key"
 	}
 };