crypto1.h 949 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include <toolbox/bit_buffer.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. typedef struct {
  7. uint32_t odd;
  8. uint32_t even;
  9. } Crypto1;
  10. Crypto1* crypto1_alloc();
  11. void crypto1_free(Crypto1* instance);
  12. void crypto1_reset(Crypto1* crypto1);
  13. void crypto1_init(Crypto1* crypto1, uint64_t key);
  14. uint8_t crypto1_bit(Crypto1* crypto1, uint8_t in, int is_encrypted);
  15. uint8_t crypto1_byte(Crypto1* crypto1, uint8_t in, int is_encrypted);
  16. uint32_t crypto1_word(Crypto1* crypto1, uint32_t in, int is_encrypted);
  17. void crypto1_decrypt(Crypto1* crypto, const BitBuffer* buff, BitBuffer* out);
  18. void crypto1_encrypt(Crypto1* crypto, uint8_t* keystream, const BitBuffer* buff, BitBuffer* out);
  19. void crypto1_encrypt_reader_nonce(
  20. Crypto1* crypto,
  21. uint64_t key,
  22. uint32_t cuid,
  23. uint8_t* nt,
  24. uint8_t* nr,
  25. BitBuffer* out,
  26. bool is_nested);
  27. uint32_t prng_successor(uint32_t x, uint32_t n);
  28. #ifdef __cplusplus
  29. }
  30. #endif