1EVP_MD_METH_NEW(3)                  OpenSSL                 EVP_MD_METH_NEW(3)
2
3
4

NAME

6       EVP_MD_meth_dup, EVP_MD_meth_new, EVP_MD_meth_free,
7       EVP_MD_meth_set_input_blocksize, EVP_MD_meth_set_result_size,
8       EVP_MD_meth_set_app_datasize, EVP_MD_meth_set_flags,
9       EVP_MD_meth_set_init, EVP_MD_meth_set_update, EVP_MD_meth_set_final,
10       EVP_MD_meth_set_copy, EVP_MD_meth_set_cleanup, EVP_MD_meth_set_ctrl,
11       EVP_MD_meth_get_input_blocksize, EVP_MD_meth_get_result_size,
12       EVP_MD_meth_get_app_datasize, EVP_MD_meth_get_flags,
13       EVP_MD_meth_get_init, EVP_MD_meth_get_update, EVP_MD_meth_get_final,
14       EVP_MD_meth_get_copy, EVP_MD_meth_get_cleanup, EVP_MD_meth_get_ctrl -
15       Routines to build up EVP_MD methods
16

SYNOPSIS

18        #include <openssl/evp.h>
19
20        EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);
21        void EVP_MD_meth_free(EVP_MD *md);
22        EVP_MD *EVP_MD_meth_dup(const EVP_MD *md);
23
24        int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);
25        int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);
26        int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);
27        int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);
28        int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));
29        int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,
30                                                             const void *data,
31                                                             size_t count));
32        int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,
33                                                           unsigned char *md));
34        int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,
35                                                         const EVP_MD_CTX *from));
36        int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));
37        int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,
38                                                         int p1, void *p2));
39
40        int EVP_MD_meth_get_input_blocksize(const EVP_MD *md);
41        int EVP_MD_meth_get_result_size(const EVP_MD *md);
42        int EVP_MD_meth_get_app_datasize(const EVP_MD *md);
43        unsigned long EVP_MD_meth_get_flags(const EVP_MD *md);
44        int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);
45        int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,
46                                                        const void *data,
47                                                        size_t count);
48        int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,
49                                                       unsigned char *md);
50        int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,
51                                                      const EVP_MD_CTX *from);
52        int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);
53        int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,
54                                                      int p1, void *p2);
55

DESCRIPTION

57       The EVP_MD type is a structure for digest method implementation.  It
58       can also have associated public/private key signing and verifying
59       routines.
60
61       EVP_MD_meth_new() creates a new EVP_MD structure.
62
63       EVP_MD_meth_dup() creates a copy of md.
64
65       EVP_MD_meth_free() destroys a EVP_MD structure.
66
67       EVP_MD_meth_set_input_blocksize() sets the internal input block size
68       for the method md to blocksize bytes.
69
70       EVP_MD_meth_set_result_size() sets the size of the result that the
71       digest method in md is expected to produce to resultsize bytes.
72
73       The digest method may have its own private data, which OpenSSL will
74       allocate for it.  EVP_MD_meth_set_app_datasize() should be used to set
75       the size for it to datasize.
76
77       EVP_MD_meth_set_flags() sets the flags to describe optional behaviours
78       in the particular md.  Several flags can be or'd together.  The
79       available flags are:
80
81       EVP_MD_FLAG_ONESHOT
82           This digest method can only handle one block of input.
83
84       EVP_MD_FLAG_XOF
85           This digest method is an extensible-output function (XOF) and
86           supports the EVP_MD_CTRL_XOF_LEN control.
87
88       EVP_MD_FLAG_DIGALGID_NULL
89           When setting up a DigestAlgorithmIdentifier, this flag will have
90           the parameter set to NULL by default.  Use this for PKCS#1.  Note:
91           if combined with EVP_MD_FLAG_DIGALGID_ABSENT, the latter will
92           override.
93
94       EVP_MD_FLAG_DIGALGID_ABSENT
95           When setting up a DigestAlgorithmIdentifier, this flag will have
96           the parameter be left absent by default.  Note: if combined with
97           EVP_MD_FLAG_DIGALGID_NULL, the latter will be overridden.
98
99       EVP_MD_FLAG_DIGALGID_CUSTOM
100           Custom DigestAlgorithmIdentifier handling via ctrl, with
101           EVP_MD_FLAG_DIGALGID_ABSENT as default.  Note: if combined with
102           EVP_MD_FLAG_DIGALGID_NULL, the latter will be overridden.
103           Currently unused.
104
105       EVP_MD_FLAG_FIPS
106           This digest method is suitable for use in FIPS mode.  Currently
107           unused.
108
109       EVP_MD_meth_set_init() sets the digest init function for md.  The
110       digest init function is called by EVP_Digest(), EVP_DigestInit(),
111       EVP_DigestInit_ex(), EVP_SignInit, EVP_SignInit_ex(), EVP_VerifyInit()
112       and EVP_VerifyInit_ex().
113
114       EVP_MD_meth_set_update() sets the digest update function for md.  The
115       digest update function is called by EVP_Digest(), EVP_DigestUpdate()
116       and EVP_SignUpdate().
117
118       EVP_MD_meth_set_final() sets the digest final function for md.  The
119       digest final function is called by EVP_Digest(), EVP_DigestFinal(),
120       EVP_DigestFinal_ex(), EVP_SignFinal() and EVP_VerifyFinal().
121
122       EVP_MD_meth_set_copy() sets the function for md to do extra
123       computations after the method's private data structure has been copied
124       from one EVP_MD_CTX to another.  If all that's needed is to copy the
125       data, there is no need for this copy function.  Note that the copy
126       function is passed two EVP_MD_CTX *, the private data structure is then
127       available with EVP_MD_CTX_md_data().  This copy function is called by
128       EVP_MD_CTX_copy() and EVP_MD_CTX_copy_ex().
129
130       EVP_MD_meth_set_cleanup() sets the function for md to do extra cleanup
131       before the method's private data structure is cleaned out and freed.
132       Note that the cleanup function is passed a EVP_MD_CTX *, the private
133       data structure is then available with EVP_MD_CTX_md_data().  This
134       cleanup function is called by EVP_MD_CTX_reset() and EVP_MD_CTX_free().
135
136       EVP_MD_meth_set_ctrl() sets the control function for md.  See
137       EVP_MD_CTX_ctrl(3) for the available controls.
138
139       EVP_MD_meth_get_input_blocksize(), EVP_MD_meth_get_result_size(),
140       EVP_MD_meth_get_app_datasize(), EVP_MD_meth_get_flags(),
141       EVP_MD_meth_get_init(), EVP_MD_meth_get_update(),
142       EVP_MD_meth_get_final(), EVP_MD_meth_get_copy(),
143       EVP_MD_meth_get_cleanup() and EVP_MD_meth_get_ctrl() are all used to
144       retrieve the method data given with the EVP_MD_meth_set_*() functions
145       above.
146

RETURN VALUES

148       EVP_MD_meth_new() and EVP_MD_meth_dup() return a pointer to a newly
149       created EVP_MD, or NULL on failure.  All EVP_MD_meth_set_*() functions
150       return 1.  EVP_MD_get_input_blocksize(), EVP_MD_meth_get_result_size(),
151       EVP_MD_meth_get_app_datasize() and EVP_MD_meth_get_flags() return the
152       indicated sizes or flags.  All other EVP_CIPHER_meth_get_*() functions
153       return pointers to their respective md function.
154

SEE ALSO

156       EVP_DigestInit(3), EVP_SignInit(3), EVP_VerifyInit(3)
157

HISTORY

159       The EVP_MD structure was openly available in OpenSSL before version
160       1.1.  The functions described here were added in OpenSSL 1.1.
161
163       Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
164
165       Licensed under the OpenSSL license (the "License").  You may not use
166       this file except in compliance with the License.  You can obtain a copy
167       in the file LICENSE in the source distribution or at
168       <https://www.openssl.org/source/license.html>.
169
170
171
1721.1.1k                            2021-03-26                EVP_MD_METH_NEW(3)
Impressum