diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/man/EVP_DigestInit.3 | 777 |
1 files changed, 0 insertions, 777 deletions
diff --git a/src/lib/libcrypto/man/EVP_DigestInit.3 b/src/lib/libcrypto/man/EVP_DigestInit.3 deleted file mode 100644 index ca36ece5fb..0000000000 --- a/src/lib/libcrypto/man/EVP_DigestInit.3 +++ /dev/null | |||
| @@ -1,777 +0,0 @@ | |||
| 1 | .\" $OpenBSD: EVP_DigestInit.3,v 1.20 2021/01/05 06:51:31 jmc Exp $ | ||
| 2 | .\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000 | ||
| 3 | .\" selective merge up to: OpenSSL a95d7574 Jul 2 12:16:38 2017 -0400 | ||
| 4 | .\" | ||
| 5 | .\" This file is a derived work. | ||
| 6 | .\" The changes are covered by the following Copyright and license: | ||
| 7 | .\" | ||
| 8 | .\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> | ||
| 9 | .\" | ||
| 10 | .\" Permission to use, copy, modify, and distribute this software for any | ||
| 11 | .\" purpose with or without fee is hereby granted, provided that the above | ||
| 12 | .\" copyright notice and this permission notice appear in all copies. | ||
| 13 | .\" | ||
| 14 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 15 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 16 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 17 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 18 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 19 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 20 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 21 | .\" | ||
| 22 | .\" The original file was written by Dr. Stephen Henson <steve@openssl.org> | ||
| 23 | .\" and Richard Levitte <levitte@openssl.org>. | ||
| 24 | .\" Copyright (c) 2000-2004, 2009, 2012-2016 The OpenSSL Project. | ||
| 25 | .\" All rights reserved. | ||
| 26 | .\" | ||
| 27 | .\" Redistribution and use in source and binary forms, with or without | ||
| 28 | .\" modification, are permitted provided that the following conditions | ||
| 29 | .\" are met: | ||
| 30 | .\" | ||
| 31 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 32 | .\" notice, this list of conditions and the following disclaimer. | ||
| 33 | .\" | ||
| 34 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 35 | .\" notice, this list of conditions and the following disclaimer in | ||
| 36 | .\" the documentation and/or other materials provided with the | ||
| 37 | .\" distribution. | ||
| 38 | .\" | ||
| 39 | .\" 3. All advertising materials mentioning features or use of this | ||
| 40 | .\" software must display the following acknowledgment: | ||
| 41 | .\" "This product includes software developed by the OpenSSL Project | ||
| 42 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 43 | .\" | ||
| 44 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 45 | .\" endorse or promote products derived from this software without | ||
| 46 | .\" prior written permission. For written permission, please contact | ||
| 47 | .\" openssl-core@openssl.org. | ||
| 48 | .\" | ||
| 49 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 50 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 51 | .\" permission of the OpenSSL Project. | ||
| 52 | .\" | ||
| 53 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 54 | .\" acknowledgment: | ||
| 55 | .\" "This product includes software developed by the OpenSSL Project | ||
| 56 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 57 | .\" | ||
| 58 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 59 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 60 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 61 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 62 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 63 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 64 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 65 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 66 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 67 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 68 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 69 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 70 | .\" | ||
| 71 | .Dd $Mdocdate: January 5 2021 $ | ||
| 72 | .Dt EVP_DIGESTINIT 3 | ||
| 73 | .Os | ||
| 74 | .Sh NAME | ||
| 75 | .Nm EVP_MD_CTX_new , | ||
| 76 | .Nm EVP_MD_CTX_reset , | ||
| 77 | .Nm EVP_MD_CTX_free , | ||
| 78 | .Nm EVP_MD_CTX_init , | ||
| 79 | .Nm EVP_MD_CTX_create , | ||
| 80 | .Nm EVP_MD_CTX_cleanup , | ||
| 81 | .Nm EVP_MD_CTX_destroy , | ||
| 82 | .Nm EVP_MD_CTX_ctrl , | ||
| 83 | .Nm EVP_DigestInit_ex , | ||
| 84 | .Nm EVP_DigestUpdate , | ||
| 85 | .Nm EVP_DigestFinal_ex , | ||
| 86 | .Nm EVP_Digest , | ||
| 87 | .Nm EVP_MD_CTX_copy_ex , | ||
| 88 | .Nm EVP_DigestInit , | ||
| 89 | .Nm EVP_DigestFinal , | ||
| 90 | .Nm EVP_MD_CTX_copy , | ||
| 91 | .Nm EVP_MAX_MD_SIZE , | ||
| 92 | .Nm EVP_MD_type , | ||
| 93 | .Nm EVP_MD_pkey_type , | ||
| 94 | .Nm EVP_MD_size , | ||
| 95 | .Nm EVP_MD_block_size , | ||
| 96 | .Nm EVP_MD_CTX_md , | ||
| 97 | .Nm EVP_MD_CTX_size , | ||
| 98 | .Nm EVP_MD_CTX_block_size , | ||
| 99 | .Nm EVP_MD_CTX_type , | ||
| 100 | .Nm EVP_md_null , | ||
| 101 | .Nm EVP_md5 , | ||
| 102 | .Nm EVP_md5_sha1 , | ||
| 103 | .Nm EVP_sha1 , | ||
| 104 | .Nm EVP_sha224 , | ||
| 105 | .Nm EVP_sha256 , | ||
| 106 | .Nm EVP_sha384 , | ||
| 107 | .Nm EVP_sha512 , | ||
| 108 | .Nm EVP_dss , | ||
| 109 | .Nm EVP_dss1 , | ||
| 110 | .Nm EVP_ripemd160 , | ||
| 111 | .Nm EVP_get_digestbyname , | ||
| 112 | .Nm EVP_get_digestbynid , | ||
| 113 | .Nm EVP_get_digestbyobj | ||
| 114 | .Nd EVP digest routines | ||
| 115 | .Sh SYNOPSIS | ||
| 116 | .In openssl/evp.h | ||
| 117 | .Ft EVP_MD_CTX * | ||
| 118 | .Fn EVP_MD_CTX_new void | ||
| 119 | .Ft int | ||
| 120 | .Fo EVP_MD_CTX_reset | ||
| 121 | .Fa "EVP_MD_CTX *ctx" | ||
| 122 | .Fc | ||
| 123 | .Ft void | ||
| 124 | .Fo EVP_MD_CTX_free | ||
| 125 | .Fa "EVP_MD_CTX *ctx" | ||
| 126 | .Fc | ||
| 127 | .Ft void | ||
| 128 | .Fo EVP_MD_CTX_init | ||
| 129 | .Fa "EVP_MD_CTX *ctx" | ||
| 130 | .Fc | ||
| 131 | .Ft EVP_MD_CTX * | ||
| 132 | .Fn EVP_MD_CTX_create void | ||
| 133 | .Ft int | ||
| 134 | .Fo EVP_MD_CTX_cleanup | ||
| 135 | .Fa "EVP_MD_CTX *ctx" | ||
| 136 | .Fc | ||
| 137 | .Ft void | ||
| 138 | .Fo EVP_MD_CTX_destroy | ||
| 139 | .Fa "EVP_MD_CTX *ctx" | ||
| 140 | .Fc | ||
| 141 | .Ft int | ||
| 142 | .Fo EVP_MD_CTX_ctrl | ||
| 143 | .Fa "EVP_MD_CTX *ctx" | ||
| 144 | .Fa "int cmd" | ||
| 145 | .Fa "int p1" | ||
| 146 | .Fa "void* p2" | ||
| 147 | .Fc | ||
| 148 | .Ft int | ||
| 149 | .Fo EVP_DigestInit_ex | ||
| 150 | .Fa "EVP_MD_CTX *ctx" | ||
| 151 | .Fa "const EVP_MD *type" | ||
| 152 | .Fa "ENGINE *impl" | ||
| 153 | .Fc | ||
| 154 | .Ft int | ||
| 155 | .Fo EVP_DigestUpdate | ||
| 156 | .Fa "EVP_MD_CTX *ctx" | ||
| 157 | .Fa "const void *d" | ||
| 158 | .Fa "size_t cnt" | ||
| 159 | .Fc | ||
| 160 | .Ft int | ||
| 161 | .Fo EVP_DigestFinal_ex | ||
| 162 | .Fa "EVP_MD_CTX *ctx" | ||
| 163 | .Fa "unsigned char *md" | ||
| 164 | .Fa "unsigned int *s" | ||
| 165 | .Fc | ||
| 166 | .Ft int | ||
| 167 | .Fo EVP_Digest | ||
| 168 | .Fa "const void *d" | ||
| 169 | .Fa "size_t cnt" | ||
| 170 | .Fa "unsigned char *md" | ||
| 171 | .Fa "unsigned int *s" | ||
| 172 | .Fa "const EVP_MD *type" | ||
| 173 | .Fa "ENGINE *impl" | ||
| 174 | .Fc | ||
| 175 | .Ft int | ||
| 176 | .Fo EVP_MD_CTX_copy_ex | ||
| 177 | .Fa "EVP_MD_CTX *out" | ||
| 178 | .Fa "const EVP_MD_CTX *in" | ||
| 179 | .Fc | ||
| 180 | .Ft int | ||
| 181 | .Fo EVP_DigestInit | ||
| 182 | .Fa "EVP_MD_CTX *ctx" | ||
| 183 | .Fa "const EVP_MD *type" | ||
| 184 | .Fc | ||
| 185 | .Ft int | ||
| 186 | .Fo EVP_DigestFinal | ||
| 187 | .Fa "EVP_MD_CTX *ctx" | ||
| 188 | .Fa "unsigned char *md" | ||
| 189 | .Fa "unsigned int *s" | ||
| 190 | .Fc | ||
| 191 | .Ft int | ||
| 192 | .Fo EVP_MD_CTX_copy | ||
| 193 | .Fa "EVP_MD_CTX *out" | ||
| 194 | .Fa "EVP_MD_CTX *in" | ||
| 195 | .Fc | ||
| 196 | .Fd #define EVP_MAX_MD_SIZE 64 /* SHA512 */ | ||
| 197 | .Ft int | ||
| 198 | .Fo EVP_MD_type | ||
| 199 | .Fa "const EVP_MD *md" | ||
| 200 | .Fc | ||
| 201 | .Ft int | ||
| 202 | .Fo EVP_MD_pkey_type | ||
| 203 | .Fa "const EVP_MD *md" | ||
| 204 | .Fc | ||
| 205 | .Ft int | ||
| 206 | .Fo EVP_MD_size | ||
| 207 | .Fa "const EVP_MD *md" | ||
| 208 | .Fc | ||
| 209 | .Ft int | ||
| 210 | .Fo EVP_MD_block_size | ||
| 211 | .Fa "const EVP_MD *md" | ||
| 212 | .Fc | ||
| 213 | .Ft const EVP_MD * | ||
| 214 | .Fo EVP_MD_CTX_md | ||
| 215 | .Fa "const EVP_MD_CTX *ctx" | ||
| 216 | .Fc | ||
| 217 | .Ft int | ||
| 218 | .Fo EVP_MD_CTX_size | ||
| 219 | .Fa "const EVP_MD *ctx" | ||
| 220 | .Fc | ||
| 221 | .Ft int | ||
| 222 | .Fo EVP_MD_CTX_block_size | ||
| 223 | .Fa "const EVP_MD *ctx" | ||
| 224 | .Fc | ||
| 225 | .Ft int | ||
| 226 | .Fo EVP_MD_CTX_type | ||
| 227 | .Fa "const EVP_MD *ctx" | ||
| 228 | .Fc | ||
| 229 | .Ft const EVP_MD * | ||
| 230 | .Fn EVP_md_null void | ||
| 231 | .Ft const EVP_MD * | ||
| 232 | .Fn EVP_md5 void | ||
| 233 | .Ft const EVP_MD * | ||
| 234 | .Fn EVP_md5_sha1 void | ||
| 235 | .Ft const EVP_MD * | ||
| 236 | .Fn EVP_sha1 void | ||
| 237 | .Ft const EVP_MD * | ||
| 238 | .Fn EVP_sha224 void | ||
| 239 | .Ft const EVP_MD * | ||
| 240 | .Fn EVP_sha256 void | ||
| 241 | .Ft const EVP_MD * | ||
| 242 | .Fn EVP_sha384 void | ||
| 243 | .Ft const EVP_MD * | ||
| 244 | .Fn EVP_sha512 void | ||
| 245 | .Ft const EVP_MD * | ||
| 246 | .Fn EVP_dss void | ||
| 247 | .Ft const EVP_MD * | ||
| 248 | .Fn EVP_dss1 void | ||
| 249 | .Ft const EVP_MD * | ||
| 250 | .Fn EVP_ripemd160 void | ||
| 251 | .Ft const EVP_MD * | ||
| 252 | .Fo EVP_get_digestbyname | ||
| 253 | .Fa "const char *name" | ||
| 254 | .Fc | ||
| 255 | .Ft const EVP_MD * | ||
| 256 | .Fo EVP_get_digestbynid | ||
| 257 | .Fa "int type" | ||
| 258 | .Fc | ||
| 259 | .Ft const EVP_MD * | ||
| 260 | .Fo EVP_get_digestbyobj | ||
| 261 | .Fa "const ASN1_OBJECT *o" | ||
| 262 | .Fc | ||
| 263 | .Sh DESCRIPTION | ||
| 264 | The EVP digest routines are a high level interface to message digests | ||
| 265 | and should be used instead of the cipher-specific functions. | ||
| 266 | .Pp | ||
| 267 | .Fn EVP_MD_CTX_new | ||
| 268 | allocates a new, empty digest context. | ||
| 269 | .Pp | ||
| 270 | .Fn EVP_MD_CTX_reset | ||
| 271 | cleans up | ||
| 272 | .Fa ctx | ||
| 273 | and resets it to the state it had after | ||
| 274 | .Fn EVP_MD_CTX_new , | ||
| 275 | such that it can be reused. | ||
| 276 | It is also suitable for digest contexts on the stack that were | ||
| 277 | used and are no longer needed. | ||
| 278 | .Pp | ||
| 279 | .Fn EVP_MD_CTX_free | ||
| 280 | cleans up | ||
| 281 | .Fa ctx | ||
| 282 | and frees the space allocated to it. | ||
| 283 | .Pp | ||
| 284 | .Fn EVP_MD_CTX_init | ||
| 285 | is a deprecated function to clear a digest context on the stack | ||
| 286 | before use. | ||
| 287 | Do not use it on a digest context returned from | ||
| 288 | .Fn EVP_MD_CTX_new | ||
| 289 | or one that was already used. | ||
| 290 | .Pp | ||
| 291 | .Fn EVP_MD_CTX_create , | ||
| 292 | .Fn EVP_MD_CTX_cleanup , | ||
| 293 | and | ||
| 294 | .Fn EVP_MD_CTX_destroy | ||
| 295 | are deprecated aliases for | ||
| 296 | .Fn EVP_MD_CTX_new , | ||
| 297 | .Fn EVP_MD_CTX_reset , | ||
| 298 | and | ||
| 299 | .Fn EVP_MD_CTX_free , | ||
| 300 | respectively. | ||
| 301 | .Pp | ||
| 302 | .Fn EVP_MD_CTX_ctrl | ||
| 303 | performs digest-specific control actions on the context | ||
| 304 | .Fa ctx . | ||
| 305 | .Pp | ||
| 306 | .Fn EVP_DigestInit_ex | ||
| 307 | sets up the digest context | ||
| 308 | .Fa ctx | ||
| 309 | to use a digest | ||
| 310 | .Fa type | ||
| 311 | from | ||
| 312 | .Vt ENGINE | ||
| 313 | .Fa impl . | ||
| 314 | The | ||
| 315 | .Fa type | ||
| 316 | will typically be supplied by a function such as | ||
| 317 | .Fn EVP_sha1 . | ||
| 318 | If | ||
| 319 | .Fa impl | ||
| 320 | is | ||
| 321 | .Dv NULL , | ||
| 322 | then the default implementation of digest | ||
| 323 | .Fa type | ||
| 324 | is used. | ||
| 325 | If | ||
| 326 | .Fa ctx | ||
| 327 | points to an unused object on the stack, it must be initialized with | ||
| 328 | .Fn EVP_MD_CTX_init | ||
| 329 | before calling this function. | ||
| 330 | .Pp | ||
| 331 | .Fn EVP_DigestUpdate | ||
| 332 | hashes | ||
| 333 | .Fa cnt | ||
| 334 | bytes of data at | ||
| 335 | .Fa d | ||
| 336 | into the digest context | ||
| 337 | .Fa ctx . | ||
| 338 | This function can be called several times on the same | ||
| 339 | .Fa ctx | ||
| 340 | to hash additional data. | ||
| 341 | .Pp | ||
| 342 | .Fn EVP_DigestFinal_ex | ||
| 343 | retrieves the digest value from | ||
| 344 | .Fa ctx | ||
| 345 | and places it in | ||
| 346 | .Fa md . | ||
| 347 | If the | ||
| 348 | .Fa s | ||
| 349 | parameter is not | ||
| 350 | .Dv NULL , | ||
| 351 | then the number of bytes of data written (i.e. the length of the | ||
| 352 | digest) will be written to the integer at | ||
| 353 | .Fa s ; | ||
| 354 | at most | ||
| 355 | .Dv EVP_MAX_MD_SIZE | ||
| 356 | bytes will be written. | ||
| 357 | After calling | ||
| 358 | .Fn EVP_DigestFinal_ex , | ||
| 359 | no additional calls to | ||
| 360 | .Fn EVP_DigestUpdate | ||
| 361 | can be made, but | ||
| 362 | .Fn EVP_DigestInit_ex | ||
| 363 | can be called to initialize a new digest operation. | ||
| 364 | .Pp | ||
| 365 | .Fn EVP_Digest | ||
| 366 | is a simple wrapper function to hash | ||
| 367 | .Fa cnt | ||
| 368 | bytes of data at | ||
| 369 | .Fa d | ||
| 370 | using the digest | ||
| 371 | .Fa type | ||
| 372 | from | ||
| 373 | .Vt ENGINE | ||
| 374 | .Fa impl | ||
| 375 | in a one-shot operation and place the digest value into | ||
| 376 | .Fa md , | ||
| 377 | and, unless | ||
| 378 | .Fa s | ||
| 379 | is | ||
| 380 | .Dv NULL , | ||
| 381 | the length of the digest in bytes into | ||
| 382 | .Pf * Fa s . | ||
| 383 | This wrapper uses a temporary digest context and passes its arguments to | ||
| 384 | .Fn EVP_DigestInit_ex , | ||
| 385 | .Fn EVP_DigestUpdate , | ||
| 386 | and | ||
| 387 | .Fn EVP_DigestFinal_ex | ||
| 388 | internally. | ||
| 389 | .Pp | ||
| 390 | .Fn EVP_MD_CTX_copy_ex | ||
| 391 | can be used to copy the message digest state from | ||
| 392 | .Fa in | ||
| 393 | to | ||
| 394 | .Fa out . | ||
| 395 | This is useful if large amounts of data are to be hashed which only | ||
| 396 | differ in the last few bytes. | ||
| 397 | If | ||
| 398 | .Fa out | ||
| 399 | points to an unused object on the stack, it must be initialized with | ||
| 400 | .Fn EVP_MD_CTX_init | ||
| 401 | before calling this function. | ||
| 402 | .Pp | ||
| 403 | .Fn EVP_DigestInit | ||
| 404 | is a deprecated function behaving like | ||
| 405 | .Fn EVP_DigestInit_ex | ||
| 406 | except that it always uses the default digest implementation | ||
| 407 | and that it requires | ||
| 408 | .Fn EVP_MD_CTX_reset | ||
| 409 | before it can be used on a context that was already used. | ||
| 410 | .Pp | ||
| 411 | .Fn EVP_DigestFinal | ||
| 412 | is a deprecated function behaving like | ||
| 413 | .Fn EVP_DigestFinal_ex | ||
| 414 | except that the digest context | ||
| 415 | .Fa ctx | ||
| 416 | is automatically cleaned up after use by calling | ||
| 417 | .Fn EVP_MD_CTX_reset | ||
| 418 | internally. | ||
| 419 | .Pp | ||
| 420 | .Fn EVP_MD_CTX_copy | ||
| 421 | is a deprecated function behaving like | ||
| 422 | .Fn EVP_MD_CTX_copy_ex | ||
| 423 | except that it requires | ||
| 424 | .Fn EVP_MD_CTX_reset | ||
| 425 | before a context that was already used can be passed as | ||
| 426 | .Fa out . | ||
| 427 | .Pp | ||
| 428 | .Fn EVP_MD_size | ||
| 429 | and | ||
| 430 | .Fn EVP_MD_CTX_size | ||
| 431 | return the size of the message digest when passed an | ||
| 432 | .Vt EVP_MD | ||
| 433 | or an | ||
| 434 | .Vt EVP_MD_CTX | ||
| 435 | structure, i.e. the size of the hash. | ||
| 436 | .Pp | ||
| 437 | .Fn EVP_MD_block_size | ||
| 438 | and | ||
| 439 | .Fn EVP_MD_CTX_block_size | ||
| 440 | return the block size of the message digest when passed an | ||
| 441 | .Vt EVP_MD | ||
| 442 | or an | ||
| 443 | .Vt EVP_MD_CTX | ||
| 444 | structure. | ||
| 445 | .Pp | ||
| 446 | .Fn EVP_MD_type | ||
| 447 | and | ||
| 448 | .Fn EVP_MD_CTX_type | ||
| 449 | return the NID of the OBJECT IDENTIFIER representing the given message | ||
| 450 | digest when passed an | ||
| 451 | .Vt EVP_MD | ||
| 452 | structure. | ||
| 453 | For example | ||
| 454 | .Fn EVP_MD_type EVP_sha1() | ||
| 455 | returns | ||
| 456 | .Dv NID_sha1 . | ||
| 457 | This function is normally used when setting ASN.1 OIDs. | ||
| 458 | .Pp | ||
| 459 | .Fn EVP_MD_pkey_type | ||
| 460 | returns the NID of the public key signing algorithm associated with this | ||
| 461 | digest. | ||
| 462 | For example | ||
| 463 | .Fn EVP_sha1 | ||
| 464 | is associated with RSA so this will return | ||
| 465 | .Dv NID_sha1WithRSAEncryption . | ||
| 466 | Since digests and signature algorithms are no longer linked this | ||
| 467 | function is only retained for compatibility reasons. | ||
| 468 | .Pp | ||
| 469 | .Fn EVP_md5 , | ||
| 470 | .Fn EVP_sha1 , | ||
| 471 | .Fn EVP_sha224 , | ||
| 472 | .Fn EVP_sha256 , | ||
| 473 | .Fn EVP_sha384 , | ||
| 474 | .Fn EVP_sha512 , | ||
| 475 | and | ||
| 476 | .Fn EVP_ripemd160 | ||
| 477 | return | ||
| 478 | .Vt EVP_MD | ||
| 479 | structures for the MD5, SHA1, SHA224, SHA256, SHA384, SHA512 and | ||
| 480 | RIPEMD160 digest algorithms respectively. | ||
| 481 | .Pp | ||
| 482 | .Fn EVP_md5_sha1 | ||
| 483 | returns an | ||
| 484 | .Vt EVP_MD | ||
| 485 | structure that provides concatenated MD5 and SHA1 message digests. | ||
| 486 | .Pp | ||
| 487 | .Fn EVP_dss | ||
| 488 | and | ||
| 489 | .Fn EVP_dss1 | ||
| 490 | return | ||
| 491 | .Vt EVP_MD | ||
| 492 | structures for SHA1 digest algorithms but using DSS (DSA) for the | ||
| 493 | signature algorithm. | ||
| 494 | Note: there is no need to use these pseudo-digests in OpenSSL 1.0.0 and | ||
| 495 | later; they are however retained for compatibility. | ||
| 496 | .Pp | ||
| 497 | .Fn EVP_md_null | ||
| 498 | is a "null" message digest that does nothing: | ||
| 499 | i.e. the hash it returns is of zero length. | ||
| 500 | .Pp | ||
| 501 | .Fn EVP_get_digestbyname , | ||
| 502 | .Fn EVP_get_digestbynid , | ||
| 503 | and | ||
| 504 | .Fn EVP_get_digestbyobj | ||
| 505 | return an | ||
| 506 | .Vt EVP_MD | ||
| 507 | structure when passed a digest name, a digest NID, or an ASN1_OBJECT | ||
| 508 | structure respectively. | ||
| 509 | The digest table must be initialized using, for example, | ||
| 510 | .Xr OpenSSL_add_all_digests 3 | ||
| 511 | for these functions to work. | ||
| 512 | .Pp | ||
| 513 | .Fn EVP_MD_CTX_size , | ||
| 514 | .Fn EVP_MD_CTX_block_size , | ||
| 515 | .Fn EVP_MD_CTX_type , | ||
| 516 | .Fn EVP_get_digestbynid , | ||
| 517 | and | ||
| 518 | .Fn EVP_get_digestbyobj | ||
| 519 | are implemented as macros. | ||
| 520 | .Pp | ||
| 521 | The EVP interface to message digests should almost always be used | ||
| 522 | in preference to the low level interfaces. | ||
| 523 | This is because the code then becomes transparent to the digest used and | ||
| 524 | much more flexible. | ||
| 525 | .Pp | ||
| 526 | New applications should use the SHA2 digest algorithms such as SHA256. | ||
| 527 | The other digest algorithms are still in common use. | ||
| 528 | .Pp | ||
| 529 | For most applications the | ||
| 530 | .Fa impl | ||
| 531 | parameter to | ||
| 532 | .Fn EVP_DigestInit_ex | ||
| 533 | will be set to NULL to use the default digest implementation. | ||
| 534 | .Pp | ||
| 535 | The functions | ||
| 536 | .Fn EVP_DigestInit , | ||
| 537 | .Fn EVP_DigestFinal , | ||
| 538 | and | ||
| 539 | .Fn EVP_MD_CTX_copy | ||
| 540 | are obsolete but are retained to maintain compatibility with existing | ||
| 541 | code. | ||
| 542 | New applications should use | ||
| 543 | .Fn EVP_DigestInit_ex , | ||
| 544 | .Fn EVP_DigestFinal_ex , | ||
| 545 | and | ||
| 546 | .Fn EVP_MD_CTX_copy_ex | ||
| 547 | because they can efficiently reuse a digest context instead of | ||
| 548 | initializing and cleaning it up on each call and allow non-default | ||
| 549 | implementations of digests to be specified. | ||
| 550 | .Pp | ||
| 551 | If digest contexts are not cleaned up after use, memory leaks will occur. | ||
| 552 | .Sh RETURN VALUES | ||
| 553 | .Fn EVP_MD_CTX_new | ||
| 554 | and | ||
| 555 | .Fn EVP_MD_CTX_create | ||
| 556 | return the new | ||
| 557 | .Vt EVP_MD_CTX | ||
| 558 | object or | ||
| 559 | .Dv NULL | ||
| 560 | for failure. | ||
| 561 | .Pp | ||
| 562 | .Fn EVP_MD_CTX_reset | ||
| 563 | and | ||
| 564 | .Fn EVP_MD_CTX_cleanup | ||
| 565 | always return 1. | ||
| 566 | .Pp | ||
| 567 | .Fn EVP_MD_CTX_ctrl , | ||
| 568 | .Fn EVP_DigestInit_ex , | ||
| 569 | .Fn EVP_DigestUpdate , | ||
| 570 | .Fn EVP_DigestFinal_ex , | ||
| 571 | .Fn EVP_Digest , | ||
| 572 | .Fn EVP_MD_CTX_copy_ex , | ||
| 573 | .Fn EVP_DigestInit , | ||
| 574 | .Fn EVP_DigestFinal , | ||
| 575 | and | ||
| 576 | .Fn EVP_MD_CTX_copy | ||
| 577 | return 1 for success or 0 for failure. | ||
| 578 | .Pp | ||
| 579 | .Fn EVP_MD_type , | ||
| 580 | .Fn EVP_MD_pkey_type , | ||
| 581 | and | ||
| 582 | .Fn EVP_MD_CTX_type | ||
| 583 | return the NID of the corresponding OBJECT IDENTIFIER or | ||
| 584 | .Dv NID_undef | ||
| 585 | if none exists. | ||
| 586 | .Pp | ||
| 587 | .Fn EVP_MD_size , | ||
| 588 | .Fn EVP_MD_block_size , | ||
| 589 | .Fn EVP_MD_CTX_size , | ||
| 590 | and | ||
| 591 | .Fn EVP_MD_CTX_block_size | ||
| 592 | return the digest or block size in bytes. | ||
| 593 | .Pp | ||
| 594 | .Fn EVP_MD_CTX_md | ||
| 595 | returns the | ||
| 596 | .Vt EVP_MD | ||
| 597 | object used by | ||
| 598 | .Fa ctx , | ||
| 599 | or | ||
| 600 | .Dv NULL | ||
| 601 | if | ||
| 602 | .Fa ctx | ||
| 603 | is | ||
| 604 | .Dv NULL . | ||
| 605 | .Pp | ||
| 606 | .Fn EVP_md_null , | ||
| 607 | .Fn EVP_md5 , | ||
| 608 | .Fn EVP_md5_sha1 , | ||
| 609 | .Fn EVP_sha1 , | ||
| 610 | .Fn EVP_dss , | ||
| 611 | .Fn EVP_dss1 , | ||
| 612 | and | ||
| 613 | .Fn EVP_ripemd160 | ||
| 614 | return pointers to the corresponding | ||
| 615 | .Vt EVP_MD | ||
| 616 | structures. | ||
| 617 | .Pp | ||
| 618 | .Fn EVP_get_digestbyname , | ||
| 619 | .Fn EVP_get_digestbynid , | ||
| 620 | and | ||
| 621 | .Fn EVP_get_digestbyobj | ||
| 622 | return either an | ||
| 623 | .Vt EVP_MD | ||
| 624 | structure or | ||
| 625 | .Dv NULL | ||
| 626 | if an error occurs. | ||
| 627 | .Sh EXAMPLES | ||
| 628 | This example digests the data "Test Message\en" and "Hello World\en", | ||
| 629 | using the digest name passed on the command line. | ||
| 630 | .Bd -literal -offset indent | ||
| 631 | #include <stdio.h> | ||
| 632 | #include <openssl/evp.h> | ||
| 633 | |||
| 634 | int | ||
| 635 | main(int argc, char *argv[]) | ||
| 636 | { | ||
| 637 | EVP_MD_CTX *mdctx; | ||
| 638 | const EVP_MD *md; | ||
| 639 | const char mess1[] = "Test Message\en"; | ||
| 640 | const char mess2[] = "Hello World\en"; | ||
| 641 | unsigned char md_value[EVP_MAX_MD_SIZE]; | ||
| 642 | int md_len, i; | ||
| 643 | |||
| 644 | OpenSSL_add_all_digests(); | ||
| 645 | |||
| 646 | if (argc <= 1) { | ||
| 647 | printf("Usage: mdtest digestname\en"); | ||
| 648 | exit(1); | ||
| 649 | } | ||
| 650 | |||
| 651 | md = EVP_get_digestbyname(argv[1]); | ||
| 652 | if (md == NULL) { | ||
| 653 | printf("Unknown message digest %s\en", argv[1]); | ||
| 654 | exit(1); | ||
| 655 | } | ||
| 656 | |||
| 657 | mdctx = EVP_MD_CTX_new(); | ||
| 658 | EVP_DigestInit_ex(mdctx, md, NULL); | ||
| 659 | EVP_DigestUpdate(mdctx, mess1, strlen(mess1)); | ||
| 660 | EVP_DigestUpdate(mdctx, mess2, strlen(mess2)); | ||
| 661 | EVP_DigestFinal_ex(mdctx, md_value, &md_len); | ||
| 662 | EVP_MD_CTX_free(mdctx); | ||
| 663 | |||
| 664 | printf("Digest is: "); | ||
| 665 | for(i = 0; i < md_len; i++) | ||
| 666 | printf("%02x", md_value[i]); | ||
| 667 | printf("\en"); | ||
| 668 | |||
| 669 | return 0; | ||
| 670 | } | ||
| 671 | .Ed | ||
| 672 | .Sh SEE ALSO | ||
| 673 | .Xr BIO_f_md 3 , | ||
| 674 | .Xr CMAC_Init 3 , | ||
| 675 | .Xr evp 3 , | ||
| 676 | .Xr EVP_BytesToKey 3 , | ||
| 677 | .Xr EVP_DigestSignInit 3 , | ||
| 678 | .Xr EVP_DigestVerifyInit 3 , | ||
| 679 | .Xr EVP_PKEY_CTX_set_signature_md 3 , | ||
| 680 | .Xr EVP_PKEY_meth_set_signctx 3 , | ||
| 681 | .Xr EVP_SignInit 3 , | ||
| 682 | .Xr EVP_sm3 3 , | ||
| 683 | .Xr EVP_VerifyInit 3 , | ||
| 684 | .Xr EVP_whirlpool 3 , | ||
| 685 | .Xr HMAC 3 , | ||
| 686 | .Xr OCSP_basic_sign 3 , | ||
| 687 | .Xr OCSP_request_sign 3 , | ||
| 688 | .Xr PKCS5_PBKDF2_HMAC 3 , | ||
| 689 | .Xr PKCS7_sign_add_signer 3 , | ||
| 690 | .Xr X509_ALGOR_set_md 3 , | ||
| 691 | .Xr X509_digest 3 , | ||
| 692 | .Xr X509_sign 3 | ||
| 693 | .Sh HISTORY | ||
| 694 | .Fn EVP_DigestInit , | ||
| 695 | .Fn EVP_DigestUpdate , | ||
| 696 | .Fn EVP_DigestFinal , | ||
| 697 | .Dv EVP_MAX_MD_SIZE , | ||
| 698 | .Fn EVP_md5 , | ||
| 699 | and | ||
| 700 | .Fn EVP_sha1 | ||
| 701 | first appeared in SSLeay 0.5.1. | ||
| 702 | .Fn EVP_dss | ||
| 703 | and | ||
| 704 | .Fn EVP_dss1 | ||
| 705 | first appeared in SSLeay 0.6.0. | ||
| 706 | .Fn EVP_MD_size | ||
| 707 | first appeared in SSLeay 0.6.6. | ||
| 708 | .Fn EVP_MD_CTX_size , | ||
| 709 | .Fn EVP_MD_CTX_type , | ||
| 710 | .Fn EVP_md_null , | ||
| 711 | and | ||
| 712 | .Fn EVP_get_digestbyname | ||
| 713 | first appeared in SSLeay 0.8.0. | ||
| 714 | .Fn EVP_MD_type , | ||
| 715 | .Fn EVP_MD_pkey_type , | ||
| 716 | .Fn EVP_get_digestbynid , | ||
| 717 | and | ||
| 718 | .Fn EVP_get_digestbyobj | ||
| 719 | first appeared in SSLeay 0.8.1. | ||
| 720 | .Fn EVP_MD_block_size , | ||
| 721 | .Fn EVP_MD_CTX_size , | ||
| 722 | .Fn EVP_MD_CTX_block_size , | ||
| 723 | .Fn EVP_rc4_40 , | ||
| 724 | .Fn EVP_rc2_40_cbc , | ||
| 725 | and | ||
| 726 | .Fn EVP_ripemd160 | ||
| 727 | first appeared in SSLeay 0.9.0. | ||
| 728 | All these functions have been available since | ||
| 729 | .Ox 2.4 . | ||
| 730 | .Pp | ||
| 731 | .Fn EVP_MD_CTX_copy | ||
| 732 | first appeared in OpenSSL 0.9.2b and has been available since | ||
| 733 | .Ox 2.6 . | ||
| 734 | .Pp | ||
| 735 | .Fn EVP_MD_CTX_md | ||
| 736 | first appeared in OpenSSL 0.9.5 and has been available since | ||
| 737 | .Ox 2.7 . | ||
| 738 | .Pp | ||
| 739 | .Fn EVP_MD_CTX_init , | ||
| 740 | .Fn EVP_MD_CTX_create , | ||
| 741 | .Fn EVP_MD_CTX_cleanup , | ||
| 742 | .Fn EVP_MD_CTX_destroy , | ||
| 743 | .Fn EVP_DigestInit_ex , | ||
| 744 | .Fn EVP_DigestFinal_ex , | ||
| 745 | .Fn EVP_Digest , | ||
| 746 | and | ||
| 747 | .Fn EVP_MD_CTX_copy_ex | ||
| 748 | first appeared in OpenSSL 0.9.7 and have been available since | ||
| 749 | .Ox 3.2 . | ||
| 750 | .Pp | ||
| 751 | .Fn EVP_sha224 , | ||
| 752 | .Fn EVP_sha256 , | ||
| 753 | .Fn EVP_sha384 , | ||
| 754 | and | ||
| 755 | .Fn EVP_sha512 | ||
| 756 | first appeared in OpenSSL 0.9.7h and 0.9.8a | ||
| 757 | and have been available since | ||
| 758 | .Ox 4.0 . | ||
| 759 | .Pp | ||
| 760 | .Fn EVP_MD_CTX_ctrl | ||
| 761 | first appeared in OpenSSL 1.1.0 and has been available since | ||
| 762 | .Ox 5.7 . | ||
| 763 | .Pp | ||
| 764 | .Fn EVP_MD_CTX_new , | ||
| 765 | .Fn EVP_MD_CTX_reset , | ||
| 766 | .Fn EVP_MD_CTX_free , | ||
| 767 | and | ||
| 768 | .Fn EVP_md5_sha1 | ||
| 769 | first appeared in OpenSSL 1.1.0 and have been available since | ||
| 770 | .Ox 6.3 . | ||
| 771 | .Pp | ||
| 772 | The link between digests and signing algorithms was fixed in OpenSSL 1.0 | ||
| 773 | and later, so now | ||
| 774 | .Fn EVP_sha1 | ||
| 775 | can be used with RSA and DSA; there is no need to use | ||
| 776 | .Fn EVP_dss1 | ||
| 777 | any more. | ||
