xor.c 511 B

1234567891011121314151617181920212223
  1. /*
  2. version 20080913
  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_xsalsa20_ref_xor(
  11. unsigned char *c,
  12. const unsigned char *m,unsigned long long mlen,
  13. const unsigned char *n,
  14. const unsigned char *k
  15. )
  16. {
  17. unsigned char subkey[32];
  18. crypto_core_hsalsa20(subkey,n,k,sigma);
  19. return crypto_stream_salsa20_xor(c,m,mlen,n + 16,subkey);
  20. }