camellia.h (4153B)
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 28 /* camellia.h 29 * 30 * Copyright (C) 2006-2025 wolfSSL Inc. 31 * 32 * This file is part of wolfSSL. 33 * 34 * wolfSSL is free software; you can redistribute it and/or modify 35 * it under the terms of the GNU General Public License as published by 36 * the Free Software Foundation; either version 3 of the License, or 37 * (at your option) any later version. 38 * 39 * wolfSSL is distributed in the hope that it will be useful, 40 * but WITHOUT ANY WARRANTY; without even the implied warranty of 41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 42 * GNU General Public License for more details. 43 * 44 * You should have received a copy of the GNU General Public License 45 * along with this program; if not, write to the Free Software 46 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 47 */ 48 49 /*! 50 \file wolfssl/wolfcrypt/camellia.h 51 */ 52 53 54 #ifndef WOLF_CRYPT_CAMELLIA_H 55 #define WOLF_CRYPT_CAMELLIA_H 56 57 #include <wolfssl/wolfcrypt/types.h> 58 59 #ifdef HAVE_CAMELLIA 60 61 #ifdef __cplusplus 62 extern "C" { 63 #endif 64 65 enum { 66 WC_CAMELLIA_BLOCK_SIZE = 16 67 }; 68 69 #define WC_CAMELLIA_TABLE_BYTE_LEN 272 70 #define WC_CAMELLIA_TABLE_WORD_LEN (WC_CAMELLIA_TABLE_BYTE_LEN / sizeof(word32)) 71 72 typedef word32 WC_CAMELLIA_KEY_TABLE_TYPE[WC_CAMELLIA_TABLE_WORD_LEN]; 73 74 typedef struct wc_Camellia { 75 word32 keySz; 76 WC_CAMELLIA_KEY_TABLE_TYPE key; 77 word32 reg[WC_CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ 78 word32 tmp[WC_CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ 79 } wc_Camellia; 80 81 82 WOLFSSL_API int wc_CamelliaSetKey(wc_Camellia* cam, 83 const byte* key, word32 len, const byte* iv); 84 WOLFSSL_API int wc_CamelliaSetIV(wc_Camellia* cam, const byte* iv); 85 WOLFSSL_API int wc_CamelliaEncryptDirect(wc_Camellia* cam, byte* out, 86 const byte* in); 87 WOLFSSL_API int wc_CamelliaDecryptDirect(wc_Camellia* cam, byte* out, 88 const byte* in); 89 WOLFSSL_API int wc_CamelliaCbcEncrypt(wc_Camellia* cam, 90 byte* out, const byte* in, word32 sz); 91 WOLFSSL_API int wc_CamelliaCbcDecrypt(wc_Camellia* cam, 92 byte* out, const byte* in, word32 sz); 93 94 #ifndef OPENSSL_COEXIST 95 96 enum { 97 CAMELLIA_BLOCK_SIZE = WC_CAMELLIA_BLOCK_SIZE 98 }; 99 100 #define CAMELLIA_TABLE_BYTE_LEN WC_CAMELLIA_TABLE_BYTE_LEN 101 #define CAMELLIA_TABLE_WORD_LEN WC_CAMELLIA_TABLE_WORD_LEN 102 103 typedef word32 KEY_TABLE_TYPE[WC_CAMELLIA_TABLE_WORD_LEN]; 104 105 typedef struct wc_Camellia Camellia; 106 107 #endif /* !OPENSSL_COEXIST */ 108 109 110 #ifdef __cplusplus 111 } /* extern "C" */ 112 #endif 113 114 #endif /* HAVE_CAMELLIA */ 115 #endif /* WOLF_CRYPT_CAMELLIA_H */ 116