summary refs log tree commit diff stats
path: root/crypto/block.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2018-12-07 19:13:50 +0300
committerDaniel P. Berrangé <berrange@redhat.com>2018-12-12 11:16:49 +0000
commit0f0d596cb16a43314c8bc4a9afa2f966203fb05f (patch)
treee8ea8ed66f59c74dc717ee8b34fc019b9a3085f0 /crypto/block.c
parent0270417c87d330243eb713a3312ea5e39e192994 (diff)
downloadfocaccia-qemu-0f0d596cb16a43314c8bc4a9afa2f966203fb05f.tar.gz
focaccia-qemu-0f0d596cb16a43314c8bc4a9afa2f966203fb05f.zip
crypto/block: introduce qcrypto_block_*crypt_helper functions
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 <vsementsov@virtuozzo.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'crypto/block.c')
-rw-r--r--crypto/block.c28
1 files changed, 28 insertions, 0 deletions
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);
+}