wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue Aug 22 10:48:22 2017 +0000
Revision:
13:f67a6c6013ca
Parent:
11:cee25a834751
wolfSSL3.12.0 with TLS1.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 11:cee25a834751 1 /* evp.h
wolfSSL 11:cee25a834751 2 *
wolfSSL 11:cee25a834751 3 * Copyright (C) 2006-2016 wolfSSL Inc.
wolfSSL 11:cee25a834751 4 *
wolfSSL 11:cee25a834751 5 * This file is part of wolfSSL.
wolfSSL 11:cee25a834751 6 *
wolfSSL 11:cee25a834751 7 * wolfSSL is free software; you can redistribute it and/or modify
wolfSSL 11:cee25a834751 8 * it under the terms of the GNU General Public License as published by
wolfSSL 11:cee25a834751 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 11:cee25a834751 10 * (at your option) any later version.
wolfSSL 11:cee25a834751 11 *
wolfSSL 11:cee25a834751 12 * wolfSSL is distributed in the hope that it will be useful,
wolfSSL 11:cee25a834751 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 11:cee25a834751 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 11:cee25a834751 15 * GNU General Public License for more details.
wolfSSL 11:cee25a834751 16 *
wolfSSL 11:cee25a834751 17 * You should have received a copy of the GNU General Public License
wolfSSL 11:cee25a834751 18 * along with this program; if not, write to the Free Software
wolfSSL 11:cee25a834751 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
wolfSSL 11:cee25a834751 20 */
wolfSSL 11:cee25a834751 21
wolfSSL 11:cee25a834751 22
wolfSSL 11:cee25a834751 23
wolfSSL 11:cee25a834751 24 /* evp.h defines mini evp openssl compatibility layer
wolfSSL 11:cee25a834751 25 *
wolfSSL 11:cee25a834751 26 */
wolfSSL 11:cee25a834751 27
wolfSSL 11:cee25a834751 28
wolfSSL 11:cee25a834751 29 #ifndef WOLFSSL_EVP_H_
wolfSSL 11:cee25a834751 30 #define WOLFSSL_EVP_H_
wolfSSL 11:cee25a834751 31
wolfSSL 11:cee25a834751 32 #include <wolfssl/wolfcrypt/settings.h>
wolfSSL 11:cee25a834751 33
wolfSSL 11:cee25a834751 34 #ifdef WOLFSSL_PREFIX
wolfSSL 11:cee25a834751 35 #include "prefix_evp.h"
wolfSSL 11:cee25a834751 36 #endif
wolfSSL 11:cee25a834751 37
wolfSSL 11:cee25a834751 38 #ifndef NO_MD5
wolfSSL 11:cee25a834751 39 #include <wolfssl/openssl/md5.h>
wolfSSL 11:cee25a834751 40 #endif
wolfSSL 11:cee25a834751 41 #include <wolfssl/openssl/sha.h>
wolfSSL 11:cee25a834751 42 #include <wolfssl/openssl/ripemd.h>
wolfSSL 11:cee25a834751 43 #include <wolfssl/openssl/rsa.h>
wolfSSL 11:cee25a834751 44 #include <wolfssl/openssl/dsa.h>
wolfSSL 11:cee25a834751 45 #include <wolfssl/openssl/ec.h>
wolfSSL 11:cee25a834751 46
wolfSSL 11:cee25a834751 47 #include <wolfssl/wolfcrypt/aes.h>
wolfSSL 11:cee25a834751 48 #include <wolfssl/wolfcrypt/des3.h>
wolfSSL 11:cee25a834751 49 #include <wolfssl/wolfcrypt/arc4.h>
wolfSSL 11:cee25a834751 50 #ifdef HAVE_IDEA
wolfSSL 11:cee25a834751 51 #include <wolfssl/wolfcrypt/idea.h>
wolfSSL 11:cee25a834751 52 #endif
wolfSSL 11:cee25a834751 53
wolfSSL 11:cee25a834751 54 #ifdef __cplusplus
wolfSSL 11:cee25a834751 55 extern "C" {
wolfSSL 11:cee25a834751 56 #endif
wolfSSL 11:cee25a834751 57
wolfSSL 11:cee25a834751 58 typedef char WOLFSSL_EVP_CIPHER;
wolfSSL 11:cee25a834751 59 typedef char WOLFSSL_EVP_MD;
wolfSSL 11:cee25a834751 60
wolfSSL 11:cee25a834751 61 #ifndef NO_MD5
wolfSSL 11:cee25a834751 62 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void);
wolfSSL 11:cee25a834751 63 #endif
wolfSSL 11:cee25a834751 64 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void);
wolfSSL 11:cee25a834751 65 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha224(void);
wolfSSL 11:cee25a834751 66 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void);
wolfSSL 11:cee25a834751 67 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void);
wolfSSL 11:cee25a834751 68 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void);
wolfSSL 11:cee25a834751 69 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void);
wolfSSL 11:cee25a834751 70
wolfSSL 11:cee25a834751 71 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ecb(void);
wolfSSL 11:cee25a834751 72 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ecb(void);
wolfSSL 11:cee25a834751 73 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ecb(void);
wolfSSL 11:cee25a834751 74 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void);
wolfSSL 11:cee25a834751 75 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void);
wolfSSL 11:cee25a834751 76 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void);
wolfSSL 11:cee25a834751 77 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void);
wolfSSL 11:cee25a834751 78 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void);
wolfSSL 11:cee25a834751 79 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void);
wolfSSL 11:cee25a834751 80 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ecb(void);
wolfSSL 11:cee25a834751 81 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_ecb(void);
wolfSSL 11:cee25a834751 82 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
wolfSSL 11:cee25a834751 83 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void);
wolfSSL 11:cee25a834751 84 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void);
wolfSSL 11:cee25a834751 85 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_idea_cbc(void);
wolfSSL 11:cee25a834751 86 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void);
wolfSSL 11:cee25a834751 87
wolfSSL 11:cee25a834751 88
wolfSSL 11:cee25a834751 89 typedef union {
wolfSSL 11:cee25a834751 90 #ifndef NO_MD5
wolfSSL 11:cee25a834751 91 WOLFSSL_MD5_CTX md5;
wolfSSL 11:cee25a834751 92 #endif
wolfSSL 11:cee25a834751 93 WOLFSSL_SHA_CTX sha;
wolfSSL 11:cee25a834751 94 #ifdef WOLFSSL_SHA224
wolfSSL 11:cee25a834751 95 WOLFSSL_SHA224_CTX sha224;
wolfSSL 11:cee25a834751 96 #endif
wolfSSL 11:cee25a834751 97 WOLFSSL_SHA256_CTX sha256;
wolfSSL 11:cee25a834751 98 #ifdef WOLFSSL_SHA384
wolfSSL 11:cee25a834751 99 WOLFSSL_SHA384_CTX sha384;
wolfSSL 11:cee25a834751 100 #endif
wolfSSL 11:cee25a834751 101 #ifdef WOLFSSL_SHA512
wolfSSL 11:cee25a834751 102 WOLFSSL_SHA512_CTX sha512;
wolfSSL 11:cee25a834751 103 #endif
wolfSSL 11:cee25a834751 104 #ifdef WOLFSSL_RIPEMD
wolfSSL 11:cee25a834751 105 WOLFSSL_RIPEMD_CTX ripemd;
wolfSSL 11:cee25a834751 106 #endif
wolfSSL 11:cee25a834751 107 } WOLFSSL_Hasher;
wolfSSL 11:cee25a834751 108
wolfSSL 11:cee25a834751 109
wolfSSL 11:cee25a834751 110 typedef struct WOLFSSL_EVP_MD_CTX {
wolfSSL 11:cee25a834751 111 WOLFSSL_Hasher hash;
wolfSSL 11:cee25a834751 112 unsigned char macType;
wolfSSL 11:cee25a834751 113 } WOLFSSL_EVP_MD_CTX;
wolfSSL 11:cee25a834751 114
wolfSSL 11:cee25a834751 115
wolfSSL 11:cee25a834751 116 typedef union {
wolfSSL 11:cee25a834751 117 #ifndef NO_AES
wolfSSL 11:cee25a834751 118 Aes aes;
wolfSSL 11:cee25a834751 119 #endif
wolfSSL 11:cee25a834751 120 #ifndef NO_DES3
wolfSSL 11:cee25a834751 121 Des des;
wolfSSL 11:cee25a834751 122 Des3 des3;
wolfSSL 11:cee25a834751 123 #endif
wolfSSL 11:cee25a834751 124 Arc4 arc4;
wolfSSL 11:cee25a834751 125 #ifdef HAVE_IDEA
wolfSSL 11:cee25a834751 126 Idea idea;
wolfSSL 11:cee25a834751 127 #endif
wolfSSL 11:cee25a834751 128 } WOLFSSL_Cipher;
wolfSSL 11:cee25a834751 129
wolfSSL 11:cee25a834751 130
wolfSSL 11:cee25a834751 131 enum {
wolfSSL 11:cee25a834751 132 AES_128_CBC_TYPE = 1,
wolfSSL 11:cee25a834751 133 AES_192_CBC_TYPE = 2,
wolfSSL 11:cee25a834751 134 AES_256_CBC_TYPE = 3,
wolfSSL 11:cee25a834751 135 AES_128_CTR_TYPE = 4,
wolfSSL 11:cee25a834751 136 AES_192_CTR_TYPE = 5,
wolfSSL 11:cee25a834751 137 AES_256_CTR_TYPE = 6,
wolfSSL 11:cee25a834751 138 AES_128_ECB_TYPE = 7,
wolfSSL 11:cee25a834751 139 AES_192_ECB_TYPE = 8,
wolfSSL 11:cee25a834751 140 AES_256_ECB_TYPE = 9,
wolfSSL 11:cee25a834751 141 DES_CBC_TYPE = 10,
wolfSSL 11:cee25a834751 142 DES_ECB_TYPE = 11,
wolfSSL 11:cee25a834751 143 DES_EDE3_CBC_TYPE = 12,
wolfSSL 11:cee25a834751 144 DES_EDE3_ECB_TYPE = 13,
wolfSSL 11:cee25a834751 145 ARC4_TYPE = 14,
wolfSSL 11:cee25a834751 146 NULL_CIPHER_TYPE = 15,
wolfSSL 11:cee25a834751 147 EVP_PKEY_RSA = 16,
wolfSSL 11:cee25a834751 148 EVP_PKEY_DSA = 17,
wolfSSL 11:cee25a834751 149 EVP_PKEY_EC = 18,
wolfSSL 11:cee25a834751 150 IDEA_CBC_TYPE = 19,
wolfSSL 11:cee25a834751 151 NID_sha1 = 64,
wolfSSL 11:cee25a834751 152 NID_md2 = 3,
wolfSSL 11:cee25a834751 153 NID_md5 = 4
wolfSSL 11:cee25a834751 154 };
wolfSSL 11:cee25a834751 155
wolfSSL 11:cee25a834751 156 #define WOLFSSL_EVP_BUF_SIZE 16
wolfSSL 11:cee25a834751 157 typedef struct WOLFSSL_EVP_CIPHER_CTX {
wolfSSL 11:cee25a834751 158 int keyLen; /* user may set for variable */
wolfSSL 11:cee25a834751 159 int block_size;
wolfSSL 11:cee25a834751 160 unsigned long flags;
wolfSSL 11:cee25a834751 161 unsigned char enc; /* if encrypt side, then true */
wolfSSL 11:cee25a834751 162 unsigned char cipherType;
wolfSSL 11:cee25a834751 163 #ifndef NO_AES
wolfSSL 11:cee25a834751 164 /* working iv pointer into cipher */
wolfSSL 11:cee25a834751 165 ALIGN16 unsigned char iv[AES_BLOCK_SIZE];
wolfSSL 11:cee25a834751 166 #elif !defined(NO_DES3)
wolfSSL 11:cee25a834751 167 /* working iv pointer into cipher */
wolfSSL 11:cee25a834751 168 ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
wolfSSL 11:cee25a834751 169 #endif
wolfSSL 11:cee25a834751 170 WOLFSSL_Cipher cipher;
wolfSSL 11:cee25a834751 171 ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
wolfSSL 11:cee25a834751 172 int bufUsed;
wolfSSL 11:cee25a834751 173 ALIGN16 byte lastBlock[WOLFSSL_EVP_BUF_SIZE];
wolfSSL 11:cee25a834751 174 int lastUsed;
wolfSSL 11:cee25a834751 175 } WOLFSSL_EVP_CIPHER_CTX;
wolfSSL 11:cee25a834751 176
wolfSSL 11:cee25a834751 177
wolfSSL 11:cee25a834751 178 #ifndef WOLFSSL_EVP_PKEY_TYPE_DEFINED /* guard on redeclaration */
wolfSSL 11:cee25a834751 179 typedef struct WOLFSSL_EVP_PKEY WOLFSSL_EVP_PKEY;
wolfSSL 11:cee25a834751 180 #define WOLFSSL_EVP_PKEY_TYPE_DEFINED
wolfSSL 11:cee25a834751 181 #endif
wolfSSL 11:cee25a834751 182
wolfSSL 11:cee25a834751 183 struct WOLFSSL_EVP_PKEY {
wolfSSL 11:cee25a834751 184 int type; /* openssh dereference */
wolfSSL 11:cee25a834751 185 int save_type; /* openssh dereference */
wolfSSL 11:cee25a834751 186 int pkey_sz;
wolfSSL 11:cee25a834751 187 union {
wolfSSL 11:cee25a834751 188 char* ptr; /* der format of key / or raw for NTRU */
wolfSSL 11:cee25a834751 189 } pkey;
wolfSSL 11:cee25a834751 190 #ifdef HAVE_ECC
wolfSSL 11:cee25a834751 191 int pkey_curve;
wolfSSL 11:cee25a834751 192 #endif
wolfSSL 11:cee25a834751 193 };
wolfSSL 11:cee25a834751 194
wolfSSL 11:cee25a834751 195 typedef int WOLFSSL_ENGINE ;
wolfSSL 11:cee25a834751 196 typedef WOLFSSL_ENGINE ENGINE;
wolfSSL 11:cee25a834751 197
wolfSSL 11:cee25a834751 198 WOLFSSL_API void wolfSSL_EVP_init(void);
wolfSSL 11:cee25a834751 199 WOLFSSL_API int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* md);
wolfSSL 11:cee25a834751 200 WOLFSSL_API int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md);
wolfSSL 11:cee25a834751 201
wolfSSL 11:cee25a834751 202 WOLFSSL_API WOLFSSL_EVP_MD_CTX *wolfSSL_EVP_MD_CTX_new (void);
wolfSSL 11:cee25a834751 203 WOLFSSL_API void wolfSSL_EVP_MD_CTX_free(WOLFSSL_EVP_MD_CTX* ctx);
wolfSSL 11:cee25a834751 204 WOLFSSL_API void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx);
wolfSSL 11:cee25a834751 205 WOLFSSL_API int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx);
wolfSSL 11:cee25a834751 206 WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_MD_CTX_md(const WOLFSSL_EVP_MD_CTX *ctx);
wolfSSL 11:cee25a834751 207 WOLFSSL_API const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_get_cipherbyname(const char *name);
wolfSSL 11:cee25a834751 208 WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name);
wolfSSL 11:cee25a834751 209
wolfSSL 11:cee25a834751 210 WOLFSSL_API int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx,
wolfSSL 11:cee25a834751 211 const WOLFSSL_EVP_MD* type);
wolfSSL 11:cee25a834751 212 WOLFSSL_API int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
wolfSSL 11:cee25a834751 213 const WOLFSSL_EVP_MD* type,
wolfSSL 11:cee25a834751 214 WOLFSSL_ENGINE *impl);
wolfSSL 11:cee25a834751 215 WOLFSSL_API int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data,
wolfSSL 11:cee25a834751 216 unsigned long sz);
wolfSSL 11:cee25a834751 217 WOLFSSL_API int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
wolfSSL 11:cee25a834751 218 unsigned int* s);
wolfSSL 11:cee25a834751 219 WOLFSSL_API int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx,
wolfSSL 11:cee25a834751 220 unsigned char* md, unsigned int* s);
wolfSSL 11:cee25a834751 221 #ifndef NO_MD5
wolfSSL 11:cee25a834751 222 WOLFSSL_API int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER*,
wolfSSL 11:cee25a834751 223 const WOLFSSL_EVP_MD*, const unsigned char*,
wolfSSL 11:cee25a834751 224 const unsigned char*, int, int, unsigned char*,
wolfSSL 11:cee25a834751 225 unsigned char*);
wolfSSL 11:cee25a834751 226 #endif
wolfSSL 11:cee25a834751 227
wolfSSL 11:cee25a834751 228 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 229 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 230
wolfSSL 11:cee25a834751 231 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX*);
wolfSSL 11:cee25a834751 232 WOLFSSL_API int wolfSSL_EVP_CIPHER_iv_length(const WOLFSSL_EVP_CIPHER*);
wolfSSL 11:cee25a834751 233
wolfSSL 11:cee25a834751 234
wolfSSL 11:cee25a834751 235 WOLFSSL_API int wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 236 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 237 unsigned char* key, unsigned char* iv,
wolfSSL 11:cee25a834751 238 int enc);
wolfSSL 11:cee25a834751 239 WOLFSSL_API int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 240 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 241 WOLFSSL_ENGINE *impl,
wolfSSL 11:cee25a834751 242 unsigned char* key, unsigned char* iv,
wolfSSL 11:cee25a834751 243 int enc);
wolfSSL 11:cee25a834751 244 WOLFSSL_API int wolfSSL_EVP_EncryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 245 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 246 unsigned char* key, unsigned char* iv);
wolfSSL 11:cee25a834751 247 WOLFSSL_API int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 248 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 249 WOLFSSL_ENGINE *impl,
wolfSSL 11:cee25a834751 250 unsigned char* key, unsigned char* iv);
wolfSSL 11:cee25a834751 251 WOLFSSL_API int wolfSSL_EVP_DecryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 252 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 253 unsigned char* key, unsigned char* iv);
wolfSSL 11:cee25a834751 254 WOLFSSL_API int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 255 const WOLFSSL_EVP_CIPHER* type,
wolfSSL 11:cee25a834751 256 WOLFSSL_ENGINE *impl,
wolfSSL 11:cee25a834751 257 unsigned char* key, unsigned char* iv);
wolfSSL 11:cee25a834751 258 WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 259 unsigned char *out, int *outl,
wolfSSL 11:cee25a834751 260 const unsigned char *in, int inl);
wolfSSL 11:cee25a834751 261 WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 262 unsigned char *out, int *outl);
wolfSSL 11:cee25a834751 263 WOLFSSL_API int wolfSSL_EVP_CipherFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 264 unsigned char *out, int *outl, int enc);
wolfSSL 11:cee25a834751 265 WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 266 unsigned char *out, int *outl);
wolfSSL 11:cee25a834751 267 WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 268 unsigned char *out, int *outl);
wolfSSL 11:cee25a834751 269 WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 270 unsigned char *out, int *outl);
wolfSSL 11:cee25a834751 271 WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
wolfSSL 11:cee25a834751 272 unsigned char *out, int *outl);
wolfSSL 11:cee25a834751 273
wolfSSL 11:cee25a834751 274 WOLFSSL_API WOLFSSL_EVP_CIPHER_CTX *wolfSSL_EVP_CIPHER_CTX_new(void);
wolfSSL 11:cee25a834751 275 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx);
wolfSSL 11:cee25a834751 276 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 277 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 278 int keylen);
wolfSSL 11:cee25a834751 279 WOLFSSL_API int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx,
wolfSSL 11:cee25a834751 280 unsigned char* dst, unsigned char* src,
wolfSSL 11:cee25a834751 281 unsigned int len);
wolfSSL 11:cee25a834751 282
wolfSSL 11:cee25a834751 283 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
wolfSSL 11:cee25a834751 284
wolfSSL 11:cee25a834751 285 WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
wolfSSL 11:cee25a834751 286 WOLFSSL_API WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY*);
wolfSSL 11:cee25a834751 287 WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EVP_PKEY_get1_EC_KEY(WOLFSSL_EVP_PKEY *key);
wolfSSL 11:cee25a834751 288
wolfSSL 11:cee25a834751 289 /* these next ones don't need real OpenSSL type, for OpenSSH compat only */
wolfSSL 11:cee25a834751 290 WOLFSSL_API void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 291 WOLFSSL_API int wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 292
wolfSSL 11:cee25a834751 293 WOLFSSL_API void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
wolfSSL 11:cee25a834751 294 unsigned char* iv, int len);
wolfSSL 11:cee25a834751 295 WOLFSSL_API void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
wolfSSL 11:cee25a834751 296 unsigned char* iv, int len);
wolfSSL 11:cee25a834751 297
wolfSSL 11:cee25a834751 298 WOLFSSL_API int wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 299 WOLFSSL_API int wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
wolfSSL 11:cee25a834751 300
wolfSSL 11:cee25a834751 301 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx);
wolfSSL 11:cee25a834751 302 WOLFSSL_API int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher);
wolfSSL 11:cee25a834751 303 WOLFSSL_API unsigned long WOLFSSL_EVP_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
wolfSSL 11:cee25a834751 304 WOLFSSL_API unsigned long WOLFSSL_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
wolfSSL 11:cee25a834751 305 WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_flags(const WOLFSSL_EVP_CIPHER *cipher);
wolfSSL 11:cee25a834751 306 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
wolfSSL 11:cee25a834751 307 WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_CTX_mode(const WOLFSSL_EVP_CIPHER_CTX *ctx);
wolfSSL 11:cee25a834751 308 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *c, int pad);
wolfSSL 11:cee25a834751 309 WOLFSSL_API int wolfSSL_EVP_add_digest(const WOLFSSL_EVP_MD *digest);
wolfSSL 11:cee25a834751 310
wolfSSL 11:cee25a834751 311 #define EVP_CIPH_STREAM_CIPHER WOLFSSL_EVP_CIPH_STREAM_CIPHER
wolfSSL 11:cee25a834751 312 #define EVP_CIPH_ECB_MODE WOLFSSL_EVP_CIPH_ECB_MODE
wolfSSL 11:cee25a834751 313 #define EVP_CIPH_CBC_MODE WOLFSSL_EVP_CIPH_CBC_MODE
wolfSSL 11:cee25a834751 314 #define EVP_CIPH_CFB_MODE WOLFSSL_EVP_CIPH_CFB_MODE
wolfSSL 11:cee25a834751 315 #define EVP_CIPH_OFB_MODE WOLFSSL_EVP_CIPH_OFB_MODE
wolfSSL 11:cee25a834751 316 #define EVP_CIPH_CTR_MODE WOLFSSL_EVP_CIPH_CTR_MODE
wolfSSL 11:cee25a834751 317 #define EVP_CIPH_GCM_MODE WOLFSSL_EVP_CIPH_GCM_MODE
wolfSSL 11:cee25a834751 318 #define EVP_CIPH_CCM_MODE WOLFSSL_EVP_CIPH_CCM_MODE
wolfSSL 11:cee25a834751 319
wolfSSL 11:cee25a834751 320 #define WOLFSSL_EVP_CIPH_MODE 0x0007
wolfSSL 11:cee25a834751 321 #define WOLFSSL_EVP_CIPH_STREAM_CIPHER 0x0
wolfSSL 11:cee25a834751 322 #define WOLFSSL_EVP_CIPH_ECB_MODE 0x1
wolfSSL 11:cee25a834751 323 #define WOLFSSL_EVP_CIPH_CBC_MODE 0x2
wolfSSL 11:cee25a834751 324 #define WOLFSSL_EVP_CIPH_CFB_MODE 0x3
wolfSSL 11:cee25a834751 325 #define WOLFSSL_EVP_CIPH_OFB_MODE 0x4
wolfSSL 11:cee25a834751 326 #define WOLFSSL_EVP_CIPH_CTR_MODE 0x5
wolfSSL 11:cee25a834751 327 #define WOLFSSL_EVP_CIPH_GCM_MODE 0x6
wolfSSL 11:cee25a834751 328 #define WOLFSSL_EVP_CIPH_CCM_MODE 0x7
wolfSSL 11:cee25a834751 329 #define WOLFSSL_EVP_CIPH_NO_PADDING 0x100
wolfSSL 11:cee25a834751 330
wolfSSL 11:cee25a834751 331 /* end OpenSSH compat */
wolfSSL 11:cee25a834751 332
wolfSSL 11:cee25a834751 333 typedef WOLFSSL_EVP_MD EVP_MD;
wolfSSL 11:cee25a834751 334 typedef WOLFSSL_EVP_CIPHER EVP_CIPHER;
wolfSSL 11:cee25a834751 335 typedef WOLFSSL_EVP_MD_CTX EVP_MD_CTX;
wolfSSL 11:cee25a834751 336 typedef WOLFSSL_EVP_CIPHER_CTX EVP_CIPHER_CTX;
wolfSSL 11:cee25a834751 337
wolfSSL 11:cee25a834751 338 #ifndef NO_MD5
wolfSSL 11:cee25a834751 339 #define EVP_md5 wolfSSL_EVP_md5
wolfSSL 11:cee25a834751 340 #endif
wolfSSL 11:cee25a834751 341 #define EVP_sha1 wolfSSL_EVP_sha1
wolfSSL 11:cee25a834751 342 #define EVP_sha224 wolfSSL_EVP_sha224
wolfSSL 11:cee25a834751 343 #define EVP_sha256 wolfSSL_EVP_sha256
wolfSSL 11:cee25a834751 344 #define EVP_sha384 wolfSSL_EVP_sha384
wolfSSL 11:cee25a834751 345 #define EVP_sha512 wolfSSL_EVP_sha512
wolfSSL 11:cee25a834751 346 #define EVP_ripemd160 wolfSSL_EVP_ripemd160
wolfSSL 11:cee25a834751 347
wolfSSL 11:cee25a834751 348 #define EVP_aes_128_cbc wolfSSL_EVP_aes_128_cbc
wolfSSL 11:cee25a834751 349 #define EVP_aes_192_cbc wolfSSL_EVP_aes_192_cbc
wolfSSL 11:cee25a834751 350 #define EVP_aes_256_cbc wolfSSL_EVP_aes_256_cbc
wolfSSL 11:cee25a834751 351 #define EVP_aes_128_ecb wolfSSL_EVP_aes_128_ecb
wolfSSL 11:cee25a834751 352 #define EVP_aes_192_ecb wolfSSL_EVP_aes_192_ecb
wolfSSL 11:cee25a834751 353 #define EVP_aes_256_ecb wolfSSL_EVP_aes_256_ecb
wolfSSL 11:cee25a834751 354 #define EVP_aes_128_ctr wolfSSL_EVP_aes_128_ctr
wolfSSL 11:cee25a834751 355 #define EVP_aes_192_ctr wolfSSL_EVP_aes_192_ctr
wolfSSL 11:cee25a834751 356 #define EVP_aes_256_ctr wolfSSL_EVP_aes_256_ctr
wolfSSL 11:cee25a834751 357 #define EVP_des_cbc wolfSSL_EVP_des_cbc
wolfSSL 11:cee25a834751 358 #define EVP_des_ecb wolfSSL_EVP_des_ecb
wolfSSL 11:cee25a834751 359 #define EVP_des_ede3_cbc wolfSSL_EVP_des_ede3_cbc
wolfSSL 11:cee25a834751 360 #define EVP_des_ede3_ecb wolfSSL_EVP_des_ede3_ecb
wolfSSL 11:cee25a834751 361 #define EVP_rc4 wolfSSL_EVP_rc4
wolfSSL 11:cee25a834751 362 #define EVP_idea_cbc wolfSSL_EVP_idea_cbc
wolfSSL 11:cee25a834751 363 #define EVP_enc_null wolfSSL_EVP_enc_null
wolfSSL 11:cee25a834751 364
wolfSSL 11:cee25a834751 365 #define EVP_MD_size wolfSSL_EVP_MD_size
wolfSSL 11:cee25a834751 366 #define EVP_MD_CTX_new wolfSSL_EVP_MD_CTX_new
wolfSSL 11:cee25a834751 367 #define EVP_MD_CTX_create wolfSSL_EVP_MD_CTX_new
wolfSSL 11:cee25a834751 368 #define EVP_MD_CTX_free wolfSSL_EVP_MD_CTX_free
wolfSSL 11:cee25a834751 369 #define EVP_MD_CTX_destroy wolfSSL_EVP_MD_CTX_free
wolfSSL 11:cee25a834751 370 #define EVP_MD_CTX_init wolfSSL_EVP_MD_CTX_init
wolfSSL 11:cee25a834751 371 #define EVP_MD_CTX_cleanup wolfSSL_EVP_MD_CTX_cleanup
wolfSSL 11:cee25a834751 372 #define EVP_MD_CTX_md wolfSSL_EVP_MD_CTX_md
wolfSSL 11:cee25a834751 373 #define EVP_MD_CTX_type wolfSSL_EVP_MD_type
wolfSSL 11:cee25a834751 374 #define EVP_MD_type wolfSSL_EVP_MD_type
wolfSSL 11:cee25a834751 375
wolfSSL 11:cee25a834751 376 #define EVP_DigestInit wolfSSL_EVP_DigestInit
wolfSSL 11:cee25a834751 377 #define EVP_DigestInit_ex wolfSSL_EVP_DigestInit_ex
wolfSSL 11:cee25a834751 378 #define EVP_DigestUpdate wolfSSL_EVP_DigestUpdate
wolfSSL 11:cee25a834751 379 #define EVP_DigestFinal wolfSSL_EVP_DigestFinal
wolfSSL 11:cee25a834751 380 #define EVP_DigestFinal_ex wolfSSL_EVP_DigestFinal_ex
wolfSSL 11:cee25a834751 381 #define EVP_BytesToKey wolfSSL_EVP_BytesToKey
wolfSSL 11:cee25a834751 382
wolfSSL 11:cee25a834751 383 #define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
wolfSSL 11:cee25a834751 384 #define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
wolfSSL 11:cee25a834751 385
wolfSSL 11:cee25a834751 386 #define EVP_CIPHER_CTX_init wolfSSL_EVP_CIPHER_CTX_init
wolfSSL 11:cee25a834751 387 #define EVP_CIPHER_CTX_cleanup wolfSSL_EVP_CIPHER_CTX_cleanup
wolfSSL 11:cee25a834751 388 #define EVP_CIPHER_CTX_iv_length wolfSSL_EVP_CIPHER_CTX_iv_length
wolfSSL 11:cee25a834751 389 #define EVP_CIPHER_CTX_key_length wolfSSL_EVP_CIPHER_CTX_key_length
wolfSSL 11:cee25a834751 390 #define EVP_CIPHER_CTX_set_key_length wolfSSL_EVP_CIPHER_CTX_set_key_length
wolfSSL 11:cee25a834751 391 #define EVP_CIPHER_CTX_mode wolfSSL_EVP_CIPHER_CTX_mode
wolfSSL 11:cee25a834751 392
wolfSSL 11:cee25a834751 393 #define EVP_CIPHER_iv_length wolfSSL_EVP_CIPHER_iv_length
wolfSSL 11:cee25a834751 394
wolfSSL 11:cee25a834751 395 #define EVP_CipherInit wolfSSL_EVP_CipherInit
wolfSSL 11:cee25a834751 396 #define EVP_CipherInit_ex wolfSSL_EVP_CipherInit_ex
wolfSSL 11:cee25a834751 397 #define EVP_EncryptInit wolfSSL_EVP_EncryptInit
wolfSSL 11:cee25a834751 398 #define EVP_EncryptInit_ex wolfSSL_EVP_EncryptInit_ex
wolfSSL 11:cee25a834751 399 #define EVP_DecryptInit wolfSSL_EVP_DecryptInit
wolfSSL 11:cee25a834751 400 #define EVP_DecryptInit_ex wolfSSL_EVP_DecryptInit_ex
wolfSSL 11:cee25a834751 401
wolfSSL 11:cee25a834751 402 #define EVP_Cipher wolfSSL_EVP_Cipher
wolfSSL 11:cee25a834751 403 #define EVP_CipherUpdate wolfSSL_EVP_CipherUpdate
wolfSSL 11:cee25a834751 404 #define EVP_EncryptUpdate wolfSSL_EVP_CipherUpdate
wolfSSL 11:cee25a834751 405 #define EVP_DecryptUpdate wolfSSL_EVP_CipherUpdate
wolfSSL 11:cee25a834751 406 #define EVP_CipherFinal wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 407 #define EVP_CipherFinal_ex wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 408 #define EVP_EncryptFinal wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 409 #define EVP_EncryptFinal_ex wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 410 #define EVP_DecryptFinal wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 411 #define EVP_DecryptFinal_ex wolfSSL_EVP_CipherFinal
wolfSSL 11:cee25a834751 412
wolfSSL 11:cee25a834751 413 #define EVP_CIPHER_CTX_free wolfSSL_EVP_CIPHER_CTX_free
wolfSSL 11:cee25a834751 414 #define EVP_CIPHER_CTX_new wolfSSL_EVP_CIPHER_CTX_new
wolfSSL 11:cee25a834751 415
wolfSSL 11:cee25a834751 416 #define EVP_get_digestbynid wolfSSL_EVP_get_digestbynid
wolfSSL 11:cee25a834751 417 #define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
wolfSSL 11:cee25a834751 418 #define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
wolfSSL 11:cee25a834751 419
wolfSSL 11:cee25a834751 420 #define EVP_PKEY_get1_RSA wolfSSL_EVP_PKEY_get1_RSA
wolfSSL 11:cee25a834751 421 #define EVP_PKEY_get1_DSA wolfSSL_EVP_PKEY_get1_DSA
wolfSSL 11:cee25a834751 422 #define EVP_PKEY_get1_EC_KEY wolfSSL_EVP_PKEY_get1_EC_KEY
wolfSSL 11:cee25a834751 423
wolfSSL 11:cee25a834751 424 #define EVP_CIPHER_CTX_block_size wolfSSL_EVP_CIPHER_CTX_block_size
wolfSSL 11:cee25a834751 425 #define EVP_CIPHER_block_size wolfSSL_EVP_CIPHER_block_size
wolfSSL 11:cee25a834751 426 #define EVP_CIPHER_flags wolfSSL_EVP_CIPHER_flags
wolfSSL 11:cee25a834751 427 #define EVP_CIPHER_CTX_set_flags wolfSSL_EVP_CIPHER_CTX_set_flags
wolfSSL 11:cee25a834751 428 #define EVP_CIPHER_CTX_set_padding wolfSSL_EVP_CIPHER_CTX_set_padding
wolfSSL 11:cee25a834751 429 #define EVP_CIPHER_CTX_flags wolfSSL_EVP_CIPHER_CTX_flags
wolfSSL 11:cee25a834751 430 #define EVP_add_digest wolfSSL_EVP_add_digest
wolfSSL 11:cee25a834751 431
wolfSSL 11:cee25a834751 432 #ifndef EVP_MAX_MD_SIZE
wolfSSL 11:cee25a834751 433 #define EVP_MAX_MD_SIZE 64 /* sha512 */
wolfSSL 11:cee25a834751 434 #endif
wolfSSL 11:cee25a834751 435
wolfSSL 11:cee25a834751 436 #ifdef __cplusplus
wolfSSL 11:cee25a834751 437 } /* extern "C" */
wolfSSL 11:cee25a834751 438 #endif
wolfSSL 11:cee25a834751 439
wolfSSL 11:cee25a834751 440
wolfSSL 11:cee25a834751 441 #endif /* WOLFSSL_EVP_H_ */
wolfSSL 11:cee25a834751 442