Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL
des3.h
00001 /* des3.h 00002 * 00003 * Copyright (C) 2006-2014 wolfSSL Inc. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL 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 * CyaSSL 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-1301, USA 00020 */ 00021 00022 00023 #ifndef NO_DES3 00024 00025 #ifndef CTAO_CRYPT_DES3_H 00026 #define CTAO_CRYPT_DES3_H 00027 00028 00029 #include <cyassl/ctaocrypt/types.h> 00030 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 #define CYASSL_3DES_CAVIUM_MAGIC 0xBEEF0003 00037 00038 enum { 00039 DES_ENC_TYPE = 2, /* cipher unique type */ 00040 DES3_ENC_TYPE = 3, /* cipher unique type */ 00041 DES_BLOCK_SIZE = 8, 00042 DES_KS_SIZE = 32, 00043 00044 DES_ENCRYPTION = 0, 00045 DES_DECRYPTION = 1 00046 }; 00047 00048 #define DES_IVLEN 8 00049 #define DES_KEYLEN 8 00050 #define DES3_IVLEN 8 00051 #define DES3_KEYLEN 24 00052 00053 00054 #ifdef STM32F2_CRYPTO 00055 enum { 00056 DES_CBC = 0, 00057 DES_ECB = 1 00058 }; 00059 #endif 00060 00061 00062 /* DES encryption and decryption */ 00063 typedef struct Des { 00064 word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ 00065 word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */ 00066 word32 key[DES_KS_SIZE]; 00067 } Des; 00068 00069 00070 /* DES3 encryption and decryption */ 00071 typedef struct Des3 { 00072 word32 key[3][DES_KS_SIZE]; 00073 word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ 00074 word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */ 00075 #ifdef HAVE_CAVIUM 00076 int devId; /* nitrox device id */ 00077 word32 magic; /* using cavium magic */ 00078 word64 contextHandle; /* nitrox context memory handle */ 00079 #endif 00080 } Des3; 00081 00082 00083 CYASSL_API int Des_SetKey(Des* des, const byte* key, const byte* iv, int dir); 00084 CYASSL_API void Des_SetIV(Des* des, const byte* iv); 00085 CYASSL_API int Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz); 00086 CYASSL_API int Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz); 00087 CYASSL_API int Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz); 00088 CYASSL_API int Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz, 00089 const byte* key, const byte* iv); 00090 00091 CYASSL_API int Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir); 00092 CYASSL_API int Des3_SetIV(Des3* des, const byte* iv); 00093 CYASSL_API int Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz); 00094 CYASSL_API int Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz); 00095 CYASSL_API int Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz, 00096 const byte* key, const byte* iv); 00097 00098 00099 #ifdef HAVE_CAVIUM 00100 CYASSL_API int Des3_InitCavium(Des3*, int); 00101 CYASSL_API void Des3_FreeCavium(Des3*); 00102 #endif 00103 00104 00105 #ifdef HAVE_FIPS 00106 /* fips wrapper calls, user can call direct */ 00107 CYASSL_API int Des3_SetKey_fips(Des3* des, const byte* key, const byte* iv, 00108 int dir); 00109 CYASSL_API int Des3_SetIV_fips(Des3* des, const byte* iv); 00110 CYASSL_API int Des3_CbcEncrypt_fips(Des3* des, byte* out, const byte* in, 00111 word32 sz); 00112 CYASSL_API int Des3_CbcDecrypt_fips(Des3* des, byte* out, const byte* in, 00113 word32 sz); 00114 #ifndef FIPS_NO_WRAPPERS 00115 /* if not impl or fips.c impl wrapper force fips calls if fips build */ 00116 #define Des3_SetKey Des3_SetKey_fips 00117 #define Des3_SetIV Des3_SetIV_fips 00118 #define Des3_CbcEncrypt Des3_CbcEncrypt_fips 00119 #define Des3_CbcDecrypt Des3_CbcDecrypt_fips 00120 #endif /* FIPS_NO_WRAPPERS */ 00121 00122 #endif /* HAVE_FIPS */ 00123 00124 00125 #ifdef __cplusplus 00126 } /* extern "C" */ 00127 #endif 00128 00129 #endif /* NO_DES3 */ 00130 #endif /* CTAO_CRYPT_DES3_H */ 00131
Generated on Wed Jul 13 2022 02:33:55 by
1.7.2