xref: /openbmc/qemu/crypto/akcipherpriv.h (revision 2f95279a)
1 /*
2  * QEMU Crypto asymmetric algorithms
3  *
4  * Copyright (c) 2022 Bytedance
5  * Author: zhenwei pi <pizhenwei@bytedance.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef QCRYPTO_AKCIPHERPRIV_H
23 #define QCRYPTO_AKCIPHERPRIV_H
24 
25 #include "qapi/qapi-types-crypto.h"
26 
27 typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
28 
29 struct QCryptoAkCipher {
30     QCryptoAkCipherAlgorithm alg;
31     QCryptoAkCipherKeyType type;
32     int max_plaintext_len;
33     int max_ciphertext_len;
34     int max_signature_len;
35     int max_dgst_len;
36     QCryptoAkCipherDriver *driver;
37 };
38 
39 struct QCryptoAkCipherDriver {
40     int (*encrypt)(QCryptoAkCipher *akcipher,
41                    const void *in, size_t in_len,
42                    void *out, size_t out_len, Error **errp);
43     int (*decrypt)(QCryptoAkCipher *akcipher,
44                    const void *out, size_t out_len,
45                    void *in, size_t in_len, Error **errp);
46     int (*sign)(QCryptoAkCipher *akcipher,
47                 const void *in, size_t in_len,
48                 void *out, size_t out_len, Error **errp);
49     int (*verify)(QCryptoAkCipher *akcipher,
50                   const void *in, size_t in_len,
51                   const void *in2, size_t in2_len, Error **errp);
52     void (*free)(QCryptoAkCipher *akcipher);
53 };
54 
55 #endif /* QCRYPTO_AKCIPHER_H */
56