Tamas Ban | a00f285 | 2019-01-23 21:46:29 +0000 | [diff] [blame] | 1 | /* |
David Hu | 981ecb6 | 2019-12-05 17:58:29 +0800 | [diff] [blame^] | 2 | * Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Tamas Ban | a00f285 | 2019-01-23 21:46:29 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Tamas Ban | d09c38f | 2019-01-23 22:04:50 +0000 | [diff] [blame] | 8 | #include <stdint.h> |
David Hu | 981ecb6 | 2019-12-05 17:58:29 +0800 | [diff] [blame^] | 9 | #include "platform/include/tfm_attest_hal.h" |
| 10 | #include "platform/include/tfm_plat_boot_seed.h" |
| 11 | |
| 12 | /*! |
| 13 | * \def BOOT_SEED |
| 14 | * |
| 15 | * \brief Fixed value for boot seed used for test. |
| 16 | */ |
| 17 | #define BOOT_SEED 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, \ |
| 18 | 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, \ |
| 19 | 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, \ |
| 20 | 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF |
| 21 | |
| 22 | static const uint8_t boot_seed[BOOT_SEED_SIZE] = {BOOT_SEED}; |
Tamas Ban | d09c38f | 2019-01-23 22:04:50 +0000 | [diff] [blame] | 23 | |
| 24 | /* Example verification service URL for initial attestation token */ |
| 25 | static const char verification_service_url[] = "www.trustedfirmware.org"; |
| 26 | |
| 27 | /* Example profile definition document for initial attestation token */ |
Tamas Ban | 12df1af | 2019-03-01 12:43:12 +0000 | [diff] [blame] | 28 | static const char attestation_profile_definition[] = "PSA_IOT_PROFILE_1"; |
Tamas Ban | a00f285 | 2019-01-23 21:46:29 +0000 | [diff] [blame] | 29 | |
| 30 | enum tfm_security_lifecycle_t tfm_attest_hal_get_security_lifecycle(void) |
| 31 | { |
| 32 | return TFM_SLC_SECURED; |
| 33 | } |
Tamas Ban | d09c38f | 2019-01-23 22:04:50 +0000 | [diff] [blame] | 34 | |
| 35 | const char * |
| 36 | tfm_attest_hal_get_verification_service(uint32_t *size) |
| 37 | { |
| 38 | *size = sizeof(verification_service_url) - 1; |
| 39 | |
| 40 | return verification_service_url; |
| 41 | } |
| 42 | |
| 43 | const char * |
| 44 | tfm_attest_hal_get_profile_definition(uint32_t *size) |
| 45 | { |
| 46 | *size = sizeof(attestation_profile_definition) - 1; |
| 47 | |
| 48 | return attestation_profile_definition; |
| 49 | } |
David Hu | 981ecb6 | 2019-12-05 17:58:29 +0800 | [diff] [blame^] | 50 | |
| 51 | enum tfm_plat_err_t tfm_plat_get_boot_seed(uint32_t size, uint8_t *buf) |
| 52 | { |
| 53 | /* FixMe: - This getter function must be ported per target platform. |
| 54 | * - Platform service shall provide an API to further interact this |
| 55 | * getter function to retrieve the boot seed. |
| 56 | */ |
| 57 | |
| 58 | uint32_t i; |
| 59 | uint8_t *p_dst = buf; |
| 60 | const uint8_t *p_src = boot_seed; |
| 61 | |
| 62 | if (size != BOOT_SEED_SIZE) { |
| 63 | return TFM_PLAT_ERR_SYSTEM_ERR; |
| 64 | } |
| 65 | |
| 66 | for (i = size; i > 0; i--) { |
| 67 | *p_dst = *p_src; |
| 68 | p_src++; |
| 69 | p_dst++; |
| 70 | } |
| 71 | |
| 72 | return TFM_PLAT_ERR_SUCCESS; |
| 73 | } |