| 1 | /* |
| 2 | * QEMU Crypto cipher driver supports |
| 3 | * |
| 4 | * Copyright (c) 2017 HUAWEI TECHNOLOGIES CO., LTD. |
| 5 | * |
| 6 | * Authors: |
| 7 | * Longpeng(Mike) <longpeng2@huawei.com> |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU GPL, version 2 or |
| 10 | * (at your option) any later version. See the COPYING file in the |
| 11 | * top-level directory. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef QCRYPTO_CIPHERPRIV_H |
| 16 | #define QCRYPTO_CIPHERPRIV_H |
| 17 | |
| 18 | #include "qapi/qapi-types-crypto.h" |
| 19 | |
| 20 | struct QCryptoCipherDriver { |
| 21 | int (*cipher_encrypt)(QCryptoCipher *cipher, |
| 22 | const void *in, |
| 23 | void *out, |
| 24 | size_t len, |
| 25 | Error **errp); |
| 26 | |
| 27 | int (*cipher_decrypt)(QCryptoCipher *cipher, |
| 28 | const void *in, |
| 29 | void *out, |
| 30 | size_t len, |
| 31 | Error **errp); |
| 32 | |
| 33 | int (*cipher_setiv)(QCryptoCipher *cipher, |
| 34 | const uint8_t *iv, size_t niv, |
| 35 | Error **errp); |
| 36 | |
| 37 | int (*cipher_setaad)(QCryptoCipher *cipher, |
| 38 | const uint8_t *aad, size_t len, |
| 39 | Error **errp); |
| 40 | |
| 41 | int (*cipher_gettag)(QCryptoCipher *cipher, |
| 42 | uint8_t *tag, size_t len, |
| 43 | Error **errp); |
| 44 | |
| 45 | void (*cipher_free)(QCryptoCipher *cipher); |
| 46 | }; |
| 47 | |
| 48 | #ifdef CONFIG_AF_ALG |
| 49 | |
| 50 | #include "afalgpriv.h" |
| 51 | |
| 52 | extern QCryptoCipher * |
| 53 | qcrypto_afalg_cipher_ctx_new(QCryptoCipherAlgo alg, |
| 54 | QCryptoCipherMode mode, |
| 55 | const uint8_t *key, |
| 56 | size_t nkey, Error **errp); |
| 57 | |
| 58 | #endif |
| 59 | |
| 60 | #endif |