|
| 1 | +/* SPDX-License-Identifier: BSD-2-Clause */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2026, Vaisala Oyj. |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef ASTEEC_H |
| 7 | +#define ASTEEC_H |
| 8 | + |
| 9 | +#include <stddef.h> |
| 10 | +#include <stdint.h> |
| 11 | +#include <sys/types.h> |
| 12 | +#include <tee_client_api.h> |
| 13 | + |
| 14 | +#ifdef __cplusplus |
| 15 | +extern "C" { |
| 16 | +#endif |
| 17 | + |
| 18 | +/** |
| 19 | + * asteec_seal() - Seal secret using hardware unique TA specific key |
| 20 | + * |
| 21 | + * @param login_method Login method such as TEEC_LOGIN_PUBLIC or TEEC_LOGIN_GROUP |
| 22 | + * @param login_gid Group ID, used with TEEC_LOGIN_GROUP and |
| 23 | + * TEEC_LOGIN_GROUP_APPLICATION methods |
| 24 | + * @param plain Pointer to plain secret |
| 25 | + * @param plain_len Byte length of plain secret |
| 26 | + * @param sealed Pointer to buffer to receive sealed secret datablob. |
| 27 | + * May be NULL when *sealed_len is 0 to query the |
| 28 | + * required output size. |
| 29 | + * @param sealed_len On input, byte length of buffer @sealed. On output, |
| 30 | + * updated with the actual size on success or the required |
| 31 | + * size when TEEC_ERROR_SHORT_BUFFER is returned. |
| 32 | + * |
| 33 | + * @return TEEC_SUCCESS on success, TEEC_ERROR_* on failure |
| 34 | + */ |
| 35 | +TEEC_Result asteec_seal(uint32_t login_method, gid_t login_gid, |
| 36 | + const void *plain, size_t plain_len, |
| 37 | + void *sealed, size_t *sealed_len); |
| 38 | + |
| 39 | +/** |
| 40 | + * asteec_unseal() - Unseal secret using hardware unique TA specific key |
| 41 | + * |
| 42 | + * @param login_method Login method such as TEEC_LOGIN_PUBLIC or TEEC_LOGIN_GROUP |
| 43 | + * @param login_gid Group ID, used with TEEC_LOGIN_GROUP and |
| 44 | + * TEEC_LOGIN_GROUP_APPLICATION methods |
| 45 | + * @param sealed Pointer to sealed secret datablob |
| 46 | + * @param sealed_len Byte length of sealed secret datablob |
| 47 | + * @param plain Pointer to buffer to receive plain secret. |
| 48 | + * May be NULL when *plain_len is 0 to query the |
| 49 | + * required output size. |
| 50 | + * @param plain_len On input, byte length of buffer @plain. On output, |
| 51 | + * updated with the actual size on success or the required |
| 52 | + * size when TEEC_ERROR_SHORT_BUFFER is returned. |
| 53 | + * |
| 54 | + * @return TEEC_SUCCESS on success, TEEC_ERROR_* on failure |
| 55 | + */ |
| 56 | +TEEC_Result asteec_unseal(uint32_t login_method, gid_t login_gid, |
| 57 | + const void *sealed, size_t sealed_len, |
| 58 | + void *plain, size_t *plain_len); |
| 59 | + |
| 60 | +#ifdef __cplusplus |
| 61 | +} |
| 62 | +#endif |
| 63 | + |
| 64 | +#endif /* ASTEEC_H */ |
0 commit comments