mifare_ctrl.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef MIFARE_CTRL__H
  2. #define MIFARE_CTRL__H
  3. /**
  4. * Copyright (C) 2011 Anders Sundman <anders@4zm.org>
  5. *
  6. * This file is part of mfterm.
  7. *
  8. * mfterm is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. * mfterm is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. * You should have received a copy of the GNU General Public License
  17. * along with mfterm. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Parts of code used in this file are from the GNU readline library file
  20. * fileman.c (GPLv3). Copyright (C) 1987-2009 Free Software Foundation, Inc
  21. */
  22. #include "tag.h"
  23. #include "dictionary.h"
  24. /**
  25. * Connect to an nfc device. Then read the tag data, authenticating with the
  26. * 'current_auth' keys of specified type, and store it in the
  27. * 'current_tag' state variable. Finally, disconnect from the device.
  28. * If there are authentication errors, those sectors will be set to
  29. * all zeroes.
  30. * Return 0 on success != 0 on failure.
  31. */
  32. int mf_read_tag(mf_tag_t* tag, mf_key_type_t key_type);
  33. /**
  34. * Connect to an nfc device. The write the tag data, authenticating with
  35. * the 'current_auth' keys of specified type. Finally, disconnect from
  36. * the device. If there are authentication errors, those sectors will
  37. * not be written.
  38. * If the key type is set to MF_UNLOCKED, try to unlock the card prior to
  39. * write. This allows some pirate cards to write block 0.
  40. * Return 0 on success != 0 on failure.
  41. */
  42. int mf_write_tag(const mf_tag_t* tag, mf_key_type_t key_type);
  43. /**
  44. * Connect to an nfc device. Then, for each sector in turn, try keys in the
  45. * dictionary for authentication. Report success or failure. If a key
  46. * is found, set it in the state variable 'current_auth'. Finally,
  47. * disconnect from the device.
  48. * Return 0 on success != 0 on failure.
  49. */
  50. int mf_dictionary_attack(mf_tag_t* tag);
  51. /**
  52. * Connect to an nfc device. Then test the keys in the 'current_auth'
  53. * by trying to authenticate to the sectors of the tag. Report success
  54. * or failure for each sector. Finally, disconnect from the device.
  55. * Return 0 on success != 0 on failure.
  56. */
  57. int mf_test_auth(const mf_tag_t* keys,
  58. mf_size_t size,
  59. mf_key_type_t key_type);
  60. #endif