seed.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* seed.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 seed.h
  18. * \author Daniel Otte
  19. * \date 2007-06-1
  20. * \brief declarations for seed
  21. * \par License
  22. * GPL
  23. *
  24. */
  25. #ifndef SEED_H_
  26. #define SEED_H_
  27. #include <stdint.h>
  28. /** \typedef seed_ctx_t
  29. * \brief SEED context
  30. *
  31. * A variable of this type may hold the key material for the SEED cipher.
  32. * This context is regulary generated by the
  33. * void seed_init(const void * key, seed_ctx_t * ctx) function.
  34. */
  35. typedef struct{
  36. uint32_t k[4];
  37. } seed_ctx_t;
  38. /******************************************************************************/
  39. /** \fn void seed_init(const void * key, seed_ctx_t * ctx)
  40. * \brief initializes context for SEED operation
  41. *
  42. * This function copys the key material into a context variable.
  43. *
  44. * \param key pointer to the key material (128 bit = 16 bytes)
  45. * \param ctx pointer to the context (seed_ctx_t)
  46. */
  47. void seed_init(const void * key, seed_ctx_t * ctx);
  48. /** \fn void seed_enc(void * buffer,const seed_ctx_t * ctx)
  49. * \brief encrypt a block with SEED
  50. *
  51. * This function encrypts a block of 64 bits (8 bytes) with the SEED algorithm.
  52. * The round keys are computed on demand, so the context is modifyed while
  53. * encrypting but the original stated is restored when the function exits.
  54. *
  55. * \param buffer pointer to the block (64 bit = 8 byte) which will be encrypted
  56. * \param ctx pointer to the key material (seed_ctx_t)
  57. */
  58. void seed_enc(void * buffer, const seed_ctx_t * ctx);
  59. /** \fn void seed_dec(void * buffer, const seed_ctx_t * ctx)
  60. * \brief decrypt a block with SEED
  61. *
  62. * This function decrypts a block of 64 bits (8 bytes) with the SEED algorithm.
  63. * The round keys are computed on demand, so the context is modifyed while
  64. * decrypting but the original stated is restored when the function exits.
  65. *
  66. * \param buffer pointer to the block (64 bit = 8 byte) which will be decrypted
  67. * \param ctx pointer to the key material (seed_ctx_t)
  68. */
  69. void seed_dec(void * buffer, const seed_ctx_t * ctx);
  70. #endif /*SEED_H_*/