ctc_des3.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* ctc_des3.h
  2. *
  3. * Copyright (C) 2006-2011 Sawtooth Consulting Ltd.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * CyaSSL 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. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  20. */
  21. #ifndef NO_DES3
  22. #ifndef CTAO_CRYPT_DES3_H
  23. #define CTAO_CRYPT_DES3_H
  24. #include "ctc_types.h"
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. enum {
  29. DES_BLOCK_SIZE = 8,
  30. DES_KS_SIZE = 32,
  31. DES_ENCRYPTION = 0,
  32. DES_DECRYPTION = 1,
  33. };
  34. /* DES encryption and decryption */
  35. typedef struct Des {
  36. word32 key[DES_KS_SIZE];
  37. word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  38. word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
  39. } Des;
  40. /* DES3 encryption and decryption */
  41. typedef struct Des3 {
  42. word32 key[3][DES_KS_SIZE];
  43. word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  44. word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
  45. } Des3;
  46. CYASSL_API void Des_SetKey(Des* des, const byte* key, const byte* iv, int dir);
  47. CYASSL_API void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz);
  48. CYASSL_API void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz);
  49. CYASSL_API void Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir);
  50. CYASSL_API void Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz);
  51. CYASSL_API void Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz);
  52. #ifdef __cplusplus
  53. } /* extern "C" */
  54. #endif
  55. #endif /* NO_DES3 */
  56. #endif /* CTAO_CRYPT_DES3_H */