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