camellia.h 3.6 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-2015 wolfSSL Inc.
  30. *
  31. * This file is part of wolfSSL. (formerly known as CyaSSL)
  32. *
  33. * wolfSSL 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. * wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  46. */
  47. #ifndef WOLF_CRYPT_CAMELLIA_H
  48. #define WOLF_CRYPT_CAMELLIA_H
  49. #include <wolfssl/wolfcrypt/types.h>
  50. #ifdef HAVE_CAMELLIA
  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. WOLFSSL_API int wc_CamelliaSetKey(Camellia* cam,
  67. const byte* key, word32 len, const byte* iv);
  68. WOLFSSL_API int wc_CamelliaSetIV(Camellia* cam, const byte* iv);
  69. WOLFSSL_API void wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
  70. const byte* in);
  71. WOLFSSL_API void wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
  72. const byte* in);
  73. WOLFSSL_API void wc_CamelliaCbcEncrypt(Camellia* cam,
  74. byte* out, const byte* in, word32 sz);
  75. WOLFSSL_API void wc_CamelliaCbcDecrypt(Camellia* cam,
  76. byte* out, const byte* in, word32 sz);
  77. #ifdef __cplusplus
  78. } /* extern "C" */
  79. #endif
  80. #endif /* HAVE_CAMELLIA */
  81. #endif /* WOLF_CRYPT_CAMELLIA_H */