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