source: UsbWattMeter/trunk/wolfssl-3.7.0/wolfssl/openssl/des.h@ 167

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

MIMEにSJISを設定

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-chdr; charset=SHIFT_JIS
File size: 3.8 KB
RevLine 
[164]1/* des.h
2 *
3 * Copyright (C) 2015 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL. (formerly known as 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-1301, USA
20 */
21
22
23/* des.h defines mini des openssl compatibility layer
24 *
25 */
26
27
28#ifndef WOLFSSL_DES_H_
29#define WOLFSSL_DES_H_
30
31#include <wolfssl/wolfcrypt/settings.h>
32
33#ifndef NO_DES3
34
35#ifdef WOLFSSL_PREFIX
36#include "prefix_des.h"
37#endif
38
39
40#ifdef __cplusplus
41 extern "C" {
42#endif
43
44typedef unsigned char WOLFSSL_DES_cblock[8];
45typedef /* const */ WOLFSSL_DES_cblock WOLFSSL_const_DES_cblock;
46typedef WOLFSSL_DES_cblock WOLFSSL_DES_key_schedule;
47
48
49enum {
50 DES_ENCRYPT = 1,
51 DES_DECRYPT = 0
52};
53
54
55WOLFSSL_API void wolfSSL_DES_set_key_unchecked(WOLFSSL_const_DES_cblock*,
56 WOLFSSL_DES_key_schedule*);
57WOLFSSL_API int wolfSSL_DES_key_sched(WOLFSSL_const_DES_cblock* key,
58 WOLFSSL_DES_key_schedule* schedule);
59WOLFSSL_API void wolfSSL_DES_cbc_encrypt(const unsigned char* input,
60 unsigned char* output, long length,
61 WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec,
62 int enc);
63WOLFSSL_API void wolfSSL_DES_ncbc_encrypt(const unsigned char* input,
64 unsigned char* output, long length,
65 WOLFSSL_DES_key_schedule* schedule,
66 WOLFSSL_DES_cblock* ivec, int enc);
67
68WOLFSSL_API void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock*);
69WOLFSSL_API void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock*, WOLFSSL_DES_cblock*,
70 WOLFSSL_DES_key_schedule*, int);
71
72
73typedef WOLFSSL_DES_cblock DES_cblock;
74typedef WOLFSSL_const_DES_cblock const_DES_cblock;
75typedef WOLFSSL_DES_key_schedule DES_key_schedule;
76
77#define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked
78#define DES_key_sched wolfSSL_DES_key_sched
79#define DES_cbc_encrypt wolfSSL_DES_cbc_encrypt
80#define DES_ncbc_encrypt wolfSSL_DES_ncbc_encrypt
81#define DES_set_odd_parity wolfSSL_DES_set_odd_parity
82#define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt
83#define DES_ede3_cbc_encrypt(input, output, sz, ks1, ks2, ks3, ivec, enc) \
84do { \
85 Des3 des; \
86 byte key[24];/* EDE uses 24 size key */ \
87 memcpy(key, (ks1), DES_BLOCK_SIZE); \
88 memcpy(&key[DES_BLOCK_SIZE], (ks2), DES_BLOCK_SIZE); \
89 memcpy(&key[DES_BLOCK_SIZE * 2], (ks3), DES_BLOCK_SIZE); \
90 if (enc) { \
91 wc_Des3_SetKey(&des, key, (const byte*)(ivec), DES_ENCRYPTION); \
92 wc_Des3_CbcEncrypt(&des, (output), (input), (sz)); \
93 } \
94 else { \
95 wc_Des3_SetKey(&des, key, (const byte*)(ivec), DES_ENCRYPTION); \
96 wc_Des3_CbcDecrypt(&des, (output), (input), (sz)); \
97 } \
98} while(0)
99
100#ifdef __cplusplus
101 } /* extern "C" */
102#endif
103
104#endif /* NO_DES3 */
105
106#endif /* WOLFSSL_DES_H_ */
Note: See TracBrowser for help on using the repository browser.