wolfSSL 3.11.1 for TLS1.3 beta

Fork of wolfSSL by wolf SSL

Committer:
wolfSSL
Date:
Tue May 30 06:16:19 2017 +0000
Revision:
13:80fb167dafdf
Parent:
3:6f956bdb3073
wolfSSL 3.11.1: TLS1.3 Beta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 3:6f956bdb3073 1 /* idea.h
wolfSSL 3:6f956bdb3073 2 *
wolfSSL 3:6f956bdb3073 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 3:6f956bdb3073 4 *
wolfSSL 3:6f956bdb3073 5 * This file is part of wolfSSL.
wolfSSL 3:6f956bdb3073 6 *
wolfSSL 3:6f956bdb3073 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 3:6f956bdb3073 8 * it under the terms of the GNU General Public License as published by
wolfSSL 3:6f956bdb3073 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 3:6f956bdb3073 10 * (at your option) any later version.
wolfSSL 3:6f956bdb3073 11 *
wolfSSL 3:6f956bdb3073 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 3:6f956bdb3073 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 3:6f956bdb3073 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 3:6f956bdb3073 15 * GNU General Public License for more details.
wolfSSL 3:6f956bdb3073 16 *
wolfSSL 3:6f956bdb3073 17 * You should have received a copy of the GNU General Public License
wolfSSL 3:6f956bdb3073 18 * along with this program; if not, write to the Free Software
wolfSSL 3:6f956bdb3073 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 3:6f956bdb3073 20 */
wolfSSL 3:6f956bdb3073 21
wolfSSL 3:6f956bdb3073 22
wolfSSL 3:6f956bdb3073 23 #ifndef WOLF_CRYPT_IDEA_H
wolfSSL 3:6f956bdb3073 24 #define WOLF_CRYPT_IDEA_H
wolfSSL 3:6f956bdb3073 25
wolfSSL 3:6f956bdb3073 26 #include <wolfssl/wolfcrypt/types.h>
wolfSSL 3:6f956bdb3073 27
wolfSSL 3:6f956bdb3073 28 #ifdef HAVE_IDEA
wolfSSL 3:6f956bdb3073 29
wolfSSL 3:6f956bdb3073 30 #ifdef __cplusplus
wolfSSL 3:6f956bdb3073 31 extern "C" {
wolfSSL 3:6f956bdb3073 32 #endif
wolfSSL 3:6f956bdb3073 33
wolfSSL 3:6f956bdb3073 34 enum {
wolfSSL 3:6f956bdb3073 35 IDEA_MODULO = 0x10001, /* 2^16+1 */
wolfSSL 3:6f956bdb3073 36 IDEA_2EXP16 = 0x10000, /* 2^16 */
wolfSSL 3:6f956bdb3073 37 IDEA_MASK = 0xFFFF, /* 16 bits set to one */
wolfSSL 3:6f956bdb3073 38 IDEA_ROUNDS = 8, /* number of rounds for IDEA */
wolfSSL 3:6f956bdb3073 39 IDEA_SK_NUM = (6*IDEA_ROUNDS + 4), /* number of subkeys */
wolfSSL 3:6f956bdb3073 40 IDEA_KEY_SIZE = 16, /* size of key in bytes */
wolfSSL 3:6f956bdb3073 41 IDEA_BLOCK_SIZE = 8, /* size of IDEA blocks in bytes */
wolfSSL 3:6f956bdb3073 42 IDEA_IV_SIZE = 8, /* size of IDEA IV in bytes */
wolfSSL 3:6f956bdb3073 43 IDEA_ENCRYPTION = 0,
wolfSSL 3:6f956bdb3073 44 IDEA_DECRYPTION = 1
wolfSSL 3:6f956bdb3073 45 };
wolfSSL 3:6f956bdb3073 46
wolfSSL 3:6f956bdb3073 47 /* IDEA encryption and decryption */
wolfSSL 3:6f956bdb3073 48 typedef struct Idea {
wolfSSL 3:6f956bdb3073 49 word32 reg[IDEA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
wolfSSL 3:6f956bdb3073 50 word32 tmp[IDEA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
wolfSSL 3:6f956bdb3073 51 word16 skey[IDEA_SK_NUM]; /* 832 bits expanded key */
wolfSSL 3:6f956bdb3073 52 } Idea;
wolfSSL 3:6f956bdb3073 53
wolfSSL 3:6f956bdb3073 54 WOLFSSL_API int wc_IdeaSetKey(Idea *idea, const byte* key, word16 keySz,
wolfSSL 3:6f956bdb3073 55 const byte *iv, int dir);
wolfSSL 3:6f956bdb3073 56 WOLFSSL_API int wc_IdeaSetIV(Idea *idea, const byte* iv);
wolfSSL 3:6f956bdb3073 57 WOLFSSL_API void wc_IdeaCipher(Idea *idea, byte* out, const byte* in);
wolfSSL 3:6f956bdb3073 58 WOLFSSL_API int wc_IdeaCbcEncrypt(Idea *idea, byte* out,
wolfSSL 3:6f956bdb3073 59 const byte* in, word32 len);
wolfSSL 3:6f956bdb3073 60 WOLFSSL_API int wc_IdeaCbcDecrypt(Idea *idea, byte* out,
wolfSSL 3:6f956bdb3073 61 const byte* in, word32 len);
wolfSSL 3:6f956bdb3073 62 #ifdef __cplusplus
wolfSSL 3:6f956bdb3073 63 } /* extern "C" */
wolfSSL 3:6f956bdb3073 64 #endif
wolfSSL 3:6f956bdb3073 65
wolfSSL 3:6f956bdb3073 66 #endif /* HAVE_IDEA */
wolfSSL 3:6f956bdb3073 67 #endif /* WOLF_CRYPT_IDEA_H */
wolfSSL 3:6f956bdb3073 68