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