afalgpriv.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * QEMU Crypto af_alg support
  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. #ifndef QCRYPTO_AFALGPRIV_H
  14. #define QCRYPTO_AFALGPRIV_H
  15. #include <linux/if_alg.h>
  16. #define SALG_TYPE_LEN_MAX 14
  17. #define SALG_NAME_LEN_MAX 64
  18. #ifndef SOL_ALG
  19. #define SOL_ALG 279
  20. #endif
  21. #define AFALG_TYPE_CIPHER "skcipher"
  22. #define AFALG_TYPE_HASH "hash"
  23. #define ALG_OPTYPE_LEN 4
  24. #define ALG_MSGIV_LEN(len) (sizeof(struct af_alg_iv) + (len))
  25. typedef struct QCryptoAFAlg QCryptoAFAlg;
  26. struct QCryptoAFAlg {
  27. int tfmfd;
  28. int opfd;
  29. struct msghdr *msg;
  30. struct cmsghdr *cmsg;
  31. };
  32. /**
  33. * qcrypto_afalg_comm_alloc:
  34. * @type: the type of crypto operation
  35. * @name: the name of crypto operation
  36. *
  37. * Allocate a QCryptoAFAlg object and bind itself to
  38. * a AF_ALG socket.
  39. *
  40. * Returns:
  41. * a new QCryptoAFAlg object, or NULL in error.
  42. */
  43. QCryptoAFAlg *
  44. qcrypto_afalg_comm_alloc(const char *type, const char *name,
  45. Error **errp);
  46. /**
  47. * afalg_comm_free:
  48. * @afalg: the QCryptoAFAlg object
  49. *
  50. * Free the @afalg.
  51. */
  52. void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
  53. #endif