diff options
author | Pascal Brand <pascal.brand@st.com> | 2016-02-16 16:59:42 +0100 |
---|---|---|
committer | Pascal Brand <pascal.brand@st.com> | 2016-02-22 09:08:16 +0100 |
commit | 9161df5004527bdc9616dd4956c972a50893dc95 (patch) | |
tree | 3d09bf436190bf675312499aba37cd91bcc08ec8 /core/arch/arm/plat-vexpress | |
parent | 41d714301703bb2e26fe4cd9a6049330972640d8 (diff) |
Properties: Adding Microsoft specific property
As an example on how to add vendor specific properties,
the microsoft specific property is added.
Original pull-request is
https://github.com/OP-TEE/optee_os/pull/460
Suggested-by: Paul Swan <paswan@microsoft.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Pascal Brand <pascal.brand@linaro.org> (QEMU)
Signed-off-by: Pascal Brand <pascal.brand@st.com>
Diffstat (limited to 'core/arch/arm/plat-vexpress')
-rw-r--r-- | core/arch/arm/plat-vexpress/sub.mk | 1 | ||||
-rw-r--r-- | core/arch/arm/plat-vexpress/vendor_props.c | 91 |
2 files changed, 92 insertions, 0 deletions
diff --git a/core/arch/arm/plat-vexpress/sub.mk b/core/arch/arm/plat-vexpress/sub.mk index 4c5aacce..086f539f 100644 --- a/core/arch/arm/plat-vexpress/sub.mk +++ b/core/arch/arm/plat-vexpress/sub.mk @@ -4,3 +4,4 @@ ifeq ($(PLATFORM_FLAVOR_juno),y) srcs-$(CFG_ARM32_core) += juno_core_pos_a32.S srcs-$(CFG_ARM64_core) += juno_core_pos_a64.S endif +srcs-y += vendor_props.c diff --git a/core/arch/arm/plat-vexpress/vendor_props.c b/core/arch/arm/plat-vexpress/vendor_props.c new file mode 100644 index 00000000..5d9c858f --- /dev/null +++ b/core/arch/arm/plat-vexpress/vendor_props.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, Linaro Limited. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include <tee/tee_svc.h> +#include <user_ta_header.h> +#include <util.h> +#include <kernel/tee_ta_manager.h> +#include <kernel/tee_common_otp.h> +#include <tee/tee_cryp_utl.h> + +/* + * The data to hash is 48 bytes made up of: + * - 16 bytes: the UUID of the calling TA. + * - 32 bytes: the hardware device ID + * The resulting endorsement seed is 32 bytes. + * + * The output buffer is the "binary" struct defined in + * the "prop_value" union and therefore comprises: + * - 4 bytes: the size of the binary value data (32) + * - 32 bytes: the binary value data (endorsement seed) + * + * Note that this code assumes an endorsement seed + * size == device ID size for convenience. + */ +static TEE_Result get_prop_endorsement(struct tee_ta_session *sess, + void *buf, size_t *blen) +{ + TEE_Result res; + uint32_t ta_endorsement_seed_size = 32; + uint8_t data[sizeof(TEE_UUID) + ta_endorsement_seed_size]; + uint32_t bin[1 + ta_endorsement_seed_size / sizeof(uint32_t)]; + uint32_t *bin_len = (uint32_t *)bin; + uint8_t *bin_val = (uint8_t *)(&bin[1]); + + if (*blen < sizeof(bin)) { + *blen = sizeof(bin); + return TEE_ERROR_SHORT_BUFFER; + } + *blen = sizeof(bin); + + memcpy(data, &sess->ctx->uuid, sizeof(TEE_UUID)); + + if (tee_otp_get_die_id(&data[sizeof(TEE_UUID)], + ta_endorsement_seed_size)) + return TEE_ERROR_BAD_STATE; + + res = tee_hash_createdigest(TEE_ALG_SHA256, data, sizeof(data), + bin_val, ta_endorsement_seed_size); + if (res != TEE_SUCCESS) + return TEE_ERROR_BAD_STATE; + + *bin_len = ta_endorsement_seed_size; + + return tee_svc_copy_to_user(sess, (void *)buf, bin, sizeof(bin)); +} + +static const struct tee_props vendor_propset_array_tee[] = { + { + .name = "com.microsoft.ta.endorsementSeed", + .prop_type = USER_TA_PROP_TYPE_BINARY_BLOCK, + .get_prop_func = get_prop_endorsement + }, +}; + +const struct tee_vendor_props vendor_props_tee = { + .props = vendor_propset_array_tee, + .len = ARRAY_SIZE(vendor_propset_array_tee), +}; |