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 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /**
  19. * @file
  20. *
  21. * Null crypto algorithm
  22. */
  23. #include <string.h>
  24. #include <gpxe/crypto.h>
  25. static void null_init ( void *ctx __unused ) {
  26. /* Do nothing */
  27. }
  28. static int null_setkey ( void *ctx __unused, void *key __unused,
  29. size_t keylen __unused ) {
  30. /* Do nothing */
  31. return 0;
  32. }
  33. static void null_encode ( void *ctx __unused, const void *src,
  34. void *dst, size_t len ) {
  35. if ( dst )
  36. memcpy ( dst, src, len );
  37. }
  38. static void null_decode ( void *ctx __unused, const void *src,
  39. void *dst, size_t len ) {
  40. if ( dst )
  41. memcpy ( dst, src, len );
  42. }
  43. static void null_final ( void *ctx __unused, void *out __unused ) {
  44. /* Do nothing */
  45. }
  46. struct crypto_algorithm crypto_null = {
  47. .name = "null",
  48. .ctxsize = 0,
  49. .blocksize = 1,
  50. .digestsize = 0,
  51. .init = null_init,
  52. .setkey = null_setkey,
  53. .encode = null_encode,
  54. .decode = null_decode,
  55. .final = null_final,
  56. };