Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
wolfSSL
Date:
Thu Apr 28 00:57:21 2016 +0000
Revision:
4:1b0d80432c79
wolfSSL 3.9.0

Who changed what in which revision?

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