stream.c 462 B

12345678910111213141516171819202122
  1. /*
  2. version 20080914
  3. D. J. Bernstein
  4. Public domain.
  5. */
  6. #include "crypto_core_hsalsa20.h"
  7. #include "crypto_stream_salsa20.h"
  8. #include "crypto_stream.h"
  9. static const unsigned char sigma[16] = "expand 32-byte k";
  10. int crypto_stream(
  11. unsigned char *c,unsigned long long clen,
  12. const unsigned char *n,
  13. const unsigned char *k
  14. )
  15. {
  16. unsigned char subkey[32];
  17. crypto_core_hsalsa20(subkey,n,k,sigma);
  18. return crypto_stream_salsa20(c,clen,n + 16,subkey);
  19. }