arc4.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * \file arc4.h
  3. *
  4. * \brief The ARCFOUR stream cipher
  5. *
  6. * Copyright (C) 2006-2010, Brainspark B.V.
  7. *
  8. * This file is part of PolarSSL (http://www.polarssl.org)
  9. * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
  10. *
  11. * All rights reserved.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #ifndef POLARSSL_ARC4_H
  28. #define POLARSSL_ARC4_H
  29. #include <string.h>
  30. /**
  31. * \brief ARC4 context structure
  32. */
  33. typedef struct
  34. {
  35. int x; /*!< permutation index */
  36. int y; /*!< permutation index */
  37. unsigned char m[256]; /*!< permutation table */
  38. }
  39. arc4_context;
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /**
  44. * \brief ARC4 key schedule
  45. *
  46. * \param ctx ARC4 context to be initialized
  47. * \param key the secret key
  48. * \param keylen length of the key
  49. */
  50. void arc4_setup( arc4_context *ctx, const unsigned char *key, unsigned int keylen );
  51. /**
  52. * \brief ARC4 cipher function
  53. *
  54. * \param ctx ARC4 context
  55. * \param length length of the input data
  56. * \param input buffer holding the input data
  57. * \param output buffer for the output data
  58. *
  59. * \return 0 if successful
  60. */
  61. int arc4_crypt( arc4_context *ctx, size_t length, const unsigned char *input,
  62. unsigned char *output );
  63. /*
  64. * \brief Checkup routine
  65. *
  66. * \return 0 if successful, or 1 if the test failed
  67. */
  68. int arc4_self_test( int verbose );
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /* arc4.h */