crypto1.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "../../lib/parity/parity.h"
  2. #include "../nfclegacy/protocols/mifare_classic.h"
  3. #include "../nfclegacy/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 nescrypto1_reset(Crypto1* crypto1);
  11. void nescrypto1_init(Crypto1* crypto1, uint64_t key);
  12. uint32_t nescrypto1_filter(uint32_t in);
  13. uint8_t nescrypto1_bit(Crypto1* crypto1, uint8_t in, int is_encrypted);
  14. uint8_t nescrypto1_byte(Crypto1* crypto1, uint8_t in, int is_encrypted);
  15. uint32_t nescrypto1_word(Crypto1* crypto1, uint32_t in, int is_encrypted);
  16. uint32_t nesprng_successor(uint32_t x, uint32_t n);
  17. void nescrypto1_decrypt(
  18. Crypto1* crypto,
  19. uint8_t* encrypted_data,
  20. uint16_t encrypted_data_bits,
  21. uint8_t* decrypted_data);
  22. void nescrypto1_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);