diff options
author | David Zeuthen <zeuthen@google.com> | 2016-03-23 16:04:05 -0400 |
---|---|---|
committer | David Zeuthen <zeuthen@google.com> | 2016-03-23 16:04:05 -0400 |
commit | ae8b123b5edb8c8e4446311c8735351619450107 (patch) | |
tree | 93ca6a9a54d12ec0eee430e77c2c1db0d4402abb /refimpl/bvb_property.h | |
parent | 67423cff39d7bd5f7d6402ad21c5a26643a3bb10 (diff) | |
download | bvb-ae8b123b5edb8c8e4446311c8735351619450107.tar.gz |
bvb_refimpl: Move library code to refimpl/ sub-directory.
This makes it easier to see exactly which files belong to the reference
implementation.
BUG=None
TEST=Code builds and unit tests pass.
Change-Id: Iebcc603985847c2f0af9df76396da138438edbef
Diffstat (limited to 'refimpl/bvb_property.h')
-rw-r--r-- | refimpl/bvb_property.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/refimpl/bvb_property.h b/refimpl/bvb_property.h new file mode 100644 index 0000000..d105e3e --- /dev/null +++ b/refimpl/bvb_property.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if !defined (BVB_INSIDE_BVB_REFIMPL_H) && !defined (BVB_REFIMPL_COMPILATION) +#error "Never include this file directly, include bvb_refimpl.h instead." +#endif + +#ifndef BVB_PROPERTY_H_ +#define BVB_PROPERTY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "bvb_boot_image_header.h" + +/* Convenience function for looking up the value for a property with + * name |key| in a Brillo boot image. If |key| is NUL-terminated, + * |key_size| may be set to 0. + * + * The |image_data| parameter must be a pointer to a Brillo Boot Image + * of size |image_size|. + * + * This function returns a pointer to the value inside the passed-in + * image or NULL if not found. Note that the value is always + * guaranteed to be followed by a NUL byte. + * + * If the value was found and |out_value_size| is not NULL, the size + * of the value is returned there. + * + * This function is O(n) in number of properties so if you need to + * look up a lot of values, you may want to build a more efficient + * lookup-table by manually walking all properties yourself. + * + * Before using this function, you MUST verify |image_data| with + * bvb_verify_boot_image() and reject it unless it's signed by a known + * good public key. + */ +const char* bvb_lookup_property(const uint8_t* image_data, size_t image_size, + const char* key, size_t key_size, + size_t* out_value_size); + +/* Like bvb_lookup_property() but parses the value as an unsigned + * 64-bit integer. Both decimal and hexadecimal representations + * (e.g. "0x2a") are supported. Returns 0 on failure and non-zero on + * success. On success, the parsed value is returned in |out_value|. + */ +int bvb_lookup_property_uint64(const uint8_t* image_data, size_t image_size, + const char* key, size_t key_size, + uint64_t* out_value); + +#ifdef __cplusplus +} +#endif + +#endif /* BVB_PROPERTY_H_ */ |