evp.h
Go to the documentation of this file.
1 /* evp.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 
23 
30 #ifndef WOLFSSL_EVP_H_
31 #define WOLFSSL_EVP_H_
32 
33 #include <wolfssl/wolfcrypt/settings.h>
34 
35 #ifdef WOLFSSL_PREFIX
36 #include "prefix_evp.h"
37 #endif
38 
39 #ifndef NO_MD4
40  #include <wolfssl/openssl/md4.h>
41 #endif
42 #ifndef NO_MD5
43  #include <wolfssl/openssl/md5.h>
44 #endif
45 #include <wolfssl/openssl/sha.h>
46 #include <wolfssl/openssl/sha3.h>
47 #include <wolfssl/openssl/ripemd.h>
48 #include <wolfssl/openssl/rsa.h>
49 #include <wolfssl/openssl/dsa.h>
50 #include <wolfssl/openssl/ec.h>
51 #include <wolfssl/openssl/dh.h>
52 
53 #include <wolfssl/wolfcrypt/aes.h>
54 #include <wolfssl/wolfcrypt/des3.h>
55 #include <wolfssl/wolfcrypt/arc4.h>
56 #include <wolfssl/wolfcrypt/hmac.h>
57 #ifdef HAVE_IDEA
58  #include <wolfssl/wolfcrypt/idea.h>
59 #endif
61 
62 #ifdef __cplusplus
63  extern "C" {
64 #endif
65 
66 
67 typedef char WOLFSSL_EVP_CIPHER;
68 #ifndef WOLFSSL_EVP_TYPE_DEFINED /* guard on redeclaration */
69 typedef char WOLFSSL_EVP_MD;
70 typedef struct WOLFSSL_EVP_PKEY WOLFSSL_EVP_PKEY;
72 #define WOLFSSL_EVP_TYPE_DEFINED
73 #endif
74 
77 
78 #ifndef NO_MD4
79  WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md4(void);
80 #endif
81 #ifndef NO_MD5
82  WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void);
83 #endif
84 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_mdc2(void);
85 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void);
86 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha224(void);
87 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void);
88 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void);
89 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void);
90 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void);
91 
92 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha3_224(void);
93 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha3_256(void);
94 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha3_384(void);
95 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_sha3_512(void);
96 
97 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ecb(void);
98 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ecb(void);
99 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ecb(void);
100 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void);
101 #if !defined(NO_AES) && defined(HAVE_AES_CBC)
102 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void);
103 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void);
104 #endif
105 #ifndef NO_AES
106 #ifdef WOLFSSL_AES_CFB
107 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cfb1(void);
108 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cfb1(void);
109 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cfb1(void);
110 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cfb8(void);
111 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cfb8(void);
112 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cfb8(void);
113 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cfb128(void);
114 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cfb128(void);
115 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cfb128(void);
116 #endif
117 #ifdef WOLFSSL_AES_OFB
118 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ofb(void);
119 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ofb(void);
120 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ofb(void);
121 #endif
122 #ifdef WOLFSSL_AES_XTS
123 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_xts(void);
124 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_xts(void);
125 #endif
126 #endif /* NO_AES */
127 #if !defined(NO_AES) && defined(HAVE_AESGCM)
128 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_gcm(void);
129 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_gcm(void);
130 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_gcm(void);
131 #endif
132 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void);
133 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void);
134 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void);
135 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ecb(void);
136 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_ecb(void);
137 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
138 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void);
139 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void);
140 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_idea_cbc(void);
141 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void);
142 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc2_cbc(void);
143 
144 
145 typedef union {
146  #ifndef NO_MD4
147  WOLFSSL_MD4_CTX md4;
148  #endif
149  #ifndef NO_MD5
150  WOLFSSL_MD5_CTX md5;
151  #endif
152  WOLFSSL_SHA_CTX sha;
153  #ifdef WOLFSSL_SHA224
154  WOLFSSL_SHA224_CTX sha224;
155  #endif
156  WOLFSSL_SHA256_CTX sha256;
157  #ifdef WOLFSSL_SHA384
158  WOLFSSL_SHA384_CTX sha384;
159  #endif
160  #ifdef WOLFSSL_SHA512
161  WOLFSSL_SHA512_CTX sha512;
162  #endif
163  #ifdef WOLFSSL_RIPEMD
164  WOLFSSL_RIPEMD_CTX ripemd;
165  #endif
166  #ifndef WOLFSSL_NOSHA3_224
167  WOLFSSL_SHA3_224_CTX sha3_224;
168  #endif
169  #ifndef WOLFSSL_NOSHA3_256
170  WOLFSSL_SHA3_256_CTX sha3_256;
171  #endif
172  WOLFSSL_SHA3_384_CTX sha3_384;
173  #ifndef WOLFSSL_NOSHA3_512
174  WOLFSSL_SHA3_512_CTX sha3_512;
175  #endif
177 
180 
182  union {
183  WOLFSSL_Hasher digest;
184  #ifndef NO_HMAC
185  Hmac hmac;
186  #endif
187  } hash;
188  int macType;
189  WOLFSSL_EVP_PKEY_CTX *pctx;
190 };
191 
192 
193 typedef union {
194 #ifndef NO_AES
195  Aes aes;
196 #ifdef WOLFSSL_AES_XTS
197  XtsAes xts;
198 #endif
199 #endif
200 #ifndef NO_DES3
201  Des des;
202  Des3 des3;
203 #endif
204  Arc4 arc4;
205 #ifdef HAVE_IDEA
206  Idea idea;
207 #endif
208 #ifdef WOLFSSL_QT
209  int (*ctrl) (WOLFSSL_EVP_CIPHER_CTX *, int type, int arg, void *ptr);
210 #endif
212 
213 
214 enum {
215  AES_128_CBC_TYPE = 1,
216  AES_192_CBC_TYPE = 2,
217  AES_256_CBC_TYPE = 3,
218  AES_128_CTR_TYPE = 4,
219  AES_192_CTR_TYPE = 5,
220  AES_256_CTR_TYPE = 6,
221  AES_128_ECB_TYPE = 7,
222  AES_192_ECB_TYPE = 8,
223  AES_256_ECB_TYPE = 9,
224  DES_CBC_TYPE = 10,
225  DES_ECB_TYPE = 11,
226  DES_EDE3_CBC_TYPE = 12,
227  DES_EDE3_ECB_TYPE = 13,
228  ARC4_TYPE = 14,
229  NULL_CIPHER_TYPE = 15,
230  EVP_PKEY_RSA = 16,
231  EVP_PKEY_DSA = 17,
232  EVP_PKEY_EC = 18,
233 #ifdef HAVE_IDEA
234  IDEA_CBC_TYPE = 19,
235 #endif
236  AES_128_GCM_TYPE = 21,
237  AES_192_GCM_TYPE = 22,
238  AES_256_GCM_TYPE = 23,
239  NID_sha1 = 64,
240  NID_sha224 = 65,
241  NID_md2 = 77,
242  NID_md4 = 257,
243  NID_md5 = 4,
244  NID_hmac = 855,
245  NID_dhKeyAgreement= 28,
246  EVP_PKEY_DH = NID_dhKeyAgreement,
247  EVP_PKEY_HMAC = NID_hmac,
248  AES_128_CFB1_TYPE = 24,
249  AES_192_CFB1_TYPE = 25,
250  AES_256_CFB1_TYPE = 26,
251  AES_128_CFB8_TYPE = 27,
252  AES_192_CFB8_TYPE = 28,
253  AES_256_CFB8_TYPE = 29,
254  AES_128_CFB128_TYPE = 30,
255  AES_192_CFB128_TYPE = 31,
256  AES_256_CFB128_TYPE = 32,
257  AES_128_OFB_TYPE = 33,
258  AES_192_OFB_TYPE = 34,
259  AES_256_OFB_TYPE = 35,
260  AES_128_XTS_TYPE = 36,
261  AES_256_XTS_TYPE = 37
262 };
263 
264 enum {
265  NID_md5WithRSA = 104,
266  NID_md5WithRSAEncryption = 8,
267  NID_dsaWithSHA1 = 113,
268  NID_dsaWithSHA1_2 = 70,
269  NID_sha1WithRSA = 115,
270  NID_sha1WithRSAEncryption = 65,
271  NID_sha224WithRSAEncryption = 671,
272  NID_sha256WithRSAEncryption = 668,
273  NID_sha384WithRSAEncryption = 669,
274  NID_sha512WithRSAEncryption = 670,
275  NID_ecdsa_with_SHA1 = 416,
276  NID_ecdsa_with_SHA224 = 793,
277  NID_ecdsa_with_SHA256 = 794,
278  NID_ecdsa_with_SHA384 = 795,
279  NID_ecdsa_with_SHA512 = 796,
280  NID_dsa_with_SHA224 = 802,
281  NID_dsa_with_SHA256 = 803,
282  NID_sha3_224 = 1096,
283  NID_sha3_256 = 1097,
284  NID_sha3_384 = 1098,
285  NID_sha3_512 = 1099,
286 };
287 
288 enum {
289  NID_aes_128_cbc = 419,
290  NID_aes_192_cbc = 423,
291  NID_aes_256_cbc = 427,
292  NID_aes_128_gcm = 895,
293  NID_aes_192_gcm = 898,
294  NID_aes_256_gcm = 901,
295  NID_aes_128_ctr = 904,
296  NID_aes_192_ctr = 905,
297  NID_aes_256_ctr = 906,
298  NID_aes_128_ecb = 418,
299  NID_aes_192_ecb = 422,
300  NID_aes_256_ecb = 426,
301  NID_des_cbc = 31,
302  NID_des_ecb = 29,
303  NID_des_ede3_cbc= 44,
304  NID_des_ede3_ecb= 33,
305  NID_idea_cbc = 34,
306  NID_aes_128_cfb1= 650,
307  NID_aes_192_cfb1= 651,
308  NID_aes_256_cfb1= 652,
309  NID_aes_128_cfb8= 653,
310  NID_aes_192_cfb8= 654,
311  NID_aes_256_cfb8= 655,
312  NID_aes_128_cfb128 = 421,
313  NID_aes_192_cfb128 = 425,
314  NID_aes_256_cfb128 = 429,
315  NID_aes_128_ofb = 420,
316  NID_aes_192_ofb = 424,
317  NID_aes_256_ofb = 428,
318  NID_aes_128_xts = 913,
319  NID_aes_256_xts = 914
320 };
321 
322 #define NID_X9_62_id_ecPublicKey EVP_PKEY_EC
323 #define NID_dhKeyAgreement EVP_PKEY_DH
324 #define NID_rsaEncryption EVP_PKEY_RSA
325 #define NID_dsa EVP_PKEY_DSA
326 
327 #define WOLFSSL_EVP_BUF_SIZE 16
329  int keyLen; /* user may set for variable */
330  int block_size;
331  unsigned long flags;
332  unsigned char enc; /* if encrypt side, then true */
333  unsigned char cipherType;
334 #ifndef NO_AES
335  /* working iv pointer into cipher */
336  ALIGN16 unsigned char iv[AES_BLOCK_SIZE];
337 #elif !defined(NO_DES3)
338  /* working iv pointer into cipher */
339  ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
340 #elif defined(HAVE_IDEA)
341  /* working iv pointer into cipher */
342  ALIGN16 unsigned char iv[IDEA_BLOCK_SIZE];
343 #endif
344  WOLFSSL_Cipher cipher;
345  ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
346  int bufUsed;
347  ALIGN16 byte lastBlock[WOLFSSL_EVP_BUF_SIZE];
348  int lastUsed;
349 #if !defined(NO_AES) || !defined(NO_DES3) || defined(HAVE_IDEA) || \
350  defined(HAVE_AESGCM) || defined (WOLFSSL_AES_XTS)
351 #define HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
352  int ivSz;
353  ALIGN16 unsigned char authTag[AES_BLOCK_SIZE];
354  int authTagSz;
355 #endif
356 };
357 
359  WOLFSSL_EVP_PKEY *pkey;
360  WOLFSSL_EVP_PKEY *peerKey;
361  int op; /* operation */
362  int padding;
363  int nbits;
364 };
365 
366 typedef int WOLFSSL_ENGINE ;
367 typedef WOLFSSL_ENGINE ENGINE;
369 
370 #define EVP_PKEY_OP_SIGN (1 << 3)
371 #define EVP_PKEY_OP_ENCRYPT (1 << 6)
372 #define EVP_PKEY_OP_DECRYPT (1 << 7)
373 #define EVP_PKEY_OP_DERIVE (1 << 8)
374 
375 WOLFSSL_API void wolfSSL_EVP_init(void);
376 WOLFSSL_API int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* md);
377 WOLFSSL_API int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md);
378 WOLFSSL_API int wolfSSL_EVP_MD_block_size(const WOLFSSL_EVP_MD *md);
379 
380 WOLFSSL_API WOLFSSL_EVP_MD_CTX *wolfSSL_EVP_MD_CTX_new (void);
381 WOLFSSL_API void wolfSSL_EVP_MD_CTX_free(WOLFSSL_EVP_MD_CTX* ctx);
382 WOLFSSL_API void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx);
383 WOLFSSL_API int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx);
384 WOLFSSL_API int wolfSSL_EVP_MD_CTX_copy(WOLFSSL_EVP_MD_CTX *out, const WOLFSSL_EVP_MD_CTX *in);
385 WOLFSSL_API int wolfSSL_EVP_MD_CTX_copy_ex(WOLFSSL_EVP_MD_CTX *out, const WOLFSSL_EVP_MD_CTX *in);
386 WOLFSSL_API int wolfSSL_EVP_MD_CTX_type(const WOLFSSL_EVP_MD_CTX *ctx);
387 WOLFSSL_API int wolfSSL_EVP_MD_CTX_size(const WOLFSSL_EVP_MD_CTX *ctx);
388 WOLFSSL_API int wolfSSL_EVP_MD_CTX_block_size(const WOLFSSL_EVP_MD_CTX *ctx);
389 WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_MD_CTX_md(const WOLFSSL_EVP_MD_CTX *ctx);
390 WOLFSSL_API const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_get_cipherbyname(const char *name);
391 WOLFSSL_API const WOLFSSL_EVP_MD *wolfSSL_EVP_get_digestbyname(const char *name);
392 WOLFSSL_API int wolfSSL_EVP_CIPHER_nid(const WOLFSSL_EVP_CIPHER *cipher);
393 
394 WOLFSSL_API int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx,
395  const WOLFSSL_EVP_MD* type);
396 WOLFSSL_API int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
397  const WOLFSSL_EVP_MD* type,
398  WOLFSSL_ENGINE *impl);
399 WOLFSSL_API int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data,
400  size_t sz);
401 WOLFSSL_API int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md,
402  unsigned int* s);
403 WOLFSSL_API int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx,
404  unsigned char* md, unsigned int* s);
405 
406 WOLFSSL_API int wolfSSL_EVP_DigestSignInit(WOLFSSL_EVP_MD_CTX *ctx,
407  WOLFSSL_EVP_PKEY_CTX **pctx,
408  const WOLFSSL_EVP_MD *type,
409  WOLFSSL_ENGINE *e,
410  WOLFSSL_EVP_PKEY *pkey);
411 WOLFSSL_API int wolfSSL_EVP_DigestSignUpdate(WOLFSSL_EVP_MD_CTX *ctx,
412  const void *d, unsigned int cnt);
413 WOLFSSL_API int wolfSSL_EVP_DigestSignFinal(WOLFSSL_EVP_MD_CTX *ctx,
414  unsigned char *sig, size_t *siglen);
415 
416 WOLFSSL_API int wolfSSL_EVP_DigestVerifyInit(WOLFSSL_EVP_MD_CTX *ctx,
417  WOLFSSL_EVP_PKEY_CTX **pctx,
418  const WOLFSSL_EVP_MD *type,
419  WOLFSSL_ENGINE *e,
420  WOLFSSL_EVP_PKEY *pkey);
421 WOLFSSL_API int wolfSSL_EVP_DigestVerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx,
422  const void *d, size_t cnt);
423 WOLFSSL_API int wolfSSL_EVP_DigestVerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
424  const unsigned char *sig,
425  size_t siglen);
426 WOLFSSL_API int wolfSSL_EVP_Digest(const unsigned char* in, int inSz, unsigned char* out,
427  unsigned int* outSz, const WOLFSSL_EVP_MD* evp,
428  WOLFSSL_ENGINE* eng);
429 
430 
431 WOLFSSL_API int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER*,
432  const WOLFSSL_EVP_MD*, const unsigned char*,
433  const unsigned char*, int, int, unsigned char*,
434  unsigned char*);
435 
436 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx);
437 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx);
438 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_ctrl(WOLFSSL_EVP_CIPHER_CTX *ctx, \
439  int type, int arg, void *ptr);
440 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX*);
441 WOLFSSL_API int wolfSSL_EVP_CIPHER_iv_length(const WOLFSSL_EVP_CIPHER*);
442 WOLFSSL_API int wolfSSL_EVP_Cipher_key_length(const WOLFSSL_EVP_CIPHER* c);
443 
444 
445 WOLFSSL_API int wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
446  const WOLFSSL_EVP_CIPHER* type,
447  const unsigned char* key,
448  const unsigned char* iv,
449  int enc);
451  const WOLFSSL_EVP_CIPHER* type,
452  WOLFSSL_ENGINE *impl,
453  const unsigned char* key,
454  const unsigned char* iv,
455  int enc);
456 WOLFSSL_API int wolfSSL_EVP_EncryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
457  const WOLFSSL_EVP_CIPHER* type,
458  const unsigned char* key,
459  const unsigned char* iv);
461  const WOLFSSL_EVP_CIPHER* type,
462  WOLFSSL_ENGINE *impl,
463  const unsigned char* key,
464  const unsigned char* iv);
465 WOLFSSL_API int wolfSSL_EVP_DecryptInit(WOLFSSL_EVP_CIPHER_CTX* ctx,
466  const WOLFSSL_EVP_CIPHER* type,
467  const unsigned char* key,
468  const unsigned char* iv);
470  const WOLFSSL_EVP_CIPHER* type,
471  WOLFSSL_ENGINE *impl,
472  const unsigned char* key,
473  const unsigned char* iv);
475  unsigned char *out, int *outl,
476  const unsigned char *in, int inl);
478  unsigned char *out, int *outl);
479 WOLFSSL_API int wolfSSL_EVP_CipherFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
480  unsigned char *out, int *outl, int enc);
481 WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
482  unsigned char *out, int *outl);
483 WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
484  unsigned char *out, int *outl);
485 WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
486  unsigned char *out, int *outl);
487 WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
488  unsigned char *out, int *outl);
489 WOLFSSL_API int wolfSSL_EVP_DecryptFinal_legacy(WOLFSSL_EVP_CIPHER_CTX *ctx,
490  unsigned char *out, int *outl);
491 
492 WOLFSSL_API WOLFSSL_EVP_CIPHER_CTX *wolfSSL_EVP_CIPHER_CTX_new(void);
493 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx);
494 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_reset(WOLFSSL_EVP_CIPHER_CTX *ctx);
495 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx);
497  int keylen);
498 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_iv_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
499  int ivLen);
500 WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, byte* iv,
501  int ivLen);
502 WOLFSSL_API int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx,
503  unsigned char* dst, unsigned char* src,
504  unsigned int len);
505 
506 WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_get_cipherbynid(int);
507 WOLFSSL_API const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int);
508 WOLFSSL_API const WOLFSSL_EVP_CIPHER *wolfSSL_EVP_CIPHER_CTX_cipher(const WOLFSSL_EVP_CIPHER_CTX *ctx);
509 
510 WOLFSSL_API int wolfSSL_EVP_PKEY_assign_RSA(WOLFSSL_EVP_PKEY* pkey,
511  WOLFSSL_RSA* key);
512 WOLFSSL_API int wolfSSL_EVP_PKEY_assign_EC_KEY(WOLFSSL_EVP_PKEY* pkey,
513  WOLFSSL_EC_KEY* key);
514 WOLFSSL_API int wolfSSL_EVP_PKEY_assign_DSA(EVP_PKEY* pkey, WOLFSSL_DSA* key);
515 WOLFSSL_API int wolfSSL_EVP_PKEY_assign_DH(EVP_PKEY* pkey, WOLFSSL_DH* key);
516 WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get0_RSA(struct WOLFSSL_EVP_PKEY *pkey);
517 WOLFSSL_API WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY*);
518 WOLFSSL_API WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY*);
519 WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EVP_PKEY_get0_EC_KEY(WOLFSSL_EVP_PKEY *pkey);
520 WOLFSSL_API WOLFSSL_EC_KEY *wolfSSL_EVP_PKEY_get1_EC_KEY(WOLFSSL_EVP_PKEY *key);
521 WOLFSSL_API WOLFSSL_DH* wolfSSL_EVP_PKEY_get0_DH(WOLFSSL_EVP_PKEY* key);
522 WOLFSSL_API WOLFSSL_DH* wolfSSL_EVP_PKEY_get1_DH(WOLFSSL_EVP_PKEY* key);
523 WOLFSSL_API int wolfSSL_EVP_PKEY_set1_RSA(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_RSA *key);
524 WOLFSSL_API int wolfSSL_EVP_PKEY_set1_DSA(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_DSA *key);
525 WOLFSSL_API int wolfSSL_EVP_PKEY_set1_DH(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_DH *key);
526 WOLFSSL_API int wolfSSL_EVP_PKEY_set1_EC_KEY(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_EC_KEY *key);
527 WOLFSSL_API int wolfSSL_EVP_PKEY_assign(WOLFSSL_EVP_PKEY *pkey, int type, void *key);
528 
529 WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_mac_key(int type, ENGINE* e,
530  const unsigned char* key, int keylen);
531 WOLFSSL_API const unsigned char* wolfSSL_EVP_PKEY_get0_hmac(const WOLFSSL_EVP_PKEY* pkey,
532  size_t* len);
533 WOLFSSL_API int wolfSSL_EVP_PKEY_sign_init(WOLFSSL_EVP_PKEY_CTX *ctx);
534 WOLFSSL_API int wolfSSL_EVP_PKEY_sign(WOLFSSL_EVP_PKEY_CTX *ctx,
535  unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen);
536 WOLFSSL_API int wolfSSL_EVP_PKEY_keygen_init(WOLFSSL_EVP_PKEY_CTX *ctx);
537 WOLFSSL_API int wolfSSL_EVP_PKEY_keygen(WOLFSSL_EVP_PKEY_CTX *ctx,
538  WOLFSSL_EVP_PKEY **ppkey);
539 WOLFSSL_API int wolfSSL_EVP_PKEY_bits(const WOLFSSL_EVP_PKEY *pkey);
540 WOLFSSL_API int wolfSSL_EVP_PKEY_CTX_free(WOLFSSL_EVP_PKEY_CTX *ctx);
541 WOLFSSL_API WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_ENGINE *e);
542 WOLFSSL_API int wolfSSL_EVP_PKEY_CTX_set_rsa_padding(WOLFSSL_EVP_PKEY_CTX *ctx, int padding);
543 WOLFSSL_API WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new_id(int id, WOLFSSL_ENGINE *e);
544 WOLFSSL_API int wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits(WOLFSSL_EVP_PKEY_CTX *ctx, int bits);
545 
546 WOLFSSL_API int wolfSSL_EVP_PKEY_derive_init(WOLFSSL_EVP_PKEY_CTX *ctx);
547 WOLFSSL_API int wolfSSL_EVP_PKEY_derive_set_peer(WOLFSSL_EVP_PKEY_CTX *ctx, WOLFSSL_EVP_PKEY *peer);
548 WOLFSSL_API int wolfSSL_EVP_PKEY_derive(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
549 
550 WOLFSSL_API int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
551  unsigned char *out, size_t *outlen,
552  const unsigned char *in, size_t inlen);
553 WOLFSSL_API int wolfSSL_EVP_PKEY_decrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx);
554 WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
555  unsigned char *out, size_t *outlen,
556  const unsigned char *in, size_t inlen);
557 WOLFSSL_API int wolfSSL_EVP_PKEY_encrypt_init(WOLFSSL_EVP_PKEY_CTX *ctx);
558 WOLFSSL_API WOLFSSL_EVP_PKEY *wolfSSL_EVP_PKEY_new(void);
559 WOLFSSL_API WOLFSSL_EVP_PKEY* wolfSSL_EVP_PKEY_new_ex(void* heap);
560 WOLFSSL_API void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY*);
561 WOLFSSL_API int wolfSSL_EVP_PKEY_size(WOLFSSL_EVP_PKEY *pkey);
562 WOLFSSL_API int wolfSSL_EVP_PKEY_missing_parameters(WOLFSSL_EVP_PKEY *pkey);
563 WOLFSSL_API int wolfSSL_EVP_PKEY_cmp(const WOLFSSL_EVP_PKEY *a, const WOLFSSL_EVP_PKEY *b);
564 WOLFSSL_API int wolfSSL_EVP_PKEY_type(int type);
565 WOLFSSL_API int wolfSSL_EVP_PKEY_id(const EVP_PKEY *pkey);
566 WOLFSSL_API int wolfSSL_EVP_PKEY_base_id(const EVP_PKEY *pkey);
567 WOLFSSL_API int wolfSSL_EVP_SignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *sigret,
568  unsigned int *siglen, WOLFSSL_EVP_PKEY *pkey);
569 WOLFSSL_API int wolfSSL_EVP_SignInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *type);
570 WOLFSSL_API int wolfSSL_EVP_SignInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
571  const WOLFSSL_EVP_MD* type,
572  WOLFSSL_ENGINE *impl);
573 WOLFSSL_API int wolfSSL_EVP_SignUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, size_t len);
574 WOLFSSL_API int wolfSSL_EVP_VerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
575  unsigned char* sig, unsigned int sig_len, WOLFSSL_EVP_PKEY *pkey);
576 WOLFSSL_API int wolfSSL_EVP_VerifyInit(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *type);
577 WOLFSSL_API int wolfSSL_EVP_VerifyUpdate(WOLFSSL_EVP_MD_CTX *ctx, const void *data, size_t len);
578 
579 
580 /* these next ones don't need real OpenSSL type, for OpenSSH compat only */
581 WOLFSSL_API void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx);
582 WOLFSSL_API int wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx);
583 
584 WOLFSSL_API void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
585  unsigned char* iv, int len);
586 WOLFSSL_API void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset,
587  unsigned char* iv, int len);
588 
589 WOLFSSL_API int wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
590 WOLFSSL_API int wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx);
591 
593 WOLFSSL_API int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher);
594 WOLFSSL_API unsigned long WOLFSSL_EVP_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
595 WOLFSSL_API unsigned long WOLFSSL_CIPHER_mode(const WOLFSSL_EVP_CIPHER *cipher);
596 WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_flags(const WOLFSSL_EVP_CIPHER *cipher);
597 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
598 WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
599 WOLFSSL_API unsigned long wolfSSL_EVP_CIPHER_CTX_mode(const WOLFSSL_EVP_CIPHER_CTX *ctx);
601 WOLFSSL_API int wolfSSL_EVP_add_digest(const WOLFSSL_EVP_MD *digest);
602 WOLFSSL_API int wolfSSL_EVP_add_cipher(const WOLFSSL_EVP_CIPHER *cipher);
603 WOLFSSL_API void wolfSSL_EVP_cleanup(void);
604 WOLFSSL_API int wolfSSL_add_all_algorithms(void);
605 WOLFSSL_API int wolfSSL_OpenSSL_add_all_algorithms_conf(void);
606 WOLFSSL_API int wolfSSL_OpenSSL_add_all_algorithms_noconf(void);
607 WOLFSSL_API int wolfSSL_EVP_read_pw_string(char*, int, const char*, int);
608 
609 WOLFSSL_API int wolfSSL_PKCS5_PBKDF2_HMAC_SHA1(const char * pass, int passlen,
610  const unsigned char * salt,
611  int saltlen, int iter,
612  int keylen, unsigned char *out);
613 
614 WOLFSSL_API int wolfSSL_PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
615  const unsigned char *salt,
616  int saltlen, int iter,
617  const WOLFSSL_EVP_MD *digest,
618  int keylen, unsigned char *out);
619 
620 WOLFSSL_LOCAL int wolfSSL_EVP_get_hashinfo(const WOLFSSL_EVP_MD* evp,
621  int* pHash, int* pHashSz);
622 
623 #define EVP_CIPH_STREAM_CIPHER WOLFSSL_EVP_CIPH_STREAM_CIPHER
624 #define EVP_CIPH_ECB_MODE WOLFSSL_EVP_CIPH_ECB_MODE
625 #define EVP_CIPH_CBC_MODE WOLFSSL_EVP_CIPH_CBC_MODE
626 #define EVP_CIPH_CFB_MODE WOLFSSL_EVP_CIPH_CFB_MODE
627 #define EVP_CIPH_OFB_MODE WOLFSSL_EVP_CIPH_OFB_MODE
628 #define EVP_CIPH_CTR_MODE WOLFSSL_EVP_CIPH_CTR_MODE
629 #define EVP_CIPH_GCM_MODE WOLFSSL_EVP_CIPH_GCM_MODE
630 #define EVP_CIPH_CCM_MODE WOLFSSL_EVP_CIPH_CCM_MODE
631 #define EVP_CIPH_XTS_MODE WOLFSSL_EVP_CIPH_XTS_MODE
632 
633 #define WOLFSSL_EVP_CIPH_MODE 0x0007
634 #define WOLFSSL_EVP_CIPH_STREAM_CIPHER 0x0
635 #define WOLFSSL_EVP_CIPH_ECB_MODE 0x1
636 #define WOLFSSL_EVP_CIPH_CBC_MODE 0x2
637 #define WOLFSSL_EVP_CIPH_CFB_MODE 0x3
638 #define WOLFSSL_EVP_CIPH_OFB_MODE 0x4
639 #define WOLFSSL_EVP_CIPH_CTR_MODE 0x5
640 #define WOLFSSL_EVP_CIPH_GCM_MODE 0x6
641 #define WOLFSSL_EVP_CIPH_CCM_MODE 0x7
642 #define WOLFSSL_EVP_CIPH_XTS_MODE 0x10
643 #define WOLFSSL_EVP_CIPH_NO_PADDING 0x100
644 #define EVP_CIPH_VARIABLE_LENGTH 0x200
645 #define WOLFSSL_EVP_CIPH_TYPE_INIT 0xff
646 
647 /* end OpenSSH compat */
648 
649 typedef WOLFSSL_EVP_MD EVP_MD;
650 typedef WOLFSSL_EVP_CIPHER EVP_CIPHER;
653 
654 #ifndef NO_MD4
655  #define EVP_md4 wolfSSL_EVP_md4
656 #endif
657 #ifndef NO_MD5
658  #define EVP_md5 wolfSSL_EVP_md5
659 #endif
660 #define EVP_sha1 wolfSSL_EVP_sha1
661 #define EVP_mdc2 wolfSSL_EVP_mdc2
662 #define EVP_dds1 wolfSSL_EVP_sha1
663 #define EVP_sha224 wolfSSL_EVP_sha224
664 #define EVP_sha256 wolfSSL_EVP_sha256
665 #define EVP_sha384 wolfSSL_EVP_sha384
666 #define EVP_sha512 wolfSSL_EVP_sha512
667 #define EVP_ripemd160 wolfSSL_EVP_ripemd160
668 
669 #define EVP_sha3_224 wolfSSL_EVP_sha3_224
670 #define EVP_sha3_256 wolfSSL_EVP_sha3_256
671 #define EVP_sha3_384 wolfSSL_EVP_sha3_384
672 #define EVP_sha3_512 wolfSSL_EVP_sha3_512
673 
674 #define EVP_aes_128_cbc wolfSSL_EVP_aes_128_cbc
675 #define EVP_aes_192_cbc wolfSSL_EVP_aes_192_cbc
676 #define EVP_aes_256_cbc wolfSSL_EVP_aes_256_cbc
677 #define EVP_aes_128_cfb1 wolfSSL_EVP_aes_128_cfb1
678 #define EVP_aes_192_cfb1 wolfSSL_EVP_aes_192_cfb1
679 #define EVP_aes_256_cfb1 wolfSSL_EVP_aes_256_cfb1
680 #define EVP_aes_128_cfb8 wolfSSL_EVP_aes_128_cfb8
681 #define EVP_aes_192_cfb8 wolfSSL_EVP_aes_192_cfb8
682 #define EVP_aes_256_cfb8 wolfSSL_EVP_aes_256_cfb8
683 #define EVP_aes_128_cfb128 wolfSSL_EVP_aes_128_cfb128
684 #define EVP_aes_192_cfb128 wolfSSL_EVP_aes_192_cfb128
685 #define EVP_aes_256_cfb128 wolfSSL_EVP_aes_256_cfb128
686 #define EVP_aes_128_ofb wolfSSL_EVP_aes_128_ofb
687 #define EVP_aes_192_ofb wolfSSL_EVP_aes_192_ofb
688 #define EVP_aes_256_ofb wolfSSL_EVP_aes_256_ofb
689 #define EVP_aes_128_xts wolfSSL_EVP_aes_128_xts
690 #define EVP_aes_256_xts wolfSSL_EVP_aes_256_xts
691 #define EVP_aes_128_gcm wolfSSL_EVP_aes_128_gcm
692 #define EVP_aes_192_gcm wolfSSL_EVP_aes_192_gcm
693 #define EVP_aes_256_gcm wolfSSL_EVP_aes_256_gcm
694 #define EVP_aes_128_ecb wolfSSL_EVP_aes_128_ecb
695 #define EVP_aes_192_ecb wolfSSL_EVP_aes_192_ecb
696 #define EVP_aes_256_ecb wolfSSL_EVP_aes_256_ecb
697 #define EVP_aes_128_ctr wolfSSL_EVP_aes_128_ctr
698 #define EVP_aes_192_ctr wolfSSL_EVP_aes_192_ctr
699 #define EVP_aes_256_ctr wolfSSL_EVP_aes_256_ctr
700 #define EVP_des_cbc wolfSSL_EVP_des_cbc
701 #define EVP_des_ecb wolfSSL_EVP_des_ecb
702 #define EVP_des_ede3_cbc wolfSSL_EVP_des_ede3_cbc
703 #define EVP_des_ede3_ecb wolfSSL_EVP_des_ede3_ecb
704 #define EVP_rc4 wolfSSL_EVP_rc4
705 #define EVP_idea_cbc wolfSSL_EVP_idea_cbc
706 #define EVP_enc_null wolfSSL_EVP_enc_null
707 
708 #define EVP_MD_size wolfSSL_EVP_MD_size
709 #define EVP_MD_CTX_new wolfSSL_EVP_MD_CTX_new
710 #define EVP_MD_CTX_create wolfSSL_EVP_MD_CTX_new
711 #define EVP_MD_CTX_free wolfSSL_EVP_MD_CTX_free
712 #define EVP_MD_CTX_destroy wolfSSL_EVP_MD_CTX_free
713 #define EVP_MD_CTX_init wolfSSL_EVP_MD_CTX_init
714 #define EVP_MD_CTX_cleanup wolfSSL_EVP_MD_CTX_cleanup
715 #define EVP_MD_CTX_reset wolfSSL_EVP_MD_CTX_cleanup
716 #define EVP_MD_CTX_md wolfSSL_EVP_MD_CTX_md
717 #define EVP_MD_CTX_type wolfSSL_EVP_MD_CTX_type
718 #define EVP_MD_CTX_size wolfSSL_EVP_MD_CTX_size
719 #define EVP_MD_CTX_block_size wolfSSL_EVP_MD_CTX_block_size
720 #define EVP_MD_type wolfSSL_EVP_MD_type
721 
722 #define EVP_Digest wolfSSL_EVP_Digest
723 #define EVP_DigestInit wolfSSL_EVP_DigestInit
724 #define EVP_DigestInit_ex wolfSSL_EVP_DigestInit_ex
725 #define EVP_DigestUpdate wolfSSL_EVP_DigestUpdate
726 #define EVP_DigestFinal wolfSSL_EVP_DigestFinal
727 #define EVP_DigestFinal_ex wolfSSL_EVP_DigestFinal_ex
728 #define EVP_DigestSignInit wolfSSL_EVP_DigestSignInit
729 #define EVP_DigestSignUpdate wolfSSL_EVP_DigestSignUpdate
730 #define EVP_DigestSignFinal wolfSSL_EVP_DigestSignFinal
731 #define EVP_DigestVerifyInit wolfSSL_EVP_DigestVerifyInit
732 #define EVP_DigestVerifyUpdate wolfSSL_EVP_DigestVerifyUpdate
733 #define EVP_DigestVerifyFinal wolfSSL_EVP_DigestVerifyFinal
734 #define EVP_BytesToKey wolfSSL_EVP_BytesToKey
735 
736 #define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
737 #define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
738 
739 #define EVP_CIPHER_CTX_init wolfSSL_EVP_CIPHER_CTX_init
740 #define EVP_CIPHER_CTX_cleanup wolfSSL_EVP_CIPHER_CTX_cleanup
741 #define EVP_CIPHER_CTX_iv_length wolfSSL_EVP_CIPHER_CTX_iv_length
742 #define EVP_CIPHER_CTX_key_length wolfSSL_EVP_CIPHER_CTX_key_length
743 #define EVP_CIPHER_CTX_set_key_length wolfSSL_EVP_CIPHER_CTX_set_key_length
744 #define EVP_CIPHER_CTX_mode wolfSSL_EVP_CIPHER_CTX_mode
745 #define EVP_CIPHER_CTX_cipher wolfSSL_EVP_CIPHER_CTX_cipher
746 
747 #define EVP_CIPHER_iv_length wolfSSL_EVP_CIPHER_iv_length
748 #define EVP_CIPHER_key_length wolfSSL_EVP_Cipher_key_length
749 
750 #define EVP_CipherInit wolfSSL_EVP_CipherInit
751 #define EVP_CipherInit_ex wolfSSL_EVP_CipherInit_ex
752 #define EVP_EncryptInit wolfSSL_EVP_EncryptInit
753 #define EVP_EncryptInit_ex wolfSSL_EVP_EncryptInit_ex
754 #define EVP_DecryptInit wolfSSL_EVP_DecryptInit
755 #define EVP_DecryptInit_ex wolfSSL_EVP_DecryptInit_ex
756 
757 #define EVP_Cipher wolfSSL_EVP_Cipher
758 #define EVP_CipherUpdate wolfSSL_EVP_CipherUpdate
759 #define EVP_EncryptUpdate wolfSSL_EVP_CipherUpdate
760 #define EVP_DecryptUpdate wolfSSL_EVP_CipherUpdate
761 #define EVP_CipherFinal wolfSSL_EVP_CipherFinal
762 #define EVP_CipherFinal_ex wolfSSL_EVP_CipherFinal
763 #define EVP_EncryptFinal wolfSSL_EVP_CipherFinal
764 #define EVP_EncryptFinal_ex wolfSSL_EVP_CipherFinal
765 #define EVP_DecryptFinal wolfSSL_EVP_CipherFinal
766 #define EVP_DecryptFinal_ex wolfSSL_EVP_CipherFinal
767 
768 #define EVP_CIPHER_CTX_free wolfSSL_EVP_CIPHER_CTX_free
769 #define EVP_CIPHER_CTX_reset wolfSSL_EVP_CIPHER_CTX_reset
770 #define EVP_CIPHER_CTX_new wolfSSL_EVP_CIPHER_CTX_new
771 
772 #define EVP_get_cipherbynid wolfSSL_EVP_get_cipherbynid
773 #define EVP_get_digestbynid wolfSSL_EVP_get_digestbynid
774 #define EVP_get_cipherbyname wolfSSL_EVP_get_cipherbyname
775 #define EVP_get_digestbyname wolfSSL_EVP_get_digestbyname
776 
777 #define EVP_PKEY_assign wolfSSL_EVP_PKEY_assign
778 #define EVP_PKEY_assign_RSA wolfSSL_EVP_PKEY_assign_RSA
779 #define EVP_PKEY_assign_DSA wolfSSL_EVP_PKEY_assign_DSA
780 #define EVP_PKEY_assign_DH wolfSSL_EVP_PKEY_assign_DH
781 #define EVP_PKEY_assign_EC_KEY wolfSSL_EVP_PKEY_assign_EC_KEY
782 #define EVP_PKEY_get1_DSA wolfSSL_EVP_PKEY_get1_DSA
783 #define EVP_PKEY_set1_DSA wolfSSL_EVP_PKEY_set1_DSA
784 #define EVP_PKEY_get0_RSA wolfSSL_EVP_PKEY_get0_RSA
785 #define EVP_PKEY_get1_RSA wolfSSL_EVP_PKEY_get1_RSA
786 #define EVP_PKEY_set1_RSA wolfSSL_EVP_PKEY_set1_RSA
787 #define EVP_PKEY_set1_EC_KEY wolfSSL_EVP_PKEY_set1_EC_KEY
788 #define EVP_PKEY_get1_EC_KEY wolfSSL_EVP_PKEY_get1_EC_KEY
789 #define EVP_PKEY_set1_DH wolfSSL_EVP_PKEY_set1_DH
790 #define EVP_PKEY_get0_DH wolfSSL_EVP_PKEY_get0_DH
791 #define EVP_PKEY_get1_DH wolfSSL_EVP_PKEY_get1_DH
792 #define EVP_PKEY_get0_EC_KEY wolfSSL_EVP_PKEY_get0_EC_KEY
793 #define EVP_PKEY_get0_hmac wolfSSL_EVP_PKEY_get0_hmac
794 #define EVP_PKEY_new_mac_key wolfSSL_EVP_PKEY_new_mac_key
795 #define EVP_MD_CTX_copy wolfSSL_EVP_MD_CTX_copy
796 #define EVP_MD_CTX_copy_ex wolfSSL_EVP_MD_CTX_copy_ex
797 #define EVP_PKEY_sign_init wolfSSL_EVP_PKEY_sign_init
798 #define EVP_PKEY_sign wolfSSL_EVP_PKEY_sign
799 #define EVP_PKEY_keygen wolfSSL_EVP_PKEY_keygen
800 #define EVP_PKEY_keygen_init wolfSSL_EVP_PKEY_keygen_init
801 #define EVP_PKEY_bits wolfSSL_EVP_PKEY_bits
802 #define EVP_PKEY_CTX_free wolfSSL_EVP_PKEY_CTX_free
803 #define EVP_PKEY_CTX_new wolfSSL_EVP_PKEY_CTX_new
804 #define EVP_PKEY_CTX_set_rsa_padding wolfSSL_EVP_PKEY_CTX_set_rsa_padding
805 #define EVP_PKEY_CTX_new_id wolfSSL_EVP_PKEY_CTX_new_id
806 #define EVP_PKEY_CTX_set_rsa_keygen_bits wolfSSL_EVP_PKEY_CTX_set_rsa_keygen_bits
807 #define EVP_PKEY_derive_init wolfSSL_EVP_PKEY_derive_init
808 #define EVP_PKEY_derive_set_peer wolfSSL_EVP_PKEY_derive_set_peer
809 #define EVP_PKEY_derive wolfSSL_EVP_PKEY_derive
810 #define EVP_PKEY_decrypt wolfSSL_EVP_PKEY_decrypt
811 #define EVP_PKEY_decrypt_init wolfSSL_EVP_PKEY_decrypt_init
812 #define EVP_PKEY_encrypt wolfSSL_EVP_PKEY_encrypt
813 #define EVP_PKEY_encrypt_init wolfSSL_EVP_PKEY_encrypt_init
814 #define EVP_PKEY_new wolfSSL_EVP_PKEY_new
815 #define EVP_PKEY_free wolfSSL_EVP_PKEY_free
816 #define EVP_PKEY_up_ref wolfSSL_EVP_PKEY_up_ref
817 #define EVP_PKEY_size wolfSSL_EVP_PKEY_size
818 #define EVP_PKEY_missing_parameters wolfSSL_EVP_PKEY_missing_parameters
819 #define EVP_PKEY_cmp wolfSSL_EVP_PKEY_cmp
820 #define EVP_PKEY_type wolfSSL_EVP_PKEY_type
821 #define EVP_PKEY_base_id wolfSSL_EVP_PKEY_base_id
822 #define EVP_PKEY_id wolfSSL_EVP_PKEY_id
823 #define EVP_SignFinal wolfSSL_EVP_SignFinal
824 #define EVP_SignInit wolfSSL_EVP_SignInit
825 #define EVP_SignInit_ex wolfSSL_EVP_SignInit_ex
826 #define EVP_SignUpdate wolfSSL_EVP_SignUpdate
827 #define EVP_VerifyFinal wolfSSL_EVP_VerifyFinal
828 #define EVP_VerifyInit wolfSSL_EVP_VerifyInit
829 #define EVP_VerifyUpdate wolfSSL_EVP_VerifyUpdate
830 
831 #define EVP_CIPHER_CTX_ctrl wolfSSL_EVP_CIPHER_CTX_ctrl
832 #define EVP_CIPHER_CTX_block_size wolfSSL_EVP_CIPHER_CTX_block_size
833 #define EVP_CIPHER_block_size wolfSSL_EVP_CIPHER_block_size
834 #define EVP_CIPHER_flags wolfSSL_EVP_CIPHER_flags
835 #define EVP_CIPHER_CTX_set_flags wolfSSL_EVP_CIPHER_CTX_set_flags
836 #define EVP_CIPHER_CTX_clear_flags wolfSSL_EVP_CIPHER_CTX_clear_flags
837 #define EVP_CIPHER_CTX_set_padding wolfSSL_EVP_CIPHER_CTX_set_padding
838 #define EVP_CIPHER_CTX_flags wolfSSL_EVP_CIPHER_CTX_flags
839 #define EVP_CIPHER_CTX_set_iv wolfSSL_EVP_CIPHER_CTX_set_iv
840 #define EVP_add_digest wolfSSL_EVP_add_digest
841 #define EVP_add_cipher wolfSSL_EVP_add_cipher
842 #define EVP_cleanup wolfSSL_EVP_cleanup
843 #define EVP_read_pw_string wolfSSL_EVP_read_pw_string
844 #define EVP_rc2_cbc wolfSSL_EVP_rc2_cbc
845 
846 #define OpenSSL_add_all_digests() wolfSSL_EVP_init()
847 #define OpenSSL_add_all_ciphers() wolfSSL_EVP_init()
848 #define OpenSSL_add_all_algorithms wolfSSL_add_all_algorithms
849 #define OpenSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf
850 #define OpenSSL_add_all_algorithms_conf wolfSSL_OpenSSL_add_all_algorithms_conf
851 
852 #define wolfSSL_OPENSSL_add_all_algorithms_noconf wolfSSL_OpenSSL_add_all_algorithms_noconf
853 #define wolfSSL_OPENSSL_add_all_algorithms_conf wolfSSL_OpenSSL_add_all_algorithms_conf
854 
855 /* provides older OpenSSL API compatibility */
856 #define OPENSSL_add_all_algorithms OpenSSL_add_all_algorithms
857 #define OPENSSL_add_all_algorithms_noconf OpenSSL_add_all_algorithms_noconf
858 #define OPENSSL_add_all_algorithms_conf OpenSSL_add_all_algorithms_conf
859 
860 #define NO_PADDING_BLOCK_SIZE 1
861 
862 #define PKCS5_PBKDF2_HMAC_SHA1 wolfSSL_PKCS5_PBKDF2_HMAC_SHA1
863 #define PKCS5_PBKDF2_HMAC wolfSSL_PKCS5_PBKDF2_HMAC
864 
865 /* OpenSSL compat. ctrl values */
866 #define EVP_CTRL_INIT 0x0
867 #define EVP_CTRL_SET_KEY_LENGTH 0x1
868 #define EVP_CTRL_SET_RC2_KEY_BITS 0x3 /* needed for qt compilation */
869 
870 #define EVP_CTRL_AEAD_SET_IVLEN 0x9
871 #define EVP_CTRL_AEAD_GET_TAG 0x10
872 #define EVP_CTRL_AEAD_SET_TAG 0x11
873 #define EVP_CTRL_AEAD_SET_IV_FIXED 0x12
874 #define EVP_CTRL_GCM_IV_GEN 0x13
875 #define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
876 #define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
877 #define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
878 #define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
879 
880 #define EVP_PKEY_print_private(arg1, arg2, arg3, arg4)
881 
882 #ifndef EVP_MAX_MD_SIZE
883  #define EVP_MAX_MD_SIZE 64 /* sha512 */
884 #endif
885 
886 #ifndef EVP_MAX_KEY_LENGTH
887 #define EVP_MAX_KEY_LENGTH 64
888 #endif
889 
890 #ifndef EVP_MAX_IV_LENGTH
891 #define EVP_MAX_IV_LENGTH 16
892 #endif
893 
894 #ifndef EVP_MAX_BLOCK_LENGTH
895  #define EVP_MAX_BLOCK_LENGTH 32 /* 2 * blocklen(AES)? */
896  /* They define this as 32. Using the same value here. */
897 #endif
898 
899 #ifndef EVP_MAX_IV_LENGTH
900  #define EVP_MAX_IV_LENGTH 16
901 #endif
902 
903 
904 #define EVP_R_BAD_DECRYPT (-MIN_CODE_E + 100 + 1)
905 #define EVP_R_BN_DECODE_ERROR (-MIN_CODE_E + 100 + 2)
906 #define EVP_R_DECODE_ERROR (-MIN_CODE_E + 100 + 3)
907 #define EVP_R_PRIVATE_KEY_DECODE_ERROR (-MIN_CODE_E + 100 + 4)
908 
909 #define EVP_PKEY_NONE NID_undef
910 #define EVP_PKEY_RSA 6
911 #define EVP_PKEY_RSA2 19
912 #define EVP_PKEY_DH 28
913 #define EVP_CIPHER_mode WOLFSSL_CIPHER_mode
914 /* WOLFSSL_EVP_CIPHER is just the string name of the cipher */
915 #define EVP_CIPHER_name(x) x
916 #define EVP_MD_CTX_reset wolfSSL_EVP_MD_CTX_cleanup
917 /* WOLFSSL_EVP_MD is just the string name of the digest */
918 #define EVP_MD_name(x) x
919 #define EVP_CIPHER_nid wolfSSL_EVP_CIPHER_nid
920 
921 
922 WOLFSSL_API void printPKEY(WOLFSSL_EVP_PKEY *k);
923 
924 #ifdef __cplusplus
925  } /* extern "C" */
926 #endif
927 
928 #include <wolfssl/openssl/objects.h>
929 
930 #endif /* WOLFSSL_EVP_H_ */
Definition: arc4.h:46
WOLFSSL_API const WOLFSSL_EVP_CIPHER * wolfSSL_EVP_des_cbc(void)
Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called on...
Definition: evp.c:3738
Definition: aes.h:239
WOLFSSL_API const WOLFSSL_EVP_CIPHER * wolfSSL_EVP_des_ede3_ecb(void)
Getter functions for the respective WOLFSSL_EVP_CIPHER pointers. wolfSSL_EVP_init() must be called on...
Definition: evp.c:3762
WOLFSSL_API int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX *ctx, const WOLFSSL_EVP_MD *type, WOLFSSL_ENGINE *impl)
Function for initializing WOLFSSL_EVP_MD_CTX. This function is a wrapper for wolfSSL_EVP_DigestInit()...
Definition: evp.c:370
Definition: rsa.h:66
WOLFSSL_API int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher)
This is a getter function for the block size of cipher.
Definition: evp.c:1053
Definition: ssl.h:316
Definition: evp.h:181
Definition: des3.h:90
Definition: aes.h:149
Definition: ec.h:106
Definition: evp.h:328
Definition: evp.h:145
Definition: sha.h:167
Definition: hmac.h:137
Definition: evp.h:193
WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl)
Function for encrypting/decrypting data. In buffer is added to be encrypted or decrypted and out buff...
Definition: evp.c:587
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx)
This is a getter function for the ctx block size.
Definition: evp.c:870
Definition: sha.h:82
Definition: sha.h:109
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX *ctx, int keylen)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure key length.
Definition: evp.c:4972
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure.
Definition: evp.c:1144
WOLFSSL_API int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX *ctx, const WOLFSSL_EVP_CIPHER *type, WOLFSSL_ENGINE *impl, const unsigned char *key, const unsigned char *iv)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherIn...
Definition: evp.c:260
Definition: idea.h:51
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *c, int pad)
Setter function for WOLFSSL_EVP_CIPHER_CTX structure to use padding.
Definition: evp.c:1164
Definition: sha.h:138
Definition: dh.h:41
WOLFSSL_API int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX *ctx, const WOLFSSL_EVP_CIPHER *type, WOLFSSL_ENGINE *impl, const unsigned char *key, const unsigned char *iv)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_EVP_CipherIn...
Definition: evp.c:241
Definition: evp.h:358
Definition: des3.h:98
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_clear_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags)
Clearing function for WOLFSSL_EVP_CIPHER_CTX structure.
Definition: evp.c:1151
Definition: dsa.h:46
WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
This function performs the final cipher operations adding in padding. If WOLFSSL_EVP_CIPH_NO_PADDING ...
Definition: evp.c:733
WOLFSSL_API int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX *ctx, const WOLFSSL_EVP_CIPHER *type, WOLFSSL_ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc)
Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a wrapper for wolfSSL_CipherInit()...
Definition: evp.c:323