summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp_locl.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h130
1 files changed, 129 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index 44e2d5cadb..f0b47a497c 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_locl.h,v 1.20 2022/01/10 12:10:26 tb Exp $ */ 1/* $OpenBSD: evp_locl.h,v 1.21 2022/01/14 08:04:14 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -67,6 +67,126 @@ __BEGIN_HIDDEN_DECLS
67 */ 67 */
68#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400 68#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400
69 69
70typedef int evp_sign_method(int type, const unsigned char *m,
71 unsigned int m_length, unsigned char *sigret, unsigned int *siglen,
72 void *key);
73typedef int evp_verify_method(int type, const unsigned char *m,
74 unsigned int m_length, const unsigned char *sigbuf, unsigned int siglen,
75 void *key);
76
77/* Type needs to be a bit field
78 * Sub-type needs to be for variations on the method, as in, can it do
79 * arbitrary encryption.... */
80struct evp_pkey_st {
81 int type;
82 int save_type;
83 int references;
84 const EVP_PKEY_ASN1_METHOD *ameth;
85 ENGINE *engine;
86 union {
87 char *ptr;
88#ifndef OPENSSL_NO_RSA
89 struct rsa_st *rsa; /* RSA */
90#endif
91#ifndef OPENSSL_NO_DSA
92 struct dsa_st *dsa; /* DSA */
93#endif
94#ifndef OPENSSL_NO_DH
95 struct dh_st *dh; /* DH */
96#endif
97#ifndef OPENSSL_NO_EC
98 struct ec_key_st *ec; /* ECC */
99#endif
100#ifndef OPENSSL_NO_GOST
101 struct gost_key_st *gost; /* GOST */
102#endif
103 } pkey;
104 int save_parameters;
105 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
106} /* EVP_PKEY */;
107
108struct env_md_st {
109 int type;
110 int pkey_type;
111 int md_size;
112 unsigned long flags;
113 int (*init)(EVP_MD_CTX *ctx);
114 int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
115 int (*final)(EVP_MD_CTX *ctx, unsigned char *md);
116 int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from);
117 int (*cleanup)(EVP_MD_CTX *ctx);
118
119 evp_sign_method *sign;
120 evp_verify_method *verify;
121 int required_pkey_type[5]; /*EVP_PKEY_xxx */
122 int block_size;
123 int ctx_size; /* how big does the ctx->md_data need to be */
124 /* control function */
125 int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
126} /* EVP_MD */;
127
128struct env_md_ctx_st {
129 const EVP_MD *digest;
130 ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
131 unsigned long flags;
132 void *md_data;
133 /* Public key context for sign/verify */
134 EVP_PKEY_CTX *pctx;
135 /* Update function: usually copied from EVP_MD */
136 int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
137} /* EVP_MD_CTX */;
138
139struct evp_cipher_st {
140 int nid;
141 int block_size;
142 int key_len; /* Default value for variable length ciphers */
143 int iv_len;
144 unsigned long flags; /* Various flags */
145 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
146 const unsigned char *iv, int enc); /* init key */
147 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
148 const unsigned char *in, size_t inl);/* encrypt/decrypt data */
149 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
150 int ctx_size; /* how big ctx->cipher_data needs to be */
151 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
152 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
153 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
154 void *app_data; /* Application data */
155} /* EVP_CIPHER */;
156
157struct evp_cipher_ctx_st {
158 const EVP_CIPHER *cipher;
159 ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
160 int encrypt; /* encrypt or decrypt */
161 int buf_len; /* number we have left */
162
163 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
164 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
165 unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
166 int num; /* used by cfb/ofb/ctr mode */
167
168 void *app_data; /* application stuff */
169 int key_len; /* May change for variable length cipher */
170 unsigned long flags; /* Various flags */
171 void *cipher_data; /* per EVP data */
172 int final_used;
173 int block_mask;
174 unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
175} /* EVP_CIPHER_CTX */;
176
177struct evp_Encode_Ctx_st {
178
179 int num; /* number saved in a partial encode/decode */
180 int length; /* The length is either the output line length
181 * (in input bytes) or the shortest input line
182 * length that is ok. Once decoding begins,
183 * the length is adjusted up each time a longer
184 * line is decoded */
185 unsigned char enc_data[80]; /* data to encode */
186 int line_num; /* number read on current line */
187 int expect_nl;
188} /* EVP_ENCODE_CTX */;
189
70/* Macros to code block cipher wrappers */ 190/* Macros to code block cipher wrappers */
71 191
72/* Wrapper functions for each cipher mode */ 192/* Wrapper functions for each cipher mode */
@@ -380,6 +500,14 @@ struct evp_aead_st {
380 const unsigned char *ad, size_t ad_len); 500 const unsigned char *ad, size_t ad_len);
381}; 501};
382 502
503/* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key
504 * and message-independent IV. */
505struct evp_aead_ctx_st {
506 const EVP_AEAD *aead;
507 /* aead_state is an opaque pointer to the AEAD specific state. */
508 void *aead_state;
509};
510
383int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name); 511int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name);
384 512
385__END_HIDDEN_DECLS 513__END_HIDDEN_DECLS