mac.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef MAC__H
  2. #define MAC__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. // The DES MAC key in use
  20. extern unsigned char current_mac_key[];
  21. /**
  22. * Compute a DES MAC, use DES in CBC mode. Key and output should be 8
  23. * bytes. The length specifies the length of the input in bytes. It
  24. * will be zero padded to 8 byte alignment if required.
  25. */
  26. int compute_mac(const unsigned char* input,
  27. unsigned char* output,
  28. const unsigned char* key,
  29. long length);
  30. /**
  31. * Compute the MAC of a given block with the specified 8 byte
  32. * key. Return a 8 byte MAC value.
  33. *
  34. * The input to MAC algo [ 4 serial | 14 data | 6 0-pad ]
  35. *
  36. * If update is * nonzero, the mac of the current tag is updated. If
  37. * not, the MAC is simply printed.
  38. */
  39. unsigned char* compute_block_mac(unsigned int block,
  40. const unsigned char* key,
  41. int update);
  42. #endif