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 HTTPClient-SSL http_access ... more
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 #ifdef HAVE_COLDFIRE_SEC 00067 byte keylen ; /* for Coldfire SEC */ 00068 byte ivlen ; /* for Coldfire SEC */ 00069 byte iv[DES3_IVLEN]; /* for Coldfire SEC */ 00070 #endif 00071 word32 key[DES_KS_SIZE]; 00072 } Des; 00073 00074 00075 /* DES3 encryption and decryption */ 00076 typedef struct Des3 { 00077 #ifdef HAVE_COLDFIRE_SEC 00078 byte keylen ; /* for Coldfire SEC */ 00079 byte ivlen ; /* for Coldfire SEC */ 00080 byte iv[DES3_IVLEN]; /* for Coldfire SEC */ 00081 #endif 00082 word32 key[3][DES_KS_SIZE]; 00083 word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ 00084 word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */ 00085 #ifdef HAVE_CAVIUM 00086 int devId; /* nitrox device id */ 00087 word32 magic; /* using cavium magic */ 00088 word64 contextHandle; /* nitrox context memory handle */ 00089 #endif 00090 } Des3; 00091 00092 00093 CYASSL_API int Des_SetKey(Des* des, const byte* key, const byte* iv, int dir); 00094 CYASSL_API void Des_SetIV(Des* des, const byte* iv); 00095 CYASSL_API void Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz); 00096 CYASSL_API void Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz); 00097 CYASSL_API void Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz); 00098 00099 CYASSL_API int Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir); 00100 CYASSL_API int Des3_SetIV(Des3* des, const byte* iv); 00101 CYASSL_API int Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz); 00102 CYASSL_API int Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz); 00103 00104 00105 #ifdef HAVE_CAVIUM 00106 CYASSL_API int Des3_InitCavium(Des3*, int); 00107 CYASSL_API void Des3_FreeCavium(Des3*); 00108 #endif 00109 00110 00111 #ifdef HAVE_FIPS 00112 /* fips wrapper calls, user can call direct */ 00113 CYASSL_API int Des3_SetKey_fips(Des3* des, const byte* key, const byte* iv, 00114 int dir); 00115 CYASSL_API int Des3_SetIV_fips(Des3* des, const byte* iv); 00116 CYASSL_API int Des3_CbcEncrypt_fips(Des3* des, byte* out, const byte* in, 00117 word32 sz); 00118 CYASSL_API int Des3_CbcDecrypt_fips(Des3* des, byte* out, const byte* in, 00119 word32 sz); 00120 #ifndef FIPS_NO_WRAPPERS 00121 /* if not impl or fips.c impl wrapper force fips calls if fips build */ 00122 #define Des3_SetKey Des3_SetKey_fips 00123 #define Des3_SetIV Des3_SetIV_fips 00124 #define Des3_CbcEncrypt Des3_CbcEncrypt_fips 00125 #define Des3_CbcDecrypt Des3_CbcDecrypt_fips 00126 #endif /* FIPS_NO_WRAPPERS */ 00127 00128 #endif /* HAVE_FIPS */ 00129 00130 00131 #ifdef __cplusplus 00132 } /* extern "C" */ 00133 #endif 00134 00135 #endif /* NO_DES3 */ 00136 #endif /* CTAO_CRYPT_DES3_H */ 00137 00138
Generated on Wed Jul 13 2022 02:18:39 by
 1.7.2
 1.7.2 
    