You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

crypto_null.c 3.4KB

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