source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/wolfcrypt/idea.h@ 164

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

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr
File size: 2.4 KB
Line 
1/* idea.h
2 *
3 * Copyright (C) 2006-2015 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL. (formerly known as CyaSSL)
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-1301, USA
20 */
21
22#ifndef WOLF_CRYPT_IDEA_H
23#define WOLF_CRYPT_IDEA_H
24
25#include <wolfssl/wolfcrypt/types.h>
26
27#ifdef HAVE_IDEA
28
29#ifdef __cplusplus
30 extern "C" {
31#endif
32
33enum {
34 IDEA_MODULO = 0x10001, /* 2^16+1 */
35 IDEA_2EXP16 = 0x10000, /* 2^16 */
36 IDEA_MASK = 0xFFFF, /* 16 bits set to one */
37 IDEA_ROUNDS = 8, /* number of rounds for IDEA */
38 IDEA_SK_NUM = (6*IDEA_ROUNDS + 4), /* number of subkeys */
39 IDEA_KEY_SIZE = 16, /* size of key in bytes */
40 IDEA_BLOCK_SIZE = 8, /* size of IDEA blocks in bytes */
41 IDEA_IV_SIZE = 8, /* size of IDEA IV in bytes */
42 IDEA_ENCRYPTION = 0,
43 IDEA_DECRYPTION = 1
44};
45
46/* IDEA encryption and decryption */
47typedef struct Idea {
48 word32 reg[IDEA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
49 word32 tmp[IDEA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
50 word16 skey[IDEA_SK_NUM]; /* 832 bits expanded key */
51} Idea;
52
53WOLFSSL_API int wc_IdeaSetKey(Idea *idea, const byte* key, word16 keySz,
54 const byte *iv, int dir);
55WOLFSSL_API int wc_IdeaSetIV(Idea *idea, const byte* iv);
56WOLFSSL_API void wc_IdeaCipher(Idea *idea, byte* out, const byte* in);
57WOLFSSL_API int wc_IdeaCbcEncrypt(Idea *idea, byte* out,
58 const byte* in, word32 len);
59WOLFSSL_API int wc_IdeaCbcDecrypt(Idea *idea, byte* out,
60 const byte* in, word32 len);
61#ifdef __cplusplus
62 } /* extern "C" */
63#endif
64
65#endif /* HAVE_IDEA */
66#endif /* WOLF_CRYPT_IDEA_H */
Note: See TracBrowser for help on using the repository browser.