salsa20.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* salsa20.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef SALSA20_H_
  17. #define SALSA20_H_
  18. #include <stdint.h>
  19. typedef struct{
  20. union {
  21. uint8_t v8[64];
  22. uint64_t v64[ 8];
  23. } a;
  24. uint8_t buffer[64];
  25. uint8_t buffer_idx;
  26. } salsa20_ctx_t;
  27. void salsa20_hash(uint32_t* a);
  28. void salsa_k32(uint32_t* dest, const uint32_t* k, const uint32_t* n);
  29. void salsa_k16(uint32_t* dest, const uint32_t* k, const uint32_t* n);
  30. void salsa20_genBlock256(void* dest, const void* k, const void* iv, uint64_t i);
  31. void salsa20_genBlock128(void* dest, const void* k, const void* iv, uint64_t i);
  32. void salsa20_init(void* key, uint16_t keylength_b, void* iv, salsa20_ctx_t* ctx);
  33. uint8_t salsa20_gen(salsa20_ctx_t* ctx);
  34. #endif /* SALSA20_H_ */