2
2
3
3
=head1 NAME
4
4
5
- EVP_MD_fetch
5
+ EVP_MD_fetch, EVP_CIPHER_fetch
6
6
- Functions to explicitly fetch algorithm implementations
7
7
8
8
=head1 SYNOPSIS
@@ -11,60 +11,106 @@ EVP_MD_fetch
11
11
12
12
EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm,
13
13
const char *properties);
14
+ EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm,
15
+ const char *properties);
14
16
15
17
=head1 DESCRIPTION
16
18
17
- The B<EVP_MD> object is used for representing a digest method implementation.
19
+ Cryptographic algorithms are represented by different OpenSSL objects depending
20
+ on what type of algorithm it is. The following cryptographic algorithm types are
21
+ supported.
18
22
19
- Having obtained a digest implementation as an B<EVP_MD> type it can be used to
20
- calculate the digest of input data using functions such as
21
- L<EVP_DigestInit_ex(3)>, L<EVP_DigestUpdate(3)> and L<EVP_DigestFinal_ex(3)>.
23
+ =over 4
24
+
25
+ =item B<EVP_MD>
26
+
27
+ Represents a digest algorithm.
28
+
29
+ =item B<EVP_CIPHER>
30
+
31
+ Represents a symmetric cipher algorithm.
32
+
33
+ =item B<EVP_MAC>
34
+
35
+ Represents a Message Authentication Code algorithm.
36
+
37
+ =item B<EVP_KDF>
38
+
39
+ Represents a Key Derivation Function algorithm.
40
+
41
+ =back
22
42
23
- Digest implementations may be obtained in one of three ways, i.e. implicit
24
- fetch, explicit fetch or user defined.
43
+ The algorithm objects may or may not have an associated algorithm
44
+ implementation.
45
+ Cryptographic algorithms are implemented by providers.
46
+ Any algorithm may be supported by zero or more providers.
47
+ In order to use an algorithm an implementation must first be obtained.
48
+ This can happen in one of three ways, i.e. implicit fetch, explicit fetch or
49
+ user defined.
25
50
26
51
=over 4
27
52
28
53
=item Implicit Fetch
29
54
30
55
With implicit fetch an application can use functions such as L<EVP_sha256(3)>,
31
- L<EVP_sha512(3)> or L<EVP_blake2b512(3)> to obtain an B<EVP_MD> object. When
32
- used in a function like L<EVP_DigestInit_ex(3)> the actual implementation to
33
- be used will be fetched implicitly using default search criteria. Typically,
34
- (unless the default search criteria have been changed and/or different providers
35
- have been loaded), this will return an implementation of the appropriate
36
- algorithm from the default provider.
56
+ L<EVP_blake2b512(3)> or L<EVP_aes_128_cbc(3)> to obtain an algorithm object with
57
+ no associated implementation.
58
+ When used in a function like L<EVP_DigestInit_ex(3)> or L<EVP_CipherInit_ex(3)>
59
+ the actual implementation to be used will be fetched implicitly using default
60
+ search criteria.
61
+ Typically, this will return an implementation of the appropriate algorithm from
62
+ the default provider unless the default search criteria have been changed and/or
63
+ different providers have been loaded.
37
64
38
65
=item Explicit Fetch
39
66
40
- With explicit fetch an application uses the EVP_MD_fetch() function to obtain
41
- an algorithm implementation. An implementation with the given name and
42
- satisfying the search criteria specified in the B<properties> parameter
43
- combined with the default search criteria will be looked for within the
44
- available providers and returned.
67
+ With explicit fetch an application uses one of the "fetch" functions to obtain
68
+ an algorithm object with an associated implementation.
69
+ An implementation with the given name that satisfies the search criteria
70
+ specified in the B<properties> parameter combined with the default search
71
+ criteria will be looked for within the available providers and returned.
45
72
See L<EVP_set_default_properties(3)> for information on default search criteria
46
73
and L<OSSL_PROVIDER(3)> for information about providers.
47
74
48
75
=item User defined
49
76
50
- Using the user defined approach an application constructs its own EVP_MD object.
51
- See L<EVP_MD_meth_new(3)> for details.
77
+ Using the user defined approach an application constructs its own algorithm
78
+ object.
79
+ See L<EVP_MD_meth_new(3)> and L<EVP_CIPHER_meth_new(3)> for details.
52
80
53
81
=back
54
82
55
- The EVP_MD_fetch() function will look for an algorithm within the providers that
56
- have been loaded into the B<OPENSSL_CTX> given in the B<ctx> parameter. This
57
- parameter may be NULL in which case the default B<OPENSSL_CTX> will be used. See
58
- L<OPENSSL_CTX_new(3)> and L<OSSL_PROVIDER_load(3)> for further details.
83
+ Having obtained an algorithm implementation as an algorithm object it can then
84
+ be used to perform cryptographic operations.
85
+ For example to calculate the digest of input data with an B<EVP_MD> algorithm
86
+ object you can use functions such as L<EVP_DigestInit_ex(3)>,
87
+ L<EVP_DigestUpdate(3)> and L<EVP_DigestFinal_ex(3)>.
88
+
89
+ The fetch functions will look for an algorithm within the providers that
90
+ have been loaded into the B<OPENSSL_CTX> given in the B<ctx> parameter.
91
+ This parameter may be NULL in which case the default B<OPENSSL_CTX> will be
92
+ used.
93
+ See L<OPENSSL_CTX_new(3)> and L<OSSL_PROVIDER_load(3)> for further details.
59
94
60
95
The B<algorithm> parameter gives the name of the algorithm to be looked up.
61
- Different algorithms can be made available by loading different providers. The
62
- built-in default provider algorithm implementation names are: SHA1, SHA224,
63
- SHA256, SHA384, SHA512, SHA512-224, SHA512-256,SHA3-224, SHA3-256, SHA3-384,
64
- SHA3-512, SHAKE128, SHAKE256, SM3, BLAKE2b512, BLAKE2s256 and MD5-SHA1.
96
+ Different algorithms can be made available by loading different providers.
97
+
98
+ The built-in default provider digest algorithm implementation names are: SHA1,
99
+ SHA224, SHA256, SHA384, SHA512, SHA512-224, SHA512-256, SHA3-224, SHA3-256,
100
+ SHA3-384, SHA3-512, SHAKE128, SHAKE256, SM3, BLAKE2b512, BLAKE2s256 and
101
+ MD5-SHA1.
102
+
103
+ The built-in default provider cipher algorithm implementation names are:
104
+ AES-256-ECB, AES-192-ECB, AES-128-ECB, AES-256-CBC, AES-192-CBC, AES-128-CBC,
105
+ AES-256-OFB, AES-192-OFB, AES-128-OFB, AES-256-CFB, AES-192-CFB, AES-128-CFB,
106
+ AES-256-CFB1, AES-192-CFB1, AES-128-CFB1, AES-256-CFB8, AES-192-CFB8,
107
+ AES-128-CFB8, AES-256-CTR, AES-192-CTR, AES-128-CTR, id-aes256-GCM,
108
+ id-aes192-GCM and id-aes128-GCM.
65
109
66
110
Additional algorithm implementations may be obtained by loading the "legacy"
67
- provider. The names of these algorithms are: RIPEMD160, MD2, MD4, MD5, MDC2 and
111
+ provider.
112
+
113
+ The legacy provider digest algorithms are: RIPEMD160, MD2, MD4, MD5, MDC2 and
68
114
whirlpool.
69
115
70
116
The B<properties> parameter specifies the search criteria that will be used to
@@ -82,8 +128,13 @@ NULL in which case any implementation from the available providers with the
82
128
given algorithm name will be returned.
83
129
84
130
The return value from a call to EVP_MD_fetch() must be freed by the caller using
85
- L<EVP_MD_meth_free(3)>. Note that EVP_MD objects are reference counted. See
86
- L<EVP_MD_upref(3)>.
131
+ L<EVP_MD_meth_free(3)>.
132
+ Note that EVP_MD objects are reference counted. See L<EVP_MD_up_ref(3)>.
133
+
134
+ The return value from a call to EVP_CIPHER_fetch() must be freed by the caller
135
+ using L<EVP_CIPHER_meth_free(3)>.
136
+ Note that EVP_CIPHER objects are reference counted.
137
+ See L<EVP_CIPHER_up_ref(3)>.
87
138
88
139
=head1 NOTES
89
140
@@ -107,6 +158,14 @@ an EVP_MD object, or NULL on error.
107
158
Fetch any available implementation of SHA256 in the default context:
108
159
109
160
EVP_MD *md = EVP_MD_fetch(NULL, "SHA256", NULL);
161
+ ...
162
+ EVP_MD_meth_free(md);
163
+
164
+ Fetch any available implementation of AES-128-CBC in the default context:
165
+
166
+ EVP_CIPHER *cipher = EVP_CIPHER_fetch(NULL, "AES-128-CBC", NULL);
167
+ ...
168
+ EVP_CIPHER_meth_free(cipher);
110
169
111
170
Fetch an implementation of SHA256 from the default provider in the default
112
171
context:
@@ -157,9 +216,10 @@ other providers:
157
216
158
217
=head1 SEE ALSO
159
218
160
- L<EVP_DigestInit(3)>, L<EVP_MD_meth_new(3)>, L<EVP_MD_meth_free(3)>,
161
- L<EVP_MD_upref(3)>, L<OSSL_PROVIDER_load(3)>, L<OPENSSL_CTX(3)>,
162
- L<EVP_set_default_properties(3)>
219
+ L<EVP_DigestInit_ex(3)>, L<EVP_EncryptInit_ex(3)>, L<EVP_MD_meth_new(3)>,
220
+ L<EVP_MD_meth_free(3)>, L<EVP_CIPHER_meth_new(3)>, L<EVP_CIPHER_meth_free(3)>,
221
+ L<EVP_MD_up_ref(3)>, L<EVP_CIPHER_up_ref(3)>, L<OSSL_PROVIDER_load(3)>,
222
+ L<OPENSSL_CTX(3)>, L<EVP_set_default_properties(3)>
163
223
164
224
=head1 HISTORY
165
225
0 commit comments