|
Packit Service |
a9384c |
/*
|
|
Packit Service |
a9384c |
* Generic wrapper for storage functions
|
|
Packit Service |
a9384c |
* (experimental only)
|
|
Packit Service |
a9384c |
*
|
|
Packit Service |
a9384c |
* Copyright (C) 2018-2020, Ondrej Kozina
|
|
Packit Service |
a9384c |
*
|
|
Packit Service |
a9384c |
* This file is free software; you can redistribute it and/or
|
|
Packit Service |
a9384c |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
a9384c |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
a9384c |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
a9384c |
*
|
|
Packit Service |
a9384c |
* This file is distributed in the hope that it will be useful,
|
|
Packit Service |
a9384c |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
a9384c |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
a9384c |
* Lesser General Public License for more details.
|
|
Packit Service |
a9384c |
*
|
|
Packit Service |
a9384c |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
a9384c |
* License along with this file; if not, write to the Free Software
|
|
Packit Service |
a9384c |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit Service |
a9384c |
*/
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
#ifndef _UTILS_STORAGE_WRAPPERS_H
|
|
Packit Service |
a9384c |
#define _UTILS_STORAGE_WRAPPERS_H
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
struct crypt_storage_wrapper;
|
|
Packit Service |
a9384c |
struct device;
|
|
Packit Service |
a9384c |
struct volume_key;
|
|
Packit Service |
a9384c |
struct crypt_device;
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
#define DISABLE_USPACE (1 << 0)
|
|
Packit Service |
a9384c |
#define DISABLE_KCAPI (1 << 1)
|
|
Packit Service |
a9384c |
#define DISABLE_DMCRYPT (1 << 2)
|
|
Packit Service |
a9384c |
#define OPEN_READONLY (1 << 3)
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
typedef enum {
|
|
Packit Service |
a9384c |
NONE = 0,
|
|
Packit Service |
a9384c |
USPACE,
|
|
Packit Service |
a9384c |
DMCRYPT
|
|
Packit Service |
a9384c |
} crypt_storage_wrapper_type;
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
int crypt_storage_wrapper_init(struct crypt_device *cd,
|
|
Packit Service |
a9384c |
struct crypt_storage_wrapper **cw,
|
|
Packit Service |
a9384c |
struct device *device,
|
|
Packit Service |
a9384c |
uint64_t data_offset,
|
|
Packit Service |
a9384c |
uint64_t iv_start,
|
|
Packit Service |
a9384c |
int sector_size,
|
|
Packit Service |
a9384c |
const char *cipher,
|
|
Packit Service |
a9384c |
struct volume_key *vk,
|
|
Packit Service |
a9384c |
uint32_t flags);
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
void crypt_storage_wrapper_destroy(struct crypt_storage_wrapper *cw);
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
/* !!! when doing 'read' or 'write' all offset values are RELATIVE to data_offset !!! */
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_read(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_read_decrypt(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_decrypt(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_write(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_encrypt_write(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
ssize_t crypt_storage_wrapper_encrypt(struct crypt_storage_wrapper *cw,
|
|
Packit Service |
a9384c |
off_t offset, void *buffer, size_t buffer_length);
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
int crypt_storage_wrapper_datasync(const struct crypt_storage_wrapper *cw);
|
|
Packit Service |
a9384c |
|
|
Packit Service |
a9384c |
crypt_storage_wrapper_type crypt_storage_wrapper_get_type(const struct crypt_storage_wrapper *cw);
|
|
Packit Service |
a9384c |
#endif
|