cryptouser.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Crypto user configuration API.
  4. *
  5. * Copyright (C) 2011 secunet Security Networks AG
  6. * Copyright (C) 2011 Steffen Klassert <steffen.klassert@secunet.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along with
  18. * this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  20. */
  21. #include <linux/types.h>
  22. /* Netlink configuration messages. */
  23. enum {
  24. CRYPTO_MSG_BASE = 0x10,
  25. CRYPTO_MSG_NEWALG = 0x10,
  26. CRYPTO_MSG_DELALG,
  27. CRYPTO_MSG_UPDATEALG,
  28. CRYPTO_MSG_GETALG,
  29. CRYPTO_MSG_DELRNG,
  30. CRYPTO_MSG_GETSTAT,
  31. __CRYPTO_MSG_MAX
  32. };
  33. #define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)
  34. #define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE)
  35. #define CRYPTO_MAX_NAME 64
  36. /* Netlink message attributes. */
  37. enum crypto_attr_type_t {
  38. CRYPTOCFGA_UNSPEC,
  39. CRYPTOCFGA_PRIORITY_VAL, /* __u32 */
  40. CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */
  41. CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */
  42. CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */
  43. CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */
  44. CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */
  45. CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */
  46. CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */
  47. CRYPTOCFGA_REPORT_AKCIPHER, /* struct crypto_report_akcipher */
  48. CRYPTOCFGA_REPORT_KPP, /* struct crypto_report_kpp */
  49. CRYPTOCFGA_REPORT_ACOMP, /* struct crypto_report_acomp */
  50. CRYPTOCFGA_STAT_LARVAL, /* struct crypto_stat */
  51. CRYPTOCFGA_STAT_HASH, /* struct crypto_stat */
  52. CRYPTOCFGA_STAT_BLKCIPHER, /* struct crypto_stat */
  53. CRYPTOCFGA_STAT_AEAD, /* struct crypto_stat */
  54. CRYPTOCFGA_STAT_COMPRESS, /* struct crypto_stat */
  55. CRYPTOCFGA_STAT_RNG, /* struct crypto_stat */
  56. CRYPTOCFGA_STAT_CIPHER, /* struct crypto_stat */
  57. CRYPTOCFGA_STAT_AKCIPHER, /* struct crypto_stat */
  58. CRYPTOCFGA_STAT_KPP, /* struct crypto_stat */
  59. CRYPTOCFGA_STAT_ACOMP, /* struct crypto_stat */
  60. __CRYPTOCFGA_MAX
  61. #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1)
  62. };
  63. struct crypto_user_alg {
  64. char cru_name[CRYPTO_MAX_NAME];
  65. char cru_driver_name[CRYPTO_MAX_NAME];
  66. char cru_module_name[CRYPTO_MAX_NAME];
  67. __u32 cru_type;
  68. __u32 cru_mask;
  69. __u32 cru_refcnt;
  70. __u32 cru_flags;
  71. };
  72. struct crypto_stat {
  73. char type[CRYPTO_MAX_NAME];
  74. union {
  75. __u32 stat_encrypt_cnt;
  76. __u32 stat_compress_cnt;
  77. __u32 stat_generate_cnt;
  78. __u32 stat_hash_cnt;
  79. __u32 stat_setsecret_cnt;
  80. };
  81. union {
  82. __u64 stat_encrypt_tlen;
  83. __u64 stat_compress_tlen;
  84. __u64 stat_generate_tlen;
  85. __u64 stat_hash_tlen;
  86. };
  87. union {
  88. __u32 stat_akcipher_err_cnt;
  89. __u32 stat_cipher_err_cnt;
  90. __u32 stat_compress_err_cnt;
  91. __u32 stat_aead_err_cnt;
  92. __u32 stat_hash_err_cnt;
  93. __u32 stat_rng_err_cnt;
  94. __u32 stat_kpp_err_cnt;
  95. };
  96. union {
  97. __u32 stat_decrypt_cnt;
  98. __u32 stat_decompress_cnt;
  99. __u32 stat_seed_cnt;
  100. __u32 stat_generate_public_key_cnt;
  101. };
  102. union {
  103. __u64 stat_decrypt_tlen;
  104. __u64 stat_decompress_tlen;
  105. };
  106. union {
  107. __u32 stat_verify_cnt;
  108. __u32 stat_compute_shared_secret_cnt;
  109. };
  110. __u32 stat_sign_cnt;
  111. };
  112. struct crypto_report_larval {
  113. char type[CRYPTO_MAX_NAME];
  114. };
  115. struct crypto_report_hash {
  116. char type[CRYPTO_MAX_NAME];
  117. unsigned int blocksize;
  118. unsigned int digestsize;
  119. };
  120. struct crypto_report_cipher {
  121. char type[CRYPTO_MAX_NAME];
  122. unsigned int blocksize;
  123. unsigned int min_keysize;
  124. unsigned int max_keysize;
  125. };
  126. struct crypto_report_blkcipher {
  127. char type[CRYPTO_MAX_NAME];
  128. char geniv[CRYPTO_MAX_NAME];
  129. unsigned int blocksize;
  130. unsigned int min_keysize;
  131. unsigned int max_keysize;
  132. unsigned int ivsize;
  133. };
  134. struct crypto_report_aead {
  135. char type[CRYPTO_MAX_NAME];
  136. char geniv[CRYPTO_MAX_NAME];
  137. unsigned int blocksize;
  138. unsigned int maxauthsize;
  139. unsigned int ivsize;
  140. };
  141. struct crypto_report_comp {
  142. char type[CRYPTO_MAX_NAME];
  143. };
  144. struct crypto_report_rng {
  145. char type[CRYPTO_MAX_NAME];
  146. unsigned int seedsize;
  147. };
  148. struct crypto_report_akcipher {
  149. char type[CRYPTO_MAX_NAME];
  150. };
  151. struct crypto_report_kpp {
  152. char type[CRYPTO_MAX_NAME];
  153. };
  154. struct crypto_report_acomp {
  155. char type[CRYPTO_MAX_NAME];
  156. };
  157. #define CRYPTO_REPORT_MAXSIZE (sizeof(struct crypto_user_alg) + \
  158. sizeof(struct crypto_report_blkcipher))