Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. /**
  25. * @file
  26. *
  27. * Null crypto algorithm
  28. */
  29. #include <string.h>
  30. #include <ipxe/crypto.h>
  31. static void digest_null_init ( void *ctx __unused ) {
  32. /* Do nothing */
  33. }
  34. static void digest_null_update ( void *ctx __unused, const void *src __unused,
  35. size_t len __unused ) {
  36. /* Do nothing */
  37. }
  38. static void digest_null_final ( void *ctx __unused, void *out __unused ) {
  39. /* Do nothing */
  40. }
  41. struct digest_algorithm digest_null = {
  42. .name = "null",
  43. .ctxsize = 0,
  44. .blocksize = 1,
  45. .digestsize = 0,
  46. .init = digest_null_init,
  47. .update = digest_null_update,
  48. .final = digest_null_final,
  49. };
  50. static int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
  51. size_t keylen __unused ) {
  52. /* Do nothing */
  53. return 0;
  54. }
  55. static void cipher_null_setiv ( void *ctx __unused,
  56. const void *iv __unused ) {
  57. /* Do nothing */
  58. }
  59. static void cipher_null_encrypt ( void *ctx __unused, const void *src,
  60. void *dst, size_t len ) {
  61. memcpy ( dst, src, len );
  62. }
  63. static void cipher_null_decrypt ( void *ctx __unused, const void *src,
  64. void *dst, size_t len ) {
  65. memcpy ( dst, src, len );
  66. }
  67. struct cipher_algorithm cipher_null = {
  68. .name = "null",
  69. .ctxsize = 0,
  70. .blocksize = 1,
  71. .setkey = cipher_null_setkey,
  72. .setiv = cipher_null_setiv,
  73. .encrypt = cipher_null_encrypt,
  74. .decrypt = cipher_null_decrypt,
  75. };
  76. static int pubkey_null_init ( void *ctx __unused, const void *key __unused,
  77. size_t key_len __unused ) {
  78. return 0;
  79. }
  80. static size_t pubkey_null_max_len ( void *ctx __unused ) {
  81. return 0;
  82. }
  83. static int pubkey_null_encrypt ( void *ctx __unused,
  84. const void *plaintext __unused,
  85. size_t plaintext_len __unused,
  86. void *ciphertext __unused ) {
  87. return 0;
  88. }
  89. static int pubkey_null_decrypt ( void *ctx __unused,
  90. const void *ciphertext __unused,
  91. size_t ciphertext_len __unused,
  92. void *plaintext __unused ) {
  93. return 0;
  94. }
  95. static int pubkey_null_sign ( void *ctx __unused,
  96. struct digest_algorithm *digest __unused,
  97. const void *value __unused,
  98. void *signature __unused ) {
  99. return 0;
  100. }
  101. static int pubkey_null_verify ( void *ctx __unused,
  102. struct digest_algorithm *digest __unused,
  103. const void *value __unused,
  104. const void *signature __unused ,
  105. size_t signature_len __unused ) {
  106. return 0;
  107. }
  108. static void pubkey_null_final ( void *ctx __unused ) {
  109. /* Do nothing */
  110. }
  111. struct pubkey_algorithm pubkey_null = {
  112. .name = "null",
  113. .ctxsize = 0,
  114. .init = pubkey_null_init,
  115. .max_len = pubkey_null_max_len,
  116. .encrypt = pubkey_null_encrypt,
  117. .decrypt = pubkey_null_decrypt,
  118. .sign = pubkey_null_sign,
  119. .verify = pubkey_null_verify,
  120. .final = pubkey_null_final,
  121. };