replaced snprintf with BIO version (for windows builds)
[oweals/openssl.git] / crypto / evp / evp_locl.h
1 /*
2  * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /* EVP_MD_CTX related stuff */
11
12 struct evp_md_ctx_st {
13     const EVP_MD *digest;
14     ENGINE *engine;             /* functional reference if 'digest' is
15                                  * ENGINE-provided */
16     unsigned long flags;
17     void *md_data;
18     /* Public key context for sign/verify */
19     EVP_PKEY_CTX *pctx;
20     /* Update function: usually copied from EVP_MD */
21     int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
22
23     /* Provider ctx */
24     void *provctx;
25     EVP_MD *fetched_digest;
26 } /* EVP_MD_CTX */ ;
27
28 struct evp_cipher_ctx_st {
29     const EVP_CIPHER *cipher;
30     ENGINE *engine;             /* functional reference if 'cipher' is
31                                  * ENGINE-provided */
32     int encrypt;                /* encrypt or decrypt */
33     int buf_len;                /* number we have left */
34     unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
35     unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
36     unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */
37     int num;                    /* used by cfb/ofb/ctr mode */
38     /* FIXME: Should this even exist? It appears unused */
39     void *app_data;             /* application stuff */
40     int key_len;                /* May change for variable length cipher */
41     unsigned long flags;        /* Various flags */
42     void *cipher_data;          /* per EVP data */
43     int final_used;
44     int block_mask;
45     unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */
46 } /* EVP_CIPHER_CTX */ ;
47
48 struct evp_mac_ctx_st {
49     const EVP_MAC *meth;         /* Method structure */
50     void *data;                  /* Individual method data */
51 } /* EVP_MAC_CTX */;
52
53 struct evp_kdf_ctx_st {
54     const EVP_KDF_METHOD *kmeth;
55     EVP_KDF_IMPL *impl;          /* Algorithm-specific data */
56 } /* EVP_KDF_CTX */ ;
57
58 int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
59                              int passlen, ASN1_TYPE *param,
60                              const EVP_CIPHER *c, const EVP_MD *md,
61                              int en_de);
62
63 struct evp_Encode_Ctx_st {
64     /* number saved in a partial encode/decode */
65     int num;
66     /*
67      * The length is either the output line length (in input bytes) or the
68      * shortest input line length that is ok.  Once decoding begins, the
69      * length is adjusted up each time a longer line is decoded
70      */
71     int length;
72     /* data to encode */
73     unsigned char enc_data[80];
74     /* number read on current line */
75     int line_num;
76     unsigned int flags;
77 };
78
79 typedef struct evp_pbe_st EVP_PBE_CTL;
80 DEFINE_STACK_OF(EVP_PBE_CTL)
81
82 int is_partially_overlapping(const void *ptr1, const void *ptr2, int len);
83
84 #include <openssl/ossl_typ.h>
85 #include <openssl/core.h>
86
87 void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
88                         const char *algorithm, const char *properties,
89                         void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
90                                             OSSL_PROVIDER *prov),
91                         int (*upref_method)(void *),
92                         void (*free_method)(void *));