laurenw-arm | 4fc77a7 | 2022-08-11 15:29:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef RSS_PLATFORM_API_H |
| 9 | #define RSS_PLATFORM_API_H |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | |
| 13 | #include "psa/error.h" |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 14 | #include <rss_crypto_defs.h> |
laurenw-arm | 4fc77a7 | 2022-08-11 15:29:56 -0500 | [diff] [blame] | 15 | |
| 16 | #define RSS_PLATFORM_API_ID_NV_READ (1010) |
| 17 | #define RSS_PLATFORM_API_ID_NV_INCREMENT (1011) |
| 18 | |
| 19 | /* |
| 20 | * Increments the given non-volatile (NV) counter by one |
| 21 | * |
| 22 | * counter_id NV counter ID. |
| 23 | * |
| 24 | * PSA_SUCCESS if the value is read correctly. Otherwise, |
| 25 | * it returns a PSA_ERROR. |
| 26 | */ |
| 27 | psa_status_t |
| 28 | rss_platform_nv_counter_increment(uint32_t counter_id); |
| 29 | |
| 30 | /* |
| 31 | * Reads the given non-volatile (NV) counter |
| 32 | * |
| 33 | * counter_id NV counter ID. |
| 34 | * size Size of the buffer to store NV counter value |
| 35 | * in bytes. |
| 36 | * val Pointer to store the current NV counter value. |
| 37 | * |
| 38 | * PSA_SUCCESS if the value is read correctly. Otherwise, |
| 39 | * it returns a PSA_ERROR. |
| 40 | */ |
| 41 | psa_status_t |
| 42 | rss_platform_nv_counter_read(uint32_t counter_id, |
| 43 | uint32_t size, uint8_t *val); |
| 44 | |
laurenw-arm | 6c4d041 | 2023-06-13 16:40:51 -0500 | [diff] [blame] | 45 | /* |
| 46 | * Reads the public key or the public part of a key pair in binary format. |
| 47 | * |
| 48 | * key Identifier of the key to export. |
| 49 | * data Buffer where the key data is to be written. |
| 50 | * data_size Size of the data buffer in bytes. |
| 51 | * data_length On success, the number of bytes that make up the key data. |
| 52 | * |
| 53 | * PSA_SUCCESS if the value is read correctly. Otherwise, |
| 54 | * it returns a PSA_ERROR. |
| 55 | */ |
| 56 | psa_status_t |
| 57 | rss_platform_key_read(enum rss_key_id_builtin_t key, uint8_t *data, |
| 58 | size_t data_size, size_t *data_length); |
| 59 | |
laurenw-arm | 4fc77a7 | 2022-08-11 15:29:56 -0500 | [diff] [blame] | 60 | #endif /* RSS_PLATFORM_API_H */ |