From 0f0d596cb16a43314c8bc4a9afa2f966203fb05f Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Fri, 7 Dec 2018 19:13:50 +0300 Subject: crypto/block: introduce qcrypto_block_*crypt_helper functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce QCryptoBlock-based functions and use them where possible. This is needed to implement thread-safe encrypt/decrypt operations. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Alberto Garcia Signed-off-by: Daniel P. Berrangé --- crypto/block.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crypto/block.c') diff --git a/crypto/block.c b/crypto/block.c index d43139dbc7..3fe3de2ef8 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -277,3 +277,31 @@ int qcrypto_block_cipher_encrypt_helper(QCryptoCipher *cipher, offset, buf, len, qcrypto_cipher_encrypt, errp); } + + +int qcrypto_block_decrypt_helper(QCryptoBlock *block, + int sectorsize, + uint64_t offset, + uint8_t *buf, + size_t len, + Error **errp) +{ + return do_qcrypto_block_cipher_encdec(block->cipher, block->niv, + block->ivgen, + sectorsize, offset, buf, len, + qcrypto_cipher_decrypt, errp); +} + + +int qcrypto_block_encrypt_helper(QCryptoBlock *block, + int sectorsize, + uint64_t offset, + uint8_t *buf, + size_t len, + Error **errp) +{ + return do_qcrypto_block_cipher_encdec(block->cipher, block->niv, + block->ivgen, + sectorsize, offset, buf, len, + qcrypto_cipher_encrypt, errp); +} -- cgit v1.2.3