Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2015 Andrew Moon, Vsevolod Stakhov
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef CHACHA_H_
  25. #define CHACHA_H_
  26. #define CHACHA_BLOCKBYTES 64
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. typedef struct chacha_state_internal_t {
  31. unsigned char s[48];
  32. size_t rounds;
  33. size_t leftover;
  34. unsigned char buffer[CHACHA_BLOCKBYTES];
  35. } chacha_state_internal;
  36. typedef struct chacha_state_t {
  37. unsigned char opaque[128];
  38. } chacha_state;
  39. typedef struct chacha_key_t {
  40. unsigned char b[32];
  41. } chacha_key;
  42. typedef struct chacha_iv_t {
  43. unsigned char b[8];
  44. } chacha_iv;
  45. typedef struct chacha_iv24_t {
  46. unsigned char b[24];
  47. } chacha_iv24;
  48. void hchacha(const unsigned char key[32], const unsigned char iv[16],
  49. unsigned char out[32], size_t rounds);
  50. void chacha_init(chacha_state *S, const chacha_key *key, const chacha_iv *iv,
  51. size_t rounds);
  52. void xchacha_init(chacha_state *S, const chacha_key *key,
  53. const chacha_iv24 *iv, size_t rounds);
  54. size_t chacha_update(chacha_state *S, const unsigned char *in,
  55. unsigned char *out, size_t inlen);
  56. size_t chacha_final(chacha_state *S, unsigned char *out);
  57. void chacha(const chacha_key *key, const chacha_iv *iv,
  58. const unsigned char *in, unsigned char *out, size_t inlen,
  59. size_t rounds);
  60. void xchacha(const chacha_key *key, const chacha_iv24 *iv,
  61. const unsigned char *in, unsigned char *out, size_t inlen,
  62. size_t rounds);
  63. const char *chacha_load(void);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* CHACHA_H_ */