crypto1.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "../../lib/parity/parity.h"
  2. #include <lib/nfc/protocols/mifare_classic.h>
  3. #include <lib/nfc/protocols/crypto1.h>
  4. #include "stddef.h"
  5. #define LF_POLY_ODD (0x29CE5C)
  6. #define LF_POLY_EVEN (0x870804)
  7. #define SWAPENDIAN(x) \
  8. ((x) = ((x) >> 8 & 0xff00ff) | ((x)&0xff00ff) << 8, (x) = (x) >> 16 | (x) << 16)
  9. #define BEBIT(x, n) FURI_BIT(x, (n) ^ 24)
  10. void crypto1_reset(Crypto1* crypto1);
  11. void crypto1_init(Crypto1* crypto1, uint64_t key);
  12. uint32_t crypto1_filter(uint32_t in);
  13. uint8_t crypto1_bit(Crypto1* crypto1, uint8_t in, int is_encrypted);
  14. uint8_t crypto1_byte(Crypto1* crypto1, uint8_t in, int is_encrypted);
  15. uint32_t crypto1_word(Crypto1* crypto1, uint32_t in, int is_encrypted);
  16. uint32_t prng_successor(uint32_t x, uint32_t n);
  17. void crypto1_decrypt(
  18. Crypto1* crypto,
  19. uint8_t* encrypted_data,
  20. uint16_t encrypted_data_bits,
  21. uint8_t* decrypted_data);
  22. void crypto1_encrypt(
  23. Crypto1* crypto,
  24. uint8_t* keystream,
  25. uint8_t* plain_data,
  26. uint16_t plain_data_bits,
  27. uint8_t* encrypted_data,
  28. uint8_t* encrypted_parity);