camellia.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-2022 wolfSSL Inc.
  30. *
  31. * This file is part of wolfSSL.
  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-1335, USA
  46. */
  47. /*!
  48. \file wolfssl/wolfcrypt/camellia.h
  49. */
  50. #ifndef WOLF_CRYPT_CAMELLIA_H
  51. #define WOLF_CRYPT_CAMELLIA_H
  52. #include <wolfssl/wolfcrypt/types.h>
  53. #ifdef HAVE_CAMELLIA
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. enum {
  58. CAMELLIA_BLOCK_SIZE = 16
  59. };
  60. #define CAMELLIA_TABLE_BYTE_LEN 272
  61. #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
  62. typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
  63. typedef struct Camellia {
  64. word32 keySz;
  65. KEY_TABLE_TYPE key;
  66. word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  67. word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
  68. } Camellia;
  69. WOLFSSL_API int wc_CamelliaSetKey(Camellia* cam,
  70. const byte* key, word32 len, const byte* iv);
  71. WOLFSSL_API int wc_CamelliaSetIV(Camellia* cam, const byte* iv);
  72. WOLFSSL_API int wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
  73. const byte* in);
  74. WOLFSSL_API int wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
  75. const byte* in);
  76. WOLFSSL_API int wc_CamelliaCbcEncrypt(Camellia* cam,
  77. byte* out, const byte* in, word32 sz);
  78. WOLFSSL_API int wc_CamelliaCbcDecrypt(Camellia* cam,
  79. byte* out, const byte* in, word32 sz);
  80. #ifdef __cplusplus
  81. } /* extern "C" */
  82. #endif
  83. #endif /* HAVE_CAMELLIA */
  84. #endif /* WOLF_CRYPT_CAMELLIA_H */