akcipherpriv.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #ifndef QCRYPTO_AKCIPHERPRIV_H
  22. #define QCRYPTO_AKCIPHERPRIV_H
  23. #include "qapi/qapi-types-crypto.h"
  24. typedef struct QCryptoAkCipherDriver QCryptoAkCipherDriver;
  25. struct QCryptoAkCipher {
  26. QCryptoAkCipherAlgorithm alg;
  27. QCryptoAkCipherKeyType type;
  28. int max_plaintext_len;
  29. int max_ciphertext_len;
  30. int max_signature_len;
  31. int max_dgst_len;
  32. QCryptoAkCipherDriver *driver;
  33. };
  34. struct QCryptoAkCipherDriver {
  35. int (*encrypt)(QCryptoAkCipher *akcipher,
  36. const void *in, size_t in_len,
  37. void *out, size_t out_len, Error **errp);
  38. int (*decrypt)(QCryptoAkCipher *akcipher,
  39. const void *out, size_t out_len,
  40. void *in, size_t in_len, Error **errp);
  41. int (*sign)(QCryptoAkCipher *akcipher,
  42. const void *in, size_t in_len,
  43. void *out, size_t out_len, Error **errp);
  44. int (*verify)(QCryptoAkCipher *akcipher,
  45. const void *in, size_t in_len,
  46. const void *in2, size_t in2_len, Error **errp);
  47. void (*free)(QCryptoAkCipher *akcipher);
  48. };
  49. #endif /* QCRYPTO_AKCIPHER_H */