From 0df73005a37cb9001c9202250513607ad4787375 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 12 Jul 2013 14:52:10 -0400 Subject: [PATCH] Use enums for signature versions Using enums for fixed values looks cleaner. Also I am planning to use version field in more places in next patch. So use enums intead of numbers like 1 and 2. Signed-off-by: Vivek Goyal --- src/evmctl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/evmctl.c b/src/evmctl.c index af681f8..d463c82 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -108,6 +108,11 @@ enum digest_algo { DIGEST_ALGO_MAX }; +enum digsig_version { + DIGSIG_VERSION_1 = 1, + DIGSIG_VERSION_2 +}; + struct pubkey_hdr { uint8_t version; /* key format version */ uint32_t timestamp; /* key made, always 0 for now */ @@ -507,7 +512,7 @@ static int sign_hash_v1(const char *hashalgo, const unsigned char *hash, int siz return -1; /* now create a new hash */ - hdr->version = 1; + hdr->version = (uint8_t) DIGSIG_VERSION_1; hdr->timestamp = time(NULL); hdr->algo = PUBKEY_ALGO_RSA; hashalgo_idx = get_hash_algo_v1(hashalgo); @@ -577,7 +582,7 @@ static int sign_hash_v2(const char *algo, const unsigned char *hash, int size, c if (!key) return -1; - hdr->version = 2; + hdr->version = (uint8_t) DIGSIG_VERSION_2; hdr->hash_algo = get_hash_algo(algo); calc_keyid_v2(&hdr->keyid, name, key);