Xuyi Wang / wolfSSL

Dependents:   OS

Committer:
wolfSSL
Date:
Sat Aug 18 22:20:43 2018 +0000
Revision:
15:117db924cf7c
wolfSSL 3.15.3

Who changed what in which revision?

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