diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/include/host_misc.h | 4 | ||||
-rw-r--r-- | host/lib/include/util_misc.h | 2 | ||||
-rw-r--r-- | host/lib21/host_fw_preamble.c | 30 | ||||
-rw-r--r-- | host/lib21/host_key.c | 72 | ||||
-rw-r--r-- | host/lib21/host_keyblock.c | 34 | ||||
-rw-r--r-- | host/lib21/host_misc.c | 6 | ||||
-rw-r--r-- | host/lib21/host_signature.c | 66 | ||||
-rw-r--r-- | host/lib21/include/host_fw_preamble2.h | 19 | ||||
-rw-r--r-- | host/lib21/include/host_key2.h | 39 | ||||
-rw-r--r-- | host/lib21/include/host_keyblock2.h | 15 | ||||
-rw-r--r-- | host/lib21/include/host_signature2.h | 38 |
11 files changed, 162 insertions, 163 deletions
diff --git a/host/lib/include/host_misc.h b/host/lib/include/host_misc.h index 6dc225c1..1bcf6f06 100644 --- a/host/lib/include/host_misc.h +++ b/host/lib/include/host_misc.h @@ -66,7 +66,7 @@ int vb2_read_file(const char *filename, uint8_t **data_ptr, uint32_t *size_ptr); int vb2_write_file(const char *filename, const void *buf, uint32_t size); /** - * Write a buffer which starts with a standard vb2_struct_common header. + * Write a buffer which starts with a standard vb21_struct_common header. * * Determines the buffer size from the common header total size field. * @@ -74,7 +74,7 @@ int vb2_write_file(const char *filename, const void *buf, uint32_t size); * @param buf Buffer to write * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_write_object(const char *filename, const void *buf); +int vb21_write_object(const char *filename, const void *buf); /** * Round up a size to a multiple of 32 bits (4 bytes). diff --git a/host/lib/include/util_misc.h b/host/lib/include/util_misc.h index d5a08fe3..f5db22b9 100644 --- a/host/lib/include/util_misc.h +++ b/host/lib/include/util_misc.h @@ -20,7 +20,7 @@ void PrintPrivKeySha1Sum(VbPrivateKey *key); /* * Our packed RSBPublicKey buffer (historically in files ending with ".keyb", - * but also the part of VbPublicKey and struct vb2_packed_key that is + * but also the part of VbPublicKey and struct vb21_packed_key that is * referenced by .key_offset) has this binary format: * * struct { diff --git a/host/lib21/host_fw_preamble.c b/host/lib21/host_fw_preamble.c index 6b5686b1..ebe3ce94 100644 --- a/host/lib21/host_fw_preamble.c +++ b/host/lib21/host_fw_preamble.c @@ -14,20 +14,20 @@ #include "host_keyblock2.h" #include "host_misc.h" #include "host_signature2.h" -#include "vb2_common.h" +#include "vb21_common.h" -int vb2_fw_preamble_create(struct vb2_fw_preamble **fp_ptr, - const struct vb2_private_key *signing_key, - const struct vb2_signature **hash_list, - uint32_t hash_count, - uint32_t fw_version, - uint32_t flags, - const char *desc) +int vb21_fw_preamble_create(struct vb21_fw_preamble **fp_ptr, + const struct vb2_private_key *signing_key, + const struct vb21_signature **hash_list, + uint32_t hash_count, + uint32_t fw_version, + uint32_t flags, + const char *desc) { - struct vb2_fw_preamble fp = { - .c.magic = VB2_MAGIC_FW_PREAMBLE, - .c.struct_version_major = VB2_FW_PREAMBLE_VERSION_MAJOR, - .c.struct_version_minor = VB2_FW_PREAMBLE_VERSION_MAJOR, + struct vb21_fw_preamble fp = { + .c.magic = VB21_MAGIC_FW_PREAMBLE, + .c.struct_version_major = VB21_FW_PREAMBLE_VERSION_MAJOR, + .c.struct_version_minor = VB21_FW_PREAMBLE_VERSION_MAJOR, .c.fixed_size = sizeof(fp), .c.desc_size = vb2_desc_size(desc), .flags = flags, @@ -50,7 +50,7 @@ int vb2_fw_preamble_create(struct vb2_fw_preamble **fp_ptr, fp.sig_offset = hash_next; - if (vb2_sig_size_for_key(&sig_size, signing_key, NULL)) + if (vb21_sig_size_for_key(&sig_size, signing_key, NULL)) return VB2_FW_PREAMBLE_CREATE_SIG_SIZE; fp.c.total_size = fp.sig_offset + sig_size; @@ -72,11 +72,11 @@ int vb2_fw_preamble_create(struct vb2_fw_preamble **fp_ptr, } /* Sign the preamble */ - if (vb2_sign_object(buf, fp.sig_offset, signing_key, NULL)) { + if (vb21_sign_object(buf, fp.sig_offset, signing_key, NULL)) { free(buf); return VB2_FW_PREAMBLE_CREATE_SIGN; } - *fp_ptr = (struct vb2_fw_preamble *)buf; + *fp_ptr = (struct vb21_fw_preamble *)buf; return VB2_SUCCESS; } diff --git a/host/lib21/host_key.c b/host/lib21/host_key.c index f7ea1622..c7ded210 100644 --- a/host/lib21/host_key.c +++ b/host/lib21/host_key.c @@ -13,7 +13,7 @@ #include "2common.h" #include "2rsa.h" #include "2sha.h" -#include "vb2_common.h" +#include "vb21_common.h" #include "host_common.h" #include "host_key2.h" #include "host_misc.h" @@ -83,12 +83,12 @@ void vb2_private_key_free(struct vb2_private_key *key) free(key); } -int vb2_private_key_unpack(struct vb2_private_key **key_ptr, - const uint8_t *buf, - uint32_t size) +int vb21_private_key_unpack(struct vb2_private_key **key_ptr, + const uint8_t *buf, + uint32_t size) { - const struct vb2_packed_private_key *pkey = - (const struct vb2_packed_private_key *)buf; + const struct vb21_packed_private_key *pkey = + (const struct vb21_packed_private_key *)buf; struct vb2_private_key *key; const unsigned char *start; uint32_t min_offset = 0; @@ -100,14 +100,14 @@ int vb2_private_key_unpack(struct vb2_private_key **key_ptr, * * TODO: If it doesn't match, pass through to the old packed key format. */ - if (pkey->c.magic != VB2_MAGIC_PACKED_PRIVATE_KEY) + if (pkey->c.magic != VB21_MAGIC_PACKED_PRIVATE_KEY) return VB2_ERROR_UNPACK_PRIVATE_KEY_MAGIC; - if (vb2_verify_common_header(buf, size)) + if (vb21_verify_common_header(buf, size)) return VB2_ERROR_UNPACK_PRIVATE_KEY_HEADER; /* Make sure key data is inside */ - if (vb2_verify_common_member(pkey, &min_offset, + if (vb21_verify_common_member(pkey, &min_offset, pkey->key_offset, pkey->key_size)) return VB2_ERROR_UNPACK_PRIVATE_KEY_DATA; @@ -117,7 +117,7 @@ int vb2_private_key_unpack(struct vb2_private_key **key_ptr, * haven't added any new fields. */ if (pkey->c.struct_version_major != - VB2_PACKED_PRIVATE_KEY_VERSION_MAJOR) + VB21_PACKED_PRIVATE_KEY_VERSION_MAJOR) return VB2_ERROR_UNPACK_PRIVATE_KEY_STRUCT_VERSION; /* Allocate the new key */ @@ -159,8 +159,8 @@ int vb2_private_key_unpack(struct vb2_private_key **key_ptr, return VB2_SUCCESS; } -int vb2_private_key_read(struct vb2_private_key **key_ptr, - const char *filename) +int vb21_private_key_read(struct vb2_private_key **key_ptr, + const char *filename) { uint32_t size = 0; uint8_t *buf; @@ -172,7 +172,7 @@ int vb2_private_key_read(struct vb2_private_key **key_ptr, if (rv) return rv; - rv = vb2_private_key_unpack(key_ptr, buf, size); + rv = vb21_private_key_unpack(key_ptr, buf, size); free(buf); @@ -227,13 +227,13 @@ int vb2_private_key_set_desc(struct vb2_private_key *key, const char *desc) return VB2_SUCCESS; } -int vb2_private_key_write(const struct vb2_private_key *key, - const char *filename) +int vb21_private_key_write(const struct vb2_private_key *key, + const char *filename) { - struct vb2_packed_private_key pkey = { - .c.magic = VB2_MAGIC_PACKED_PRIVATE_KEY, - .c.struct_version_major = VB2_PACKED_PRIVATE_KEY_VERSION_MAJOR, - .c.struct_version_minor = VB2_PACKED_PRIVATE_KEY_VERSION_MINOR, + struct vb21_packed_private_key pkey = { + .c.magic = VB21_MAGIC_PACKED_PRIVATE_KEY, + .c.struct_version_major = VB21_PACKED_PRIVATE_KEY_VERSION_MAJOR, + .c.struct_version_minor = VB21_PACKED_PRIVATE_KEY_VERSION_MINOR, .c.fixed_size = sizeof(pkey), .sig_alg = key->sig_alg, .hash_alg = key->hash_alg, @@ -277,7 +277,7 @@ int vb2_private_key_write(const struct vb2_private_key *key, free(rsabuf); } - rv = vb2_write_object(filename, buf); + rv = vb21_write_object(filename, buf); free(buf); return rv ? VB2_ERROR_PRIVATE_KEY_WRITE_FILE : VB2_SUCCESS; @@ -433,8 +433,8 @@ int vb2_public_key_set_desc(struct vb2_public_key *key, const char *desc) return VB2_SUCCESS; } -int vb2_packed_key_read(struct vb2_packed_key **key_ptr, - const char *filename) +int vb21_packed_key_read(struct vb21_packed_key **key_ptr, + const char *filename) { struct vb2_public_key key; uint8_t *buf; @@ -446,21 +446,21 @@ int vb2_packed_key_read(struct vb2_packed_key **key_ptr, return VB2_ERROR_READ_PACKED_KEY_DATA; /* Sanity check: make sure key unpacks properly */ - if (vb2_unpack_key(&key, buf, size)) + if (vb21_unpack_key(&key, buf, size)) return VB2_ERROR_READ_PACKED_KEY; - *key_ptr = (struct vb2_packed_key *)buf; + *key_ptr = (struct vb21_packed_key *)buf; return VB2_SUCCESS; } -int vb2_public_key_pack(struct vb2_packed_key **key_ptr, - const struct vb2_public_key *pubk) +int vb21_public_key_pack(struct vb21_packed_key **key_ptr, + const struct vb2_public_key *pubk) { - struct vb2_packed_key key = { - .c.magic = VB2_MAGIC_PACKED_KEY, - .c.struct_version_major = VB2_PACKED_KEY_VERSION_MAJOR, - .c.struct_version_minor = VB2_PACKED_KEY_VERSION_MINOR, + struct vb21_packed_key key = { + .c.magic = VB21_MAGIC_PACKED_KEY, + .c.struct_version_major = VB21_PACKED_KEY_VERSION_MAJOR, + .c.struct_version_minor = VB21_PACKED_KEY_VERSION_MINOR, }; uint8_t *buf; uint32_t *buf32; @@ -508,7 +508,7 @@ int vb2_public_key_pack(struct vb2_packed_key **key_ptr, pubk->arrsize * sizeof(uint32_t)); } - *key_ptr = (struct vb2_packed_key *)buf; + *key_ptr = (struct vb21_packed_key *)buf; return VB2_SUCCESS; } @@ -561,17 +561,17 @@ enum vb2_signature_algorithm vb2_rsa_sig_alg(struct rsa_st *rsa) return VB2_SIG_INVALID; } -int vb2_public_key_write(const struct vb2_public_key *key, - const char *filename) +int vb21_public_key_write(const struct vb2_public_key *key, + const char *filename) { - struct vb2_packed_key *pkey; + struct vb21_packed_key *pkey; int ret; - ret = vb2_public_key_pack(&pkey, key); + ret = vb21_public_key_pack(&pkey, key); if (ret) return ret; - ret = vb2_write_object(filename, pkey); + ret = vb21_write_object(filename, pkey); free(pkey); return ret; diff --git a/host/lib21/host_keyblock.c b/host/lib21/host_keyblock.c index 42b91c77..cb8c3127 100644 --- a/host/lib21/host_keyblock.c +++ b/host/lib21/host_keyblock.c @@ -8,30 +8,30 @@ #include "2sysincludes.h" #include "2common.h" #include "2rsa.h" -#include "vb2_common.h" +#include "vb21_common.h" #include "host_common.h" #include "host_key2.h" #include "host_keyblock2.h" #include "host_misc.h" #include "host_signature2.h" -int vb2_keyblock_create(struct vb2_keyblock **kb_ptr, - const struct vb2_public_key *data_key, - const struct vb2_private_key **signing_keys, - uint32_t signing_key_count, - uint32_t flags, - const char *desc) +int vb21_keyblock_create(struct vb21_keyblock **kb_ptr, + const struct vb2_public_key *data_key, + const struct vb2_private_key **signing_keys, + uint32_t signing_key_count, + uint32_t flags, + const char *desc) { - struct vb2_keyblock kb = { - .c.magic = VB2_MAGIC_KEYBLOCK, - .c.struct_version_major = VB2_KEYBLOCK_VERSION_MAJOR, - .c.struct_version_minor = VB2_KEYBLOCK_VERSION_MAJOR, + struct vb21_keyblock kb = { + .c.magic = VB21_MAGIC_KEYBLOCK, + .c.struct_version_major = VB21_KEYBLOCK_VERSION_MAJOR, + .c.struct_version_minor = VB21_KEYBLOCK_VERSION_MAJOR, .c.fixed_size = sizeof(kb), .flags = flags, .sig_count = signing_key_count, }; - struct vb2_packed_key *key = NULL; + struct vb21_packed_key *key = NULL; uint32_t sig_size; uint8_t *buf; @@ -43,10 +43,10 @@ int vb2_keyblock_create(struct vb2_keyblock **kb_ptr, kb.c.desc_size = vb2_desc_size(desc); kb.key_offset = kb.c.fixed_size + kb.c.desc_size; - if (vb2_sig_size_for_keys(&sig_size, signing_keys, signing_key_count)) + if (vb21_sig_size_for_keys(&sig_size, signing_keys, signing_key_count)) return VB2_KEYBLOCK_CREATE_SIG_SIZE; - if (vb2_public_key_pack(&key, data_key)) + if (vb21_public_key_pack(&key, data_key)) return VB2_KEYBLOCK_CREATE_DATA_KEY; kb.sig_offset = kb.key_offset + key->c.total_size; @@ -66,12 +66,12 @@ int vb2_keyblock_create(struct vb2_keyblock **kb_ptr, free(key); /* Sign the keyblock */ - if (vb2_sign_object_multiple(buf, kb.sig_offset, signing_keys, - signing_key_count)) { + if (vb21_sign_object_multiple(buf, kb.sig_offset, signing_keys, + signing_key_count)) { free(buf); return VB2_KEYBLOCK_CREATE_SIGN; } - *kb_ptr = (struct vb2_keyblock *)buf; + *kb_ptr = (struct vb21_keyblock *)buf; return VB2_SUCCESS; } diff --git a/host/lib21/host_misc.c b/host/lib21/host_misc.c index ee9426a6..59c8c0a8 100644 --- a/host/lib21/host_misc.c +++ b/host/lib21/host_misc.c @@ -13,7 +13,7 @@ #include "2sysincludes.h" #include "2common.h" #include "2sha.h" -#include "vb2_common.h" +#include "vb21_common.h" #include "host_common.h" #include "host_misc2.h" @@ -81,9 +81,9 @@ int vb2_write_file(const char *filename, const void *buf, uint32_t size) return VB2_SUCCESS; } -int vb2_write_object(const char *filename, const void *buf) +int vb21_write_object(const char *filename, const void *buf) { - const struct vb2_struct_common *cptr = buf; + const struct vb21_struct_common *cptr = buf; return vb2_write_file(filename, buf, cptr->total_size); } diff --git a/host/lib21/host_signature.c b/host/lib21/host_signature.c index 539a74bc..01f4f326 100644 --- a/host/lib21/host_signature.c +++ b/host/lib21/host_signature.c @@ -11,7 +11,7 @@ #include "2common.h" #include "2rsa.h" #include "2sha.h" -#include "vb2_common.h" +#include "vb21_common.h" #include "host_common.h" #include "host_key2.h" #include "host_signature2.h" @@ -76,16 +76,16 @@ static int vb2_digest_info(enum vb2_hash_algorithm hash_alg, } } -int vb2_sign_data(struct vb2_signature **sig_ptr, - const uint8_t *data, - uint32_t size, - const struct vb2_private_key *key, - const char *desc) +int vb21_sign_data(struct vb21_signature **sig_ptr, + const uint8_t *data, + uint32_t size, + const struct vb2_private_key *key, + const char *desc) { - struct vb2_signature s = { - .c.magic = VB2_MAGIC_SIGNATURE, - .c.struct_version_major = VB2_SIGNATURE_VERSION_MAJOR, - .c.struct_version_minor = VB2_SIGNATURE_VERSION_MINOR, + struct vb21_signature s = { + .c.magic = VB21_MAGIC_SIGNATURE, + .c.struct_version_major = VB21_SIGNATURE_VERSION_MAJOR, + .c.struct_version_minor = VB21_SIGNATURE_VERSION_MINOR, .c.fixed_size = sizeof(s), .sig_alg = key->sig_alg, .hash_alg = key->hash_alg, @@ -176,29 +176,29 @@ int vb2_sign_data(struct vb2_signature **sig_ptr, } free(sig_digest); - *sig_ptr = (struct vb2_signature *)buf; + *sig_ptr = (struct vb21_signature *)buf; return VB2_SUCCESS; } -int vb2_sig_size_for_key(uint32_t *size_ptr, - const struct vb2_private_key *key, - const char *desc) +int vb21_sig_size_for_key(uint32_t *size_ptr, + const struct vb2_private_key *key, + const char *desc) { uint32_t size = vb2_sig_size(key->sig_alg, key->hash_alg); if (!size) return VB2_ERROR_SIG_SIZE_FOR_KEY; - size += sizeof(struct vb2_signature); + size += sizeof(struct vb21_signature); size += vb2_desc_size(desc ? desc : key->desc); *size_ptr = size; return VB2_SUCCESS; } -int vb2_sig_size_for_keys(uint32_t *size_ptr, - const struct vb2_private_key **key_list, - uint32_t key_count) +int vb21_sig_size_for_keys(uint32_t *size_ptr, + const struct vb2_private_key **key_list, + uint32_t key_count) { uint32_t total = 0, size = 0; int rv, i; @@ -206,7 +206,7 @@ int vb2_sig_size_for_keys(uint32_t *size_ptr, *size_ptr = 0; for (i = 0; i < key_count; i++) { - rv = vb2_sig_size_for_key(&size, key_list[i], NULL); + rv = vb21_sig_size_for_key(&size, key_list[i], NULL); if (rv) return rv; total += size; @@ -216,16 +216,16 @@ int vb2_sig_size_for_keys(uint32_t *size_ptr, return VB2_SUCCESS; } -int vb2_sign_object(uint8_t *buf, - uint32_t sig_offset, - const struct vb2_private_key *key, - const char *desc) +int vb21_sign_object(uint8_t *buf, + uint32_t sig_offset, + const struct vb2_private_key *key, + const char *desc) { - struct vb2_struct_common *c = (struct vb2_struct_common *)buf; - struct vb2_signature *sig = NULL; + struct vb21_struct_common *c = (struct vb21_struct_common *)buf; + struct vb21_signature *sig = NULL; int rv; - rv = vb2_sign_data(&sig, buf, sig_offset, key, desc); + rv = vb21_sign_data(&sig, buf, sig_offset, key, desc); if (rv) return rv; @@ -240,19 +240,19 @@ int vb2_sign_object(uint8_t *buf, return VB2_SUCCESS; } -int vb2_sign_object_multiple(uint8_t *buf, - uint32_t sig_offset, - const struct vb2_private_key **key_list, - uint32_t key_count) +int vb21_sign_object_multiple(uint8_t *buf, + uint32_t sig_offset, + const struct vb2_private_key **key_list, + uint32_t key_count) { - struct vb2_struct_common *c = (struct vb2_struct_common *)buf; + struct vb21_struct_common *c = (struct vb21_struct_common *)buf; uint32_t sig_next = sig_offset; int rv, i; for (i = 0; i < key_count; i++) { - struct vb2_signature *sig = NULL; + struct vb21_signature *sig = NULL; - rv = vb2_sign_data(&sig, buf, sig_offset, key_list[i], NULL); + rv = vb21_sign_data(&sig, buf, sig_offset, key_list[i], NULL); if (rv) return rv; diff --git a/host/lib21/include/host_fw_preamble2.h b/host/lib21/include/host_fw_preamble2.h index 9723441f..e759edc5 100644 --- a/host/lib21/include/host_fw_preamble2.h +++ b/host/lib21/include/host_fw_preamble2.h @@ -8,10 +8,9 @@ #ifndef VBOOT_REFERENCE_HOST_FW_PREAMBLE2_H_ #define VBOOT_REFERENCE_HOST_FW_PREAMBLE2_H_ -#include "vb2_struct.h" - struct vb2_private_key; - +struct vb21_fw_preamble; +struct vb21_signature; /** * Create and sign a firmware preamble. * @@ -25,12 +24,12 @@ struct vb2_private_key; * @param desc Description for preamble, or NULL if none * @return VB2_SUCCESS, or non-zero error code if failure. */ -int vb2_fw_preamble_create(struct vb2_fw_preamble **fp_ptr, - const struct vb2_private_key *signing_key, - const struct vb2_signature **hash_list, - uint32_t hash_count, - uint32_t fw_version, - uint32_t flags, - const char *desc); +int vb21_fw_preamble_create(struct vb21_fw_preamble **fp_ptr, + const struct vb2_private_key *signing_key, + const struct vb21_signature **hash_list, + uint32_t hash_count, + uint32_t fw_version, + uint32_t flags, + const char *desc); #endif /* VBOOT_REFERENCE_HOST_FW_PREAMBLE2_H_ */ diff --git a/host/lib21/include/host_key2.h b/host/lib21/include/host_key2.h index 67113c13..7c95ac16 100644 --- a/host/lib21/include/host_key2.h +++ b/host/lib21/include/host_key2.h @@ -11,6 +11,7 @@ #include "2struct.h" struct vb2_public_key; +struct vb21_packed_key; /* Private key data, in-memory format for use in signing calls. */ struct vb2_private_key { @@ -57,7 +58,7 @@ extern struct vb2_text_vs_enum vb2_text_vs_hash[]; void vb2_private_key_free(struct vb2_private_key *key); /** - * Unpack a private key from vb2_packed_private_key format. + * Unpack a private key from vb21_packed_private_key format. * * @param key_ptr Destination for newly allocated key; this must be * freed with vb2_private_key_free(). @@ -65,20 +66,20 @@ void vb2_private_key_free(struct vb2_private_key *key); * @param size Size of buffer in bytes * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_private_key_unpack(struct vb2_private_key **key_ptr, - const uint8_t *buf, - uint32_t size); +int vb21_private_key_unpack(struct vb2_private_key **key_ptr, + const uint8_t *buf, + uint32_t size); /** - * Read a private key from vb2_packed_private_key format. + * Read a private key from vb21_packed_private_key format. * * @param key_ptr Destination for newly allocated key; this must be * freed with vb2_private_key_free(). * @param filename File to read key data from. * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_private_key_read(struct vb2_private_key **key_ptr, - const char *filename); +int vb21_private_key_read(struct vb2_private_key **key_ptr, + const char *filename); /** * Read a private key from a .pem file. @@ -104,14 +105,14 @@ int vb2_private_key_read_pem(struct vb2_private_key **key_ptr, int vb2_private_key_set_desc(struct vb2_private_key *key, const char *desc); /** - * Write a private key to vb2_packed_private_key format. + * Write a private key to vb21_packed_private_key format. * * @param key Key to write * @param filename File to write key data to. * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_private_key_write(const struct vb2_private_key *key, - const char *filename); +int vb21_private_key_write(const struct vb2_private_key *key, + const char *filename); /** * Get a private key for an unsigned hash @@ -150,7 +151,7 @@ uint8_t *vb2_public_key_packed_data(struct vb2_public_key *key); * * Note that this should ONLY be called for public keys allocated via one * of those functions; public keys created or filled in other ways (such as - * vb2_unpack_key()) do not allocate memory for sub-fields in the same way. + * vb21_unpack_key()) do not allocate memory for sub-fields in the same way. * * @param key Key to free */ @@ -182,17 +183,17 @@ int vb2_public_key_read_keyb(struct vb2_public_key **key_ptr, int vb2_public_key_set_desc(struct vb2_public_key *key, const char *desc); /** - * Read a public key in vb2_packed_key format. + * Read a public key in vb21_packed_key format. * * @param key_ptr On success, points to the newly allocated key buffer. * Caller is responsible for calling free() on this. * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_packed_key_read(struct vb2_packed_key **key_ptr, +int vb21_packed_key_read(struct vb21_packed_key **key_ptr, const char *filename); /** - * Pack a public key into vb2_packed_key format. + * Pack a public key into vb21_packed_key format. * * @param pubk Public key to pack * @param key_ptr On success, points to a newly allocated packed key @@ -200,8 +201,8 @@ int vb2_packed_key_read(struct vb2_packed_key **key_ptr, * this. * @return VB2_SUCCESS, or non-zero if error. */ -int vb2_public_key_pack(struct vb2_packed_key **key_ptr, - const struct vb2_public_key *pubk); +int vb21_public_key_pack(struct vb21_packed_key **key_ptr, + const struct vb2_public_key *pubk); /** * Get a public key for an unsigned hash. @@ -223,13 +224,13 @@ int vb2_public_key_hash(struct vb2_public_key *key, enum vb2_signature_algorithm vb2_rsa_sig_alg(struct rsa_st *rsa); /** - * Write a public key to the vb2_packed_key format. + * Write a public key to the vb21_packed_key format. * * @param key Key to write * @param filename File to write key data to. * @return VB2_SUCCESS, or non-zero error code if error. */ -int vb2_public_key_write(const struct vb2_public_key *key, - const char *filename); +int vb21_public_key_write(const struct vb2_public_key *key, + const char *filename); #endif /* VBOOT_REFERENCE_HOST_KEY2_H_ */ diff --git a/host/lib21/include/host_keyblock2.h b/host/lib21/include/host_keyblock2.h index 23d34843..6abfdc98 100644 --- a/host/lib21/include/host_keyblock2.h +++ b/host/lib21/include/host_keyblock2.h @@ -8,10 +8,9 @@ #ifndef VBOOT_REFERENCE_HOST_KEYBLOCK2_H_ #define VBOOT_REFERENCE_HOST_KEYBLOCK2_H_ -#include "2struct.h" - struct vb2_private_key; struct vb2_public_key; +struct vb21_keyblock; /** * Create and sign a keyblock. @@ -26,11 +25,11 @@ struct vb2_public_key; * taken from the data key. * @return VB2_SUCCESS, or non-zero error code if failure. */ -int vb2_keyblock_create(struct vb2_keyblock **kb_ptr, - const struct vb2_public_key *data_key, - const struct vb2_private_key **signing_keys, - uint32_t signing_key_count, - uint32_t flags, - const char *desc); +int vb21_keyblock_create(struct vb21_keyblock **kb_ptr, + const struct vb2_public_key *data_key, + const struct vb2_private_key **signing_keys, + uint32_t signing_key_count, + uint32_t flags, + const char *desc); #endif /* VBOOT_REFERENCE_HOST_KEYBLOCK2_H_ */ diff --git a/host/lib21/include/host_signature2.h b/host/lib21/include/host_signature2.h index aecd6dfc..8eb95ba8 100644 --- a/host/lib21/include/host_signature2.h +++ b/host/lib21/include/host_signature2.h @@ -24,11 +24,11 @@ struct vb2_private_key; * key description will be used. * @return VB2_SUCCESS, or non-zero error code on failure. */ -int vb2_sign_data(struct vb2_signature **sig_ptr, - const uint8_t *data, - uint32_t size, - const struct vb2_private_key *key, - const char *desc); +int vb21_sign_data(struct vb21_signature **sig_ptr, + const uint8_t *data, + uint32_t size, + const struct vb2_private_key *key, + const char *desc); /** * Calculate the signature size for a private key. @@ -39,9 +39,9 @@ int vb2_sign_data(struct vb2_signature **sig_ptr, * key description will be used. * @return VB2_SUCCESS, or non-zero error code on failure. */ -int vb2_sig_size_for_key(uint32_t *size_ptr, - const struct vb2_private_key *key, - const char *desc); +int vb21_sig_size_for_key(uint32_t *size_ptr, + const struct vb2_private_key *key, + const char *desc); /** * Calculate the total signature size for a list of keys. @@ -51,9 +51,9 @@ int vb2_sig_size_for_key(uint32_t *size_ptr, * @param key_count Number of keys. * @return VB2_SUCCESS, or non-zero error code on failure. */ -int vb2_sig_size_for_keys(uint32_t *size_ptr, - const struct vb2_private_key **key_list, - uint32_t key_count); +int vb21_sig_size_for_keys(uint32_t *size_ptr, + const struct vb2_private_key **key_list, + uint32_t key_count); /** * Sign object with a key. @@ -65,10 +65,10 @@ int vb2_sig_size_for_keys(uint32_t *size_ptr, * @param key Key to sign object with * @param desc If non-null, description to use for signature */ -int vb2_sign_object(uint8_t *buf, - uint32_t sig_offset, - const struct vb2_private_key *key, - const char *desc); +int vb21_sign_object(uint8_t *buf, + uint32_t sig_offset, + const struct vb2_private_key *key, + const char *desc); /** * Sign object with list of keys. @@ -80,9 +80,9 @@ int vb2_sign_object(uint8_t *buf, * @param key_list List of keys to sign object with * @param key_count Number of keys in list */ -int vb2_sign_object_multiple(uint8_t *buf, - uint32_t sig_offset, - const struct vb2_private_key **key_list, - uint32_t key_count); +int vb21_sign_object_multiple(uint8_t *buf, + uint32_t sig_offset, + const struct vb2_private_key **key_list, + uint32_t key_count); #endif /* VBOOT_REFERENCE_HOST_SIGNATURE2_H_ */ |