des.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* des.h */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. /**
  17. * \file des.h
  18. * \author Daniel Otte
  19. * \date 2007-06-16
  20. * \brief des and tdes declarations
  21. * \license GPLv3 or later
  22. *
  23. */
  24. #ifndef DES_H_
  25. #define DES_H_
  26. /* the FIPS 46-3 (1999-10-25) name for triple DES is triple data encryption algorithm so TDEA.
  27. * Also we only implement the three key mode */
  28. /** \def tdea_enc
  29. * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
  30. */
  31. /** \def tdea_dec
  32. * \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
  33. */
  34. #define tdea_enc tdes_enc
  35. #define tdea_dec tdes_dec
  36. /** \fn void des_enc(void* out, const void* in, const void* key)
  37. * \brief encrypt a block with DES
  38. *
  39. * This function encrypts a block of 64 bits (8 bytes) with the DES algorithm.
  40. * Key expansion is done automatically. The key is 64 bits long, but note that
  41. * only 56 bits are used (the LSB of each byte is dropped). The input and output
  42. * blocks may overlap.
  43. *
  44. * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
  45. * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
  46. * \param key pointer to the key (64 bit = 8 byte)
  47. */
  48. void des_enc(void* out, const void* in, const void* key);
  49. /** \fn void des_dec(void* out, const void* in, const void* key)
  50. * \brief decrypt a block with DES
  51. *
  52. * This function decrypts a block of 64 bits (8 bytes) with the DES algorithm.
  53. * Key expansion is done automatically. The key is 64 bits long, but note that
  54. * only 56 bits are used (the LSB of each byte is dropped). The input and output
  55. * blocks may overlap.
  56. *
  57. * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
  58. * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
  59. * \param key pointer to the key (64 bit = 8 byte)
  60. */
  61. void des_dec(void* out, const void* in, const void* key);
  62. /** \fn void tdes_enc(void* out, const void* in, const void* key)
  63. * \brief encrypt a block with Tripple-DES
  64. *
  65. * This function encrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
  66. * algorithm. Key expansion is done automatically. The key is 192 bits long, but
  67. * note that only 178 bits are used (the LSB of each byte is dropped). The input
  68. * and output blocks may overlap.
  69. *
  70. * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
  71. * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
  72. * \param key pointer to the key (192 bit = 24 byte)
  73. */
  74. void tdes_enc(void* out, const void* in, const void* key);
  75. /** \fn void tdes_dec(void* out, const void* in, const void* key)
  76. * \brief decrypt a block with Tripple-DES
  77. *
  78. * This function decrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
  79. * algorithm. Key expansion is done automatically. The key is 192 bits long, but
  80. * note that only 178 bits are used (the LSB of each byte is dropped). The input
  81. * and output blocks may overlap.
  82. *
  83. * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
  84. * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
  85. * \param key pointer to the key (192 bit = 24 byte)
  86. */
  87. void tdes_dec(void* out, const void* in, const void* key);
  88. #endif /*DES_H_*/