Use enums for signature versions
authorVivek Goyal <vgoyal@redhat.com>
Fri, 12 Jul 2013 18:52:10 +0000 (14:52 -0400)
committerDmitry Kasatkin <d.kasatkin@samsung.com>
Fri, 9 Aug 2013 12:55:53 +0000 (15:55 +0300)
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 <vgoyal@redhat.com>
src/evmctl.c

index af681f8..d463c82 100644 (file)
@@ -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);