A simple CyaSSL-based HMAC-MD5 implementation. Licensed under GPL v2.
Dependents: RFrec_full RFtrans_full
The output will be base64-encoded, with trailing "==", like this:
j62o/jZsAZD9i9m+32lIuQ==
Example
#include "mbed.h" #include "hmac_md5.h" Serial pc(USBTX, USBRX); // tx, rx void main(void) { const char * key = "MySecretKey"; const char * text = "message to be signed"; char output[26]; HMAC_MD5(key, text, output); printf("result = %s\n", output); while(true){} }
types.h@0:83f3dcfa5c8f, 2013-02-06 (annotated)
- Committer:
- igrokhotkov
- Date:
- Wed Feb 06 20:35:03 2013 +0000
- Revision:
- 0:83f3dcfa5c8f
initial revision
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igrokhotkov | 0:83f3dcfa5c8f | 1 | /* types.h |
igrokhotkov | 0:83f3dcfa5c8f | 2 | * |
igrokhotkov | 0:83f3dcfa5c8f | 3 | * Copyright (C) 2006-2012 Sawtooth Consulting Ltd. |
igrokhotkov | 0:83f3dcfa5c8f | 4 | * |
igrokhotkov | 0:83f3dcfa5c8f | 5 | * This file is part of CyaSSL. |
igrokhotkov | 0:83f3dcfa5c8f | 6 | * |
igrokhotkov | 0:83f3dcfa5c8f | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
igrokhotkov | 0:83f3dcfa5c8f | 8 | * it under the terms of the GNU General Public License as published by |
igrokhotkov | 0:83f3dcfa5c8f | 9 | * the Free Software Foundation; either version 2 of the License, or |
igrokhotkov | 0:83f3dcfa5c8f | 10 | * (at your option) any later version. |
igrokhotkov | 0:83f3dcfa5c8f | 11 | * |
igrokhotkov | 0:83f3dcfa5c8f | 12 | * CyaSSL is distributed in the hope that it will be useful, |
igrokhotkov | 0:83f3dcfa5c8f | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
igrokhotkov | 0:83f3dcfa5c8f | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
igrokhotkov | 0:83f3dcfa5c8f | 15 | * GNU General Public License for more details. |
igrokhotkov | 0:83f3dcfa5c8f | 16 | * |
igrokhotkov | 0:83f3dcfa5c8f | 17 | * You should have received a copy of the GNU General Public License |
igrokhotkov | 0:83f3dcfa5c8f | 18 | * along with this program; if not, write to the Free Software |
igrokhotkov | 0:83f3dcfa5c8f | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
igrokhotkov | 0:83f3dcfa5c8f | 20 | */ |
igrokhotkov | 0:83f3dcfa5c8f | 21 | |
igrokhotkov | 0:83f3dcfa5c8f | 22 | |
igrokhotkov | 0:83f3dcfa5c8f | 23 | #ifndef CTAO_CRYPT_TYPES_H |
igrokhotkov | 0:83f3dcfa5c8f | 24 | #define CTAO_CRYPT_TYPES_H |
igrokhotkov | 0:83f3dcfa5c8f | 25 | |
igrokhotkov | 0:83f3dcfa5c8f | 26 | #include "settings.h" |
igrokhotkov | 0:83f3dcfa5c8f | 27 | |
igrokhotkov | 0:83f3dcfa5c8f | 28 | #ifdef __cplusplus |
igrokhotkov | 0:83f3dcfa5c8f | 29 | extern "C" { |
igrokhotkov | 0:83f3dcfa5c8f | 30 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 31 | |
igrokhotkov | 0:83f3dcfa5c8f | 32 | |
igrokhotkov | 0:83f3dcfa5c8f | 33 | #if defined(WORDS_BIGENDIAN) |
igrokhotkov | 0:83f3dcfa5c8f | 34 | #define BIG_ENDIAN_ORDER |
igrokhotkov | 0:83f3dcfa5c8f | 35 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 36 | |
igrokhotkov | 0:83f3dcfa5c8f | 37 | #ifndef BIG_ENDIAN_ORDER |
igrokhotkov | 0:83f3dcfa5c8f | 38 | #define LITTLE_ENDIAN_ORDER |
igrokhotkov | 0:83f3dcfa5c8f | 39 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 40 | |
igrokhotkov | 0:83f3dcfa5c8f | 41 | #ifndef CYASSL_TYPES |
igrokhotkov | 0:83f3dcfa5c8f | 42 | #ifndef byte |
igrokhotkov | 0:83f3dcfa5c8f | 43 | typedef unsigned char byte; |
igrokhotkov | 0:83f3dcfa5c8f | 44 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 45 | typedef unsigned short word16; |
igrokhotkov | 0:83f3dcfa5c8f | 46 | typedef unsigned int word32; |
igrokhotkov | 0:83f3dcfa5c8f | 47 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 48 | |
igrokhotkov | 0:83f3dcfa5c8f | 49 | |
igrokhotkov | 0:83f3dcfa5c8f | 50 | /* try to set SIZEOF_LONG or LONG_LONG if user didn't */ |
igrokhotkov | 0:83f3dcfa5c8f | 51 | #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__) |
igrokhotkov | 0:83f3dcfa5c8f | 52 | #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG) |
igrokhotkov | 0:83f3dcfa5c8f | 53 | #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \ |
igrokhotkov | 0:83f3dcfa5c8f | 54 | || defined(__mips64) || defined(__x86_64__)) |
igrokhotkov | 0:83f3dcfa5c8f | 55 | /* long should be 64bit */ |
igrokhotkov | 0:83f3dcfa5c8f | 56 | #define SIZEOF_LONG 8 |
igrokhotkov | 0:83f3dcfa5c8f | 57 | #elif defined(__i386__) |
igrokhotkov | 0:83f3dcfa5c8f | 58 | /* long long should be 64bit */ |
igrokhotkov | 0:83f3dcfa5c8f | 59 | #define SIZEOF_LONG_LONG 8 |
igrokhotkov | 0:83f3dcfa5c8f | 60 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 61 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 62 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 63 | |
igrokhotkov | 0:83f3dcfa5c8f | 64 | |
igrokhotkov | 0:83f3dcfa5c8f | 65 | #if defined(_MSC_VER) || defined(__BCPLUSPLUS__) |
igrokhotkov | 0:83f3dcfa5c8f | 66 | #define WORD64_AVAILABLE |
igrokhotkov | 0:83f3dcfa5c8f | 67 | #define W64LIT(x) x##ui64 |
igrokhotkov | 0:83f3dcfa5c8f | 68 | typedef unsigned __int64 word64; |
igrokhotkov | 0:83f3dcfa5c8f | 69 | #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8 |
igrokhotkov | 0:83f3dcfa5c8f | 70 | #define WORD64_AVAILABLE |
igrokhotkov | 0:83f3dcfa5c8f | 71 | #define W64LIT(x) x##LL |
igrokhotkov | 0:83f3dcfa5c8f | 72 | typedef unsigned long word64; |
igrokhotkov | 0:83f3dcfa5c8f | 73 | #elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG == 8 |
igrokhotkov | 0:83f3dcfa5c8f | 74 | #define WORD64_AVAILABLE |
igrokhotkov | 0:83f3dcfa5c8f | 75 | #define W64LIT(x) x##LL |
igrokhotkov | 0:83f3dcfa5c8f | 76 | typedef unsigned long long word64; |
igrokhotkov | 0:83f3dcfa5c8f | 77 | #else |
igrokhotkov | 0:83f3dcfa5c8f | 78 | #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as |
igrokhotkov | 0:83f3dcfa5c8f | 79 | mp_digit, no 64 bit type so make mp_digit 16 bit */ |
igrokhotkov | 0:83f3dcfa5c8f | 80 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 81 | |
igrokhotkov | 0:83f3dcfa5c8f | 82 | |
igrokhotkov | 0:83f3dcfa5c8f | 83 | /* These platforms have 64-bit CPU registers. */ |
igrokhotkov | 0:83f3dcfa5c8f | 84 | #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ |
igrokhotkov | 0:83f3dcfa5c8f | 85 | defined(__mips64) || defined(__x86_64__) || defined(_M_X64)) |
igrokhotkov | 0:83f3dcfa5c8f | 86 | typedef word64 word; |
igrokhotkov | 0:83f3dcfa5c8f | 87 | #else |
igrokhotkov | 0:83f3dcfa5c8f | 88 | typedef word32 word; |
igrokhotkov | 0:83f3dcfa5c8f | 89 | #ifdef WORD64_AVAILABLE |
igrokhotkov | 0:83f3dcfa5c8f | 90 | #define CTAOCRYPT_SLOW_WORD64 |
igrokhotkov | 0:83f3dcfa5c8f | 91 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 92 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 93 | |
igrokhotkov | 0:83f3dcfa5c8f | 94 | |
igrokhotkov | 0:83f3dcfa5c8f | 95 | enum { |
igrokhotkov | 0:83f3dcfa5c8f | 96 | WORD_SIZE = sizeof(word), |
igrokhotkov | 0:83f3dcfa5c8f | 97 | BIT_SIZE = 8, |
igrokhotkov | 0:83f3dcfa5c8f | 98 | WORD_BITS = WORD_SIZE * BIT_SIZE |
igrokhotkov | 0:83f3dcfa5c8f | 99 | }; |
igrokhotkov | 0:83f3dcfa5c8f | 100 | |
igrokhotkov | 0:83f3dcfa5c8f | 101 | #define CYASSL_MAX_16BIT 0xffffU |
igrokhotkov | 0:83f3dcfa5c8f | 102 | |
igrokhotkov | 0:83f3dcfa5c8f | 103 | /* use inlining if compiler allows */ |
igrokhotkov | 0:83f3dcfa5c8f | 104 | #ifndef INLINE |
igrokhotkov | 0:83f3dcfa5c8f | 105 | #ifndef NO_INLINE |
igrokhotkov | 0:83f3dcfa5c8f | 106 | #ifdef _MSC_VER |
igrokhotkov | 0:83f3dcfa5c8f | 107 | #define INLINE __inline |
igrokhotkov | 0:83f3dcfa5c8f | 108 | #elif defined(__GNUC__) |
igrokhotkov | 0:83f3dcfa5c8f | 109 | #define INLINE inline |
igrokhotkov | 0:83f3dcfa5c8f | 110 | #elif defined(THREADX) |
igrokhotkov | 0:83f3dcfa5c8f | 111 | #define INLINE _Inline |
igrokhotkov | 0:83f3dcfa5c8f | 112 | #elif defined(__IAR_SYSTEMS_ICC__) |
igrokhotkov | 0:83f3dcfa5c8f | 113 | #define INLINE inline |
igrokhotkov | 0:83f3dcfa5c8f | 114 | #else |
igrokhotkov | 0:83f3dcfa5c8f | 115 | #define INLINE |
igrokhotkov | 0:83f3dcfa5c8f | 116 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 117 | #else |
igrokhotkov | 0:83f3dcfa5c8f | 118 | #define INLINE |
igrokhotkov | 0:83f3dcfa5c8f | 119 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 120 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 121 | |
igrokhotkov | 0:83f3dcfa5c8f | 122 | |
igrokhotkov | 0:83f3dcfa5c8f | 123 | /* set up rotate style */ |
igrokhotkov | 0:83f3dcfa5c8f | 124 | #if defined(_MSC_VER) || defined(__BCPLUSPLUS__) |
igrokhotkov | 0:83f3dcfa5c8f | 125 | #define INTEL_INTRINSICS |
igrokhotkov | 0:83f3dcfa5c8f | 126 | #define FAST_ROTATE |
igrokhotkov | 0:83f3dcfa5c8f | 127 | #elif defined(__MWERKS__) && TARGET_CPU_PPC |
igrokhotkov | 0:83f3dcfa5c8f | 128 | #define PPC_INTRINSICS |
igrokhotkov | 0:83f3dcfa5c8f | 129 | #define FAST_ROTATE |
igrokhotkov | 0:83f3dcfa5c8f | 130 | #elif defined(__GNUC__) && defined(__i386__) |
igrokhotkov | 0:83f3dcfa5c8f | 131 | /* GCC does peephole optimizations which should result in using rotate |
igrokhotkov | 0:83f3dcfa5c8f | 132 | instructions */ |
igrokhotkov | 0:83f3dcfa5c8f | 133 | #define FAST_ROTATE |
igrokhotkov | 0:83f3dcfa5c8f | 134 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 135 | |
igrokhotkov | 0:83f3dcfa5c8f | 136 | |
igrokhotkov | 0:83f3dcfa5c8f | 137 | /* Micrium will use Visual Studio for compilation but not the Win32 API */ |
igrokhotkov | 0:83f3dcfa5c8f | 138 | #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \ |
igrokhotkov | 0:83f3dcfa5c8f | 139 | && !defined(EBSNET) |
igrokhotkov | 0:83f3dcfa5c8f | 140 | #define USE_WINDOWS_API |
igrokhotkov | 0:83f3dcfa5c8f | 141 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 142 | |
igrokhotkov | 0:83f3dcfa5c8f | 143 | |
igrokhotkov | 0:83f3dcfa5c8f | 144 | /* idea to add global alloc override by Moisés Guimarães */ |
igrokhotkov | 0:83f3dcfa5c8f | 145 | /* default to libc stuff */ |
igrokhotkov | 0:83f3dcfa5c8f | 146 | /* XREALLOC is used once in normal math lib, not in fast math lib */ |
igrokhotkov | 0:83f3dcfa5c8f | 147 | /* XFREE on some embeded systems doesn't like free(0) so test */ |
igrokhotkov | 0:83f3dcfa5c8f | 148 | #ifdef XMALLOC_USER |
igrokhotkov | 0:83f3dcfa5c8f | 149 | /* prototypes for user heap override functions */ |
igrokhotkov | 0:83f3dcfa5c8f | 150 | #include <stddef.h> /* for size_t */ |
igrokhotkov | 0:83f3dcfa5c8f | 151 | extern void *XMALLOC(size_t n, void* heap, int type); |
igrokhotkov | 0:83f3dcfa5c8f | 152 | extern void *XREALLOC(void *p, size_t n, void* heap, int type); |
igrokhotkov | 0:83f3dcfa5c8f | 153 | extern void XFREE(void *p, void* heap, int type); |
igrokhotkov | 0:83f3dcfa5c8f | 154 | #elif !defined(MICRIUM_MALLOC) && !defined(EBSNET) \ |
igrokhotkov | 0:83f3dcfa5c8f | 155 | && !defined(CYASSL_SAFERTOS) && !defined(FREESCALE_MQX) \ |
igrokhotkov | 0:83f3dcfa5c8f | 156 | && !defined(CYASSL_LEANPSK) |
igrokhotkov | 0:83f3dcfa5c8f | 157 | /* default C runtime, can install different routines at runtime */ |
igrokhotkov | 0:83f3dcfa5c8f | 158 | #include "memory.h" |
igrokhotkov | 0:83f3dcfa5c8f | 159 | #define XMALLOC(s, h, t) ((void)h, (void)t, CyaSSL_Malloc((s))) |
igrokhotkov | 0:83f3dcfa5c8f | 160 | #define XFREE(p, h, t) {void* xp = (p); if((xp)) CyaSSL_Free((xp));} |
igrokhotkov | 0:83f3dcfa5c8f | 161 | #define XREALLOC(p, n, h, t) CyaSSL_Realloc((p), (n)) |
igrokhotkov | 0:83f3dcfa5c8f | 162 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 163 | |
igrokhotkov | 0:83f3dcfa5c8f | 164 | #ifndef STRING_USER |
igrokhotkov | 0:83f3dcfa5c8f | 165 | #include <string.h> |
igrokhotkov | 0:83f3dcfa5c8f | 166 | char* mystrnstr(const char* s1, const char* s2, unsigned int n); |
igrokhotkov | 0:83f3dcfa5c8f | 167 | |
igrokhotkov | 0:83f3dcfa5c8f | 168 | #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) |
igrokhotkov | 0:83f3dcfa5c8f | 169 | #define XMEMSET(b,c,l) memset((b),(c),(l)) |
igrokhotkov | 0:83f3dcfa5c8f | 170 | #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 171 | #define XMEMMOVE(d,s,l) memmove((d),(s),(l)) |
igrokhotkov | 0:83f3dcfa5c8f | 172 | |
igrokhotkov | 0:83f3dcfa5c8f | 173 | #define XSTRLEN(s1) strlen((s1)) |
igrokhotkov | 0:83f3dcfa5c8f | 174 | #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 175 | /* strstr, strncmp, and strncat only used by CyaSSL proper, not required for |
igrokhotkov | 0:83f3dcfa5c8f | 176 | CTaoCrypt only */ |
igrokhotkov | 0:83f3dcfa5c8f | 177 | #define XSTRSTR(s1,s2) strstr((s1),(s2)) |
igrokhotkov | 0:83f3dcfa5c8f | 178 | #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 179 | #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 180 | #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 181 | #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n)) |
igrokhotkov | 0:83f3dcfa5c8f | 182 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 183 | |
igrokhotkov | 0:83f3dcfa5c8f | 184 | #if defined(HAVE_ECC) || defined(HAVE_OCSP) |
igrokhotkov | 0:83f3dcfa5c8f | 185 | #ifndef CTYPE_USER |
igrokhotkov | 0:83f3dcfa5c8f | 186 | #include <ctype.h> |
igrokhotkov | 0:83f3dcfa5c8f | 187 | #define XTOUPPER(c) toupper((c)) |
igrokhotkov | 0:83f3dcfa5c8f | 188 | #define XISALPHA(c) isalpha((c)) |
igrokhotkov | 0:83f3dcfa5c8f | 189 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 190 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 191 | |
igrokhotkov | 0:83f3dcfa5c8f | 192 | |
igrokhotkov | 0:83f3dcfa5c8f | 193 | /* memory allocation types for user hints */ |
igrokhotkov | 0:83f3dcfa5c8f | 194 | enum { |
igrokhotkov | 0:83f3dcfa5c8f | 195 | DYNAMIC_TYPE_CA = 1, |
igrokhotkov | 0:83f3dcfa5c8f | 196 | DYNAMIC_TYPE_CERT = 2, |
igrokhotkov | 0:83f3dcfa5c8f | 197 | DYNAMIC_TYPE_KEY = 3, |
igrokhotkov | 0:83f3dcfa5c8f | 198 | DYNAMIC_TYPE_FILE = 4, |
igrokhotkov | 0:83f3dcfa5c8f | 199 | DYNAMIC_TYPE_SUBJECT_CN = 5, |
igrokhotkov | 0:83f3dcfa5c8f | 200 | DYNAMIC_TYPE_PUBLIC_KEY = 6, |
igrokhotkov | 0:83f3dcfa5c8f | 201 | DYNAMIC_TYPE_SIGNER = 7, |
igrokhotkov | 0:83f3dcfa5c8f | 202 | DYNAMIC_TYPE_NONE = 8, |
igrokhotkov | 0:83f3dcfa5c8f | 203 | DYNAMIC_TYPE_BIGINT = 9, |
igrokhotkov | 0:83f3dcfa5c8f | 204 | DYNAMIC_TYPE_RSA = 10, |
igrokhotkov | 0:83f3dcfa5c8f | 205 | DYNAMIC_TYPE_METHOD = 11, |
igrokhotkov | 0:83f3dcfa5c8f | 206 | DYNAMIC_TYPE_OUT_BUFFER = 12, |
igrokhotkov | 0:83f3dcfa5c8f | 207 | DYNAMIC_TYPE_IN_BUFFER = 13, |
igrokhotkov | 0:83f3dcfa5c8f | 208 | DYNAMIC_TYPE_INFO = 14, |
igrokhotkov | 0:83f3dcfa5c8f | 209 | DYNAMIC_TYPE_DH = 15, |
igrokhotkov | 0:83f3dcfa5c8f | 210 | DYNAMIC_TYPE_DOMAIN = 16, |
igrokhotkov | 0:83f3dcfa5c8f | 211 | DYNAMIC_TYPE_SSL = 17, |
igrokhotkov | 0:83f3dcfa5c8f | 212 | DYNAMIC_TYPE_CTX = 18, |
igrokhotkov | 0:83f3dcfa5c8f | 213 | DYNAMIC_TYPE_WRITEV = 19, |
igrokhotkov | 0:83f3dcfa5c8f | 214 | DYNAMIC_TYPE_OPENSSL = 20, |
igrokhotkov | 0:83f3dcfa5c8f | 215 | DYNAMIC_TYPE_DSA = 21, |
igrokhotkov | 0:83f3dcfa5c8f | 216 | DYNAMIC_TYPE_CRL = 22, |
igrokhotkov | 0:83f3dcfa5c8f | 217 | DYNAMIC_TYPE_REVOKED = 23, |
igrokhotkov | 0:83f3dcfa5c8f | 218 | DYNAMIC_TYPE_CRL_ENTRY = 24, |
igrokhotkov | 0:83f3dcfa5c8f | 219 | DYNAMIC_TYPE_CERT_MANAGER = 25, |
igrokhotkov | 0:83f3dcfa5c8f | 220 | DYNAMIC_TYPE_CRL_MONITOR = 26, |
igrokhotkov | 0:83f3dcfa5c8f | 221 | DYNAMIC_TYPE_OCSP_STATUS = 27, |
igrokhotkov | 0:83f3dcfa5c8f | 222 | DYNAMIC_TYPE_OCSP_ENTRY = 28, |
igrokhotkov | 0:83f3dcfa5c8f | 223 | DYNAMIC_TYPE_ALTNAME = 29, |
igrokhotkov | 0:83f3dcfa5c8f | 224 | DYNAMIC_TYPE_SUITES = 30, |
igrokhotkov | 0:83f3dcfa5c8f | 225 | DYNAMIC_TYPE_CIPHER = 31, |
igrokhotkov | 0:83f3dcfa5c8f | 226 | DYNAMIC_TYPE_RNG = 32, |
igrokhotkov | 0:83f3dcfa5c8f | 227 | DYNAMIC_TYPE_ARRAYS = 33, |
igrokhotkov | 0:83f3dcfa5c8f | 228 | DYNAMIC_TYPE_DTLS_POOL = 34, |
igrokhotkov | 0:83f3dcfa5c8f | 229 | DYNAMIC_TYPE_SOCKADDR = 35, |
igrokhotkov | 0:83f3dcfa5c8f | 230 | DYNAMIC_TYPE_LIBZ = 36, |
igrokhotkov | 0:83f3dcfa5c8f | 231 | DYNAMIC_TYPE_ECC = 37, |
igrokhotkov | 0:83f3dcfa5c8f | 232 | DYNAMIC_TYPE_TMP_BUFFER = 38, |
igrokhotkov | 0:83f3dcfa5c8f | 233 | DYNAMIC_TYPE_CAVIUM_TMP = 40, |
igrokhotkov | 0:83f3dcfa5c8f | 234 | DYNAMIC_TYPE_CAVIUM_RSA = 41 |
igrokhotkov | 0:83f3dcfa5c8f | 235 | }; |
igrokhotkov | 0:83f3dcfa5c8f | 236 | |
igrokhotkov | 0:83f3dcfa5c8f | 237 | /* stack protection */ |
igrokhotkov | 0:83f3dcfa5c8f | 238 | enum { |
igrokhotkov | 0:83f3dcfa5c8f | 239 | MIN_STACK_BUFFER = 8 |
igrokhotkov | 0:83f3dcfa5c8f | 240 | }; |
igrokhotkov | 0:83f3dcfa5c8f | 241 | |
igrokhotkov | 0:83f3dcfa5c8f | 242 | |
igrokhotkov | 0:83f3dcfa5c8f | 243 | |
igrokhotkov | 0:83f3dcfa5c8f | 244 | /* settings detection for compile vs runtime math incombatibilities */ |
igrokhotkov | 0:83f3dcfa5c8f | 245 | enum { |
igrokhotkov | 0:83f3dcfa5c8f | 246 | #if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG) |
igrokhotkov | 0:83f3dcfa5c8f | 247 | CTC_SETTINGS = 0x0 |
igrokhotkov | 0:83f3dcfa5c8f | 248 | #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8) |
igrokhotkov | 0:83f3dcfa5c8f | 249 | CTC_SETTINGS = 0x1 |
igrokhotkov | 0:83f3dcfa5c8f | 250 | #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8) |
igrokhotkov | 0:83f3dcfa5c8f | 251 | CTC_SETTINGS = 0x2 |
igrokhotkov | 0:83f3dcfa5c8f | 252 | #elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4) |
igrokhotkov | 0:83f3dcfa5c8f | 253 | CTC_SETTINGS = 0x4 |
igrokhotkov | 0:83f3dcfa5c8f | 254 | #elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG) |
igrokhotkov | 0:83f3dcfa5c8f | 255 | CTC_SETTINGS = 0x8 |
igrokhotkov | 0:83f3dcfa5c8f | 256 | #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG) && (SIZEOF_LONG == 8) |
igrokhotkov | 0:83f3dcfa5c8f | 257 | CTC_SETTINGS = 0x10 |
igrokhotkov | 0:83f3dcfa5c8f | 258 | #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8) |
igrokhotkov | 0:83f3dcfa5c8f | 259 | CTC_SETTINGS = 0x20 |
igrokhotkov | 0:83f3dcfa5c8f | 260 | #elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 4) |
igrokhotkov | 0:83f3dcfa5c8f | 261 | CTC_SETTINGS = 0x40 |
igrokhotkov | 0:83f3dcfa5c8f | 262 | #else |
igrokhotkov | 0:83f3dcfa5c8f | 263 | #error "bad math long / long long settings" |
igrokhotkov | 0:83f3dcfa5c8f | 264 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 265 | }; |
igrokhotkov | 0:83f3dcfa5c8f | 266 | |
igrokhotkov | 0:83f3dcfa5c8f | 267 | |
igrokhotkov | 0:83f3dcfa5c8f | 268 | CYASSL_API word32 CheckRunTimeSettings(void); |
igrokhotkov | 0:83f3dcfa5c8f | 269 | |
igrokhotkov | 0:83f3dcfa5c8f | 270 | /* If user uses RSA, DH, DSA, or ECC math lib directly then fast math and long |
igrokhotkov | 0:83f3dcfa5c8f | 271 | types need to match at compile time and run time, CheckCtcSettings will |
igrokhotkov | 0:83f3dcfa5c8f | 272 | return 1 if a match otherwise 0 */ |
igrokhotkov | 0:83f3dcfa5c8f | 273 | #define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings()) |
igrokhotkov | 0:83f3dcfa5c8f | 274 | |
igrokhotkov | 0:83f3dcfa5c8f | 275 | |
igrokhotkov | 0:83f3dcfa5c8f | 276 | #ifdef __cplusplus |
igrokhotkov | 0:83f3dcfa5c8f | 277 | } /* extern "C" */ |
igrokhotkov | 0:83f3dcfa5c8f | 278 | #endif |
igrokhotkov | 0:83f3dcfa5c8f | 279 | |
igrokhotkov | 0:83f3dcfa5c8f | 280 | |
igrokhotkov | 0:83f3dcfa5c8f | 281 | #endif /* CTAO_CRYPT_TYPES_H */ |
igrokhotkov | 0:83f3dcfa5c8f | 282 |