1
0

chacha.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* $OpenBSD: chacha.h,v 1.8 2019/01/22 00:59:21 dlg Exp $ */
  2. /*
  3. * Copyright (c) 2014 Joel Sing <[email protected]>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef HEADER_CHACHA_H
  18. #define HEADER_CHACHA_H
  19. #include <openssl/opensslconf.h>
  20. #if defined(OPENSSL_NO_CHACHA)
  21. #error ChaCha is disabled.
  22. #endif
  23. #include <stddef.h>
  24. #include <stdint.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. typedef struct {
  29. unsigned int input[16];
  30. unsigned char ks[64];
  31. unsigned char unused;
  32. } ChaCha_ctx;
  33. void ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key,
  34. unsigned int keybits);
  35. void ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv,
  36. const unsigned char *counter);
  37. void ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in,
  38. size_t len);
  39. void CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len,
  40. const unsigned char key[32], const unsigned char iv[8], uint64_t counter);
  41. void CRYPTO_xchacha_20(unsigned char *out, const unsigned char *in, size_t len,
  42. const unsigned char key[32], const unsigned char iv[24]);
  43. void CRYPTO_hchacha_20(unsigned char out[32],
  44. const unsigned char key[32], const unsigned char iv[16]);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* HEADER_CHACHA_H */