camellia.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* camellia.h ver 1.2.0
  2. *
  3. * Copyright (c) 2006,2007
  4. * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer as
  11. * the first lines of this file unmodified.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. /* camellia.h
  28. *
  29. * Copyright (C) 2006-2013 wolfSSL Inc.
  30. *
  31. * This file is part of CyaSSL.
  32. *
  33. * CyaSSL is free software; you can redistribute it and/or modify
  34. * it under the terms of the GNU General Public License as published by
  35. * the Free Software Foundation; either version 2 of the License, or
  36. * (at your option) any later version.
  37. *
  38. * CyaSSL is distributed in the hope that it will be useful,
  39. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41. * GNU General Public License for more details.
  42. *
  43. * You should have received a copy of the GNU General Public License
  44. * along with this program; if not, write to the Free Software
  45. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  46. */
  47. #ifdef HAVE_CAMELLIA
  48. #ifndef CTAO_CRYPT_CAMELLIA_H
  49. #define CTAO_CRYPT_CAMELLIA_H
  50. #include <cyassl/ctaocrypt/types.h>
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. enum {
  55. CAMELLIA_BLOCK_SIZE = 16
  56. };
  57. #define CAMELLIA_TABLE_BYTE_LEN 272
  58. #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
  59. typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
  60. typedef struct Camellia {
  61. word32 keySz;
  62. KEY_TABLE_TYPE key;
  63. word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  64. word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  65. } Camellia;
  66. CYASSL_API int CamelliaSetKey(Camellia* cam,
  67. const byte* key, word32 len, const byte* iv);
  68. CYASSL_API int CamelliaSetIV(Camellia* cam, const byte* iv);
  69. CYASSL_API void CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in);
  70. CYASSL_API void CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in);
  71. CYASSL_API void CamelliaCbcEncrypt(Camellia* cam,
  72. byte* out, const byte* in, word32 sz);
  73. CYASSL_API void CamelliaCbcDecrypt(Camellia* cam,
  74. byte* out, const byte* in, word32 sz);
  75. #ifdef __cplusplus
  76. } /* extern "C" */
  77. #endif
  78. #endif /* CTAO_CRYPT_AES_H */
  79. #endif /* HAVE_CAMELLIA */