@@ -334,6 +334,13 @@ static int cryptodev_builtin_sym_operation(
return -VIRTIO_CRYPTO_NOTSUPP;
}
+ if (op_info->op_code != VIRTIO_CRYPTO_CIPHER_ENCRYPT &&
+ op_info->op_code != VIRTIO_CRYPTO_CIPHER_DECRYPT) {
+ error_setg(errp,
+ "Unsupported op code: %u", op_info->op_code);
+ return -VIRTIO_CRYPTO_NOTSUPP;
+ }
+
sess = builtin->sessions[op_info->session_id];
if (op_info->iv_len > 0) {
@@ -103,6 +103,7 @@ typedef struct CryptoDevBackendSymSessionInfo {
*
* @session_id: session index which was previously
* created by cryptodev_backend_sym_create_session()
+ * @op_code: operation code (refer to virtio_crypto.h)
* @aad_len: byte length of additional authenticated data
* @iv_len: byte length of initialization vector or counter
* @src_len: byte length of source data
@@ -129,6 +130,8 @@ typedef struct CryptoDevBackendSymSessionInfo {
*/
typedef struct CryptoDevBackendSymOpInfo {
uint64_t session_id;
+ /* corresponding with virtio crypto spec */
+ uint32_t op_code;
uint32_t aad_len;
uint32_t iv_len;
uint32_t src_len;
We need the op_code to identify which of crypto operations for stateless crypto operation. Let's add it. Signed-off-by: Gonglei <arei.gonglei@huawei.com> --- backends/cryptodev-builtin.c | 7 +++++++ include/sysemu/cryptodev.h | 3 +++ 2 files changed, 10 insertions(+)