source: azure_iot_hub_riscv/trunk/wolfssl-4.4.0/wolfssl/wolfcrypt/idea.h@ 453

Last change on this file since 453 was 453, checked in by coas-nagasima, 4 years ago

ファイルを追加

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