14 #ifndef __SEFILE_SYSCALL__
15 #define __SEFILE_SYSCALL__
23 #include "se3/se3c1def.h"
30 #include <sys/types.h>
45 #define SEFILE_READ O_RDONLY
47 #define SEFILE_WRITE O_RDWR
56 #define SEFILE_NEWFILE O_CREAT | O_TRUNC
67 #define SEFILE_BEGIN SEEK_SET
69 #define SEFILE_CURRENT SEEK_CUR
70 #define SEFILE_END SEEK_END
91 #define SEFILE_READ GENERIC_READ
93 #define SEFILE_WRITE GENERIC_READ | GENERIC_WRITE
103 #define SEFILE_NEWFILE CREATE_ALWAYS
105 #define SEFILE_OPEN OPEN_EXISTING
115 #define SEFILE_BEGIN FILE_BEGIN
117 #define SEFILE_CURRENT FILE_CURRENT
118 #define SEFILE_END FILE_END
125 #include <sys/stat.h>
127 #include <sys/types.h>
140 #define SEFILE_READ O_RDONLY
142 #define SEFILE_WRITE O_RDWR
153 #define SEFILE_NEWFILE O_CREAT | O_TRUNC
155 #define SEFILE_OPEN 0
166 #define SEFILE_BEGIN SEEK_SET
168 #define SEFILE_CURRENT SEEK_CUR
169 #define SEFILE_END SEEK_END
174 #define MAX_PATHNAME 256
184 #define SEFILE_ENV_ALREADY_SET 15
186 #define SEFILE_ENV_WRONG_PARAMETER 16
187 #define SEFILE_ENV_MALLOC_ERROR 17
188 #define SEFILE_ENV_NOT_SET 18
189 #define SEFILE_SECTOR_MALLOC_ERR 19
190 #define SEFILE_GET_FILEPOINTER_ERR 20
191 #define SEFILE_HANDLE_MALLOC_ERR 21
192 #define SEFILE_CLOSE_HANDLE_ERR 22
193 #define SEFILE_CREATE_ERROR 23
194 #define SEFILE_OPEN_ERROR 24
195 #define SEFILE_WRITE_ERROR 25
196 #define SEFILE_SEEK_ERROR 26
197 #define SEFILE_READ_ERROR 27
198 #define SEFILE_ILLEGAL_SEEK 28
199 #define SEFILE_FILESIZE_ERROR 29
200 #define SEFILE_BUFFER_MALLOC_ERR 30
201 #define SEFILE_FILENAME_DEC_ERROR 31
202 #define SEFILE_FILENAME_ENC_ERROR 32
203 #define SEFILE_DIRNAME_ENC_ERROR 33
204 #define SEFILE_DIRNAME_DEC_ERROR 34
205 #define SEFILE_DIRNAME_TOO_LONG 35
206 #define SEFILE_MKDIR_ERROR 36
207 #define SEFILE_LS_ERROR 37
208 #define SEFILE_USER_NOT_ALLOWED 38
209 #define SEFILE_ENV_INIT_ERROR 39
210 #define SEFILE_ENV_UPDATE_ERROR 40
211 #define SEFILE_INTEGRITY_ERROR 41
212 #define SEFILE_NAME_NOT_VALID 42
213 #define SEFILE_TRUNCATE_ERROR 43
214 #define SEFILE_DEVICE_SN_MISMATCH 44
215 #define SEFILE_KEYID_NOT_PRESENT 45
216 #define SEFILE_ALGID_NOT_PRESENT 46
217 #define SEFILE_PATH_TOO_LONG 47
218 #define SEFILE_SYNC_ERR 48
219 #define SEFILE_SIGNATURE_MISMATCH 49
232 #ifndef SEFILE_SECTOR_SIZE
234 #define SEFILE_SECTOR_SIZE 512
236 #define SEFILE_SECTOR_DATA_SIZE (SEFILE_SECTOR_SIZE-B5_SHA256_DIGEST_SIZE)
237 //#define SEFILE_SECTOR_DATA_SIZE (SEFILE_SECTOR_SIZE-4)
238 #define SEFILE_BLOCK_SIZE B5_AES_BLK_SIZE
240 #define SEFILE_LOGIC_DATA (SEFILE_SECTOR_DATA_SIZE-2)
242 #define SEFILE_SECTOR_OVERHEAD (SEFILE_SECTOR_SIZE-SEFILE_LOGIC_DATA)
266 uint16_t
secure_init(se3_session *s, uint32_t keyID, uint16_t crypto);
285 uint16_t
secure_update(se3_session *s, int32_t keyID, uint16_t crypto);
307 uint16_t
crypto_filename(
char *path,
char *enc_name, uint16_t *encoded_length);
321 uint16_t
secure_open(
char *path, SEFILE_FHANDLE *hFile, int32_t mode, int32_t access);
334 uint16_t
secure_create(
char *path, SEFILE_FHANDLE *hFile,
int mode);
345 uint16_t
secure_write(SEFILE_FHANDLE *hFile, uint8_t * dataIn, uint32_t dataIn_len);
356 uint16_t
secure_read(SEFILE_FHANDLE *hFile, uint8_t * dataOut, uint32_t dataOut_len, uint32_t * bytesRead);
369 uint16_t
secure_seek(SEFILE_FHANDLE *hFile, int32_t offset, int32_t *position ,uint8_t whence);
401 uint16_t
secure_ls(
char *path,
char *list, uint32_t * list_length);
434 #endif //__SEFILE_SYSCALL__
uint16_t secure_sync(SEFILE_FHANDLE *hFile)
This function is used in case we want to be sure that the physical file is synced with the OS buffers...
Definition: SEfile.c:1833
uint16_t secure_ls(char *path, char *list, uint32_t *list_length)
This function identifies which encrypted files and encrypted directories are present in the directory...
Definition: SEfile.c:1085
uint16_t secure_read(SEFILE_FHANDLE *hFile, uint8_t *dataOut, uint32_t dataOut_len, uint32_t *bytesRead)
This function reads from hFile bytesRead characters out of dataOut_len correctly decrypted ones and s...
Definition: SEfile.c:736
uint16_t secure_write(SEFILE_FHANDLE *hFile, uint8_t *dataIn, uint32_t dataIn_len)
This function writes the characters given by dataIn to the encrypted file hFile. Before writing them...
Definition: SEfile.c:580
uint16_t secure_mkdir(char *path)
This function creates a directory with an encrypted name.
Definition: SEfile.c:1211
The SEFILE_HANDLE struct.
Definition: SEfile.c:24
uint16_t secure_seek(SEFILE_FHANDLE *hFile, int32_t offset, int32_t *position, uint8_t whence)
This function is used to move correctly the file pointer.
Definition: SEfile.c:842
uint16_t secure_getfilesize(char *path, uint32_t *position)
This function is used to get the total logic size of an encrypted file pointed by path...
Definition: SEfile.c:1191
uint16_t secure_update(se3_session *s, int32_t keyID, uint16_t crypto)
This function can be called only after the secure_init() function and give to the user the possibilit...
Definition: SEfile.c:329
uint16_t secure_truncate(SEFILE_FHANDLE *hFile, uint32_t size)
This function resizes the file pointed by hFile to size. If size is bigger than its current size the ...
Definition: SEfile.c:971
uint16_t secure_open(char *path, SEFILE_FHANDLE *hFile, int32_t mode, int32_t creation)
This function opens a secure file and create a SEFILE_FHANDLE that can be used in future...
Definition: SEfile.c:379
uint16_t secure_create(char *path, SEFILE_FHANDLE *hFile, int mode)
This function creates a new secure file and creates a SEFILE_FHANDLE that can be used in future...
Definition: SEfile.c:462
uint16_t secure_finit()
This function deallocate the structures defined by the secure_init(). Should be called at the end of ...
Definition: SEfile.c:364
struct SEFILE_HANDLE * SEFILE_FHANDLE
Definition: SEfile.h:27
uint16_t secure_init(se3_session *s, uint32_t keyID, uint16_t crypto)
This function creates a new secure environment, by allocating statically the parameters needed by the...
Definition: SEfile.c:240
uint16_t crypto_filename(char *path, char *enc_name, uint16_t *encoded_length)
This function computes the encrypted name of the file specified at position path and its length...
Definition: SEfile.c:1280
uint16_t secure_close(SEFILE_FHANDLE *hFile)
This function releases resources related to hFile.
Definition: SEfile.c:1048