mifare_ctrl.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * Return 0 on success != 0 on failure.
  39. */
  40. int mf_write_tag(const mf_tag_t* tag, mf_key_type_t key_type);
  41. /**
  42. * Connect to an nfc device. Then, for each sector in turn, try keys in the
  43. * dictionary for authentication. Report success or failure. If a key
  44. * is found, set it in the state variable 'current_auth'. Finally,
  45. * disconnect from the device.
  46. * Return 0 on success != 0 on failure.
  47. */
  48. int mf_dictionary_attack(mf_tag_t* tag);
  49. /**
  50. * Connect to an nfc device. Then test the keys in the 'current_auth'
  51. * by trying to authenticate to the sectors of the tag. Report success
  52. * or failure for each sector. Finally, disconnect from the device.
  53. * Return 0 on success != 0 on failure.
  54. */
  55. int mf_test_auth(const mf_tag_t* keys,
  56. mf_size_t size,
  57. mf_key_type_t key_type);
  58. #endif