]>
Commit | Line | Data |
---|---|---|
27af42f9 DSH |
1 | /* evp_int.h */ |
2 | /* | |
3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project | |
4 | * 2015. | |
5 | */ | |
6 | /* ==================================================================== | |
7 | * Copyright (c) 2015 The OpenSSL Project. All rights reserved. | |
8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | |
12 | * | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * | |
16 | * 2. Redistributions in binary form must reproduce the above copyright | |
17 | * notice, this list of conditions and the following disclaimer in | |
18 | * the documentation and/or other materials provided with the | |
19 | * distribution. | |
20 | * | |
21 | * 3. All advertising materials mentioning features or use of this | |
22 | * software must display the following acknowledgment: | |
23 | * "This product includes software developed by the OpenSSL Project | |
24 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | |
25 | * | |
26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | |
27 | * endorse or promote products derived from this software without | |
28 | * prior written permission. For written permission, please contact | |
29 | * licensing@OpenSSL.org. | |
30 | * | |
31 | * 5. Products derived from this software may not be called "OpenSSL" | |
32 | * nor may "OpenSSL" appear in their names without prior written | |
33 | * permission of the OpenSSL Project. | |
34 | * | |
35 | * 6. Redistributions of any form whatsoever must retain the following | |
36 | * acknowledgment: | |
37 | * "This product includes software developed by the OpenSSL Project | |
38 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | |
39 | * | |
40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | |
41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | |
44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
51 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
52 | * ==================================================================== | |
53 | * | |
54 | * This product includes cryptographic software written by Eric Young | |
55 | * (eay@cryptsoft.com). This product includes software written by Tim | |
56 | * Hudson (tjh@cryptsoft.com). | |
57 | * | |
58 | */ | |
59 | ||
60 | struct evp_pkey_ctx_st { | |
61 | /* Method associated with this operation */ | |
62 | const EVP_PKEY_METHOD *pmeth; | |
63 | /* Engine that implements this method or NULL if builtin */ | |
64 | ENGINE *engine; | |
65 | /* Key: may be NULL */ | |
66 | EVP_PKEY *pkey; | |
67 | /* Peer key for key agreement, may be NULL */ | |
68 | EVP_PKEY *peerkey; | |
69 | /* Actual operation */ | |
70 | int operation; | |
71 | /* Algorithm specific data */ | |
72 | void *data; | |
73 | /* Application specific data */ | |
74 | void *app_data; | |
75 | /* Keygen callback */ | |
76 | EVP_PKEY_gen_cb *pkey_gencb; | |
77 | /* implementation specific keygen data */ | |
78 | int *keygen_info; | |
79 | int keygen_info_count; | |
80 | } /* EVP_PKEY_CTX */ ; | |
81 | ||
82 | #define EVP_PKEY_FLAG_DYNAMIC 1 | |
83 | ||
84 | struct evp_pkey_method_st { | |
85 | int pkey_id; | |
86 | int flags; | |
87 | int (*init) (EVP_PKEY_CTX *ctx); | |
88 | int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); | |
89 | void (*cleanup) (EVP_PKEY_CTX *ctx); | |
90 | int (*paramgen_init) (EVP_PKEY_CTX *ctx); | |
91 | int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); | |
92 | int (*keygen_init) (EVP_PKEY_CTX *ctx); | |
93 | int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); | |
94 | int (*sign_init) (EVP_PKEY_CTX *ctx); | |
95 | int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | |
96 | const unsigned char *tbs, size_t tbslen); | |
97 | int (*verify_init) (EVP_PKEY_CTX *ctx); | |
98 | int (*verify) (EVP_PKEY_CTX *ctx, | |
99 | const unsigned char *sig, size_t siglen, | |
100 | const unsigned char *tbs, size_t tbslen); | |
101 | int (*verify_recover_init) (EVP_PKEY_CTX *ctx); | |
102 | int (*verify_recover) (EVP_PKEY_CTX *ctx, | |
103 | unsigned char *rout, size_t *routlen, | |
104 | const unsigned char *sig, size_t siglen); | |
105 | int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); | |
106 | int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | |
107 | EVP_MD_CTX *mctx); | |
108 | int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); | |
109 | int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, | |
110 | EVP_MD_CTX *mctx); | |
111 | int (*encrypt_init) (EVP_PKEY_CTX *ctx); | |
112 | int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | |
113 | const unsigned char *in, size_t inlen); | |
114 | int (*decrypt_init) (EVP_PKEY_CTX *ctx); | |
115 | int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | |
116 | const unsigned char *in, size_t inlen); | |
117 | int (*derive_init) (EVP_PKEY_CTX *ctx); | |
118 | int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); | |
119 | int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2); | |
120 | int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value); | |
121 | } /* EVP_PKEY_METHOD */ ; | |
122 | ||
a8eba56e | 123 | DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) |
4a1f3f27 | 124 | |
27af42f9 | 125 | void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); |
8f463dbd DSH |
126 | |
127 | extern const EVP_PKEY_METHOD cmac_pkey_meth; | |
128 | extern const EVP_PKEY_METHOD dh_pkey_meth; | |
129 | extern const EVP_PKEY_METHOD dhx_pkey_meth; | |
130 | extern const EVP_PKEY_METHOD dsa_pkey_meth; | |
131 | extern const EVP_PKEY_METHOD ec_pkey_meth; | |
132 | extern const EVP_PKEY_METHOD hmac_pkey_meth; | |
133 | extern const EVP_PKEY_METHOD rsa_pkey_meth; | |
2db6bf6f RL |
134 | |
135 | struct evp_md_st { | |
136 | int type; | |
137 | int pkey_type; | |
138 | int md_size; | |
139 | unsigned long flags; | |
140 | int (*init) (EVP_MD_CTX *ctx); | |
141 | int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); | |
142 | int (*final) (EVP_MD_CTX *ctx, unsigned char *md); | |
143 | int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from); | |
144 | int (*cleanup) (EVP_MD_CTX *ctx); | |
145 | int block_size; | |
146 | int ctx_size; /* how big does the ctx->md_data need to be */ | |
147 | /* control function */ | |
148 | int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2); | |
149 | } /* EVP_MD */ ; | |
150 |