A library for setting up Secure Socket Layer (SSL) connections and verifying remote hosts using certificates. Contains only the source files for mbed platform implementation of the library.
Dependents: HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL HTTPClient-SSL
cyassl/ctaocrypt/des3.h@6:cf58d49e1a86, 2015-03-23 (annotated)
- Committer:
- Mike Fiore
- Date:
- Mon Mar 23 16:51:07 2015 -0500
- Revision:
- 6:cf58d49e1a86
- Parent:
- 0:b86d15c6ba29
fix whitespace in sha512.c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vanger | 0:b86d15c6ba29 | 1 | /* des3.h |
Vanger | 0:b86d15c6ba29 | 2 | * |
Vanger | 0:b86d15c6ba29 | 3 | * Copyright (C) 2006-2014 wolfSSL Inc. |
Vanger | 0:b86d15c6ba29 | 4 | * |
Vanger | 0:b86d15c6ba29 | 5 | * This file is part of CyaSSL. |
Vanger | 0:b86d15c6ba29 | 6 | * |
Vanger | 0:b86d15c6ba29 | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
Vanger | 0:b86d15c6ba29 | 8 | * it under the terms of the GNU General Public License as published by |
Vanger | 0:b86d15c6ba29 | 9 | * the Free Software Foundation; either version 2 of the License, or |
Vanger | 0:b86d15c6ba29 | 10 | * (at your option) any later version. |
Vanger | 0:b86d15c6ba29 | 11 | * |
Vanger | 0:b86d15c6ba29 | 12 | * CyaSSL is distributed in the hope that it will be useful, |
Vanger | 0:b86d15c6ba29 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Vanger | 0:b86d15c6ba29 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Vanger | 0:b86d15c6ba29 | 15 | * GNU General Public License for more details. |
Vanger | 0:b86d15c6ba29 | 16 | * |
Vanger | 0:b86d15c6ba29 | 17 | * You should have received a copy of the GNU General Public License |
Vanger | 0:b86d15c6ba29 | 18 | * along with this program; if not, write to the Free Software |
Vanger | 0:b86d15c6ba29 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
Vanger | 0:b86d15c6ba29 | 20 | */ |
Vanger | 0:b86d15c6ba29 | 21 | |
Vanger | 0:b86d15c6ba29 | 22 | |
Vanger | 0:b86d15c6ba29 | 23 | #ifndef NO_DES3 |
Vanger | 0:b86d15c6ba29 | 24 | |
Vanger | 0:b86d15c6ba29 | 25 | #ifndef CTAO_CRYPT_DES3_H |
Vanger | 0:b86d15c6ba29 | 26 | #define CTAO_CRYPT_DES3_H |
Vanger | 0:b86d15c6ba29 | 27 | |
Vanger | 0:b86d15c6ba29 | 28 | |
Vanger | 0:b86d15c6ba29 | 29 | #include <cyassl/ctaocrypt/types.h> |
Vanger | 0:b86d15c6ba29 | 30 | |
Vanger | 0:b86d15c6ba29 | 31 | |
Vanger | 0:b86d15c6ba29 | 32 | #ifdef __cplusplus |
Vanger | 0:b86d15c6ba29 | 33 | extern "C" { |
Vanger | 0:b86d15c6ba29 | 34 | #endif |
Vanger | 0:b86d15c6ba29 | 35 | |
Vanger | 0:b86d15c6ba29 | 36 | #define CYASSL_3DES_CAVIUM_MAGIC 0xBEEF0003 |
Vanger | 0:b86d15c6ba29 | 37 | |
Vanger | 0:b86d15c6ba29 | 38 | enum { |
Vanger | 0:b86d15c6ba29 | 39 | DES_ENC_TYPE = 2, /* cipher unique type */ |
Vanger | 0:b86d15c6ba29 | 40 | DES3_ENC_TYPE = 3, /* cipher unique type */ |
Vanger | 0:b86d15c6ba29 | 41 | DES_BLOCK_SIZE = 8, |
Vanger | 0:b86d15c6ba29 | 42 | DES_KS_SIZE = 32, |
Vanger | 0:b86d15c6ba29 | 43 | |
Vanger | 0:b86d15c6ba29 | 44 | DES_ENCRYPTION = 0, |
Vanger | 0:b86d15c6ba29 | 45 | DES_DECRYPTION = 1 |
Vanger | 0:b86d15c6ba29 | 46 | }; |
Vanger | 0:b86d15c6ba29 | 47 | |
Vanger | 0:b86d15c6ba29 | 48 | #define DES_IVLEN 8 |
Vanger | 0:b86d15c6ba29 | 49 | #define DES_KEYLEN 8 |
Vanger | 0:b86d15c6ba29 | 50 | #define DES3_IVLEN 8 |
Vanger | 0:b86d15c6ba29 | 51 | #define DES3_KEYLEN 24 |
Vanger | 0:b86d15c6ba29 | 52 | |
Vanger | 0:b86d15c6ba29 | 53 | |
Vanger | 0:b86d15c6ba29 | 54 | #ifdef STM32F2_CRYPTO |
Vanger | 0:b86d15c6ba29 | 55 | enum { |
Vanger | 0:b86d15c6ba29 | 56 | DES_CBC = 0, |
Vanger | 0:b86d15c6ba29 | 57 | DES_ECB = 1 |
Vanger | 0:b86d15c6ba29 | 58 | }; |
Vanger | 0:b86d15c6ba29 | 59 | #endif |
Vanger | 0:b86d15c6ba29 | 60 | |
Vanger | 0:b86d15c6ba29 | 61 | |
Vanger | 0:b86d15c6ba29 | 62 | /* DES encryption and decryption */ |
Vanger | 0:b86d15c6ba29 | 63 | typedef struct Des { |
Vanger | 0:b86d15c6ba29 | 64 | word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ |
Vanger | 0:b86d15c6ba29 | 65 | word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */ |
Vanger | 0:b86d15c6ba29 | 66 | word32 key[DES_KS_SIZE]; |
Vanger | 0:b86d15c6ba29 | 67 | } Des; |
Vanger | 0:b86d15c6ba29 | 68 | |
Vanger | 0:b86d15c6ba29 | 69 | |
Vanger | 0:b86d15c6ba29 | 70 | /* DES3 encryption and decryption */ |
Vanger | 0:b86d15c6ba29 | 71 | typedef struct Des3 { |
Vanger | 0:b86d15c6ba29 | 72 | word32 key[3][DES_KS_SIZE]; |
Vanger | 0:b86d15c6ba29 | 73 | word32 reg[DES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */ |
Vanger | 0:b86d15c6ba29 | 74 | word32 tmp[DES_BLOCK_SIZE / sizeof(word32)]; /* same */ |
Vanger | 0:b86d15c6ba29 | 75 | #ifdef HAVE_CAVIUM |
Vanger | 0:b86d15c6ba29 | 76 | int devId; /* nitrox device id */ |
Vanger | 0:b86d15c6ba29 | 77 | word32 magic; /* using cavium magic */ |
Vanger | 0:b86d15c6ba29 | 78 | word64 contextHandle; /* nitrox context memory handle */ |
Vanger | 0:b86d15c6ba29 | 79 | #endif |
Vanger | 0:b86d15c6ba29 | 80 | } Des3; |
Vanger | 0:b86d15c6ba29 | 81 | |
Vanger | 0:b86d15c6ba29 | 82 | |
Vanger | 0:b86d15c6ba29 | 83 | CYASSL_API int Des_SetKey(Des* des, const byte* key, const byte* iv, int dir); |
Vanger | 0:b86d15c6ba29 | 84 | CYASSL_API void Des_SetIV(Des* des, const byte* iv); |
Vanger | 0:b86d15c6ba29 | 85 | CYASSL_API int Des_CbcEncrypt(Des* des, byte* out, const byte* in, word32 sz); |
Vanger | 0:b86d15c6ba29 | 86 | CYASSL_API int Des_CbcDecrypt(Des* des, byte* out, const byte* in, word32 sz); |
Vanger | 0:b86d15c6ba29 | 87 | CYASSL_API int Des_EcbEncrypt(Des* des, byte* out, const byte* in, word32 sz); |
Vanger | 0:b86d15c6ba29 | 88 | CYASSL_API int Des_CbcDecryptWithKey(byte* out, const byte* in, word32 sz, |
Vanger | 0:b86d15c6ba29 | 89 | const byte* key, const byte* iv); |
Vanger | 0:b86d15c6ba29 | 90 | |
Vanger | 0:b86d15c6ba29 | 91 | CYASSL_API int Des3_SetKey(Des3* des, const byte* key, const byte* iv,int dir); |
Vanger | 0:b86d15c6ba29 | 92 | CYASSL_API int Des3_SetIV(Des3* des, const byte* iv); |
Vanger | 0:b86d15c6ba29 | 93 | CYASSL_API int Des3_CbcEncrypt(Des3* des, byte* out, const byte* in,word32 sz); |
Vanger | 0:b86d15c6ba29 | 94 | CYASSL_API int Des3_CbcDecrypt(Des3* des, byte* out, const byte* in,word32 sz); |
Vanger | 0:b86d15c6ba29 | 95 | CYASSL_API int Des3_CbcDecryptWithKey(byte* out, const byte* in, word32 sz, |
Vanger | 0:b86d15c6ba29 | 96 | const byte* key, const byte* iv); |
Vanger | 0:b86d15c6ba29 | 97 | |
Vanger | 0:b86d15c6ba29 | 98 | |
Vanger | 0:b86d15c6ba29 | 99 | #ifdef HAVE_CAVIUM |
Vanger | 0:b86d15c6ba29 | 100 | CYASSL_API int Des3_InitCavium(Des3*, int); |
Vanger | 0:b86d15c6ba29 | 101 | CYASSL_API void Des3_FreeCavium(Des3*); |
Vanger | 0:b86d15c6ba29 | 102 | #endif |
Vanger | 0:b86d15c6ba29 | 103 | |
Vanger | 0:b86d15c6ba29 | 104 | |
Vanger | 0:b86d15c6ba29 | 105 | #ifdef HAVE_FIPS |
Vanger | 0:b86d15c6ba29 | 106 | /* fips wrapper calls, user can call direct */ |
Vanger | 0:b86d15c6ba29 | 107 | CYASSL_API int Des3_SetKey_fips(Des3* des, const byte* key, const byte* iv, |
Vanger | 0:b86d15c6ba29 | 108 | int dir); |
Vanger | 0:b86d15c6ba29 | 109 | CYASSL_API int Des3_SetIV_fips(Des3* des, const byte* iv); |
Vanger | 0:b86d15c6ba29 | 110 | CYASSL_API int Des3_CbcEncrypt_fips(Des3* des, byte* out, const byte* in, |
Vanger | 0:b86d15c6ba29 | 111 | word32 sz); |
Vanger | 0:b86d15c6ba29 | 112 | CYASSL_API int Des3_CbcDecrypt_fips(Des3* des, byte* out, const byte* in, |
Vanger | 0:b86d15c6ba29 | 113 | word32 sz); |
Vanger | 0:b86d15c6ba29 | 114 | #ifndef FIPS_NO_WRAPPERS |
Vanger | 0:b86d15c6ba29 | 115 | /* if not impl or fips.c impl wrapper force fips calls if fips build */ |
Vanger | 0:b86d15c6ba29 | 116 | #define Des3_SetKey Des3_SetKey_fips |
Vanger | 0:b86d15c6ba29 | 117 | #define Des3_SetIV Des3_SetIV_fips |
Vanger | 0:b86d15c6ba29 | 118 | #define Des3_CbcEncrypt Des3_CbcEncrypt_fips |
Vanger | 0:b86d15c6ba29 | 119 | #define Des3_CbcDecrypt Des3_CbcDecrypt_fips |
Vanger | 0:b86d15c6ba29 | 120 | #endif /* FIPS_NO_WRAPPERS */ |
Vanger | 0:b86d15c6ba29 | 121 | |
Vanger | 0:b86d15c6ba29 | 122 | #endif /* HAVE_FIPS */ |
Vanger | 0:b86d15c6ba29 | 123 | |
Vanger | 0:b86d15c6ba29 | 124 | |
Vanger | 0:b86d15c6ba29 | 125 | #ifdef __cplusplus |
Vanger | 0:b86d15c6ba29 | 126 | } /* extern "C" */ |
Vanger | 0:b86d15c6ba29 | 127 | #endif |
Vanger | 0:b86d15c6ba29 | 128 | |
Vanger | 0:b86d15c6ba29 | 129 | #endif /* NO_DES3 */ |
Vanger | 0:b86d15c6ba29 | 130 | #endif /* CTAO_CRYPT_DES3_H */ |
Vanger | 0:b86d15c6ba29 | 131 |