source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/wolfcrypt/des3.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: 3.4 KB
Line 
1/* des3.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_DES3_H
23#define WOLF_CRYPT_DES3_H
24
25#include <wolfssl/wolfcrypt/types.h>
26
27#ifndef NO_DES3
28
29#ifdef HAVE_FIPS
30/* included for fips @wc_fips */
31#include <cyassl/ctaocrypt/des3.h>
32#endif
33
34#ifdef __cplusplus
35 extern "C" {
36#endif
37
38#ifndef HAVE_FIPS /* to avoid redifinition of macros */
39#define WOLFSSL_3DES_CAVIUM_MAGIC 0xBEEF0003
40
41enum {
42 DES_ENC_TYPE = 2, /* cipher unique type */
43 DES3_ENC_TYPE = 3, /* cipher unique type */
44 DES_BLOCK_SIZE = 8,
45 DES_KS_SIZE = 32,
46
47 DES_ENCRYPTION = 0,
48 DES_DECRYPTION = 1
49};
50
51#define DES_IVLEN 8
52#define DES_KEYLEN 8
53#define DES3_IVLEN 8
54#define DES3_KEYLEN 24
55
56
57#ifdef STM32F2_CRYPTO
58enum {
59 DES_CBC = 0,
60 DES_ECB = 1
61};
62#endif
63
64
65/* DES encryption and decryption */
66typedef struct Des {
67 word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
68 word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
69 word32 key[DES_KS_SIZE];
70} Des;
71
72
73/* DES3 encryption and decryption */
74typedef struct Des3 {
75 word32 key[3][DES_KS_SIZE];
76 word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
77 word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */
78#ifdef HAVE_CAVIUM
79 int devId; /* nitrox device id */
80 word32 magic; /* using cavium magic */
81 word64 contextHandle; /* nitrox context memory handle */
82#endif
83} Des3;
84#endif /* HAVE_FIPS */
85
86WOLFSSL_API int wc_Des_SetKey(Des* des, const byte* key,
87 const byte* iv, int dir);
88WOLFSSL_API void wc_Des_SetIV(Des* des, const byte* iv);
89WOLFSSL_API int wc_Des_CbcEncrypt(Des* des, byte* out,
90 const byte* in, word32 sz);
91WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out,
92 const byte* in, word32 sz);
93WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
94 const byte* in, word32 sz);
95
96WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
97 const byte* iv,int dir);
98WOLFSSL_API int wc_Des3_SetIV(Des3* des, const byte* iv);
99WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out,
100 const byte* in,word32 sz);
101WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out,
102 const byte* in,word32 sz);
103
104#ifdef HAVE_CAVIUM
105 WOLFSSL_API int wc_Des3_InitCavium(Des3*, int);
106 WOLFSSL_API void wc_Des3_FreeCavium(Des3*);
107#endif
108
109#ifdef __cplusplus
110 } /* extern "C" */
111#endif
112
113#endif /* NO_DES3 */
114#endif /* WOLF_CRYPT_DES3_H */
115
Note: See TracBrowser for help on using the repository browser.