Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

crypto_null.c 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. /**
  21. * @file
  22. *
  23. * Null crypto algorithm
  24. */
  25. #include <string.h>
  26. #include <ipxe/crypto.h>
  27. static void digest_null_init ( void *ctx __unused ) {
  28. /* Do nothing */
  29. }
  30. static void digest_null_update ( void *ctx __unused, const void *src __unused,
  31. size_t len __unused ) {
  32. /* Do nothing */
  33. }
  34. static void digest_null_final ( void *ctx __unused, void *out __unused ) {
  35. /* Do nothing */
  36. }
  37. struct digest_algorithm digest_null = {
  38. .name = "null",
  39. .ctxsize = 0,
  40. .blocksize = 1,
  41. .digestsize = 0,
  42. .init = digest_null_init,
  43. .update = digest_null_update,
  44. .final = digest_null_final,
  45. };
  46. static int cipher_null_setkey ( void *ctx __unused, const void *key __unused,
  47. size_t keylen __unused ) {
  48. /* Do nothing */
  49. return 0;
  50. }
  51. static void cipher_null_setiv ( void *ctx __unused,
  52. const void *iv __unused ) {
  53. /* Do nothing */
  54. }
  55. static void cipher_null_encrypt ( void *ctx __unused, const void *src,
  56. void *dst, size_t len ) {
  57. memcpy ( dst, src, len );
  58. }
  59. static void cipher_null_decrypt ( void *ctx __unused, const void *src,
  60. void *dst, size_t len ) {
  61. memcpy ( dst, src, len );
  62. }
  63. struct cipher_algorithm cipher_null = {
  64. .name = "null",
  65. .ctxsize = 0,
  66. .blocksize = 1,
  67. .setkey = cipher_null_setkey,
  68. .setiv = cipher_null_setiv,
  69. .encrypt = cipher_null_encrypt,
  70. .decrypt = cipher_null_decrypt,
  71. };
  72. static int pubkey_null_init ( void *ctx __unused, const void *key __unused,
  73. size_t key_len __unused ) {
  74. return 0;
  75. }
  76. static size_t pubkey_null_max_len ( void *ctx __unused ) {
  77. return 0;
  78. }
  79. static int pubkey_null_encrypt ( void *ctx __unused,
  80. const void *plaintext __unused,
  81. size_t plaintext_len __unused,
  82. void *ciphertext __unused ) {
  83. return 0;
  84. }
  85. static int pubkey_null_decrypt ( void *ctx __unused,
  86. const void *ciphertext __unused,
  87. size_t ciphertext_len __unused,
  88. void *plaintext __unused ) {
  89. return 0;
  90. }
  91. static int pubkey_null_sign ( void *ctx __unused,
  92. struct digest_algorithm *digest __unused,
  93. const void *value __unused,
  94. void *signature __unused ) {
  95. return 0;
  96. }
  97. static int pubkey_null_verify ( void *ctx __unused,
  98. struct digest_algorithm *digest __unused,
  99. const void *value __unused,
  100. const void *signature __unused ,
  101. size_t signature_len __unused ) {
  102. return 0;
  103. }
  104. static void pubkey_null_final ( void *ctx __unused ) {
  105. /* Do nothing */
  106. }
  107. struct pubkey_algorithm pubkey_null = {
  108. .name = "null",
  109. .ctxsize = 0,
  110. .init = pubkey_null_init,
  111. .max_len = pubkey_null_max_len,
  112. .encrypt = pubkey_null_encrypt,
  113. .decrypt = pubkey_null_decrypt,
  114. .sign = pubkey_null_sign,
  115. .verify = pubkey_null_verify,
  116. .final = pubkey_null_final,
  117. };