tpm2-tss  master
TPM Software stack 2.0 TCG spec compliant implementation
ifapi_io.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*******************************************************************************
3  * Copyright 2018-2019, Fraunhofer SIT sponsored by Infineon Technologies AG
4  * All rights reserved.
5  ******************************************************************************/
6 
7 #ifndef IFAPI_IO_H
8 #define IFAPI_IO_H
9 
10 #include <stdbool.h> // for bool
11 #include <stdint.h> // for uint8_t
12 #include <stdio.h> // for size_t, FILE
13 
14 #include "tss2_common.h" // for TSS2_RC
15 #include "tss2_fapi.h" // for FAPI_POLL_HANDLE
16 
17 typedef struct IFAPI_IO {
18  FILE *stream;
19  short pollevents;
20  const char *char_buffer;
21  char *char_rbuffer;
22  size_t buffer_length;
23  size_t buffer_idx;
24 } IFAPI_IO;
25 
26 #ifdef TEST_FAPI_ASYNC
27 #define _IFAPI_IO_RETRIES 1
28 #else /* TEST_FAPI_ASYNC */
29 #define IFAPI_IO_RETRIES 0
30 #endif /* TEST_FAPI_ASYNC */
31 
32 static int ifapi_io_retry __attribute__((unused)) = IFAPI_IO_RETRIES;
33 
34 #define IFAPI_IO_STREAM context->io.stream
35 #define IFAPI_IO_BUFF context->io.char_buffer
36 #define IFAPI_IO_RBUFF context->io.char_rbuffer
37 #define IFAPI_IO_BUFFLEN context->io.buffer_length
38 #define IFAPI_IO_BUFFIDX context->io.buffer_idx
39 
40 TSS2_RC
41 ifapi_io_read_async(struct IFAPI_IO *io, const char *filename);
42 
43 TSS2_RC
44 ifapi_io_read_finish(struct IFAPI_IO *io, uint8_t **buffer, size_t *length);
45 
46 TSS2_RC
48  const char *filename,
49  const uint8_t *buffer,
50  size_t length);
51 
52 TSS2_RC
54 
55 TSS2_RC
56 ifapi_io_check_file_writeable(const char *file);
57 
58 TSS2_RC
59 ifapi_io_check_create_dir(const char *dirname, int mode);
60 
61 TSS2_RC
62 ifapi_io_remove_file(const char *file);
63 
64 TSS2_RC
65 ifapi_io_remove_directories(const char *dirname, const char *keystore_path, const char *sub_dir);
66 
67 TSS2_RC
68 ifapi_io_dirfiles(const char *dirname, char ***files, size_t *numfiles);
69 
70 TSS2_RC
71 ifapi_io_dirfiles_all(const char *searchPath, char ***pathlist, size_t *numPaths);
72 
73 bool ifapi_io_path_exists(const char *path);
74 
75 TSS2_RC
77 
78 TSS2_RC
79 ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles);
80 
81 #endif /* IFAPI_IO_H */
TSS2_RC ifapi_io_dirfiles_all(const char *searchPath, char ***pathlist, size_t *numPaths)
Definition: ifapi_io.c:667
TSS2_RC ifapi_io_poll(IFAPI_IO *io)
Definition: ifapi_io.c:732
TSS2_RC ifapi_io_write_finish(struct IFAPI_IO *io)
Definition: ifapi_io.c:313
TSS2_RC ifapi_io_dirfiles(const char *dirname, char ***files, size_t *numfiles)
Definition: ifapi_io.c:510
TSS2_RC ifapi_io_write_async(struct IFAPI_IO *io, const char *filename, const uint8_t *buffer, size_t length)
Definition: ifapi_io.c:241
TSS2_RC ifapi_io_check_file_writeable(const char *file)
Definition: ifapi_io.c:351
TSS2_RC ifapi_io_read_finish(struct IFAPI_IO *io, uint8_t **buffer, size_t *length)
Definition: ifapi_io.c:186
TSS2_RC ifapi_io_poll_handles(IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles)
Definition: ifapi_io.c:762
TSS2_RC ifapi_io_remove_file(const char *file)
Definition: ifapi_io.c:399
TSS2_RC ifapi_io_read_async(struct IFAPI_IO *io, const char *filename)
Definition: ifapi_io.c:106
bool ifapi_io_path_exists(const char *path)
Definition: ifapi_io.c:712
Definition: ifapi_io.h:17