1 /* 2 * Copyright 2024 The ChromiumOS Authors 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef __GSC_UTILS_BOOT_PARAM_PLATFORM_H 8 #define __GSC_UTILS_BOOT_PARAM_PLATFORM_H 9 10 #include "boot_param_types.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 /* Perform HKDF-SHA256(ikm, salt, info) */ 17 bool __platform_hkdf_sha256( 18 /* [IN] input key material */ 19 const struct slice_ref_s ikm, 20 /* [IN] salt */ 21 const struct slice_ref_s salt, 22 /* [IN] info */ 23 const struct slice_ref_s info, 24 /* [IN/OUT] .size sets length for hkdf, 25 * .data is where the digest will be placed 26 */ 27 const struct slice_mut_s result 28 ); 29 30 /* Calculate SH256 for the provided buffer */ 31 bool __platform_sha256( 32 /* [IN] data to hash */ 33 const struct slice_ref_s data, 34 /* [OUT] resulting digest */ 35 uint8_t digest[DIGEST_BYTES] 36 ); 37 38 /* Get DICE config */ 39 bool __platform_get_dice_config( 40 /* [OUT] DICE config */ 41 struct dice_config_s *cfg 42 ); 43 44 /* Get GSC boot parameters */ 45 bool __platform_get_gsc_boot_param( 46 /* [OUT] early entropy */ 47 uint8_t early_entropy[EARLY_ENTROPY_BYTES], 48 /* [OUT] SessionKeySeed */ 49 uint8_t session_key_seed[KEY_SEED_BYTES], 50 /* [OUT] AuthTokenKeySeed */ 51 uint8_t auth_token_key_seed[KEY_SEED_BYTES] 52 ); 53 54 /* Generate ECDSA P-256 key using HMAC-DRBG initialized by the seed */ 55 bool __platform_ecdsa_p256_keygen_hmac_drbg( 56 /* [IN] key seed */ 57 const uint8_t seed[DIGEST_BYTES], 58 /* [OUT] ECDSA key handle */ 59 const void **key 60 ); 61 62 /* Generate ECDSA P-256 signature: 64 bytes (R | S) */ 63 bool __platform_ecdsa_p256_sign( 64 /* [IN] ECDSA key handle */ 65 const void *key, 66 /* [IN] data to sign */ 67 const struct slice_ref_s data, 68 /* [OUT] resulting signature */ 69 uint8_t signature[ECDSA_SIG_BYTES] 70 ); 71 72 /* Get ECDSA public key X, Y */ 73 bool __platform_ecdsa_p256_get_pub_key( 74 /* [IN] ECDSA key handle */ 75 const void *key, 76 /* [OUT] public key structure */ 77 struct ecdsa_public_s *pub_key 78 ); 79 80 /* Free ECDSA key handle */ 81 void __platform_ecdsa_p256_free( 82 /* [IN] ECDSA key handle */ 83 const void *key 84 ); 85 86 /* Check if APROV status allows making 'normal' boot mode decision */ 87 bool __platform_aprov_status_allows_normal( 88 /* [IN] APROV status */ 89 uint32_t aprov_status 90 ); 91 92 /* Print error string to log */ 93 void __platform_log_str( 94 /* [IN] string to print */ 95 const char *str 96 ); 97 98 /* memcpy */ 99 void __platform_memcpy(void *dest, const void *src, size_t size); 100 101 /* memset */ 102 void __platform_memset(void *dest, uint8_t fill, size_t size); 103 104 /* memcmp */ 105 int __platform_memcmp(const void *str1, const void *str2, size_t size); 106 107 #ifdef __cplusplus 108 } /* extern "C" */ 109 #endif 110 111 #endif /* __GSC_UTILS_BOOT_PARAM_PLATFORM_H */ 112