tcrypt.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Quick & dirty crypto testing module.
  4. *
  5. * This will only exist until we have a better testing mechanism
  6. * (e.g. a char device).
  7. *
  8. * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
  9. * Copyright (c) 2002 Jean-Francois Dive <jef@linuxbe.org>
  10. * Copyright (c) 2007 Nokia Siemens Networks
  11. */
  12. #ifndef _CRYPTO_TCRYPT_H
  13. #define _CRYPTO_TCRYPT_H
  14. struct cipher_speed_template {
  15. const char *key;
  16. unsigned int klen;
  17. };
  18. struct aead_speed_template {
  19. const char *key;
  20. unsigned int klen;
  21. };
  22. struct hash_speed {
  23. unsigned int blen; /* buffer length */
  24. unsigned int plen; /* per-update length */
  25. };
  26. /*
  27. * DES test vectors.
  28. */
  29. #define DES3_SPEED_VECTORS 1
  30. static struct cipher_speed_template des3_speed_template[] = {
  31. {
  32. .key = "\x01\x23\x45\x67\x89\xab\xcd\xef"
  33. "\x55\x55\x55\x55\x55\x55\x55\x55"
  34. "\xfe\xdc\xba\x98\x76\x54\x32\x10",
  35. .klen = 24,
  36. }
  37. };
  38. /*
  39. * Cipher speed tests
  40. */
  41. static u8 speed_template_8[] = {8, 0};
  42. static u8 speed_template_16[] = {16, 0};
  43. static u8 speed_template_24[] = {24, 0};
  44. static u8 speed_template_8_16[] = {8, 16, 0};
  45. static u8 speed_template_8_32[] = {8, 32, 0};
  46. static u8 speed_template_16_32[] = {16, 32, 0};
  47. static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
  48. static u8 speed_template_20_28_36[] = {20, 28, 36, 0};
  49. static u8 speed_template_32_40_48[] = {32, 40, 48, 0};
  50. static u8 speed_template_32_48[] = {32, 48, 0};
  51. static u8 speed_template_32_48_64[] = {32, 48, 64, 0};
  52. static u8 speed_template_32_64[] = {32, 64, 0};
  53. static u8 speed_template_32[] = {32, 0};
  54. /*
  55. * AEAD speed tests
  56. */
  57. static u8 aead_speed_template_19[] = {19, 0};
  58. static u8 aead_speed_template_20[] = {20, 0};
  59. static u8 aead_speed_template_36[] = {36, 0};
  60. /*
  61. * Digest speed tests
  62. */
  63. static struct hash_speed generic_hash_speed_template[] = {
  64. { .blen = 16, .plen = 16, },
  65. { .blen = 64, .plen = 16, },
  66. { .blen = 64, .plen = 64, },
  67. { .blen = 256, .plen = 16, },
  68. { .blen = 256, .plen = 64, },
  69. { .blen = 256, .plen = 256, },
  70. { .blen = 1024, .plen = 16, },
  71. { .blen = 1024, .plen = 256, },
  72. { .blen = 1024, .plen = 1024, },
  73. { .blen = 2048, .plen = 16, },
  74. { .blen = 2048, .plen = 256, },
  75. { .blen = 2048, .plen = 1024, },
  76. { .blen = 2048, .plen = 2048, },
  77. { .blen = 4096, .plen = 16, },
  78. { .blen = 4096, .plen = 256, },
  79. { .blen = 4096, .plen = 1024, },
  80. { .blen = 4096, .plen = 4096, },
  81. { .blen = 8192, .plen = 16, },
  82. { .blen = 8192, .plen = 256, },
  83. { .blen = 8192, .plen = 1024, },
  84. { .blen = 8192, .plen = 4096, },
  85. { .blen = 8192, .plen = 8192, },
  86. /* End marker */
  87. { .blen = 0, .plen = 0, }
  88. };
  89. static struct hash_speed poly1305_speed_template[] = {
  90. { .blen = 96, .plen = 16, },
  91. { .blen = 96, .plen = 32, },
  92. { .blen = 96, .plen = 96, },
  93. { .blen = 288, .plen = 16, },
  94. { .blen = 288, .plen = 32, },
  95. { .blen = 288, .plen = 288, },
  96. { .blen = 1056, .plen = 32, },
  97. { .blen = 1056, .plen = 1056, },
  98. { .blen = 2080, .plen = 32, },
  99. { .blen = 2080, .plen = 2080, },
  100. { .blen = 4128, .plen = 4128, },
  101. { .blen = 8224, .plen = 8224, },
  102. /* End marker */
  103. { .blen = 0, .plen = 0, }
  104. };
  105. #endif /* _CRYPTO_TCRYPT_H */