threefish.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* threefish.c */
  2. /*
  3. This file is part of the ARM-Crypto-Lib.
  4. Copyright (C) 2009 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 threefish.h
  18. * \author Daniel Otte
  19. * \email daniel.otte@rub.de
  20. * \date 2009-03-12
  21. * \license GPLv3 or later
  22. * \brief Implementation of the Threefish block cipher
  23. * \ingroup Threefish
  24. */
  25. #ifndef THREEFISH_H_
  26. #define THREEFISH_H_
  27. #include <stdint.h>
  28. #define THREEFISH256_BLOCKSIZE 256
  29. #define THREEFISH256_BLOCKSIZE_B ((THREEFISH256_BLOCKSIZE+7)/8)
  30. #define THREEFISH512_BLOCKSIZE 512
  31. #define THREEFISH512_BLOCKSIZE_B ((THREEFISH512_BLOCKSIZE+7)/8)
  32. #define THREEFISH1024_BLOCKSIZE 1024
  33. #define THREEFISH1024_BLOCKSIZE_B ((THREEFISH1024_BLOCKSIZE+7)/8)
  34. /** \typedef threefish256_ctx_t
  35. * \brief holds key data for Threefish-256
  36. *
  37. * A variable of this type may hold the key data for Threefish-256 encryption
  38. * or decryption..
  39. */
  40. typedef struct{
  41. uint64_t k[5];
  42. uint64_t t[3];
  43. } threefish256_ctx_t;
  44. /** \typedef threefish512_ctx_t
  45. * \brief holds key data for Threefish-512
  46. *
  47. * A variable of this type may hold the key data for Threefish-512 encryption
  48. * or decryption..
  49. */
  50. typedef struct{
  51. uint64_t k[9];
  52. uint64_t t[3];
  53. } threefish512_ctx_t;
  54. /** \typedef threefish1024_ctx_t
  55. * \brief holds key data for Threefish-1024
  56. *
  57. * A variable of this type may hold the key data for Threefish-1024 encryption
  58. * or decryption..
  59. */
  60. typedef struct{
  61. uint64_t k[17];
  62. uint64_t t[3];
  63. } threefish1024_ctx_t;
  64. void threefish_mix(void* data, uint8_t rot);
  65. void threefish_invmix(void* data, uint8_t rot);
  66. void threefish256_init(const void* key, const void* tweak, threefish256_ctx_t* ctx);
  67. void threefish512_init(const void* key, const void* tweak, threefish512_ctx_t* ctx);
  68. void threefish1024_init(const void* key, const void* tweak, threefish1024_ctx_t* ctx);
  69. void threefish256_enc(void* data, const threefish256_ctx_t* ctx);
  70. void threefish512_enc(void* data, const threefish512_ctx_t* ctx);
  71. void threefish1024_enc(void* data, const threefish1024_ctx_t* ctx);
  72. void threefish256_dec(void* data, const threefish256_ctx_t* ctx);
  73. void threefish512_dec(void* data, const threefish512_ctx_t* ctx);
  74. void threefish1024_dec(void* data, const threefish1024_ctx_t* ctx);
  75. #endif /* THREEFISH_H_ */