ssh lib

Dependents:   OS

Committer:
sPymbed
Date:
Mon Nov 25 14:23:49 2019 +0000
Revision:
1:e4ea39eba2fb
Parent:
0:1387ff3eed4a
improved

Who changed what in which revision?

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