wolf SSL / wolfSSL-TLS13-Beta

Fork of wolfSSL by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers des.h Source File

des.h

00001 /* des.h
00002  *
00003  * Copyright (C) 2006-2016 wolfSSL Inc.
00004  *
00005  * This file is part of wolfSSL.
00006  *
00007  * wolfSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * wolfSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
00020  */
00021 
00022 
00023 
00024 /*  des.h defines mini des openssl compatibility layer 
00025  *
00026  */
00027 
00028 
00029 #ifndef WOLFSSL_DES_H_
00030 #define WOLFSSL_DES_H_
00031 
00032 #include <wolfssl/wolfcrypt/settings.h>
00033 
00034 #ifndef NO_DES3
00035 
00036 #ifdef WOLFSSL_PREFIX
00037 #include "prefix_des.h"
00038 #endif
00039 
00040 
00041 #ifdef __cplusplus
00042     extern "C" {
00043 #endif
00044 
00045 typedef unsigned char WOLFSSL_DES_cblock[8];
00046 typedef /* const */ WOLFSSL_DES_cblock WOLFSSL_const_DES_cblock;
00047 typedef WOLFSSL_DES_cblock WOLFSSL_DES_key_schedule;
00048 
00049 
00050 enum {
00051     DES_ENCRYPT = 1,
00052     DES_DECRYPT = 0
00053 };
00054 
00055 
00056 WOLFSSL_API int wolfSSL_DES_set_key(WOLFSSL_const_DES_cblock* myDes,
00057                                                WOLFSSL_DES_key_schedule* key);
00058 WOLFSSL_API int wolfSSL_DES_set_key_checked(WOLFSSL_const_DES_cblock* myDes,
00059                                                WOLFSSL_DES_key_schedule* key);
00060 WOLFSSL_API void wolfSSL_DES_set_key_unchecked(WOLFSSL_const_DES_cblock*,
00061                                              WOLFSSL_DES_key_schedule*);
00062 WOLFSSL_API int  wolfSSL_DES_key_sched(WOLFSSL_const_DES_cblock* key,
00063                                      WOLFSSL_DES_key_schedule* schedule);
00064 WOLFSSL_API void wolfSSL_DES_cbc_encrypt(const unsigned char* input,
00065                      unsigned char* output, long length,
00066                      WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec,
00067                      int enc);
00068 WOLFSSL_API void wolfSSL_DES_ede3_cbc_encrypt(const unsigned char* input,
00069                                       unsigned char* output, long sz,
00070                                       WOLFSSL_DES_key_schedule* ks1,
00071                                       WOLFSSL_DES_key_schedule* ks2,
00072                                       WOLFSSL_DES_key_schedule* ks3,
00073                                       WOLFSSL_DES_cblock* ivec, int enc);
00074 WOLFSSL_API void wolfSSL_DES_ncbc_encrypt(const unsigned char* input,
00075                       unsigned char* output, long length,
00076                       WOLFSSL_DES_key_schedule* schedule,
00077                       WOLFSSL_DES_cblock* ivec, int enc);
00078 
00079 WOLFSSL_API void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock*);
00080 WOLFSSL_API void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock*, WOLFSSL_DES_cblock*,
00081                                        WOLFSSL_DES_key_schedule*, int);
00082 
00083 
00084 typedef WOLFSSL_DES_cblock DES_cblock;
00085 typedef WOLFSSL_const_DES_cblock const_DES_cblock;
00086 typedef WOLFSSL_DES_key_schedule DES_key_schedule;
00087 
00088 #define DES_check_key(x) /* Define WOLFSSL_CHECK_DESKEY to check key */
00089 #define DES_set_key           wolfSSL_DES_set_key
00090 #define DES_set_key_checked   wolfSSL_DES_set_key_checked
00091 #define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked
00092 #define DES_key_sched         wolfSSL_DES_key_sched
00093 #define DES_cbc_encrypt       wolfSSL_DES_cbc_encrypt
00094 #define DES_ncbc_encrypt      wolfSSL_DES_ncbc_encrypt
00095 #define DES_set_odd_parity    wolfSSL_DES_set_odd_parity
00096 #define DES_ecb_encrypt       wolfSSL_DES_ecb_encrypt
00097 #define DES_ede3_cbc_encrypt  wolfSSL_DES_ede3_cbc_encrypt
00098 
00099 #ifdef __cplusplus
00100     } /* extern "C" */
00101 #endif
00102 
00103 #endif /* NO_DES3 */
00104 
00105 #endif /* WOLFSSL_DES_H_ */
00106