1.\" $OpenBSD: EVP_DigestInit.3,v 1.24 2022/08/31 14:27:34 tb 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: August 31 2022 $ 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_ripemd160 , 109.Nm EVP_get_digestbyname , 110.Nm EVP_get_digestbynid , 111.Nm EVP_get_digestbyobj 112.Nd EVP digest routines 113.Sh SYNOPSIS 114.In openssl/evp.h 115.Ft EVP_MD_CTX * 116.Fn EVP_MD_CTX_new void 117.Ft int 118.Fo EVP_MD_CTX_reset 119.Fa "EVP_MD_CTX *ctx" 120.Fc 121.Ft void 122.Fo EVP_MD_CTX_free 123.Fa "EVP_MD_CTX *ctx" 124.Fc 125.Ft void 126.Fo EVP_MD_CTX_init 127.Fa "EVP_MD_CTX *ctx" 128.Fc 129.Ft EVP_MD_CTX * 130.Fn EVP_MD_CTX_create void 131.Ft int 132.Fo EVP_MD_CTX_cleanup 133.Fa "EVP_MD_CTX *ctx" 134.Fc 135.Ft void 136.Fo EVP_MD_CTX_destroy 137.Fa "EVP_MD_CTX *ctx" 138.Fc 139.Ft int 140.Fo EVP_MD_CTX_ctrl 141.Fa "EVP_MD_CTX *ctx" 142.Fa "int cmd" 143.Fa "int p1" 144.Fa "void* p2" 145.Fc 146.Ft int 147.Fo EVP_DigestInit_ex 148.Fa "EVP_MD_CTX *ctx" 149.Fa "const EVP_MD *type" 150.Fa "ENGINE *impl" 151.Fc 152.Ft int 153.Fo EVP_DigestUpdate 154.Fa "EVP_MD_CTX *ctx" 155.Fa "const void *d" 156.Fa "size_t cnt" 157.Fc 158.Ft int 159.Fo EVP_DigestFinal_ex 160.Fa "EVP_MD_CTX *ctx" 161.Fa "unsigned char *md" 162.Fa "unsigned int *s" 163.Fc 164.Ft int 165.Fo EVP_Digest 166.Fa "const void *d" 167.Fa "size_t cnt" 168.Fa "unsigned char *md" 169.Fa "unsigned int *s" 170.Fa "const EVP_MD *type" 171.Fa "ENGINE *impl" 172.Fc 173.Ft int 174.Fo EVP_MD_CTX_copy_ex 175.Fa "EVP_MD_CTX *out" 176.Fa "const EVP_MD_CTX *in" 177.Fc 178.Ft int 179.Fo EVP_DigestInit 180.Fa "EVP_MD_CTX *ctx" 181.Fa "const EVP_MD *type" 182.Fc 183.Ft int 184.Fo EVP_DigestFinal 185.Fa "EVP_MD_CTX *ctx" 186.Fa "unsigned char *md" 187.Fa "unsigned int *s" 188.Fc 189.Ft int 190.Fo EVP_MD_CTX_copy 191.Fa "EVP_MD_CTX *out" 192.Fa "EVP_MD_CTX *in" 193.Fc 194.Fd #define EVP_MAX_MD_SIZE 64 /* SHA512 */ 195.Ft int 196.Fo EVP_MD_type 197.Fa "const EVP_MD *md" 198.Fc 199.Ft int 200.Fo EVP_MD_pkey_type 201.Fa "const EVP_MD *md" 202.Fc 203.Ft int 204.Fo EVP_MD_size 205.Fa "const EVP_MD *md" 206.Fc 207.Ft int 208.Fo EVP_MD_block_size 209.Fa "const EVP_MD *md" 210.Fc 211.Ft const EVP_MD * 212.Fo EVP_MD_CTX_md 213.Fa "const EVP_MD_CTX *ctx" 214.Fc 215.Ft int 216.Fo EVP_MD_CTX_size 217.Fa "const EVP_MD *ctx" 218.Fc 219.Ft int 220.Fo EVP_MD_CTX_block_size 221.Fa "const EVP_MD *ctx" 222.Fc 223.Ft int 224.Fo EVP_MD_CTX_type 225.Fa "const EVP_MD *ctx" 226.Fc 227.Ft const EVP_MD * 228.Fn EVP_md_null void 229.Ft const EVP_MD * 230.Fn EVP_md5 void 231.Ft const EVP_MD * 232.Fn EVP_md5_sha1 void 233.Ft const EVP_MD * 234.Fn EVP_sha1 void 235.Ft const EVP_MD * 236.Fn EVP_sha224 void 237.Ft const EVP_MD * 238.Fn EVP_sha256 void 239.Ft const EVP_MD * 240.Fn EVP_sha384 void 241.Ft const EVP_MD * 242.Fn EVP_sha512 void 243.Ft const EVP_MD * 244.Fn EVP_ripemd160 void 245.Ft const EVP_MD * 246.Fo EVP_get_digestbyname 247.Fa "const char *name" 248.Fc 249.Ft const EVP_MD * 250.Fo EVP_get_digestbynid 251.Fa "int type" 252.Fc 253.Ft const EVP_MD * 254.Fo EVP_get_digestbyobj 255.Fa "const ASN1_OBJECT *o" 256.Fc 257.Sh DESCRIPTION 258The EVP digest routines are a high level interface to message digests 259and should be used instead of the cipher-specific functions. 260.Pp 261.Fn EVP_MD_CTX_new 262allocates a new, empty digest context. 263.Pp 264.Fn EVP_MD_CTX_reset 265cleans up 266.Fa ctx 267and resets it to the state it had after 268.Fn EVP_MD_CTX_new , 269such that it can be reused. 270.Pp 271.Fn EVP_MD_CTX_free 272cleans up 273.Fa ctx 274and frees the space allocated to it. 275.Pp 276.Fn EVP_MD_CTX_init 277is a deprecated function to clear a digest context on the stack 278before use. 279Do not use it on a digest context returned from 280.Fn EVP_MD_CTX_new 281or one that was already used. 282.Pp 283.Fn EVP_MD_CTX_create , 284.Fn EVP_MD_CTX_cleanup , 285and 286.Fn EVP_MD_CTX_destroy 287are deprecated aliases for 288.Fn EVP_MD_CTX_new , 289.Fn EVP_MD_CTX_reset , 290and 291.Fn EVP_MD_CTX_free , 292respectively. 293.Pp 294.Fn EVP_MD_CTX_ctrl 295performs digest-specific control actions on the context 296.Fa ctx . 297.Pp 298.Fn EVP_DigestInit_ex 299sets up the digest context 300.Fa ctx 301to use a digest 302.Fa type 303from 304.Vt ENGINE 305.Fa impl . 306The 307.Fa type 308will typically be supplied by a function such as 309.Fn EVP_sha1 . 310If 311.Fa impl 312is 313.Dv NULL , 314then the default implementation of digest 315.Fa type 316is used. 317.Pp 318.Fn EVP_DigestUpdate 319hashes 320.Fa cnt 321bytes of data at 322.Fa d 323into the digest context 324.Fa ctx . 325This function can be called several times on the same 326.Fa ctx 327to hash additional data. 328.Pp 329.Fn EVP_DigestFinal_ex 330retrieves the digest value from 331.Fa ctx 332and places it in 333.Fa md . 334If the 335.Fa s 336parameter is not 337.Dv NULL , 338then the number of bytes of data written (i.e. the length of the 339digest) will be written to the integer at 340.Fa s ; 341at most 342.Dv EVP_MAX_MD_SIZE 343bytes will be written. 344After calling 345.Fn EVP_DigestFinal_ex , 346no additional calls to 347.Fn EVP_DigestUpdate 348can be made, but 349.Fn EVP_DigestInit_ex 350can be called to initialize a new digest operation. 351.Pp 352.Fn EVP_Digest 353is a simple wrapper function to hash 354.Fa cnt 355bytes of data at 356.Fa d 357using the digest 358.Fa type 359from 360.Vt ENGINE 361.Fa impl 362in a one-shot operation and place the digest value into 363.Fa md , 364and, unless 365.Fa s 366is 367.Dv NULL , 368the length of the digest in bytes into 369.Pf * Fa s . 370This wrapper uses a temporary digest context and passes its arguments to 371.Fn EVP_DigestInit_ex , 372.Fn EVP_DigestUpdate , 373and 374.Fn EVP_DigestFinal_ex 375internally. 376.Pp 377.Fn EVP_MD_CTX_copy_ex 378can be used to copy the message digest state from 379.Fa in 380to 381.Fa out . 382This is useful if large amounts of data are to be hashed which only 383differ in the last few bytes. 384.Pp 385.Fn EVP_DigestInit 386is a deprecated function behaving like 387.Fn EVP_DigestInit_ex 388except that it always uses the default digest implementation 389and that it requires 390.Fn EVP_MD_CTX_reset 391before it can be used on a context that was already used. 392.Pp 393.Fn EVP_DigestFinal 394is a deprecated function behaving like 395.Fn EVP_DigestFinal_ex 396except that the digest context 397.Fa ctx 398is automatically cleaned up after use by calling 399.Fn EVP_MD_CTX_reset 400internally. 401.Pp 402.Fn EVP_MD_CTX_copy 403is a deprecated function behaving like 404.Fn EVP_MD_CTX_copy_ex 405except that it requires 406.Fn EVP_MD_CTX_reset 407before a context that was already used can be passed as 408.Fa out . 409.Pp 410.Fn EVP_MD_size 411and 412.Fn EVP_MD_CTX_size 413return the size of the message digest when passed an 414.Vt EVP_MD 415or an 416.Vt EVP_MD_CTX 417structure, i.e. the size of the hash. 418.Pp 419.Fn EVP_MD_block_size 420and 421.Fn EVP_MD_CTX_block_size 422return the block size of the message digest when passed an 423.Vt EVP_MD 424or an 425.Vt EVP_MD_CTX 426structure. 427.Pp 428.Fn EVP_MD_type 429and 430.Fn EVP_MD_CTX_type 431return the NID of the OBJECT IDENTIFIER representing the given message 432digest when passed an 433.Vt EVP_MD 434structure. 435For example 436.Fn EVP_MD_type EVP_sha1() 437returns 438.Dv NID_sha1 . 439This function is normally used when setting ASN.1 OIDs. 440.Pp 441.Fn EVP_MD_pkey_type 442returns the NID of the public key signing algorithm associated with this 443digest. 444For example 445.Fn EVP_sha1 446is associated with RSA so this will return 447.Dv NID_sha1WithRSAEncryption . 448Since digests and signature algorithms are no longer linked, this 449function is only retained for compatibility reasons. 450.Pp 451.Fn EVP_md5 , 452.Fn EVP_sha1 , 453.Fn EVP_sha224 , 454.Fn EVP_sha256 , 455.Fn EVP_sha384 , 456.Fn EVP_sha512 , 457and 458.Fn EVP_ripemd160 459return 460.Vt EVP_MD 461structures for the MD5, SHA1, SHA224, SHA256, SHA384, SHA512 and 462RIPEMD160 digest algorithms respectively. 463.Pp 464.Fn EVP_md5_sha1 465returns an 466.Vt EVP_MD 467structure that provides concatenated MD5 and SHA1 message digests. 468.Pp 469.Fn EVP_md_null 470is a "null" message digest that does nothing: 471i.e. the hash it returns is of zero length. 472.Pp 473.Fn EVP_get_digestbyname , 474.Fn EVP_get_digestbynid , 475and 476.Fn EVP_get_digestbyobj 477return an 478.Vt EVP_MD 479structure when passed a digest name, a digest NID, or an ASN1_OBJECT 480structure respectively. 481.Pp 482.Fn EVP_MD_CTX_size , 483.Fn EVP_MD_CTX_block_size , 484.Fn EVP_MD_CTX_type , 485.Fn EVP_get_digestbynid , 486and 487.Fn EVP_get_digestbyobj 488are implemented as macros. 489.Pp 490The EVP interface to message digests should almost always be used 491in preference to the low level interfaces. 492This is because the code then becomes transparent to the digest used and 493much more flexible. 494.Pp 495New applications should use the SHA2 digest algorithms such as SHA256. 496The other digest algorithms are still in common use. 497.Pp 498For most applications the 499.Fa impl 500parameter to 501.Fn EVP_DigestInit_ex 502will be set to NULL to use the default digest implementation. 503.Pp 504The functions 505.Fn EVP_DigestInit , 506.Fn EVP_DigestFinal , 507and 508.Fn EVP_MD_CTX_copy 509are obsolete but are retained to maintain compatibility with existing 510code. 511New applications should use 512.Fn EVP_DigestInit_ex , 513.Fn EVP_DigestFinal_ex , 514and 515.Fn EVP_MD_CTX_copy_ex 516because they can efficiently reuse a digest context instead of 517initializing and cleaning it up on each call and allow non-default 518implementations of digests to be specified. 519.Pp 520If digest contexts are not cleaned up after use, memory leaks will occur. 521.Sh RETURN VALUES 522.Fn EVP_MD_CTX_new 523and 524.Fn EVP_MD_CTX_create 525return the new 526.Vt EVP_MD_CTX 527object or 528.Dv NULL 529for failure. 530.Pp 531.Fn EVP_MD_CTX_reset 532and 533.Fn EVP_MD_CTX_cleanup 534always return 1. 535.Pp 536.Fn EVP_MD_CTX_ctrl , 537.Fn EVP_DigestInit_ex , 538.Fn EVP_DigestUpdate , 539.Fn EVP_DigestFinal_ex , 540.Fn EVP_Digest , 541.Fn EVP_MD_CTX_copy_ex , 542.Fn EVP_DigestInit , 543.Fn EVP_DigestFinal , 544and 545.Fn EVP_MD_CTX_copy 546return 1 for success or 0 for failure. 547.Pp 548.Fn EVP_MD_type , 549.Fn EVP_MD_pkey_type , 550and 551.Fn EVP_MD_CTX_type 552return the NID of the corresponding OBJECT IDENTIFIER or 553.Dv NID_undef 554if none exists. 555.Pp 556.Fn EVP_MD_size , 557.Fn EVP_MD_block_size , 558.Fn EVP_MD_CTX_size , 559and 560.Fn EVP_MD_CTX_block_size 561return the digest or block size in bytes. 562.Pp 563.Fn EVP_MD_CTX_md 564returns the 565.Vt EVP_MD 566object used by 567.Fa ctx , 568or 569.Dv NULL 570if 571.Fa ctx 572is 573.Dv NULL . 574.Pp 575.Fn EVP_md_null , 576.Fn EVP_md5 , 577.Fn EVP_md5_sha1 , 578.Fn EVP_sha1 , 579and 580.Fn EVP_ripemd160 581return pointers to the corresponding 582.Vt EVP_MD 583structures. 584.Pp 585.Fn EVP_get_digestbyname , 586.Fn EVP_get_digestbynid , 587and 588.Fn EVP_get_digestbyobj 589return either an 590.Vt EVP_MD 591structure or 592.Dv NULL 593if an error occurs. 594.Sh EXAMPLES 595This example digests the data "Test Message\en" and "Hello World\en", 596using the digest name passed on the command line. 597.Bd -literal -offset indent 598#include <stdio.h> 599#include <openssl/evp.h> 600 601int 602main(int argc, char *argv[]) 603{ 604 EVP_MD_CTX *mdctx; 605 const EVP_MD *md; 606 const char mess1[] = "Test Message\en"; 607 const char mess2[] = "Hello World\en"; 608 unsigned char md_value[EVP_MAX_MD_SIZE]; 609 int md_len, i; 610 611 if (argc <= 1) { 612 printf("Usage: mdtest digestname\en"); 613 exit(1); 614 } 615 616 md = EVP_get_digestbyname(argv[1]); 617 if (md == NULL) { 618 printf("Unknown message digest %s\en", argv[1]); 619 exit(1); 620 } 621 622 mdctx = EVP_MD_CTX_new(); 623 EVP_DigestInit_ex(mdctx, md, NULL); 624 EVP_DigestUpdate(mdctx, mess1, strlen(mess1)); 625 EVP_DigestUpdate(mdctx, mess2, strlen(mess2)); 626 EVP_DigestFinal_ex(mdctx, md_value, &md_len); 627 EVP_MD_CTX_free(mdctx); 628 629 printf("Digest is: "); 630 for(i = 0; i < md_len; i++) 631 printf("%02x", md_value[i]); 632 printf("\en"); 633 634 return 0; 635} 636.Ed 637.Sh SEE ALSO 638.Xr BIO_f_md 3 , 639.Xr CMAC_Init 3 , 640.Xr evp 3 , 641.Xr EVP_BytesToKey 3 , 642.Xr EVP_DigestSignInit 3 , 643.Xr EVP_DigestVerifyInit 3 , 644.Xr EVP_PKEY_CTX_set_signature_md 3 , 645.Xr EVP_PKEY_meth_set_signctx 3 , 646.Xr EVP_SignInit 3 , 647.Xr EVP_sm3 3 , 648.Xr EVP_VerifyInit 3 , 649.Xr EVP_whirlpool 3 , 650.Xr HMAC 3 , 651.Xr OCSP_basic_sign 3 , 652.Xr OCSP_request_sign 3 , 653.Xr PKCS5_PBKDF2_HMAC 3 , 654.Xr PKCS7_sign_add_signer 3 , 655.Xr X509_ALGOR_set_md 3 , 656.Xr X509_digest 3 , 657.Xr X509_sign 3 658.Sh HISTORY 659.Fn EVP_DigestInit , 660.Fn EVP_DigestUpdate , 661.Fn EVP_DigestFinal , 662.Dv EVP_MAX_MD_SIZE , 663.Fn EVP_md5 , 664and 665.Fn EVP_sha1 666first appeared in SSLeay 0.5.1. 667.Fn EVP_MD_size 668first appeared in SSLeay 0.6.6. 669.Fn EVP_MD_CTX_size , 670.Fn EVP_MD_CTX_type , 671.Fn EVP_md_null , 672and 673.Fn EVP_get_digestbyname 674first appeared in SSLeay 0.8.0. 675.Fn EVP_MD_type , 676.Fn EVP_MD_pkey_type , 677.Fn EVP_get_digestbynid , 678and 679.Fn EVP_get_digestbyobj 680first appeared in SSLeay 0.8.1. 681.Fn EVP_MD_block_size , 682.Fn EVP_MD_CTX_size , 683.Fn EVP_MD_CTX_block_size , 684.Fn EVP_rc4_40 , 685.Fn EVP_rc2_40_cbc , 686and 687.Fn EVP_ripemd160 688first appeared in SSLeay 0.9.0. 689All these functions have been available since 690.Ox 2.4 . 691.Pp 692.Fn EVP_MD_CTX_copy 693first appeared in OpenSSL 0.9.2b and has been available since 694.Ox 2.6 . 695.Pp 696.Fn EVP_MD_CTX_md 697first appeared in OpenSSL 0.9.5 and has been available since 698.Ox 2.7 . 699.Pp 700.Fn EVP_MD_CTX_init , 701.Fn EVP_MD_CTX_create , 702.Fn EVP_MD_CTX_cleanup , 703.Fn EVP_MD_CTX_destroy , 704.Fn EVP_DigestInit_ex , 705.Fn EVP_DigestFinal_ex , 706.Fn EVP_Digest , 707and 708.Fn EVP_MD_CTX_copy_ex 709first appeared in OpenSSL 0.9.7 and have been available since 710.Ox 3.2 . 711.Pp 712.Fn EVP_sha224 , 713.Fn EVP_sha256 , 714.Fn EVP_sha384 , 715and 716.Fn EVP_sha512 717first appeared in OpenSSL 0.9.7h and 0.9.8a 718and have been available since 719.Ox 4.0 . 720.Pp 721.Fn EVP_MD_CTX_ctrl 722first appeared in OpenSSL 1.1.0 and has been available since 723.Ox 5.7 . 724.Pp 725.Fn EVP_MD_CTX_new , 726.Fn EVP_MD_CTX_reset , 727.Fn EVP_MD_CTX_free , 728and 729.Fn EVP_md5_sha1 730first appeared in OpenSSL 1.1.0 and have been available since 731.Ox 6.3 . 732.Pp 733The link between digests and signing algorithms was fixed in OpenSSL 1.0 734and later, so now 735.Fn EVP_sha1 736can be used with RSA and DSA. 737