summaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-03-04 16:13:45 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-10 23:46:07 +0000
commit36bc59140c9d3d4110b3d1c4b7c6b0b84875e81e (patch)
tree33dacefd33271d0cb35a7f39d298e486c5387ce5 /host
parent0f21441e78114805e2baf61b1cabc6a5b55183c6 (diff)
downloadvboot-36bc59140c9d3d4110b3d1c4b7c6b0b84875e81e.tar.gz
vb21: Rename struct vb2_guid to struct vb2_id
Since the ID structure isn't a true GUID anymore, let's call it something else. BUG=none BRANCH=none TEST=make runtests Change-Id: I96f511bd5587a94d2cc20764e26d7ef0096de04c Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/256182 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'host')
-rw-r--r--host/lib21/host_key.c26
-rw-r--r--host/lib21/host_misc.c12
-rw-r--r--host/lib21/host_signature.c2
-rw-r--r--host/lib21/include/host_key2.h10
-rw-r--r--host/lib21/include/host_misc2.h22
5 files changed, 31 insertions, 41 deletions
diff --git a/host/lib21/host_key.c b/host/lib21/host_key.c
index 78a6d2ec..b18d018c 100644
--- a/host/lib21/host_key.c
+++ b/host/lib21/host_key.c
@@ -126,10 +126,10 @@ int vb2_private_key_unpack(struct vb2_private_key **key_ptr,
if (!key)
return VB2_ERROR_UNPACK_PRIVATE_KEY_ALLOC;
- /* Copy key algorithms and guid */
+ /* Copy key algorithms and ID */
key->sig_alg = pkey->sig_alg;
key->hash_alg = pkey->hash_alg;
- key->guid = pkey->guid;
+ key->id = pkey->id;
/* Unpack RSA key */
if (pkey->sig_alg == VB2_SIG_NONE) {
@@ -238,14 +238,14 @@ int vb2_private_key_write(const struct vb2_private_key *key,
.c.fixed_size = sizeof(pkey),
.sig_alg = key->sig_alg,
.hash_alg = key->hash_alg,
- .guid = key->guid,
+ .id = key->id,
};
uint8_t *buf;
uint8_t *rsabuf = NULL;
int rsalen = 0;
int rv;
- memcpy(&pkey.guid, &key->guid, sizeof(pkey.guid));
+ memcpy(&pkey.id, &key->id, sizeof(pkey.id));
pkey.c.desc_size = vb2_desc_size(key->desc);
@@ -297,7 +297,7 @@ int vb2_private_key_hash(const struct vb2_private_key **key_ptr,
.hash_alg = VB2_HASH_SHA1,
.sig_alg = VB2_SIG_NONE,
.desc = "Unsigned SHA1",
- .guid = VB2_GUID_NONE_SHA1,
+ .id = VB2_ID_NONE_SHA1,
};
*key_ptr = &key;
return VB2_SUCCESS;
@@ -310,7 +310,7 @@ int vb2_private_key_hash(const struct vb2_private_key **key_ptr,
.hash_alg = VB2_HASH_SHA256,
.sig_alg = VB2_SIG_NONE,
.desc = "Unsigned SHA-256",
- .guid = VB2_GUID_NONE_SHA256,
+ .id = VB2_ID_NONE_SHA256,
};
*key_ptr = &key;
return VB2_SUCCESS;
@@ -323,7 +323,7 @@ int vb2_private_key_hash(const struct vb2_private_key **key_ptr,
.hash_alg = VB2_HASH_SHA512,
.sig_alg = VB2_SIG_NONE,
.desc = "Unsigned SHA-512",
- .guid = VB2_GUID_NONE_SHA512,
+ .id = VB2_ID_NONE_SHA512,
};
*key_ptr = &key;
return VB2_SUCCESS;
@@ -340,8 +340,8 @@ int vb2_public_key_alloc(struct vb2_public_key **key_ptr,
struct vb2_public_key *key;
uint32_t key_data_size = vb2_packed_key_size(sig_alg);
- /* The buffer contains the key, its GUID, and its packed data */
- uint32_t buf_size = sizeof(*key) + sizeof(struct vb2_guid) +
+ /* The buffer contains the key, its ID, and its packed data */
+ uint32_t buf_size = sizeof(*key) + sizeof(struct vb2_id) +
key_data_size;
if (!key_data_size)
@@ -351,7 +351,7 @@ int vb2_public_key_alloc(struct vb2_public_key **key_ptr,
if (!key)
return VB2_ERROR_PUBLIC_KEY_ALLOC;
- key->guid = (struct vb2_guid *)(key + 1);
+ key->id = (struct vb2_id *)(key + 1);
key->sig_alg = sig_alg;
*key_ptr = key;
@@ -372,7 +372,7 @@ void vb2_public_key_free(struct vb2_public_key *key)
uint8_t *vb2_public_key_packed_data(struct vb2_public_key *key)
{
- return (uint8_t *)(key->guid + 1);
+ return (uint8_t *)(key->id + 1);
}
int vb2_public_key_read_keyb(struct vb2_public_key **key_ptr,
@@ -485,7 +485,7 @@ int vb2_public_key_pack(struct vb2_packed_key **key_ptr,
key.key_version = pubk->version;
key.sig_alg = pubk->sig_alg;
key.hash_alg = pubk->hash_alg;
- key.guid = *pubk->guid;
+ key.id = *pubk->id;
/* Allocate the new buffer */
buf = calloc(1, key.c.total_size);
@@ -539,7 +539,7 @@ int vb2_public_key_hash(struct vb2_public_key *key,
key->sig_alg = VB2_SIG_NONE;
key->hash_alg = hash_alg;
- key->guid = vb2_hash_guid(hash_alg);
+ key->id = vb2_hash_id(hash_alg);
return VB2_SUCCESS;
}
diff --git a/host/lib21/host_misc.c b/host/lib21/host_misc.c
index 5e8a7cb5..db5e8243 100644
--- a/host/lib21/host_misc.c
+++ b/host/lib21/host_misc.c
@@ -136,24 +136,24 @@ static const char *onebyte(const char *str, uint8_t *vptr)
return str;
}
-int vb2_str_to_guid(const char *str, struct vb2_guid *guid)
+int vb2_str_to_id(const char *str, struct vb2_id *id)
{
uint8_t val;
int i;
if (!str)
- return VB2_ERROR_STR_TO_GUID;
+ return VB2_ERROR_STR_TO_ID;
- memset(guid, 0, sizeof(*guid));
+ memset(id, 0, sizeof(*id));
- for (i = 0; i < NUM_GUID_BYTES; i++) {
+ for (i = 0; i < VB2_ID_NUM_BYTES; i++) {
str = onebyte(str, &val);
if (!str)
break;
- guid->raw[i] = val;
+ id->raw[i] = val;
}
/* If we get at least one valid byte, that's good enough. */
- return i ? VB2_SUCCESS : VB2_ERROR_STR_TO_GUID;
+ return i ? VB2_SUCCESS : VB2_ERROR_STR_TO_ID;
}
diff --git a/host/lib21/host_signature.c b/host/lib21/host_signature.c
index 11785c71..50cc8f0a 100644
--- a/host/lib21/host_signature.c
+++ b/host/lib21/host_signature.c
@@ -91,7 +91,7 @@ int vb2_sign_data(struct vb2_signature **sig_ptr,
.sig_alg = key->sig_alg,
.hash_alg = key->hash_alg,
.data_size = size,
- .guid = key->guid,
+ .id = key->id,
};
struct vb2_digest_context dc;
diff --git a/host/lib21/include/host_key2.h b/host/lib21/include/host_key2.h
index b219ae63..67113c13 100644
--- a/host/lib21/include/host_key2.h
+++ b/host/lib21/include/host_key2.h
@@ -18,7 +18,7 @@ struct vb2_private_key {
enum vb2_hash_algorithm hash_alg; /* Hash algorithm */
enum vb2_signature_algorithm sig_alg; /* Signature algorithm */
char *desc; /* Description */
- struct vb2_guid guid; /* Key GUID */
+ struct vb2_id id; /* Key ID */
};
/* Convert between enums and human-readable form. Terminated with {0, 0}. */
@@ -127,8 +127,8 @@ int vb2_private_key_hash(const struct vb2_private_key **key_ptr,
/**
* Allocate a public key buffer of sufficient size for the signature algorithm.
*
- * This only initializes the sig_alg field and the guid field to an empty
- * guid. It does not set any of the other fields in *key_ptr.
+ * This only initializes the sig_alg field and the id field to an empty
+ * id. It does not set any of the other fields in *key_ptr.
*
* @param key_ptr Destination for newly allocated key; this must be
* freed with vb2_public_key_free().
@@ -141,7 +141,7 @@ int vb2_public_key_alloc(struct vb2_public_key **key_ptr,
/**
* Return the packed data for a key allocated with vb2_public_key_alloc().
*
- * The packed data is in the same buffer, following the key struct and GUID.
+ * The packed data is in the same buffer, following the key struct and ID.
*/
uint8_t *vb2_public_key_packed_data(struct vb2_public_key *key);
@@ -160,7 +160,7 @@ void vb2_public_key_free(struct vb2_public_key *key);
* Read a public key from a .keyb file.
*
* Guesses the signature algorithm based on the size of the .keyb file. Does
- * not set the hash_alg, guid, or desc fields, since those are not contained in
+ * not set the hash_alg, id, or desc fields, since those are not contained in
* the .keyb file.
*
* @param key_ptr Destination for newly allocated key; this must be
diff --git a/host/lib21/include/host_misc2.h b/host/lib21/include/host_misc2.h
index 86ec13f0..5d891cad 100644
--- a/host/lib21/include/host_misc2.h
+++ b/host/lib21/include/host_misc2.h
@@ -9,28 +9,18 @@
#include <stdint.h>
#include <stdio.h>
-#include "2guid.h"
+#include "2id.h"
/* Length of string representation, including trailing '\0' */
-#define VB2_GUID_MIN_STRLEN (2 * NUM_GUID_BYTES + 1)
+#define VB2_ID_MIN_STRLEN (2 * VB2_ID_NUM_BYTES + 1)
/**
- * Convert string to struct vb2_guid.
+ * Convert hex string to struct vb2_id.
*
- * @param str Example: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
- * @param guid Destination for binary representation
+ * @param str Example: "01ABef000042"
+ * @param id Destination for binary representation
* @return VB2_SUCCESS, or non-zero if error.
*/
-int vb2_str_to_guid(const char *str, struct vb2_guid *guid);
-
-/**
- * Convert struct vb2_guid to string.
- *
- * @param guid Binary representation
- * @param str Buffer for result "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
- * @return VB2_SUCCESS, or non-zero if error.
- */
-int vb2_guid_to_str(const struct vb2_guid *guid,
- char *buf, unsigned int buflen);
+int vb2_str_to_id(const char *str, struct vb2_id *id);
#endif /* VBOOT_REFERENCE_HOST_MISC2_H_ */