2 * QEMU Crypto block device encryption
4 * Copyright (c) 2015-2016 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef QCRYPTO_BLOCKPRIV_H
22 #define QCRYPTO_BLOCKPRIV_H
24 #include "crypto/block.h"
26 typedef struct QCryptoBlockDriver QCryptoBlockDriver
;
29 QCryptoBlockFormat format
;
31 const QCryptoBlockDriver
*driver
;
34 QCryptoCipher
*cipher
;
36 QCryptoHashAlgorithm kdfhash
;
38 uint64_t payload_offset
; /* In bytes */
41 struct QCryptoBlockDriver
{
42 int (*open
)(QCryptoBlock
*block
,
43 QCryptoBlockOpenOptions
*options
,
44 const char *optprefix
,
45 QCryptoBlockReadFunc readfunc
,
50 int (*create
)(QCryptoBlock
*block
,
51 QCryptoBlockCreateOptions
*options
,
52 const char *optprefix
,
53 QCryptoBlockInitFunc initfunc
,
54 QCryptoBlockWriteFunc writefunc
,
58 int (*get_info
)(QCryptoBlock
*block
,
59 QCryptoBlockInfo
*info
,
62 void (*cleanup
)(QCryptoBlock
*block
);
64 int (*encrypt
)(QCryptoBlock
*block
,
69 int (*decrypt
)(QCryptoBlock
*block
,
75 bool (*has_format
)(const uint8_t *buf
,
80 int qcrypto_block_decrypt_helper(QCryptoCipher
*cipher
,
89 int qcrypto_block_encrypt_helper(QCryptoCipher
*cipher
,
98 #endif /* QCRYPTO_BLOCKPRIV_H */