<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jflopezfernandez</id>
	<title>OpenSSLWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openssl.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jflopezfernandez"/>
	<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php/Special:Contributions/Jflopezfernandez"/>
	<updated>2026-05-12T17:08:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.13</generator>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=3121</id>
		<title>Talk:Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=3121"/>
		<updated>2020-09-15T16:16:29Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* Pretty significant rewrite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pretty significant rewrite ==&lt;br /&gt;
&lt;br /&gt;
I noticed a lot of the information on the page was essentially a print out of the program help menu, so I thought it would be more beneficial to provide a basic introduction to the command-line utilities in tutorial form, with links to the official documentation. It isn't finished, as there are a lot of topics I didn't cover (certificates being a significant topic I did not cover), but because of the magnitude of the changes, I thought it best to stop here and get feedback on the changes. I'm brand-new to the project and I'm excited contribute in a meaningful way, so please if there is any wrong information, the style is off, etc., please do pass that along.&lt;br /&gt;
&lt;br /&gt;
This rewrite is essentially a reformatting of the previous version, with a lot of additional explanations from the perldocs. The bulk of the changes come from the removing of the old code samples, which were essentially just the helps menus, and the addition of code examples which again come primarily from the perldocs. There's also a table with all of the standard commands which link to their respective manpage on the main openssl site. I thought this was better because now we only have to update one set of documentation, which itself is automatically generated from the pod files.&lt;br /&gt;
&lt;br /&gt;
--[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 03:35, 30 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: This new style page looks great!! Please continue with it.&lt;br /&gt;
: A point to note about the ec key generation stuff. It is not necessary to first create an ec params file. It is simpler just to generate the key directly using genpkey and passing the pkeyopt &amp;quot;ec_paramgen_curve&amp;quot;. See the man page for further details.&lt;br /&gt;
: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 08:27, 30 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: Awesome, I'll go ahead and add that in, thanks for the heads up. I'm glad you like the change; I was pretty nervous about it since it was a pretty big change and I'm still brand-new.&lt;br /&gt;
:: --[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:27, 30 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
::: During this rewrite a comment about base64 usage 64 characters per line limit and -A usage was lost&lt;br /&gt;
::: i found it while rereading one old answer i did on stack overflow see https://askubuntu.com/questions/178521/how-can-i-decode-a-base64-string-from-the-command-line reference )&lt;br /&gt;
::: --[[User:Philippe lhardy|Philippe lhardy]] ([[User talk:Philippe lhardy|talk]]) 15:43, 14 June 2020 (UTC)&lt;br /&gt;
&lt;br /&gt;
:::: Hi, Philippe, sorry about that; I've gone ahead and re-added the information. Can't believe I missed that, but thanks for letting me know.&lt;br /&gt;
:::: --[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 16:16, 15 September 2020 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=3120</id>
		<title>Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=3120"/>
		<updated>2020-09-15T16:14:58Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Re-added information about the limitations of base64 encoding, as discussed in the talk page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''openssl''' program provides a rich variety of commands, each of which often has a wealth of options and arguments. Many commands use an external configuration file for some or all of their arguments and have a &amp;lt;code&amp;gt;-config&amp;lt;/code&amp;gt; option to specify that file. The environment variable [[OPENSSL_CONF]] can be used to specify the location of the configuration file. If the environment variable is not specified, a default file is created in the default certificate storage area called '''openssl.cnf'''. The settings in this default configuration file depend on the flags set when the version of OpenSSL being used was built.&lt;br /&gt;
&lt;br /&gt;
This article is an overview of the available tools provided by openssl. For all of the details on usage and implementation, you can find the [https://www.openssl.org/docs/manmaster/ manpages] which are automatically generated from the source code at the [https://www.openssl.org/ official OpenSSL project home]. Likewise, the source code itself may be found on the [https://www.openssl.org/source/ OpenSSL project home page], as well as on the [https://github.com/openssl/openssl OpenSSL Github]. The main OpenSSL site also includes an [https://www.openssl.org/docs/manmaster/man1/openssl.html overview of the command-line utilities], as well as links to all of their respective documentation.&lt;br /&gt;
&lt;br /&gt;
=Getting Started=&lt;br /&gt;
&lt;br /&gt;
The entry point for the OpenSSL library is the '''openssl''' binary, usually &amp;lt;tt&amp;gt;/usr/bin/openssl&amp;lt;/tt&amp;gt; on Linux. The general syntax for calling openssl is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl command [ command_options ] [ command_arguments ]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can call openssl without arguments to enter the interactive mode prompt. You may then enter commands directly, exiting with either a &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt; command or by issuing a termination signal with either &amp;lt;tt&amp;gt;Ctrl+C&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Ctrl+D&amp;lt;/tt&amp;gt;. The following is a sample interactive session in which the user invokes the [[prime]] command twice before using the &amp;lt;tt&amp;gt;quit&amp;lt;/tt&amp;gt; command to terminate the session.&lt;br /&gt;
&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 13467269&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 16651079&lt;br /&gt;
 OpenSSL&amp;gt; quit&lt;br /&gt;
&lt;br /&gt;
=Basic Tasks=&lt;br /&gt;
&lt;br /&gt;
This section is a brief tutorial on performing the most basic tasks using OpenSSL. For a detailed explanation of the rationale behind the syntax and semantics of the commands shown here, see the section on [[#Commands|Commands]].&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, the general syntax of a command is &amp;lt;code&amp;gt;openssl command [ command_options ] [ command_arguments ]&amp;lt;/code&amp;gt;. The help command is no different, but it does have its idiosyncrasies. To view the top-level help menu, you can call openssl as follows.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help&lt;br /&gt;
&lt;br /&gt;
This query will print all of the available commands, like so:&lt;br /&gt;
&lt;br /&gt;
 Standard commands&lt;br /&gt;
 asn1parse         ca                ciphers           cms               &lt;br /&gt;
 crl               crl2pkcs7         dgst              dhparam           &lt;br /&gt;
 dsa               dsaparam          ec                ecparam&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Note the above output was truncated, so only the first four lines of output are shown.&lt;br /&gt;
&lt;br /&gt;
A help menu for each command may be requested in two different ways. First, the same command used above may be repeated, followed by the name of the command to print help for.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
&lt;br /&gt;
The program will then display the valid options for the given command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
The second way of requesting the help menu for a particular command is by using the first option in the output shown above, namely &amp;lt;code&amp;gt;openssl command -help&amp;lt;/code&amp;gt;. Both commands will yield the same output; the help menu displayed will be exactly the same.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -help&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
For additional information on the usage of a particular command, the project [https://www.openssl.org/docs/manpages.html manpages] are a great source of information. Another excellent source of information is the project perldocs. [https://perldoc.perl.org/5.30.0/perldoc.html perldoc] is a utility included with most if not all [https://www.perl.org/ Perl] distributions, and it's capable of displaying documentation information in a variety of formats, one of which is as manpages. Not surprisingly, the project documentation is generated from the pod files located in the &amp;lt;tt&amp;gt;doc&amp;lt;/tt&amp;gt; directory of the source code.&lt;br /&gt;
&lt;br /&gt;
==Getting Library Version Information==&lt;br /&gt;
&lt;br /&gt;
 $ openssl version&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
&lt;br /&gt;
As mentioned above, the &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; command's help menu may be queried for additional options like so:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -help&lt;br /&gt;
 Usage: version [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help  Display this summary&lt;br /&gt;
  -a     Show all data&lt;br /&gt;
  -b     Show build date&lt;br /&gt;
  -d     Show configuration directory&lt;br /&gt;
  -e     Show engines directory&lt;br /&gt;
  -f     Show compiler flags used&lt;br /&gt;
  -o     Show some internal datatype options&lt;br /&gt;
  -p     Show target build platform&lt;br /&gt;
  -r     Show random seeding options&lt;br /&gt;
  -v     Show library version&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;tt&amp;gt;-a&amp;lt;/tt&amp;gt; option to show all version information yields the following output on my current machine:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -a&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
 built on: Tue May 28 16:23:39 2019 UTC&lt;br /&gt;
 platform: linux-x86_64&lt;br /&gt;
 options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) &lt;br /&gt;
 compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -D_FORTIFY_SOURCE=2&lt;br /&gt;
 OPENSSLDIR: &amp;quot;/etc/ssl&amp;quot;&lt;br /&gt;
 ENGINESDIR: &amp;quot;/usr/lib/engines-1.1&amp;quot;&lt;br /&gt;
 Seeding source: os-specific&lt;br /&gt;
&lt;br /&gt;
==Generating an RSA Private Key==&lt;br /&gt;
&lt;br /&gt;
Generating a private key can be done in a variety of different ways depending on the type of key, algorithm, bits, and other options your specific use case may require. In this example, we are generating a private key using RSA and a key size of 2048 bits.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
To generate a password protected private key, the previous command may be slightly amended as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
The addition of the &amp;lt;tt&amp;gt;-aes256&amp;lt;/tt&amp;gt; option specifies the cipher to use to encrypt the private key file. For a list of available ciphers in the library, you can run the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
&lt;br /&gt;
With your private key in hand, you can use the following command to see the key's details, such as its modulus and its constituent primes. Remember to change the name of the input file to the file name of your private key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
&lt;br /&gt;
The above command yields the following output in my specific case. Your output will differ but should be structurally similar.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDZD6IMLRFk4CaF&lt;br /&gt;
 w0rhRienwuE5EZ6xFE8e3C5TVi1+d9Enhi38RgkwD7UlWxPE6AWhp5T3kfrFWdak&lt;br /&gt;
 1lZFVPp7/btOKLjKUru15nLoA4AKYtz9W9PhsM0dyzLc6FQ6K4ReQam5pHCqI2zF&lt;br /&gt;
 82MwE+eIAduvuqyoQLKiI608EArWZqDtMUpBJzv0UVEYvRdnMWpCwfzpI+hPJywV&lt;br /&gt;
 CcTlNCT/ctGgBKyIx+dDuZ7bR9MNmSW7GreJEbTH+R13xT3dd/JCka1+LYCl4h0q&lt;br /&gt;
 oWhFPhOkvQzmmSzUmZlAlTDQLv2eAdJIrQcsnKZ3SsIOCC/3IpqwSzpid38Ill4O&lt;br /&gt;
 xH6XIrVFAgMBAAECggEBAJ2MC0JrM8TULSHJrf/0u7O4b2DMuTIuW386sSUr17mD&lt;br /&gt;
 nfviGF6TNvf7bq++e4rgHbZHvIg1HJ9Bpdne+J86HtUARYNlazru8fAFZEGiyLzB&lt;br /&gt;
 JUV/8TpO6ZJGepR8zSWrkFgZsOddw6i6LalADy5GRDcjoiDajZdR3lZxLrv5qOQU&lt;br /&gt;
 I1vKTf4Zs2Tl3gnaJ/Il1gBHIQ9W9xUH8jPBIwj51iXwCh8H0BiDPvFkU7cHIFCP&lt;br /&gt;
 sJhGsGp6OS3uSwwQuSE+NqbuPfVilysCcwgZduknyio0QO1YfMBL6+XoKE/bFHsn&lt;br /&gt;
 N+FzzczQg9sWyiwVR+3EeI9kp4JSElNh2nqG96i4QAECgYEA76OLUGrShHb4saoP&lt;br /&gt;
 aYnBAKLEdWj5K483JdY6BSbdd5RkDbJG8ExmcbfTas/BGdKc4iVCkxV3ysxKnX18&lt;br /&gt;
 PfxATHDLL8NMa+gGgZY5oTKUsrXEpS132HhCJ9T9LoesQjRb4kOZH8POVqm6O4Xf&lt;br /&gt;
 lCt0y1+M1eQHI1NPO9CmPBgouEUCgYEA5+F4SS8RMyYRkU/kx195fwh0hhaOElzr&lt;br /&gt;
 E8mZou3NFL/XT6/9t+2+7sMTuiQCP9zIa6s+/rrXdjWtrTcDp4WlDITas0UUgZhv&lt;br /&gt;
 YVBQBF4vhHxIVwJxnT9Gwi4XM1JlFmVHofWD71P6DRe7jSWRS3CujP3AE9vmpWMx&lt;br /&gt;
 tE1D9qLiWQECgYB445LzFYBvrKjWz4iI4CJKFNJwvGz+iXfzkXehg7KzkVtMAYSB&lt;br /&gt;
 0rjXYzm3J2ktgq778nn8Qxc0agy2GEil6GvzY+9MgAQ8Z0do9gTKif6zjLjP7vkH&lt;br /&gt;
 bdtJxsuWPoEqwMkdgqZrfNbJp0O4pVddovJ/agtdF3R2YJ+W+DH0HOfl1QKBgFnM&lt;br /&gt;
 c2zEEYEhaQRBUHP1gXO0rouPCI4L9e2/0QPL2/QBJzzxBuzH4X1NhsI7V7OrqOIp&lt;br /&gt;
 e0fiy7Y3q369I2ko1HY4rQln4z0c72VcWOCYKQbBqrInfCBNdPWWK93wNr2pk0gh&lt;br /&gt;
 cGqqtteDLVrIBbCVfsOTMWN/cZ7y/zi4A23sPoQBAoGAEPzcIjOyoB97Pzd7iNim&lt;br /&gt;
 Gin8RkwXIiFGSHo8vAh74CKBNokThM50OUNm5T2eJ4huzPpowQ+ID1mB5EjEai9n&lt;br /&gt;
 JY9ll3cUpawiIIW/6uGTHyXfvZWNtqEYXrVJ6fcDaKcW4y3cplNj/SJaBW8HXsW7&lt;br /&gt;
 YGHW3zHsgy7EOAOzPwlm9oE=&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 RSA Private-Key: (2048 bit, 2 primes)&lt;br /&gt;
 modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 publicExponent: 65537 (0x10001)&lt;br /&gt;
 privateExponent:&lt;br /&gt;
     00:9d:8c:0b:42:6b:33:c4:d4:2d:21:c9:ad:ff:f4:&lt;br /&gt;
     bb:b3:b8:6f:60:cc:b9:32:2e:5b:7f:3a:b1:25:2b:&lt;br /&gt;
     d7:b9:83:9d:fb:e2:18:5e:93:36:f7:fb:6e:af:be:&lt;br /&gt;
     7b:8a:e0:1d:b6:47:bc:88:35:1c:9f:41:a5:d9:de:&lt;br /&gt;
     f8:9f:3a:1e:d5:00:45:83:65:6b:3a:ee:f1:f0:05:&lt;br /&gt;
     64:41:a2:c8:bc:c1:25:45:7f:f1:3a:4e:e9:92:46:&lt;br /&gt;
     7a:94:7c:cd:25:ab:90:58:19:b0:e7:5d:c3:a8:ba:&lt;br /&gt;
     2d:a9:40:0f:2e:46:44:37:23:a2:20:da:8d:97:51:&lt;br /&gt;
     de:56:71:2e:bb:f9:a8:e4:14:23:5b:ca:4d:fe:19:&lt;br /&gt;
     b3:64:e5:de:09:da:27:f2:25:d6:00:47:21:0f:56:&lt;br /&gt;
     f7:15:07:f2:33:c1:23:08:f9:d6:25:f0:0a:1f:07:&lt;br /&gt;
     d0:18:83:3e:f1:64:53:b7:07:20:50:8f:b0:98:46:&lt;br /&gt;
     b0:6a:7a:39:2d:ee:4b:0c:10:b9:21:3e:36:a6:ee:&lt;br /&gt;
     3d:f5:62:97:2b:02:73:08:19:76:e9:27:ca:2a:34:&lt;br /&gt;
     40:ed:58:7c:c0:4b:eb:e5:e8:28:4f:db:14:7b:27:&lt;br /&gt;
     37:e1:73:cd:cc:d0:83:db:16:ca:2c:15:47:ed:c4:&lt;br /&gt;
     78:8f:64:a7:82:52:12:53:61:da:7a:86:f7:a8:b8:&lt;br /&gt;
     40:01&lt;br /&gt;
 prime1:&lt;br /&gt;
     00:ef:a3:8b:50:6a:d2:84:76:f8:b1:aa:0f:69:89:&lt;br /&gt;
     c1:00:a2:c4:75:68:f9:2b:8f:37:25:d6:3a:05:26:&lt;br /&gt;
     dd:77:94:64:0d:b2:46:f0:4c:66:71:b7:d3:6a:cf:&lt;br /&gt;
     c1:19:d2:9c:e2:25:42:93:15:77:ca:cc:4a:9d:7d:&lt;br /&gt;
     7c:3d:fc:40:4c:70:cb:2f:c3:4c:6b:e8:06:81:96:&lt;br /&gt;
     39:a1:32:94:b2:b5:c4:a5:2d:77:d8:78:42:27:d4:&lt;br /&gt;
     fd:2e:87:ac:42:34:5b:e2:43:99:1f:c3:ce:56:a9:&lt;br /&gt;
     ba:3b:85:df:94:2b:74:cb:5f:8c:d5:e4:07:23:53:&lt;br /&gt;
     4f:3b:d0:a6:3c:18:28:b8:45&lt;br /&gt;
 prime2:&lt;br /&gt;
     00:e7:e1:78:49:2f:11:33:26:11:91:4f:e4:c7:5f:&lt;br /&gt;
     79:7f:08:74:86:16:8e:12:5c:eb:13:c9:99:a2:ed:&lt;br /&gt;
     cd:14:bf:d7:4f:af:fd:b7:ed:be:ee:c3:13:ba:24:&lt;br /&gt;
     02:3f:dc:c8:6b:ab:3e:fe:ba:d7:76:35:ad:ad:37:&lt;br /&gt;
     03:a7:85:a5:0c:84:da:b3:45:14:81:98:6f:61:50:&lt;br /&gt;
     50:04:5e:2f:84:7c:48:57:02:71:9d:3f:46:c2:2e:&lt;br /&gt;
     17:33:52:65:16:65:47:a1:f5:83:ef:53:fa:0d:17:&lt;br /&gt;
     bb:8d:25:91:4b:70:ae:8c:fd:c0:13:db:e6:a5:63:&lt;br /&gt;
     31:b4:4d:43:f6:a2:e2:59:01&lt;br /&gt;
 exponent1:&lt;br /&gt;
     78:e3:92:f3:15:80:6f:ac:a8:d6:cf:88:88:e0:22:&lt;br /&gt;
     4a:14:d2:70:bc:6c:fe:89:77:f3:91:77:a1:83:b2:&lt;br /&gt;
     b3:91:5b:4c:01:84:81:d2:b8:d7:63:39:b7:27:69:&lt;br /&gt;
     2d:82:ae:fb:f2:79:fc:43:17:34:6a:0c:b6:18:48:&lt;br /&gt;
     a5:e8:6b:f3:63:ef:4c:80:04:3c:67:47:68:f6:04:&lt;br /&gt;
     ca:89:fe:b3:8c:b8:cf:ee:f9:07:6d:db:49:c6:cb:&lt;br /&gt;
     96:3e:81:2a:c0:c9:1d:82:a6:6b:7c:d6:c9:a7:43:&lt;br /&gt;
     b8:a5:57:5d:a2:f2:7f:6a:0b:5d:17:74:76:60:9f:&lt;br /&gt;
     96:f8:31:f4:1c:e7:e5:d5&lt;br /&gt;
 exponent2:&lt;br /&gt;
     59:cc:73:6c:c4:11:81:21:69:04:41:50:73:f5:81:&lt;br /&gt;
     73:b4:ae:8b:8f:08:8e:0b:f5:ed:bf:d1:03:cb:db:&lt;br /&gt;
     f4:01:27:3c:f1:06:ec:c7:e1:7d:4d:86:c2:3b:57:&lt;br /&gt;
     b3:ab:a8:e2:29:7b:47:e2:cb:b6:37:ab:7e:bd:23:&lt;br /&gt;
     69:28:d4:76:38:ad:09:67:e3:3d:1c:ef:65:5c:58:&lt;br /&gt;
     e0:98:29:06:c1:aa:b2:27:7c:20:4d:74:f5:96:2b:&lt;br /&gt;
     dd:f0:36:bd:a9:93:48:21:70:6a:aa:b6:d7:83:2d:&lt;br /&gt;
     5a:c8:05:b0:95:7e:c3:93:31:63:7f:71:9e:f2:ff:&lt;br /&gt;
     38:b8:03:6d:ec:3e:84:01&lt;br /&gt;
 coefficient:&lt;br /&gt;
     10:fc:dc:22:33:b2:a0:1f:7b:3f:37:7b:88:d8:a6:&lt;br /&gt;
     1a:29:fc:46:4c:17:22:21:46:48:7a:3c:bc:08:7b:&lt;br /&gt;
     e0:22:81:36:89:13:84:ce:74:39:43:66:e5:3d:9e:&lt;br /&gt;
     27:88:6e:cc:fa:68:c1:0f:88:0f:59:81:e4:48:c4:&lt;br /&gt;
     6a:2f:67:25:8f:65:97:77:14:a5:ac:22:20:85:bf:&lt;br /&gt;
     ea:e1:93:1f:25:df:bd:95:8d:b6:a1:18:5e:b5:49:&lt;br /&gt;
     e9:f7:03:68:a7:16:e3:2d:dc:a6:53:63:fd:22:5a:&lt;br /&gt;
     05:6f:07:5e:c5:bb:60:61:d6:df:31:ec:83:2e:c4:&lt;br /&gt;
     38:03:b3:3f:09:66:f6:81&lt;br /&gt;
&lt;br /&gt;
Keep in mind the above key was generated solely for pedagogical purposes; never give anyone access to your private keys.&lt;br /&gt;
&lt;br /&gt;
==Generating a Public Key==&lt;br /&gt;
&lt;br /&gt;
Having previously generated your private key, you may generate the corresponding public key using the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -out public-key.pem -pubout&lt;br /&gt;
&lt;br /&gt;
You may once again view the key details, using a slightly different command this time.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in public-key.pem -pubin -text&lt;br /&gt;
&lt;br /&gt;
The output for the public key will be shorter, as it carries much less information, and it will look something like this.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PUBLIC KEY-----&lt;br /&gt;
 MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Q+iDC0RZOAmhcNK4UYn&lt;br /&gt;
 p8LhORGesRRPHtwuU1YtfnfRJ4Yt/EYJMA+1JVsTxOgFoaeU95H6xVnWpNZWRVT6&lt;br /&gt;
 e/27Tii4ylK7teZy6AOACmLc/VvT4bDNHcsy3OhUOiuEXkGpuaRwqiNsxfNjMBPn&lt;br /&gt;
 iAHbr7qsqECyoiOtPBAK1mag7TFKQSc79FFRGL0XZzFqQsH86SPoTycsFQnE5TQk&lt;br /&gt;
 /3LRoASsiMfnQ7me20fTDZkluxq3iRG0x/kdd8U93XfyQpGtfi2ApeIdKqFoRT4T&lt;br /&gt;
 pL0M5pks1JmZQJUw0C79ngHSSK0HLJymd0rCDggv9yKasEs6Ynd/CJZeDsR+lyK1&lt;br /&gt;
 RQIDAQAB&lt;br /&gt;
 -----END PUBLIC KEY-----&lt;br /&gt;
 RSA Public-Key: (2048 bit)&lt;br /&gt;
 Modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 Exponent: 65537 (0x10001)&lt;br /&gt;
&lt;br /&gt;
For more information on generating keys, see the source code documentation, located in the &amp;lt;tt&amp;gt;doc/HOWTO/keys.txt&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Generating Keys Based on Elliptic Curves==&lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to generating a key:&lt;br /&gt;
&lt;br /&gt;
# Generate the parameters for the specific curve you are using&lt;br /&gt;
# Use those parameters to generate the key&lt;br /&gt;
&lt;br /&gt;
To see the list of curves instrinsically supported by openssl, you can use the &amp;lt;tt&amp;gt;-list_curves&amp;lt;/t&amp;gt; option when calling the &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -list_curves&lt;br /&gt;
   secp112r1 : SECG/WTLS curve over a 112 bit prime field&lt;br /&gt;
   secp112r2 : SECG curve over a 112 bit prime field&lt;br /&gt;
   secp128r1 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp128r2 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp160k1 : SECG curve over a 160 bit prime field&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
For this example I will use the &amp;lt;tt&amp;gt;prime256v1&amp;lt;/tt&amp;gt; curve, which is an &amp;lt;tt&amp;gt;X9.62/SECG&amp;lt;/tt&amp;gt; curve over a 256 bit prime field.&lt;br /&gt;
&lt;br /&gt;
===Generating the Curve Parameters===&lt;br /&gt;
&lt;br /&gt;
Having selected our curve, we now call &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; to generate our parameters file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -name prime256v1 -out prime256v1.pem&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters to Standard Out====&lt;br /&gt;
&lt;br /&gt;
You can print the generated curve parameters to the terminal output with the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -text&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters as C Code====&lt;br /&gt;
&lt;br /&gt;
Analogously, you may also output the generated curve parameters as C code. The parameters can then be loaded by calling the &amp;lt;tt&amp;gt;get_ec_group_XXX()&amp;lt;/tt&amp;gt; function. To print the C code to the current terminal's output, the following command may be used:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -C&lt;br /&gt;
&lt;br /&gt;
And here are the first few lines of the corresponding output:&lt;br /&gt;
&lt;br /&gt;
 EC_GROUP *get_ec_group_256(void)&lt;br /&gt;
 {&lt;br /&gt;
     static unsigned char ec_p_256[] = {&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,&lt;br /&gt;
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,&lt;br /&gt;
         ...&lt;br /&gt;
&lt;br /&gt;
===Generating the Key===&lt;br /&gt;
&lt;br /&gt;
With the curve parameters in hand, we are now free to generate the key. Just as with the [#Generating an RSA Private Key|RSA] example above, we may optionally specify a cipher algorithm with which to encrypt the private key. The call to generate the key using the elliptic curve parameters generated in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -paramfile prime256v1.pem -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
===Putting it All Together===&lt;br /&gt;
&lt;br /&gt;
The process of generation a curve based on elliptic-curves can be streamlined by calling the &amp;lt;tt&amp;gt;genpkey&amp;lt;/tt&amp;gt; command directly and specifying both the algorithm and the name of the curve to use for parameter generation. In it's simplest form, the command to generate a key based on the same curve as in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256&lt;br /&gt;
&lt;br /&gt;
This command will result in the generated key being printed to the terminal's output.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256&lt;br /&gt;
 &lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgqqYoJGowXJ5/GTkB&lt;br /&gt;
 SRLnBMNWLoQ2RM/QxrY+bfDDGRahRANCAASPY4eTANkwIIAWhh32eoFl2YFLJSWy&lt;br /&gt;
 bdITdZ82O5JDpDijmGmJ2hepe5afek9WVqxMPYjmbTwMPO3xMGbqUiJD&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
&lt;br /&gt;
Remember that you can specify a cipher algorithm to encrypt the key with, which something you may or may not want to do, depending on your specific use case. Here is a slightly more complete example showing a key generated with a password and written to a specific output file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
Just as with the previous example, you can use the &amp;lt;tt&amp;gt;pkey&amp;lt;/tt&amp;gt; command to inspect your newly-generated key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
 Enter pass phrase for private-key.pem:&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgEO7CxgTwi0hsjdbp&lt;br /&gt;
 sXWuU2x2flLthxqXabYDOqOZCvuhRANCAAQVTLkeCBJdvMnqwZKYJxrPvTTuanrD&lt;br /&gt;
 NkyAPQCARKsQ7bVrP6ky/5uAcAvjuZB0xKCcSp7roXLWRzD/y/ik8P5R&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 Private-Key: (256 bit)&lt;br /&gt;
 priv:&lt;br /&gt;
     10:ee:c2:c6:04:f0:8b:48:6c:8d:d6:e9:b1:75:ae:&lt;br /&gt;
     53:6c:76:7e:52:ed:87:1a:97:69:b6:03:3a:a3:99:&lt;br /&gt;
     0a:fb&lt;br /&gt;
 pub:&lt;br /&gt;
     04:15:4c:b9:1e:08:12:5d:bc:c9:ea:c1:92:98:27:&lt;br /&gt;
     1a:cf:bd:34:ee:6a:7a:c3:36:4c:80:3d:00:80:44:&lt;br /&gt;
     ab:10:ed:b5:6b:3f:a9:32:ff:9b:80:70:0b:e3:b9:&lt;br /&gt;
     90:74:c4:a0:9c:4a:9e:eb:a1:72:d6:47:30:ff:cb:&lt;br /&gt;
     f8:a4:f0:fe:51&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
For more details on elliptic curve cryptography or key generation, check out the [https://www.openssl.org/docs/manpages.html manpages].&lt;br /&gt;
&lt;br /&gt;
==Base64 Encoding Strings==&lt;br /&gt;
&lt;br /&gt;
For simple string encoding, you can use &amp;quot;here string&amp;quot; syntax with the [[Base64 Encoding|base64]] command as below. Intuitively, the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; flag specifies the action to be encoding.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -e &amp;lt;&amp;lt;&amp;lt; 'Welcome to openssl wiki'&lt;br /&gt;
 V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK&lt;br /&gt;
&lt;br /&gt;
Similarly, the base64 command's &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flag may be used to indicate decoding mode.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -d &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK'&lt;br /&gt;
 Welcome to openssl wiki&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''Note:''''' base64 line length is limited to 76 characters by default in openssl (and generated with 64 characters per line).&lt;br /&gt;
&lt;br /&gt;
 openssl base64 -e &amp;lt;&amp;lt;&amp;lt; 'Welcome to openssl wiki with a very long line that splits...'&lt;br /&gt;
 V2VsY29tZSB0byBvcGVuc3NsIHdpa2kgd2l0aCBhIHZlcnkgbG9uZyBsaW5lIHRo&lt;br /&gt;
 YXQgc3BsaXRzLi4uCg==&lt;br /&gt;
 openssl base64 -d &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kgd2l0aCBhIHZlcnkgbG9uZyBsaW5lIHRoYXQgc3BsaXRzLi4uCg=='&lt;br /&gt;
&lt;br /&gt;
=&amp;gt; NOTHING!&lt;br /&gt;
&lt;br /&gt;
To be able to decode a base64 line without line feeds that exceeds the default 76 character length restriction use the &amp;lt;code&amp;gt;-A&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
 openssl base64 -d -A &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kgd2l0aCBhIHZlcnkgbG9uZyBsaW5lIHRoYXQgc3BsaXRzLi4uCg=='&lt;br /&gt;
 Welcome to openssl wiki with a very long line that splits...&lt;br /&gt;
&lt;br /&gt;
It is recommended to actually split base64 strings into multiple lines of 64 characters, however, since the &amp;lt;code&amp;gt;-A&amp;lt;/code&amp;gt; option is buggy, particularly with its handling of long files.&lt;br /&gt;
&lt;br /&gt;
==Generating a File Hash==&lt;br /&gt;
&lt;br /&gt;
One of the most basic uses of the [[dgst]] command (short for digest) is viewing the hash of a given file. To do this, simply invoke the command with the specified digest algorithm to use. For this example, I will be hashing an arbitrary file on my system using the [[MD5]], [[SHA1]], and [[SHA384]] algorithms.&lt;br /&gt;
&lt;br /&gt;
 $ openssl dgst -md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
For a list of the available digest algorithms, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-algorithms&lt;br /&gt;
 RSA-MD4 =&amp;gt; MD4&lt;br /&gt;
 RSA-MD5 =&amp;gt; MD5&lt;br /&gt;
 RSA-MDC2 =&amp;gt; MDC2&lt;br /&gt;
 RSA-RIPEMD160 =&amp;gt; RIPEMD160&lt;br /&gt;
 RSA-SHA1 =&amp;gt; SHA1&lt;br /&gt;
 RSA-SHA1-2 =&amp;gt; RSA-SHA1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use a similar command to see the available [[Digest Commands|digest commands]]:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-commands&lt;br /&gt;
 blake2b512        blake2s256        gost              md4               &lt;br /&gt;
 md5               mdc2              rmd160            sha1              &lt;br /&gt;
 sha224            sha256            sha3-224          sha3-256          &lt;br /&gt;
 sha3-384          sha3-512          sha384            sha512            &lt;br /&gt;
 sha512-224        sha512-256        shake128          shake256          &lt;br /&gt;
 sm3      &lt;br /&gt;
&lt;br /&gt;
Below are three sample invocations of the [[md5]], [[sha1]], and [[sha384]] digest commands using the same file as the [[dgst]] command invocation above.&lt;br /&gt;
&lt;br /&gt;
 $ openssl md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
==File Encryption and Decryption==&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates a simple file encryption and decryption using the [[enc]] command. The first argument is the cipher algorithm to use for encrypting the file. For this example I carefully selected the [[AES-256]] algorithm in [[CBC Mode]] by looking up the available ciphers and picking out the first one I saw. To see the list of available ciphers, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -ciphers&lt;br /&gt;
 Supported ciphers:&lt;br /&gt;
 -aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             &lt;br /&gt;
 -aes-128-cfb8              -aes-128-ctr               -aes-128-ecb              &lt;br /&gt;
 -aes-128-ofb               -aes-192-cbc               -aes-192-cfb              &lt;br /&gt;
 -aes-192-cfb1              -aes-192-cfb8              -aes-192-ctr&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
 AES-128-CBC&lt;br /&gt;
 AES-128-CBC-HMAC-SHA1&lt;br /&gt;
 AES-128-CBC-HMAC-SHA256&lt;br /&gt;
 id-aes128-CCM&lt;br /&gt;
 AES-128-CFB&lt;br /&gt;
 AES-128-CFB1&lt;br /&gt;
 AES-128-CFB8&lt;br /&gt;
 AES-128-CTR&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Having selected an encryption algorithm, you must then specify whether the action you are taking is either encryption or decryption via the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flags, respectively. The &amp;lt;tt&amp;gt;-iter&amp;lt;/tt&amp;gt; flag specifies the number of iterations on the password used for deriving the encryption key. A higher iteration count increases the time required to brute-force the resulting file. Using this option implies enabling use of the [[Password-Based Key Derivation Function 2]], usually set using the &amp;lt;tt&amp;gt;-pbkdf2&amp;lt;/tt&amp;gt; flag. We then use the &amp;lt;tt&amp;gt;-salt&amp;lt;/tt&amp;gt; flag to enable the use of a randomly generated salt in the key-derivation function.&lt;br /&gt;
&lt;br /&gt;
Putting it all together, you can see the command to encrypt a file and the corresponding output below. Note that the passwords entered by the user are blank, just as they would usually be in a terminal session.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -e -iter 1000 -salt -in primes.dat -out primes.enc&lt;br /&gt;
 enter aes-256-cbc encryption password:&lt;br /&gt;
 Verifying - enter aes-256-cbc encryption password:&lt;br /&gt;
&lt;br /&gt;
The analogous decryption command is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -d -iter 1000 -in primes.enc -out primes.dec&lt;br /&gt;
 enter aes-256-cbc decryption password:&lt;br /&gt;
&lt;br /&gt;
=Commands=&lt;br /&gt;
&lt;br /&gt;
There are three different kinds of commands. These are [[Standard commands|standard commands]], [[Cipher commands|cipher commands]], and [[Digest comands|digest commands]]. Calling the OpenSSL top-level &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt; command with no arguments will result in openssl printing all available commands by group, sorted alphabetically.&lt;br /&gt;
&lt;br /&gt;
==Standard Commands==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto; text-align: center; width: 65%;&amp;quot;&lt;br /&gt;
|+ Overview of OpenSSL's command line utilities&lt;br /&gt;
! style=&amp;quot;width: 25%; padding: 4px;&amp;quot; | Command&lt;br /&gt;
! style=&amp;quot;width: 75%; padding: 4px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/asn1parse.html asn1parse]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Parse an ASN.1 sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ca.html ca]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Authority (CA) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ciphers.html ciphers]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Cipher Suite Description Determination.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/cms.html cms]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CMS (Cryptographic Message Syntax) utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl.html crl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Revocation List (CRL) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl2pkcs7.html crl2pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CRL to PKCS#7 Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dgst.html dgst]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Digest calculation. MAC calculations are superseded by mac(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dhparam.html dhparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation and Management of Diffie-Hellman Parameters. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsa.html dsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsaparam.html dsaparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Parameter Generation and Management. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ec.html ec]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC (Elliptic curve) key processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ecparam.html ecparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC parameter manipulation and generation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/enc.html enc]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Encoding with Ciphers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/engine.html engine]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Engine (loadable module) information and manipulation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/errstr.html errstr]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Error Number to Error String Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/gendsa.html gendsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of DSA Private Key from Parameters. Superseded by genpkey(1) and pkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genpkey.html genpkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of Private Key or Parameters.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genrsa.html genrsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of RSA Private Key. Superseded by genpkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/info.html info]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Display diverse information built into the OpenSSL libraries.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/kdf.html kdf]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Key Derivation Functions.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/mac.html mac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Authentication Code Calculation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/nseq.html nseq]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create or examine a Netscape certificate sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ocsp.html ocsp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Online Certificate Status Protocol utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/passwd.html passwd]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of hashed passwords.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs12.html pkcs12]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#12 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs7.html pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#7 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs8.html pkcs8]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#8 format private key conversion tool.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkey.html pkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public and private key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyparam.html pkeyparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm parameter management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyutl.html pkeyutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm cryptographic operation utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/prime.html prime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Compute prime numbers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rand.html rand]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generate pseudo-random bytes.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rehash.html rehash]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create symbolic links to certificate and CRL files named by the hash values.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/req.html req]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#10 X.509 Certificate Signing Request (CSR) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsa.html rsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsautl.html rsautl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA utility for signing, verification, encryption, and decryption. Superseded by pkeyutl(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_client.html s_client]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_server.html s_server]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_time.html s_time]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Connection Timer.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/sess_id.html sess_id]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Session Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/smime.html smime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  S/MIME mail processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/speed.html speed]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Algorithm Speed Measurement.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/spkac.html spkac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SPKAC printing and generating utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/srp.html srp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Maintain SRP password file.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/storeutl.html storeutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Utility to list and display certificates, keys, CRLs, etc.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ts.html ts]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Time Stamping Authority tool (client/server).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/verify.html verify]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Verification.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/version.html version]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  OpenSSL Version Information.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/x509.html x509]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Data Management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Further reading =&lt;br /&gt;
&lt;br /&gt;
* Paul Heinlein. [https://www.madboa.com/geek/openssl/ &amp;quot;OpenSSL Command-Line HOWTO&amp;quot;]. Has many quick cookbook-style recipes for doing common tasks using the &amp;quot;oppenssl&amp;quot; command-line application.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:Shell level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=User_talk:Jflopezfernandez&amp;diff=2870</id>
		<title>User talk:Jflopezfernandez</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=User_talk:Jflopezfernandez&amp;diff=2870"/>
		<updated>2019-08-26T10:27:16Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created user talk page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi! Feel free to reach out to me if I make a mistake, I'm always looking to learn :)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Main_Page&amp;diff=2869</id>
		<title>Talk:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Main_Page&amp;diff=2869"/>
		<updated>2019-08-25T18:03:34Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Replying to thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content Outline&lt;br /&gt;
&lt;br /&gt;
== OpenSSL Quick Links ==&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;TABLE border=0&amp;gt;&lt;br /&gt;
     &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[OpenSSL Overview]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Compilation and Installation]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Internals]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libcrypto API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libssl API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Examples]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[License]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Command Line Utilities]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Related Links]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
  &amp;lt;/TABLE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Administrivia ==&lt;br /&gt;
Site guidelines, legal and admininstrative issues.&lt;br /&gt;
:* [[Basic rules]], [[Commercial Product Disclaimer]], [[Contributions]], [[Copyright]], [[License]]&lt;br /&gt;
:* Using This Wiki&lt;br /&gt;
:: [http://meta.wikimedia.org/wiki/Help:Contents Wiki User's Guide], [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings list], [http://www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ], [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki Mailing List]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
This section contains the automagically generated man pages from the OpenSSL git repository, and similar &amp;quot;man&amp;quot; style reference documentation. The man pages are automatically imported from the OpenSSL git repository and local wiki modifications are submitted as patches.&lt;br /&gt;
:* OpenSSL Manual Pages&lt;br /&gt;
::* [[Manual:Openssl(1)]], [[Manual:Ssl(3)]], [[Manual:Crypto(3)]], [[Documentation Index]]&lt;br /&gt;
:: If you wish to edit any of the Manual page content please refer to the [[Guidelines for Manual Page Authors]] page.&lt;br /&gt;
:* [[API]], [[Libcrypto API]], [[Libssl API]]&lt;br /&gt;
:* [[FIPS mode()]], [[FIPS_mode_set()]]&lt;br /&gt;
&lt;br /&gt;
== Usage and Programming ==&lt;br /&gt;
This section has discussions of practical issues in using OpenSSL&lt;br /&gt;
:* Building from Source&lt;br /&gt;
:: Where to find it, the different versions, how to build and install it.&lt;br /&gt;
:* [[OpenSSL Overview]]&lt;br /&gt;
:* [[Versioning]]&lt;br /&gt;
:* [[Compilation and Installation]]&lt;br /&gt;
:* EVP&lt;br /&gt;
:: Programming techniques and example code&lt;br /&gt;
:: Use of EVP is preferred for most applications and circumstances&lt;br /&gt;
::* [[EVP Asymmetric Encryption and Decryption of an Envelope]]&lt;br /&gt;
::* [[EVP Authenticated Encryption and Decryption]]&lt;br /&gt;
::* [[EVP Symmetric Encryption and Decryption]]&lt;br /&gt;
::* [[EVP Key and Parameter Generation]]&lt;br /&gt;
::* [[EVP Key Agreement]]&lt;br /&gt;
::* [[EVP Message Digests]]&lt;br /&gt;
::* [[EVP Key Derivation]]&lt;br /&gt;
::* [[EVP Signing and Verifying|EVP Signing and Verifying (including MAC codes)]]&lt;br /&gt;
:* Low Level APIs&lt;br /&gt;
:: More specialized non-EVP usage&lt;br /&gt;
::* [[Diffie-Hellman parameters]]&lt;br /&gt;
&lt;br /&gt;
== Concepts and Theory ==&lt;br /&gt;
Discussions of basic cryptographic theory and concepts&lt;br /&gt;
Discussions of common operational issues&lt;br /&gt;
:* [[Base64]]&lt;br /&gt;
:* [[FIPS 140-2]]&lt;br /&gt;
:* [[Random Numbers]]&lt;br /&gt;
:* [[Diffie Hellman]]&lt;br /&gt;
:* [[Elliptic Curve Diffie Hellman]]&lt;br /&gt;
:* [[Elliptic Curve Cryptography]]&lt;br /&gt;
&lt;br /&gt;
== Internals and Development ==&lt;br /&gt;
This section is for internal details of primary interest to OpenSSL maintainers and power users&lt;br /&gt;
:* [[Internals]]&lt;br /&gt;
:* [[Code Quality]]&lt;br /&gt;
:* [[Static and Dynamic Analysis]]&lt;br /&gt;
&lt;br /&gt;
== Miscellanous ==&lt;br /&gt;
For the material that doesn't seem to fit anywhere else&lt;br /&gt;
:* New topics pending categorization (not yet linked elsewhere)&lt;br /&gt;
:* Incomplete or contentious pages under discussion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
I like it - it brings the interesting content right up front. It probably needs to have some top and tail text to describe what this wiki is for, and how to contribute. I added a link to the Elliptic Curve Cryptography page above&lt;br /&gt;
--[[User:Matt|Matt]] 15:02, 30 May 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Proposed Change: Quick Links ==&lt;br /&gt;
&lt;br /&gt;
I'm proposing a change of the quick links section to use the wikitable syntax. This is the current version, but I can modify the styling as required, like changing the background and removing the border to look as if we just moved the old table to the center, if anyone prefers that.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto; text-align: center;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 200px; | [[OpenSSL Overview]] || style=&amp;quot;width: 200px;&amp;quot; | [[Compilation and Installation]] || style=&amp;quot;width: 200px;&amp;quot; | [[Internals]] || style=&amp;quot;width: 200px;&amp;quot; | [[Mailing Lists]]&lt;br /&gt;
|-&lt;br /&gt;
| [[libcrypto API]] || [[libssl API]] || [[Examples]] || [[Documentation Index|Index of all API functions]]&lt;br /&gt;
|-&lt;br /&gt;
| [[License]] || [[Command Line Utilities]] || [[Related Links]] || [[Binaries]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SSL and TLS Protocols]] || [[1.1 API Changes]] || [[FIPS modules]] || [[TLS1.3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The main benefit in my opinion is the code. This is the code for the table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto; text-align: center;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 200px; | [[OpenSSL Overview]] || style=&amp;quot;width: 200px;&amp;quot; | [[Compilation and Installation]] || style=&amp;quot;width: 200px;&amp;quot; | [[Internals]] || style=&amp;quot;width: 200px;&amp;quot; | [[Mailing Lists]]&lt;br /&gt;
|-&lt;br /&gt;
| [[libcrypto API]] || [[libssl API]] || [[Examples]] || [[Documentation Index|Index of all API functions]]&lt;br /&gt;
|-&lt;br /&gt;
| [[License]] || [[Command Line Utilities]] || [[Related Links]] || [[Binaries]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SSL and TLS Protocols]] || [[1.1 API Changes]] || [[FIPS modules]] || [[TLS1.3]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The previous table's code used image files to manipulate the alignment, and I think it makes adding or removing links a lot harder than it needs to be.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;TABLE border=0&amp;gt;&lt;br /&gt;
     &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[OpenSSL Overview]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Compilation and Installation]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Internals]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Mailing Lists]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libcrypto API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libssl API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Examples]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Documentation Index|Index of all API functions]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[License]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Command Line Utilities]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Related Links]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Binaries]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[SSL and TLS Protocols]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[1.1 API Changes]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[FIPS modules]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[TLS1.3]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
  &amp;lt;/TABLE&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let me know what you think; I appreciate any and all feedback.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 19:52, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: Wow - yeah. That looks great to me.&lt;br /&gt;
: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 22:33, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: Do you think it's okay to make the change? There haven't been any objections,&lt;br /&gt;
:: but I'm not sure what the procedure is for making changes like this. I think&lt;br /&gt;
:: it's substantial enough to merit some kind of review process since it's the&lt;br /&gt;
:: main page, but like I said, I don't really know.&lt;br /&gt;
::&lt;br /&gt;
:: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 18:03, 25 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Main_Page&amp;diff=2866</id>
		<title>Talk:Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Main_Page&amp;diff=2866"/>
		<updated>2019-08-09T19:52:24Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* Proposed Change: Quick Links */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Content Outline&lt;br /&gt;
&lt;br /&gt;
== OpenSSL Quick Links ==&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;TABLE border=0&amp;gt;&lt;br /&gt;
     &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[OpenSSL Overview]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Compilation and Installation]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Internals]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libcrypto API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libssl API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Examples]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[License]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Command Line Utilities]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Related Links]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
  &amp;lt;/TABLE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Administrivia ==&lt;br /&gt;
Site guidelines, legal and admininstrative issues.&lt;br /&gt;
:* [[Basic rules]], [[Commercial Product Disclaimer]], [[Contributions]], [[Copyright]], [[License]]&lt;br /&gt;
:* Using This Wiki&lt;br /&gt;
:: [http://meta.wikimedia.org/wiki/Help:Contents Wiki User's Guide], [http://www.mediawiki.org/wiki/Manual:Configuration_settings Configuration settings list], [http://www.mediawiki.org/wiki/Manual:FAQ MediaWiki FAQ], [https://lists.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki Mailing List]&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
This section contains the automagically generated man pages from the OpenSSL git repository, and similar &amp;quot;man&amp;quot; style reference documentation. The man pages are automatically imported from the OpenSSL git repository and local wiki modifications are submitted as patches.&lt;br /&gt;
:* OpenSSL Manual Pages&lt;br /&gt;
::* [[Manual:Openssl(1)]], [[Manual:Ssl(3)]], [[Manual:Crypto(3)]], [[Documentation Index]]&lt;br /&gt;
:: If you wish to edit any of the Manual page content please refer to the [[Guidelines for Manual Page Authors]] page.&lt;br /&gt;
:* [[API]], [[Libcrypto API]], [[Libssl API]]&lt;br /&gt;
:* [[FIPS mode()]], [[FIPS_mode_set()]]&lt;br /&gt;
&lt;br /&gt;
== Usage and Programming ==&lt;br /&gt;
This section has discussions of practical issues in using OpenSSL&lt;br /&gt;
:* Building from Source&lt;br /&gt;
:: Where to find it, the different versions, how to build and install it.&lt;br /&gt;
:* [[OpenSSL Overview]]&lt;br /&gt;
:* [[Versioning]]&lt;br /&gt;
:* [[Compilation and Installation]]&lt;br /&gt;
:* EVP&lt;br /&gt;
:: Programming techniques and example code&lt;br /&gt;
:: Use of EVP is preferred for most applications and circumstances&lt;br /&gt;
::* [[EVP Asymmetric Encryption and Decryption of an Envelope]]&lt;br /&gt;
::* [[EVP Authenticated Encryption and Decryption]]&lt;br /&gt;
::* [[EVP Symmetric Encryption and Decryption]]&lt;br /&gt;
::* [[EVP Key and Parameter Generation]]&lt;br /&gt;
::* [[EVP Key Agreement]]&lt;br /&gt;
::* [[EVP Message Digests]]&lt;br /&gt;
::* [[EVP Key Derivation]]&lt;br /&gt;
::* [[EVP Signing and Verifying|EVP Signing and Verifying (including MAC codes)]]&lt;br /&gt;
:* Low Level APIs&lt;br /&gt;
:: More specialized non-EVP usage&lt;br /&gt;
::* [[Diffie-Hellman parameters]]&lt;br /&gt;
&lt;br /&gt;
== Concepts and Theory ==&lt;br /&gt;
Discussions of basic cryptographic theory and concepts&lt;br /&gt;
Discussions of common operational issues&lt;br /&gt;
:* [[Base64]]&lt;br /&gt;
:* [[FIPS 140-2]]&lt;br /&gt;
:* [[Random Numbers]]&lt;br /&gt;
:* [[Diffie Hellman]]&lt;br /&gt;
:* [[Elliptic Curve Diffie Hellman]]&lt;br /&gt;
:* [[Elliptic Curve Cryptography]]&lt;br /&gt;
&lt;br /&gt;
== Internals and Development ==&lt;br /&gt;
This section is for internal details of primary interest to OpenSSL maintainers and power users&lt;br /&gt;
:* [[Internals]]&lt;br /&gt;
:* [[Code Quality]]&lt;br /&gt;
:* [[Static and Dynamic Analysis]]&lt;br /&gt;
&lt;br /&gt;
== Miscellanous ==&lt;br /&gt;
For the material that doesn't seem to fit anywhere else&lt;br /&gt;
:* New topics pending categorization (not yet linked elsewhere)&lt;br /&gt;
:* Incomplete or contentious pages under discussion&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
I like it - it brings the interesting content right up front. It probably needs to have some top and tail text to describe what this wiki is for, and how to contribute. I added a link to the Elliptic Curve Cryptography page above&lt;br /&gt;
--[[User:Matt|Matt]] 15:02, 30 May 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Proposed Change: Quick Links ==&lt;br /&gt;
&lt;br /&gt;
I'm proposing a change of the quick links section to use the wikitable syntax. This is the current version, but I can modify the styling as required, like changing the background and removing the border to look as if we just moved the old table to the center, if anyone prefers that.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto; text-align: center;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 200px; | [[OpenSSL Overview]] || style=&amp;quot;width: 200px;&amp;quot; | [[Compilation and Installation]] || style=&amp;quot;width: 200px;&amp;quot; | [[Internals]] || style=&amp;quot;width: 200px;&amp;quot; | [[Mailing Lists]]&lt;br /&gt;
|-&lt;br /&gt;
| [[libcrypto API]] || [[libssl API]] || [[Examples]] || [[Documentation Index|Index of all API functions]]&lt;br /&gt;
|-&lt;br /&gt;
| [[License]] || [[Command Line Utilities]] || [[Related Links]] || [[Binaries]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SSL and TLS Protocols]] || [[1.1 API Changes]] || [[FIPS modules]] || [[TLS1.3]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The main benefit in my opinion is the code. This is the code for the table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto; text-align: center;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 200px; | [[OpenSSL Overview]] || style=&amp;quot;width: 200px;&amp;quot; | [[Compilation and Installation]] || style=&amp;quot;width: 200px;&amp;quot; | [[Internals]] || style=&amp;quot;width: 200px;&amp;quot; | [[Mailing Lists]]&lt;br /&gt;
|-&lt;br /&gt;
| [[libcrypto API]] || [[libssl API]] || [[Examples]] || [[Documentation Index|Index of all API functions]]&lt;br /&gt;
|-&lt;br /&gt;
| [[License]] || [[Command Line Utilities]] || [[Related Links]] || [[Binaries]]&lt;br /&gt;
|-&lt;br /&gt;
| [[SSL and TLS Protocols]] || [[1.1 API Changes]] || [[FIPS modules]] || [[TLS1.3]]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The previous table's code used image files to manipulate the alignment, and I think it makes adding or removing links a lot harder than it needs to be.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;TABLE border=0&amp;gt;&lt;br /&gt;
     &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[OpenSSL Overview]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Compilation and Installation]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Internals]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Mailing Lists]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libcrypto API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[libssl API]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Examples]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Documentation Index|Index of all API functions]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[License]] &amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Command Line Utilities]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Related Links]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Binaries]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
      &amp;lt;TR&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[SSL and TLS Protocols]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[1.1 API Changes]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[FIPS modules]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[Image:HTAB.png]][[Image:HTAB.png]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
        &amp;lt;TD&amp;gt;[[TLS1.3]]&amp;lt;/TD&amp;gt;&lt;br /&gt;
      &amp;lt;/TR&amp;gt;&lt;br /&gt;
  &amp;lt;/TABLE&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let me know what you think; I appreciate any and all feedback.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 19:52, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Basic_rules&amp;diff=2865</id>
		<title>Basic rules</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Basic_rules&amp;diff=2865"/>
		<updated>2019-08-09T19:38:03Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Modified the headings so the organization was a little clearer, and removed one of the misuse sections, as there were two identical ones&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Basic Rules =&lt;br /&gt;
&lt;br /&gt;
== Access and Privileges ==&lt;br /&gt;
&lt;br /&gt;
=== Eligibility ===&lt;br /&gt;
We do not want to exclude anyone from participation and so will impose the minimal restrictions consistent with the basic integrity of the site. For the beginning at least edit privileges will be given to any registered account. If necessary then later when we have a pool of sysops manual intervention may be required for edit privileges.&lt;br /&gt;
&lt;br /&gt;
=== Misuse ===&lt;br /&gt;
If your account is used for spam or vandalism it may be deleted without warning. If that account was compromised without your knowledge or consent then contact us and we'll figure out how to restore your access.&lt;br /&gt;
&lt;br /&gt;
== Content ==&lt;br /&gt;
&lt;br /&gt;
=== Copyrights ===&lt;br /&gt;
Only content in the public domain or under the OpenSSL license should be added to this wiki. We don't have the expertise or means to properly research copyright issues and so will probably be forced to remove any content if complaints of copyright infringement are received.&lt;br /&gt;
&lt;br /&gt;
=== Disclaimers ===&lt;br /&gt;
If any OpenSSL team member reports any content as factually incorrect, and does not immediately correct it, that content may be edited to include a disclaimer noting the presence of uncorrected errors.&lt;br /&gt;
&lt;br /&gt;
=== Commercial Products ===&lt;br /&gt;
&lt;br /&gt;
OpenSSL does not endorse any specific commercial products or services. Reference to such products and services is permissible when restricted to factually verifiable information appropriate in the current context, but such references should be accompanied by a link to the [[Commercial Product Disclaimer]] page.&lt;br /&gt;
&lt;br /&gt;
[[Category:Wiki Usage]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Versioning&amp;diff=2864</id>
		<title>Versioning</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Versioning&amp;diff=2864"/>
		<updated>2019-08-09T19:15:11Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added link to the command-line utilities overview page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Versioning]]&lt;br /&gt;
OpenSSL version numbers are formatted as n1.n2.n3x, where n1-3 are numbers and x, if present, is one or more letters. These can change depending on the release type:&lt;br /&gt;
&lt;br /&gt;
- '''Major releases''' that change one/both of the first two digits, which can break compatibility with previous versions&lt;br /&gt;
&lt;br /&gt;
- '''Minor releases''' that change the last digit, e.g. 1.1.0 vs. 1.1.1, can and are likely to contain new features, but in a way that does not break binary compatibility. This means that an application compiled and dynamically linked with 1.1.0 does not need to be recompiled when the shared library is updated to 1.1.1. It should be noted that some features are transparent to the application such as the maximum negotiated TLS version and cipher suites, performance improvements and so on. There is no need to recompile applications to benefit from these features.&lt;br /&gt;
&lt;br /&gt;
- '''Letter releases''', such as 1.0.2a, exclusively contain bug and security fixes and no new features. &lt;br /&gt;
&lt;br /&gt;
The full release strategy for OpenSSL is available [https://www.openssl.org/policies/releasestrat.html here]&lt;br /&gt;
&lt;br /&gt;
== Finding the current version ==&lt;br /&gt;
&lt;br /&gt;
The [[Command Line Utilities|command line tool]] [https://www.openssl.org/docs/manmaster/apps/version.html version] can be used to determine the installed OpenSSL version.&lt;br /&gt;
&lt;br /&gt;
Header file [https://github.com/openssl/openssl/blob/master/include/openssl/opensslv.h opensslv.h] also contains information about the version number.&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Cryptogams_SHA&amp;diff=2863</id>
		<title>Cryptogams SHA</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Cryptogams_SHA&amp;diff=2863"/>
		<updated>2019-08-09T19:11:36Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Fixed typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.openssl.org/~appro/cryptogams/ Cryptogams] is Andy Polyakov's project used to develop high speed cryptographic primitives and share them with other developers. This wiki article will show you how to use Cryptogams ARMv4 SHA-1 implementation. According to the head notes the ARMv4 implementation runs around 6.5 cycles per byte (cpb). Typical C/C++ implementations run around 10 to 20 cpb and Andy's routines should outperform all of them.&lt;br /&gt;
&lt;br /&gt;
Andy's Cryptogam implementations are provided by OpenSSL, but they are also available stand alone under a BSD license. The BSD style license is permissive and allows developers to use Andy's high speed cryptography without an OpenSSL dependency or licensing terms.&lt;br /&gt;
&lt;br /&gt;
There are 6 steps to the process. The first step obtains the sources. The second step creates an ASM source file. The third step compiles and assembles the source file into an object file. The fourth steps determines the API. The fifth step creates a C header file. The final step integrates the object file into a program. Once you create the files &amp;lt;tt&amp;gt;sha1-armv4.h&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;sha1-armv4.S&amp;lt;/tt&amp;gt; you can use &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; to restore symbols back to their Cryptogams name with &amp;lt;tt&amp;gt;sed -i 's|OPENSSL|CRYPTOGAMS|g' sha1-armv4.h sha1-armv4.S&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A few cautions before you begin. First, you are going to examine undocumented features of the OpenSSL library to learn how to work with the Cryptogam's sources. The Cryptogam sources are stable but things could change over time. Second, the ARMv4 implementation hashes full SHA blocks. You are responsible for things like padding and side channel counter-measures.&lt;br /&gt;
&lt;br /&gt;
If you experience ''&amp;quot;unexpected reloc type 0x03&amp;quot;'' when building a shared object then see [https://sourceware.org/ml/binutils/2019-05/msg00287.html What does unexpected reloc type 0x03 mean?] on the Binutils mailing list.&lt;br /&gt;
&lt;br /&gt;
==Obtain Source Files==&lt;br /&gt;
&lt;br /&gt;
There are two source files you need for Cryptogams SHA. The first is [https://github.com/openssl/openssl/blob/master/crypto/perlasm/arm-xlate.pl &amp;lt;tt&amp;gt;arm-xlate.pl&amp;lt;/tt&amp;gt;] and the second is [https://github.com/openssl/openssl/blob/master/crypto/sha/asm/sha1-armv4-large.pl &amp;lt;tt&amp;gt;sha1-armv4.pl&amp;lt;/tt&amp;gt;]. They are available in the OpenSSL sources. The following commands fetch OpenSSL and then peels off the two Cryptogams files of interest.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Clone OpenSSL for the latest Cryptogams sources&lt;br /&gt;
git clone https://github.com/openssl/openssl.git&lt;br /&gt;
&lt;br /&gt;
mkdir cryptogams/&lt;br /&gt;
&lt;br /&gt;
cp ./openssl/crypto/perlasm/arm-xlate.pl ./cryptogams/&lt;br /&gt;
cp ./openssl/crypto/sha/asm/sha1-armv4-large.pl ./cryptogams/&lt;br /&gt;
cp ./openssl/crypto/arm_arch.h cryptogams/&lt;br /&gt;
&lt;br /&gt;
cd cryptogams/&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create ASM File==&lt;br /&gt;
&lt;br /&gt;
The second step is to run &amp;lt;tt&amp;gt;sha1-armv4-large.pl&amp;lt;/tt&amp;gt; to produce an assembly language source file that can be consumed by GCC. &amp;lt;tt&amp;gt;sha1-armv4-large.pl&amp;lt;/tt&amp;gt; internally calls &amp;lt;tt&amp;gt;arm-xlate.pl&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;linux32&amp;lt;/tt&amp;gt; is the flavor used by the translate program. &amp;lt;tt&amp;gt;sha1-armv4.S&amp;lt;/tt&amp;gt; is the output filename. In the command below note the &amp;lt;tt&amp;gt;*.S&amp;lt;/tt&amp;gt; file extension, which is a capitol '''''S'''''. Do not use a lowercase '''''s''''' because GCC must drive the compile and assemble step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;perl sha1-armv4-large.pl linux32 sha1-armv4.S&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GCC is needed to drive the process because there are C macros in the source file. Some Cryptogam source files have this requirement, while some others do not. &amp;lt;tt&amp;gt;sha1-armv4&amp;lt;/tt&amp;gt; happens to have the requirement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cat sha1-armv4.S&lt;br /&gt;
@ Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved.&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
#ifndef __KERNEL__&lt;br /&gt;
# include &amp;quot;arm_arch.h&amp;quot;&lt;br /&gt;
#else&lt;br /&gt;
# define __ARM_ARCH__ __LINUX_ARM_ARCH__&lt;br /&gt;
#endif&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point there is an ASM file but it needs two small fixups. First, &amp;lt;tt&amp;gt;arm_arch.h&amp;lt;/tt&amp;gt; is an OpenSSL source file so the dependency must be removed. Second, GCC defines &amp;lt;tt&amp;gt;__ARM_ARCH&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;__ARM_ARCH__&amp;lt;/tt&amp;gt; so a &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; is needed.&lt;br /&gt;
&lt;br /&gt;
To fixup the source files execute the following two commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;# Remove OpenSSL include&lt;br /&gt;
sed -i 's/# include &amp;quot;arm_arch.h&amp;quot;//g' sha1-armv4.S&lt;br /&gt;
&lt;br /&gt;
# Fix GCC defines&lt;br /&gt;
sed -i 's/__ARM_ARCH__/__ARM_ARCH/g' sha1-armv4.S&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternately, instead of the two &amp;lt;tt&amp;gt;sed's&amp;lt;/tt&amp;gt;, you can open &amp;lt;tt&amp;gt;arm_arch.h&amp;lt;/tt&amp;gt;, copy the defines and paste them directly into &amp;lt;tt&amp;gt;sha1-armv4.S&amp;lt;/tt&amp;gt;. Take care when using &amp;lt;tt&amp;gt;arm_arch.h&amp;lt;/tt&amp;gt; as it carries the OpenSSL license.&lt;br /&gt;
&lt;br /&gt;
After the two fixups &amp;lt;tt&amp;gt;sha1-armv4.S&amp;lt;/tt&amp;gt; is ready to be compiled by GCC.&lt;br /&gt;
&lt;br /&gt;
==Compile Source File==&lt;br /&gt;
&lt;br /&gt;
The source file is ready to be compiled and assembled. At this point there are two choices. First, you can use ARMv5t or higher which includes Thumb instructions. The following compiles the source file with ARMv5t.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc -march=armv5t -c sha1-armv4.S&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second choice uses ARMv4 and avoids Thumb instructions. If you want to avoid Thumb then add &amp;lt;tt&amp;gt;-marm&amp;lt;/tt&amp;gt; to you compile command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc -march=armv4 -marm -c sha1-armv4.S&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using ARMv5t as an example you now have an object file with the following symbols. Symbols with a capitol '''''T''''' are public and exported. Symbols with a lower '''''t''''' are private and should not be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc -march=armv4 -marm -c sha1-armv4.S&lt;br /&gt;
$ nm sha1-armv4.o&lt;br /&gt;
00000000 T sha1_block_data_order&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And you can inspect the generated code with &amp;lt;tt&amp;gt;objdump&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ objdump --disassemble sha1-armv4.o&lt;br /&gt;
sha1-armv4.o:     file format elf32-littlearm&lt;br /&gt;
&lt;br /&gt;
Disassembly of section .text:&lt;br /&gt;
&lt;br /&gt;
00000000 &amp;lt;sha1_block_data_order&amp;gt;:&lt;br /&gt;
   0:   e92d5ff0        push    {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr}&lt;br /&gt;
   4:   e0812302        add     r2, r1, r2, lsl #6&lt;br /&gt;
   8:   e89000f8        ldm     r0, {r3, r4, r5, r6, r7}&lt;br /&gt;
   c:   e59f858c        ldr     r8, [pc, #1420] ; 5a0 &amp;lt;sha1_block_data_order+0x5a0&amp;gt;&lt;br /&gt;
  10:   e1a0e00d        mov     lr, sp&lt;br /&gt;
  14:   e24dd03c        sub     sp, sp, #60     ; 0x3c&lt;br /&gt;
  18:   e1a05f65        ror     r5, r5, #30&lt;br /&gt;
  1c:   e1a06f66        ror     r6, r6, #30&lt;br /&gt;
&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine API==&lt;br /&gt;
&lt;br /&gt;
The next step is determine the API so you can call it from a C program. Unfortunately the API is not documented and you have to dig around the OpenSSL sources. Fortunately there is one function of interest called &amp;lt;tt&amp;gt;sha1_block_data_order&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A quick &amp;lt;tt&amp;gt;grep&amp;lt;/tt&amp;gt; of OpenSSL sources reveals the following for &amp;lt;tt&amp;gt;sha1_block_data_order&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;openssl$ grep -nIR sha1_block_data_order | grep '\.c'&lt;br /&gt;
crypto/evp/e_sha_cbc_hmac_sha1.c:95:    void sha1_block_data_order(void *c, const void *p, size_t len);&lt;br /&gt;
crypto/evp/e_sha_cbc_hmac_sha1.c:115:        sha1_block_data_order(c, ptr, len / SHA_CBLOCK);&lt;br /&gt;
crypto/evp/e_sha_cbc_hmac_sha1.c:615:        sha1_block_data_order(&amp;amp;key-&amp;gt;md, data, 1);&lt;br /&gt;
crypto/evp/e_sha_cbc_hmac_sha1.c:631:        sha1_block_data_order(&amp;amp;key-&amp;gt;md, data, 1);&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need several more symbols, and and they are &amp;lt;tt&amp;gt;OPENSSL_armcap_P&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;ARMV7_NEON&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ARMV8_SHA1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ grep -nIR OPENSSL_armcap_P&lt;br /&gt;
...&lt;br /&gt;
crypto/armcap.c:20:unsigned int OPENSSL_armcap_P = 0;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lather, rinse, repeat for &amp;lt;tt&amp;gt;ARMV7_NEON&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ARMV8_SHA1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Create C Header==&lt;br /&gt;
&lt;br /&gt;
The fifth step creates a C header file based on information from [[#Determine_API|Determine API]]. The header file is needed for two reasons. First, it removes the OpenSSL dependency from your project. Second, it avoids OpenSSL licensing violations.&lt;br /&gt;
&lt;br /&gt;
Below is the C Header file you can use. While it is not obvious, the &amp;lt;tt&amp;gt;len&amp;lt;/tt&amp;gt; parameter from [[#Determine_API|Determine API]] is a block count, not a byte count.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Header file for use with Cryptogam's ARMv4 SHA1.    */&lt;br /&gt;
/* Also see http://www.openssl.org/~appro/cryptogams/  */&lt;br /&gt;
/* https://wiki.openssl.org/index.php/Cryptogams_SHA.  */&lt;br /&gt;
&lt;br /&gt;
#ifndef CRYPTOGAMS_SHA1_ARMV4_H&lt;br /&gt;
#define CRYPTOGAMS_SHA1_ARMV4_H&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
extern &amp;quot;C&amp;quot; {&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
extern unsigned int OPENSSL_armcap_P;&lt;br /&gt;
void sha1_block_data_order(void *state, const void *data, size_t blocks);&lt;br /&gt;
&lt;br /&gt;
/* Auxval caps */&lt;br /&gt;
#ifndef HWCAP_NEON&lt;br /&gt;
# define HWCAP_NEON (1 &amp;lt;&amp;lt; 12)&lt;br /&gt;
#endif&lt;br /&gt;
#ifndef HWCAP_SHA1&lt;br /&gt;
# define HWCAP_SHA1 (1 &amp;lt;&amp;lt; 5)&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/* OpenSSL caps */&lt;br /&gt;
#define ARMV7_NEON (1&amp;lt;&amp;lt;0)&lt;br /&gt;
#define ARMV8_SHA1 (1&amp;lt;&amp;lt;3)&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#endif  /* CRYPTOGAMS_SHA1_ARMV4_H */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Test Program==&lt;br /&gt;
&lt;br /&gt;
The final step is to test the integration of Cryptogam's SHA with your program.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc -std=c99 sha1-armv4-test.c ./sha1-armv4.o -o sha1-armv4-test.exe&lt;br /&gt;
$ ./sha1-armv4-test.exe&lt;br /&gt;
SHA1 hash of empty message: DA39A3EE5E6B4B0D...&lt;br /&gt;
Success!&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the test program is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#define _GNU_SOURCE&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/auxv.h&amp;gt;&lt;br /&gt;
#include &amp;quot;sha1-armv4.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
/* processor caps */&lt;br /&gt;
unsigned int OPENSSL_armcap_P = 0;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    /* processor caps */&lt;br /&gt;
    if (getauxval(AT_HWCAP) &amp;amp; HWCAP_NEON)&lt;br /&gt;
        OPENSSL_armcap_P |= ARMV7_NEON;&lt;br /&gt;
    if (getauxval(AT_HWCAP) &amp;amp; HWCAP_SHA1)&lt;br /&gt;
        OPENSSL_armcap_P |= ARMV8_SHA1;&lt;br /&gt;
&lt;br /&gt;
    /* empty message with padding */&lt;br /&gt;
    uint8_t message[64];&lt;br /&gt;
    memset(message, 0x00, sizeof(message));&lt;br /&gt;
    message[0] = 0x80;&lt;br /&gt;
&lt;br /&gt;
    /* initial state */&lt;br /&gt;
    uint32_t state[5] = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};&lt;br /&gt;
&lt;br /&gt;
    sha1_block_data_order(state, message, 1);&lt;br /&gt;
&lt;br /&gt;
    const uint8_t b1 = (uint8_t)(state[0] &amp;gt;&amp;gt; 24);&lt;br /&gt;
    const uint8_t b2 = (uint8_t)(state[0] &amp;gt;&amp;gt; 16);&lt;br /&gt;
    const uint8_t b3 = (uint8_t)(state[0] &amp;gt;&amp;gt;  8);&lt;br /&gt;
    const uint8_t b4 = (uint8_t)(state[0] &amp;gt;&amp;gt;  0);&lt;br /&gt;
    const uint8_t b5 = (uint8_t)(state[1] &amp;gt;&amp;gt; 24);&lt;br /&gt;
    const uint8_t b6 = (uint8_t)(state[1] &amp;gt;&amp;gt; 16);&lt;br /&gt;
    const uint8_t b7 = (uint8_t)(state[1] &amp;gt;&amp;gt;  8);&lt;br /&gt;
    const uint8_t b8 = (uint8_t)(state[1] &amp;gt;&amp;gt;  0);&lt;br /&gt;
&lt;br /&gt;
    /* DA39A3EE5E6B4B0D... */&lt;br /&gt;
    printf(&amp;quot;SHA1 hash of empty message: &amp;quot;);&lt;br /&gt;
    printf(&amp;quot;%02X%02X%02X%02X%02X%02X%02X%02X...\n&amp;quot;,&lt;br /&gt;
        b1, b2, b3, b4, b5, b6, b7, b8);&lt;br /&gt;
&lt;br /&gt;
    int success = ((b1 == 0xDA) &amp;amp;&amp;amp; (b2 == 0x39) &amp;amp;&amp;amp; (b3 == 0xA3) &amp;amp;&amp;amp; (b4 == 0xEE) &amp;amp;&amp;amp;&lt;br /&gt;
                    (b5 == 0x5E) &amp;amp;&amp;amp; (b6 == 0x6B) &amp;amp;&amp;amp; (b7 == 0x4B) &amp;amp;&amp;amp; (b8 == 0x0D));&lt;br /&gt;
&lt;br /&gt;
    if (success)&lt;br /&gt;
        printf(&amp;quot;Success!\n&amp;quot;);&lt;br /&gt;
    else&lt;br /&gt;
        printf(&amp;quot;Failure!\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    return (success != 0 ? 0 : 1);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Symbol Names==&lt;br /&gt;
&lt;br /&gt;
The article used the same names as they appeared in the Cryptogams source code. For example, &amp;lt;tt&amp;gt;sha1_block_data_order&amp;lt;/tt&amp;gt; is the names of function in the source code, and they will show up in the object file and when compiled and in the library when linked.&lt;br /&gt;
&lt;br /&gt;
It is possible the function and date names will collide if you also link to OpenSSL, either directly or indirectly. If you plan on using Cryptogams code in a shared object then you should rename all symbols to avoid collisions. To rename symbols for SHA-1 you should rename &amp;lt;tt&amp;gt;sha1_block_data_order&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPENSSL_armcap_P&amp;lt;/tt&amp;gt;. Assuming you are using &amp;lt;tt&amp;gt;MYLIB&amp;lt;/tt&amp;gt; as a prefix the following &amp;lt;tt&amp;gt;sed&amp;lt;/tt&amp;gt; should do the job.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;sed -i 's/OPENSSL/MYLIB/g' sha1_armv4.h sha1_armv4.S&lt;br /&gt;
sed -i 's/sha1_block_data_order/MYLIB_sha1_block_data_order/g' sha1_armv4.h sha1_armv4.S&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can verify public symbols were renamed with &amp;lt;tt&amp;gt;nm aes-armv4.o&amp;lt;/tt&amp;gt;. Generally speaking, all symbols with capitol letters like &amp;lt;tt&amp;gt;T&amp;lt;/tt&amp;gt; (public function), &amp;lt;tt&amp;gt;B&amp;lt;/tt&amp;gt; (uninitialized data), &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt; (common data), &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt; (initialized data), and &amp;lt;tt&amp;gt;R&amp;lt;/tt&amp;gt; (read-only data) should be renamed.&lt;br /&gt;
&lt;br /&gt;
==Benchmarks==&lt;br /&gt;
&lt;br /&gt;
You can perform a rough benchmark using the code shown below. Prior to executing the benchmark program you should move the CPU from &amp;lt;tt&amp;gt;on-demand&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;powersave&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#define _GNU_SOURCE&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
#include &amp;lt;time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/auxv.h&amp;gt;&lt;br /&gt;
#include &amp;quot;sha1-armv4.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
/* processor caps */&lt;br /&gt;
unsigned int OPENSSL_armcap_P = 0;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char* argv[])&lt;br /&gt;
{&lt;br /&gt;
    /* set processor caps */&lt;br /&gt;
    if (getauxval(AT_HWCAP) &amp;amp; HWCAP_NEON)&lt;br /&gt;
        OPENSSL_armcap_P |= ARMV7_NEON;&lt;br /&gt;
    if (getauxval(AT_HWCAP) &amp;amp; HWCAP_SHA1)&lt;br /&gt;
        OPENSSL_armcap_P |= ARMV8_SHA1;&lt;br /&gt;
&lt;br /&gt;
    const unsigned int STEPS = 128;&lt;br /&gt;
    uint8_t* buf = (uint8_t*)malloc(STEPS*64+64);&lt;br /&gt;
    memset(buf, 0x00, 16);&lt;br /&gt;
&lt;br /&gt;
    double elapsed = 0.0;&lt;br /&gt;
    size_t total = 0;&lt;br /&gt;
&lt;br /&gt;
    struct timespec start, end;&lt;br /&gt;
    clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &amp;amp;start);&lt;br /&gt;
&lt;br /&gt;
    uint32_t state[5] = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};&lt;br /&gt;
&lt;br /&gt;
    do&lt;br /&gt;
    {&lt;br /&gt;
        size_t idx = 0;&lt;br /&gt;
        for (unsigned int i=0; i&amp;lt;STEPS; ++i)&lt;br /&gt;
            sha1_block_data_order(state, buf, idx+1);&lt;br /&gt;
        total += 64*STEPS;&lt;br /&gt;
        &lt;br /&gt;
        clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &amp;amp;end);&lt;br /&gt;
        elapsed = (end.tv_sec-start.tv_sec);&lt;br /&gt;
    }&lt;br /&gt;
    while (elapsed &amp;lt; 3 /* seconds */);&lt;br /&gt;
&lt;br /&gt;
    /* Increase precision of elapsed time */&lt;br /&gt;
    elapsed = ((double)end.tv_sec-start.tv_sec) +&lt;br /&gt;
              ((double)end.tv_nsec-start.tv_nsec) / 1000 / 1000 / 1000;&lt;br /&gt;
&lt;br /&gt;
    /* CPU freq of 1 GHz */&lt;br /&gt;
    const double cpuFreq = 1000.0*1000*1000;&lt;br /&gt;
&lt;br /&gt;
    const double bytes = total;&lt;br /&gt;
    const double ghz = cpuFreq / 1000 / 1000 / 1000;&lt;br /&gt;
    const double mbs = bytes / elapsed / 1024 / 1024;&lt;br /&gt;
    const double cpb = elapsed * cpuFreq / bytes;&lt;br /&gt;
    &lt;br /&gt;
    printf(&amp;quot;%.0f bytes\n&amp;quot;, bytes);&lt;br /&gt;
    printf(&amp;quot;%.02f mbs\n&amp;quot;, mbs);&lt;br /&gt;
    printf(&amp;quot;%.02f cpb\n&amp;quot;, cpb);&lt;br /&gt;
    &lt;br /&gt;
    free(buf);&lt;br /&gt;
    &lt;br /&gt;
    return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results below are from a [https://www.amazon.com/gp/product/B07D4L7GXZ Libre Computer Tritium H3] with a Cortex-A7 Sun7i SoC running at 1 GHz. A C/C++ SHA implementation runs about 22 cpb on the dev-board. Notice &amp;lt;tt&amp;gt;sha1-armv4.S&amp;lt;/tt&amp;gt; was compiled with &amp;lt;tt&amp;gt;-march=armv7&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ gcc -std=c99 -march=armv7 -c sha1-armv4.S -o sha1-armv7.o&lt;br /&gt;
$ gcc -O3 -std=c99 sha1-armv7-test.c sha1-armv7.o -o sha1-armv7-test.exe&lt;br /&gt;
$ ./sha1-armv7-test.exe&lt;br /&gt;
180994048 bytes&lt;br /&gt;
57.59 mbs&lt;br /&gt;
16.56 cpb&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== iOS Builds ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sha1-armv4&amp;lt;/tt&amp;gt; can be configured for iOS. Simply use &amp;lt;tt&amp;gt;ios32&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;ios64&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;linux32&amp;lt;/tt&amp;gt; as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ perl sha1-armv4-large.pl ios32 sha1-armv4.S&lt;br /&gt;
$ clang -arch armv7 sha1-armv4.S -c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ nm sha1-armv4.o&lt;br /&gt;
000012d0 s OPENSSL_armcap_P&lt;br /&gt;
00000004 C _OPENSSL_armcap_P&lt;br /&gt;
00000000 T _sha1_block_data_order&lt;br /&gt;
00001100 t sha1_block_data_order_armv8&lt;br /&gt;
00000560 t sha1_block_data_order_neon&lt;br /&gt;
&lt;br /&gt;
$ otool -tV sha1-armv4.o&lt;br /&gt;
sha1-armv4.o:&lt;br /&gt;
(__TEXT,__text) section&lt;br /&gt;
_sha1_block_data_order:&lt;br /&gt;
00000000        f8dfc4ec        ldr.w   r12, [pc, #0x4ec]&lt;br /&gt;
00000004        f2af0308        subw    r3, pc, #0x8&lt;br /&gt;
00000008        f853c00c        ldr.w   r12, [r3, r12]&lt;br /&gt;
0000000c        f8dcc000        ldr.w   r12, [r12]&lt;br /&gt;
00000010        f01c0f08        tst.w   r12, #0x8&lt;br /&gt;
00000014        f0418074        bne.w   sha1_block_data_order_armv8&lt;br /&gt;
00000018        f01c0f01        tst.w   r12, #0x1&lt;br /&gt;
0000001c        f04082a0        bne.w   sha1_block_data_order_neon&lt;br /&gt;
00000020        e92d5ff0        push.w  {r4, r5, r6, r7, r8, r9, r10, r11, r12, lr}&lt;br /&gt;
...&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[Category:Cryptogams]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_mode()&amp;diff=2862</id>
		<title>Talk:FIPS mode()</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_mode()&amp;diff=2862"/>
		<updated>2019-08-09T19:06:17Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Feel free to edit the notice, especially in case anyone thinks it's too intense. I figured users should be immediately told if the functionality they're expecting but aren't getting isn't because of an error they on their end.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 16:05, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: I removed the notice and made some changes per Matt's request. The thread at the [[Talk:FIPS Mode|FIPS mode talk page]] has all of the details.&lt;br /&gt;
: &lt;br /&gt;
: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 19:06, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2861</id>
		<title>Talk:FIPS Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2861"/>
		<updated>2019-08-09T19:05:10Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;lt;tt&amp;gt;FIPS Mode&amp;lt;/tt&amp;gt; link on the home page was broken, so I added a redirect as a stopgap, but I think it would be better to use this page to explain what FIPS mode is, and then include a link to the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:31, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yes, I agree. And actually the FIPS_mode() page that you have redirected to would be better off as a man page in the source repo rather than as a wiki page. Of course in 1.1.1 this function doesn't do anything at all (although it exists). In 3.0 it will do something again, but that code needs to be implemented.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 15:36, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: That's good to know, I actually didn't know that. I'll make a note of that on the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page, as there's currently no indication it doesn't do anything right now.&lt;br /&gt;
:&lt;br /&gt;
: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:53, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: Just to clarify my earlier comment. It does do something in 1.0.2 too. 1.0.2 is a FIPS capable release, 1.1.1 is not FIPS capable, 3.0 will be FIPS capable again. Confused yet? :-)&lt;br /&gt;
: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 16:07, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: Oh, wow, now I really am confused. Can you take a look at the [[FIPS_mode()]] page? I added a notice based on the first thing you told me, but now I'm not sure it's right, and I don't want others to share in my current state of confusion haha.&lt;br /&gt;
::&lt;br /&gt;
:: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 16:20, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
::: No, it's not quite right. I'd remove the notice and add something in the body of the text saying that OpenSSL 1.1.0 and 1.1.1 are not FIPS capable and therefore this function always returns 0 in those releases&lt;br /&gt;
::: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 16:24, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:::: Okay, I just finished making the changes. Could I bother you again to take a look and let me know what you think? Thanks for the feedback.&lt;br /&gt;
:::: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 19:05, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=FIPS_mode()&amp;diff=2860</id>
		<title>FIPS mode()</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=FIPS_mode()&amp;diff=2860"/>
		<updated>2019-08-09T19:03:30Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Removed the previously added notice and updated the page as per Matt's suggestions on the FIPS mode talk page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''FIPS_mode()''' function is used to determine the current [[FIPS]] [[FIPS 140-2|140-2]] mode of operation by a program utilizing the services of the validated library. The library must have been built with the [[FIPS Object Module]], and the FIPS Object Module must have been acquired, built, and installed in accordance with the [https://www.openssl.org/docs/fips/SecurityPolicy-2.0.16.pdf security policy].&lt;br /&gt;
&lt;br /&gt;
The return value is either &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; to indicate that the FIPS mode of operation is not enabled, or the value used for the &amp;lt;tt&amp;gt;ONOFF&amp;lt;/tt&amp;gt; parameter passed to an earlier successful call to &amp;lt;tt&amp;gt;FIPS_mode_set()&amp;lt;/tt&amp;gt;. Effectively, any non-zero value indicates FIPS mode. Values other than &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt; may have additional significance, such as designating an additional restriction to [[Suite B]] algorithms.&lt;br /&gt;
&lt;br /&gt;
The only current [[FIPS]]-capable release of OpenSSL is version 1.0.2. Calling the function from an application linked to OpenSSL versions &amp;lt;tt&amp;gt;1.1.0&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;1.1.1&amp;lt;/tt&amp;gt; will always return &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt;, indicating non-FIPS mode, with an error code of &amp;lt;tt&amp;gt;CRYPTO_R_FIPS_MODE_NOT_SUPPORTED (0x0f06d065)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
FIPS support was introduced in version 0.9.7 of [https://www.openssl.org/ OpenSSL].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Example =&lt;br /&gt;
To call the function, the OpenSSL &amp;lt;tt&amp;gt;crypto&amp;lt;/tt&amp;gt; header must be included.&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;openssl/crypto.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function itself takes no parameters, and returns an integer indicating the mode of operation as described above.&lt;br /&gt;
&lt;br /&gt;
 int FIPS_MODE(void);&lt;br /&gt;
&lt;br /&gt;
In the following example, the program tests the return value of the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; function call, exiting with an error if the library being linked to is not FIPS-capable. The return value of the function is saved because the return code may carry additional information, in addition to FIPS-capability (see above).&lt;br /&gt;
&lt;br /&gt;
 int fips_compatible_build = -1;&lt;br /&gt;
 &lt;br /&gt;
 if ((fips_compatible_build = FIPS_mode()) == 0) {&lt;br /&gt;
     fprintf(stderr, &amp;quot;The current version of OpenSSL is not FIPS-capable.\n&amp;quot;);&lt;br /&gt;
     exit(EXIT_FAILURE);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
* FIPS_mode_set(3)&lt;br /&gt;
* FIPS_selftest(3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
&amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; was formerly included with &amp;lt;openssl/fips.h&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= External Links =&lt;br /&gt;
* Information regarding the [https://www.openssl.org/docs/fips.html OpenSSL FIPS 140-2 validation] at the [https://www.openssl.org/ OpenSSL] project.&lt;br /&gt;
* [https://www.openssl.org/docs/fips/SecurityPolicy-2.0.16.pdf OpenSSL Security Policy]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:FIPS 140-2]]&lt;br /&gt;
[[Category:Crypto API]]&lt;br /&gt;
[[Category:C level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2858</id>
		<title>Talk:FIPS Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2858"/>
		<updated>2019-08-09T16:20:27Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;lt;tt&amp;gt;FIPS Mode&amp;lt;/tt&amp;gt; link on the home page was broken, so I added a redirect as a stopgap, but I think it would be better to use this page to explain what FIPS mode is, and then include a link to the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:31, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yes, I agree. And actually the FIPS_mode() page that you have redirected to would be better off as a man page in the source repo rather than as a wiki page. Of course in 1.1.1 this function doesn't do anything at all (although it exists). In 3.0 it will do something again, but that code needs to be implemented.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 15:36, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: That's good to know, I actually didn't know that. I'll make a note of that on the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page, as there's currently no indication it doesn't do anything right now.&lt;br /&gt;
:&lt;br /&gt;
: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:53, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: Just to clarify my earlier comment. It does do something in 1.0.2 too. 1.0.2 is a FIPS capable release, 1.1.1 is not FIPS capable, 3.0 will be FIPS capable again. Confused yet? :-)&lt;br /&gt;
: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 16:07, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: Oh, wow, now I really am confused. Can you take a look at the [[FIPS_mode()]] page? I added a notice based on the first thing you told me, but now I'm not sure it's right, and I don't want others to share in my current state of confusion haha.&lt;br /&gt;
::&lt;br /&gt;
:: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 16:20, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_mode()&amp;diff=2856</id>
		<title>Talk:FIPS mode()</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_mode()&amp;diff=2856"/>
		<updated>2019-08-09T16:05:50Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created page with &amp;quot;Feel free to edit the notice, especially in case anyone thinks it's too intense. I figured users should be immediately told if the functionality they're expecting but aren't g...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Feel free to edit the notice, especially in case anyone thinks it's too intense. I figured users should be immediately told if the functionality they're expecting but aren't getting isn't because of an error they on their end.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 16:05, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=FIPS_mode()&amp;diff=2855</id>
		<title>FIPS mode()</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=FIPS_mode()&amp;diff=2855"/>
		<updated>2019-08-09T16:03:45Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added a notice indicating the version in the current release has no functionality&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left: auto; margin-right: auto; margin-top: 36px; margin-bottom: 36px; text-align: center; background-color: #FF8787; border: 1px solid #FA0000;&amp;quot;&lt;br /&gt;
| style=&amp;quot;font-size: 16px; font-weight: bold; border: none; padding: 8px;&amp;quot; | Not Currently Implemented&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;border: none; padding-left: 16px; padding-right: 16px; padding-bottom: 8px;&amp;quot; | This function as currently implemented does nothing. It is part of the currently-planned 3.0.0 release, but has not yet been written.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NAME'''&lt;br /&gt;
&lt;br /&gt;
FIPS_mode - retrieve the current FIPS 140-2 mode of operation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''SYNOPSIS'''&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;openssl/crypto.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 int FIPS_mode(void);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''DESCRIPTION'''&lt;br /&gt;
&lt;br /&gt;
FIPS_mode() is used to determine the FIPS mode of operation by a program utilizing the services of the validated library. The library must have been built with the FIPS Object Module, and the FIPS Object Module must have been acquired, built, and installed in accordance with the Security Policy.&lt;br /&gt;
&lt;br /&gt;
The return value is either 0 to indicate that the FIPS mode of operation is not enabled, or the value used for the ONOFF parameter passed to an earlier successful call to FIPS_mode_set(). Effectively any non-zero value indicates FIPS mode; values other than 1 may have additional significance such as designating an additional restriction to Suite B algorithms.&lt;br /&gt;
&lt;br /&gt;
If the library was built without support of the FIPS Object Module, then the function will return 0 with an error code of CRYPTO_R_FIPS_MODE_NOT_SUPPORTED (0x0f06d065).&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''RETURN VALUES'''&lt;br /&gt;
&lt;br /&gt;
A return code of non-zero indicates FIPS mode, 0 indicates non-FIPS mode. When called from a version of OpenSSL that is not &amp;quot;FIPS capable&amp;quot; (capable of utilizing an embedded FIPS Object Module), then FIPS_mode() will always return 0.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''SEE ALSO'''&lt;br /&gt;
&lt;br /&gt;
FIPS_mode_set(3), FIPS_selftest(3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''NOTES'''&lt;br /&gt;
&lt;br /&gt;
FIPS_mode() was formerly included with &amp;lt;openssl/fips.h&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
'''HISTORY'''&lt;br /&gt;
&lt;br /&gt;
FIPS support was introduced in version 0.9.7 of OpenSSL.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:FIPS 140-2]]&lt;br /&gt;
[[Category:Crypto API]]&lt;br /&gt;
[[Category:C level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2854</id>
		<title>Talk:FIPS Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2854"/>
		<updated>2019-08-09T15:53:51Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;lt;tt&amp;gt;FIPS Mode&amp;lt;/tt&amp;gt; link on the home page was broken, so I added a redirect as a stopgap, but I think it would be better to use this page to explain what FIPS mode is, and then include a link to the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:31, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yes, I agree. And actually the FIPS_mode() page that you have redirected to would be better off as a man page in the source repo rather than as a wiki page. Of course in 1.1.1 this function doesn't do anything at all (although it exists). In 3.0 it will do something again, but that code needs to be implemented.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 15:36, 9 August 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: That's good to know, I actually didn't know that. I'll make a note of that on the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page, as there's currently no indication it doesn't do anything right now.&lt;br /&gt;
:&lt;br /&gt;
: -- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:53, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Base64&amp;diff=2852</id>
		<title>Base64</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Base64&amp;diff=2852"/>
		<updated>2019-08-09T15:34:33Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added page to the Examples and C level categories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Encode binary information 8 bits into ASCII.&lt;br /&gt;
&lt;br /&gt;
This is PEM base encode, it exists other base64 encoding scheme like this used by crypt.&lt;br /&gt;
&lt;br /&gt;
== Algorithm ==&lt;br /&gt;
&lt;br /&gt;
3 x 8 bits binary are concatenated to form a 24bits word that is split in 4 x 6bits each being translating into an ascii value using a character ordered in following list :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ &lt;br /&gt;
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||&lt;br /&gt;
0000000000111111111122222222223333333333444444444455555555556666&lt;br /&gt;
0123456789012345678901234567890123456789012345678901234567890123&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[what makes 26 * 2 + 10 + 2 = 64 values]&lt;br /&gt;
&lt;br /&gt;
Since it encodes by group of 3 bytes, when last group of 3 bytes miss one byte then = is used, when it miss 2 bytes then == is used for padding.&lt;br /&gt;
&lt;br /&gt;
== Openssl command ==&lt;br /&gt;
&lt;br /&gt;
base64 or -enc base64 can be used to decode lines see [[Command_Line_Utilities]]&lt;br /&gt;
&lt;br /&gt;
== EVP API ==&lt;br /&gt;
&lt;br /&gt;
crypto/evp/encode.c&lt;br /&gt;
crypto/evp/bio_b64.C&lt;br /&gt;
&lt;br /&gt;
If you need to encode a block of data, use the '''&amp;lt;tt&amp;gt;EVP_EncodeBlock&amp;lt;/tt&amp;gt;''' function, example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
unsigned char sourceData[16] = {0x30,0x82,0x07,0x39,0x30,0x82,0x05,0x21,0xA0,0x03,0x02,0x01,0x02,0x02,0x04,0x00};&lt;br /&gt;
char encodedData[100];&lt;br /&gt;
EVP_EncodeBlock((unsigned char *)encodedData, sourceData, 16);&lt;br /&gt;
printf(encodedData);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== WARNINGS ===&lt;br /&gt;
&lt;br /&gt;
=== other unsupported base64 scheme ===&lt;br /&gt;
&lt;br /&gt;
Warning crypt() password encryption function uses another base64 scheme which is not the openssl base64 one. :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&lt;br /&gt;
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||&lt;br /&gt;
0000000000111111111122222222223333333333444444444455555555556666&lt;br /&gt;
0123456789012345678901234567890123456789012345678901234567890123&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== base64 uses PEM 80 characters per line ===&lt;br /&gt;
&lt;br /&gt;
Base64 itself does not impose a line split, but openssl uses it in PEM context hence enforce that base64 content is splitted by lines with a maximum of 80 characters.&lt;br /&gt;
&lt;br /&gt;
With C code it is possible to ask to disregard lines breaks : BIO_set_flags(d,BIO_FLAGS_BASE64_NO_NL);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Encoding]]&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:C level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2851</id>
		<title>Talk:FIPS Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:FIPS_Mode&amp;diff=2851"/>
		<updated>2019-08-09T15:31:34Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created page with &amp;quot;The &amp;lt;tt&amp;gt;FIPS Mode&amp;lt;/tt&amp;gt; link on the home page was broken, so I added a redirect as a stopgap, but I think it would be better to use this page to explain what FIPS mode is, and...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &amp;lt;tt&amp;gt;FIPS Mode&amp;lt;/tt&amp;gt; link on the home page was broken, so I added a redirect as a stopgap, but I think it would be better to use this page to explain what FIPS mode is, and then include a link to the &amp;lt;tt&amp;gt;FIPS_mode()&amp;lt;/tt&amp;gt; page.&lt;br /&gt;
&lt;br /&gt;
-- [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:31, 9 August 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=FIPS_Mode&amp;diff=2850</id>
		<title>FIPS Mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=FIPS_Mode&amp;diff=2850"/>
		<updated>2019-08-09T15:26:48Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created as a redirect to the FIPS_mode(), as it did not currently exist&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[FIPS_mode()]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2849</id>
		<title>Template:Broken Link</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2849"/>
		<updated>2019-08-06T05:56:01Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Modified so that the template itself is not included in the category of all pages with a broken link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sup&amp;gt;[[:Category:Broken Links|[Broken Link]]]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
==Overview==&lt;br /&gt;
The purpose of this template is to group all of the outstanding broken links in the wiki into the [[:Category:Broken Links|broken links]] category.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;&lt;br /&gt;
[[Category:Broken Links]]&lt;br /&gt;
&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2847</id>
		<title>Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2847"/>
		<updated>2019-07-30T21:11:58Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added section on 1-step ecc key generation, as per Matt's suggestion on the discussion page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''openssl''' program provides a rich variety of commands, each of which often has a wealth of options and arguments. Many commands use an external configuration file for some or all of their arguments and have a &amp;lt;code&amp;gt;-config&amp;lt;/code&amp;gt; option to specify that file. The environment variable [[OPENSSL_CONF]] can be used to specify the location of the configuration file. If the environment variable is not specified, a default file is created in the default certificate storage area called '''openssl.cnf'''. The settings in this default configuration file depend on the flags set when the version of OpenSSL being used was built.&lt;br /&gt;
&lt;br /&gt;
This article is an overview of the available tools provided by openssl. For all of the details on usage and implementation, you can find the [https://www.openssl.org/docs/manmaster/ manpages] which are automatically generated from the source code at the [https://www.openssl.org/ official OpenSSL project home]. Likewise, the source code itself may be found on the [https://www.openssl.org/source/ OpenSSL project home page], as well as on the [https://github.com/openssl/openssl OpenSSL Github]. The main OpenSSL site also includes an [https://www.openssl.org/docs/manmaster/man1/openssl.html overview of the command-line utilities], as well as links to all of their respective documentation.&lt;br /&gt;
&lt;br /&gt;
=Getting Started=&lt;br /&gt;
&lt;br /&gt;
The entry point for the OpenSSL library is the '''openssl''' binary, usually &amp;lt;tt&amp;gt;/usr/bin/openssl&amp;lt;/tt&amp;gt; on Linux. The general syntax for calling openssl is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl command [ command_options ] [ command_arguments ]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can call openssl without arguments to enter the interactive mode prompt. You may then enter commands directly, exiting with either a &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt; command or by issuing a termination signal with either &amp;lt;tt&amp;gt;Ctrl+C&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Ctrl+D&amp;lt;/tt&amp;gt;. The following is a sample interactive session in which the user invokes the [[prime]] command twice before using the &amp;lt;tt&amp;gt;quit&amp;lt;/tt&amp;gt; command to terminate the session.&lt;br /&gt;
&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 13467269&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 16651079&lt;br /&gt;
 OpenSSL&amp;gt; quit&lt;br /&gt;
&lt;br /&gt;
=Basic Tasks=&lt;br /&gt;
&lt;br /&gt;
This section is a brief tutorial on performing the most basic tasks using OpenSSL. For a detailed explanation of the rationale behind the syntax and semantics of the commands shown here, see the section on [[#Commands|Commands]].&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, the general syntax of a command is &amp;lt;code&amp;gt;openssl command [ command_options ] [ command_arguments ]&amp;lt;/code&amp;gt;. The help command is no different, but it does have its idiosyncrasies. To view the top-level help menu, you can call openssl as follows.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help&lt;br /&gt;
&lt;br /&gt;
This query will print all of the available commands, like so:&lt;br /&gt;
&lt;br /&gt;
 Standard commands&lt;br /&gt;
 asn1parse         ca                ciphers           cms               &lt;br /&gt;
 crl               crl2pkcs7         dgst              dhparam           &lt;br /&gt;
 dsa               dsaparam          ec                ecparam&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Note the above output was truncated, so only the first four lines of output are shown.&lt;br /&gt;
&lt;br /&gt;
A help menu for each command may be requested in two different ways. First, the same command used above may be repeated, followed by the name of the command to print help for.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
&lt;br /&gt;
The program will then display the valid options for the given command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
The second way of requesting the help menu for a particular command is by using the first option in the output shown above, namely &amp;lt;code&amp;gt;openssl command -help&amp;lt;/code&amp;gt;. Both commands will yield the same output; the help menu displayed will be exactly the same.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -help&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
For additional information on the usage of a particular command, the project [https://www.openssl.org/docs/manpages.html manpages] are a great source of information. Another excellent source of information is the project perldocs. [https://perldoc.perl.org/5.30.0/perldoc.html perldoc] is a utility included with most if not all [https://www.perl.org/ Perl] distributions, and it's capable of displaying documentation information in a variety of formats, one of which is as manpages. Not surprisingly, the project documentation is generated from the pod files located in the &amp;lt;tt&amp;gt;doc&amp;lt;/tt&amp;gt; directory of the source code.&lt;br /&gt;
&lt;br /&gt;
==Getting Library Version Information==&lt;br /&gt;
&lt;br /&gt;
 $ openssl version&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
&lt;br /&gt;
As mentioned above, the &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; command's help menu may be queried for additional options like so:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -help&lt;br /&gt;
 Usage: version [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help  Display this summary&lt;br /&gt;
  -a     Show all data&lt;br /&gt;
  -b     Show build date&lt;br /&gt;
  -d     Show configuration directory&lt;br /&gt;
  -e     Show engines directory&lt;br /&gt;
  -f     Show compiler flags used&lt;br /&gt;
  -o     Show some internal datatype options&lt;br /&gt;
  -p     Show target build platform&lt;br /&gt;
  -r     Show random seeding options&lt;br /&gt;
  -v     Show library version&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;tt&amp;gt;-a&amp;lt;/tt&amp;gt; option to show all version information yields the following output on my current machine:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -a&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
 built on: Tue May 28 16:23:39 2019 UTC&lt;br /&gt;
 platform: linux-x86_64&lt;br /&gt;
 options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) &lt;br /&gt;
 compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -D_FORTIFY_SOURCE=2&lt;br /&gt;
 OPENSSLDIR: &amp;quot;/etc/ssl&amp;quot;&lt;br /&gt;
 ENGINESDIR: &amp;quot;/usr/lib/engines-1.1&amp;quot;&lt;br /&gt;
 Seeding source: os-specific&lt;br /&gt;
&lt;br /&gt;
==Generating an RSA Private Key==&lt;br /&gt;
&lt;br /&gt;
Generating a private key can be done in a variety of different ways depending on the type of key, algorithm, bits, and other options your specific use case may require. In this example, we are generating a private key using RSA and a key size of 2048 bits.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
To generate a password protected private key, the previous command may be slightly amended as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
The addition of the &amp;lt;tt&amp;gt;-aes256&amp;lt;/tt&amp;gt; option specifies the cipher to use to encrypt the private key file. For a list of available ciphers in the library, you can run the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
&lt;br /&gt;
With your private key in hand, you can use the following command to see the key's details, such as its modulus and its constituent primes. Remember to change the name of the input file to the file name of your private key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
&lt;br /&gt;
The above command yields the following output in my specific case. Your output will differ but should be structurally similar.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDZD6IMLRFk4CaF&lt;br /&gt;
 w0rhRienwuE5EZ6xFE8e3C5TVi1+d9Enhi38RgkwD7UlWxPE6AWhp5T3kfrFWdak&lt;br /&gt;
 1lZFVPp7/btOKLjKUru15nLoA4AKYtz9W9PhsM0dyzLc6FQ6K4ReQam5pHCqI2zF&lt;br /&gt;
 82MwE+eIAduvuqyoQLKiI608EArWZqDtMUpBJzv0UVEYvRdnMWpCwfzpI+hPJywV&lt;br /&gt;
 CcTlNCT/ctGgBKyIx+dDuZ7bR9MNmSW7GreJEbTH+R13xT3dd/JCka1+LYCl4h0q&lt;br /&gt;
 oWhFPhOkvQzmmSzUmZlAlTDQLv2eAdJIrQcsnKZ3SsIOCC/3IpqwSzpid38Ill4O&lt;br /&gt;
 xH6XIrVFAgMBAAECggEBAJ2MC0JrM8TULSHJrf/0u7O4b2DMuTIuW386sSUr17mD&lt;br /&gt;
 nfviGF6TNvf7bq++e4rgHbZHvIg1HJ9Bpdne+J86HtUARYNlazru8fAFZEGiyLzB&lt;br /&gt;
 JUV/8TpO6ZJGepR8zSWrkFgZsOddw6i6LalADy5GRDcjoiDajZdR3lZxLrv5qOQU&lt;br /&gt;
 I1vKTf4Zs2Tl3gnaJ/Il1gBHIQ9W9xUH8jPBIwj51iXwCh8H0BiDPvFkU7cHIFCP&lt;br /&gt;
 sJhGsGp6OS3uSwwQuSE+NqbuPfVilysCcwgZduknyio0QO1YfMBL6+XoKE/bFHsn&lt;br /&gt;
 N+FzzczQg9sWyiwVR+3EeI9kp4JSElNh2nqG96i4QAECgYEA76OLUGrShHb4saoP&lt;br /&gt;
 aYnBAKLEdWj5K483JdY6BSbdd5RkDbJG8ExmcbfTas/BGdKc4iVCkxV3ysxKnX18&lt;br /&gt;
 PfxATHDLL8NMa+gGgZY5oTKUsrXEpS132HhCJ9T9LoesQjRb4kOZH8POVqm6O4Xf&lt;br /&gt;
 lCt0y1+M1eQHI1NPO9CmPBgouEUCgYEA5+F4SS8RMyYRkU/kx195fwh0hhaOElzr&lt;br /&gt;
 E8mZou3NFL/XT6/9t+2+7sMTuiQCP9zIa6s+/rrXdjWtrTcDp4WlDITas0UUgZhv&lt;br /&gt;
 YVBQBF4vhHxIVwJxnT9Gwi4XM1JlFmVHofWD71P6DRe7jSWRS3CujP3AE9vmpWMx&lt;br /&gt;
 tE1D9qLiWQECgYB445LzFYBvrKjWz4iI4CJKFNJwvGz+iXfzkXehg7KzkVtMAYSB&lt;br /&gt;
 0rjXYzm3J2ktgq778nn8Qxc0agy2GEil6GvzY+9MgAQ8Z0do9gTKif6zjLjP7vkH&lt;br /&gt;
 bdtJxsuWPoEqwMkdgqZrfNbJp0O4pVddovJ/agtdF3R2YJ+W+DH0HOfl1QKBgFnM&lt;br /&gt;
 c2zEEYEhaQRBUHP1gXO0rouPCI4L9e2/0QPL2/QBJzzxBuzH4X1NhsI7V7OrqOIp&lt;br /&gt;
 e0fiy7Y3q369I2ko1HY4rQln4z0c72VcWOCYKQbBqrInfCBNdPWWK93wNr2pk0gh&lt;br /&gt;
 cGqqtteDLVrIBbCVfsOTMWN/cZ7y/zi4A23sPoQBAoGAEPzcIjOyoB97Pzd7iNim&lt;br /&gt;
 Gin8RkwXIiFGSHo8vAh74CKBNokThM50OUNm5T2eJ4huzPpowQ+ID1mB5EjEai9n&lt;br /&gt;
 JY9ll3cUpawiIIW/6uGTHyXfvZWNtqEYXrVJ6fcDaKcW4y3cplNj/SJaBW8HXsW7&lt;br /&gt;
 YGHW3zHsgy7EOAOzPwlm9oE=&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 RSA Private-Key: (2048 bit, 2 primes)&lt;br /&gt;
 modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 publicExponent: 65537 (0x10001)&lt;br /&gt;
 privateExponent:&lt;br /&gt;
     00:9d:8c:0b:42:6b:33:c4:d4:2d:21:c9:ad:ff:f4:&lt;br /&gt;
     bb:b3:b8:6f:60:cc:b9:32:2e:5b:7f:3a:b1:25:2b:&lt;br /&gt;
     d7:b9:83:9d:fb:e2:18:5e:93:36:f7:fb:6e:af:be:&lt;br /&gt;
     7b:8a:e0:1d:b6:47:bc:88:35:1c:9f:41:a5:d9:de:&lt;br /&gt;
     f8:9f:3a:1e:d5:00:45:83:65:6b:3a:ee:f1:f0:05:&lt;br /&gt;
     64:41:a2:c8:bc:c1:25:45:7f:f1:3a:4e:e9:92:46:&lt;br /&gt;
     7a:94:7c:cd:25:ab:90:58:19:b0:e7:5d:c3:a8:ba:&lt;br /&gt;
     2d:a9:40:0f:2e:46:44:37:23:a2:20:da:8d:97:51:&lt;br /&gt;
     de:56:71:2e:bb:f9:a8:e4:14:23:5b:ca:4d:fe:19:&lt;br /&gt;
     b3:64:e5:de:09:da:27:f2:25:d6:00:47:21:0f:56:&lt;br /&gt;
     f7:15:07:f2:33:c1:23:08:f9:d6:25:f0:0a:1f:07:&lt;br /&gt;
     d0:18:83:3e:f1:64:53:b7:07:20:50:8f:b0:98:46:&lt;br /&gt;
     b0:6a:7a:39:2d:ee:4b:0c:10:b9:21:3e:36:a6:ee:&lt;br /&gt;
     3d:f5:62:97:2b:02:73:08:19:76:e9:27:ca:2a:34:&lt;br /&gt;
     40:ed:58:7c:c0:4b:eb:e5:e8:28:4f:db:14:7b:27:&lt;br /&gt;
     37:e1:73:cd:cc:d0:83:db:16:ca:2c:15:47:ed:c4:&lt;br /&gt;
     78:8f:64:a7:82:52:12:53:61:da:7a:86:f7:a8:b8:&lt;br /&gt;
     40:01&lt;br /&gt;
 prime1:&lt;br /&gt;
     00:ef:a3:8b:50:6a:d2:84:76:f8:b1:aa:0f:69:89:&lt;br /&gt;
     c1:00:a2:c4:75:68:f9:2b:8f:37:25:d6:3a:05:26:&lt;br /&gt;
     dd:77:94:64:0d:b2:46:f0:4c:66:71:b7:d3:6a:cf:&lt;br /&gt;
     c1:19:d2:9c:e2:25:42:93:15:77:ca:cc:4a:9d:7d:&lt;br /&gt;
     7c:3d:fc:40:4c:70:cb:2f:c3:4c:6b:e8:06:81:96:&lt;br /&gt;
     39:a1:32:94:b2:b5:c4:a5:2d:77:d8:78:42:27:d4:&lt;br /&gt;
     fd:2e:87:ac:42:34:5b:e2:43:99:1f:c3:ce:56:a9:&lt;br /&gt;
     ba:3b:85:df:94:2b:74:cb:5f:8c:d5:e4:07:23:53:&lt;br /&gt;
     4f:3b:d0:a6:3c:18:28:b8:45&lt;br /&gt;
 prime2:&lt;br /&gt;
     00:e7:e1:78:49:2f:11:33:26:11:91:4f:e4:c7:5f:&lt;br /&gt;
     79:7f:08:74:86:16:8e:12:5c:eb:13:c9:99:a2:ed:&lt;br /&gt;
     cd:14:bf:d7:4f:af:fd:b7:ed:be:ee:c3:13:ba:24:&lt;br /&gt;
     02:3f:dc:c8:6b:ab:3e:fe:ba:d7:76:35:ad:ad:37:&lt;br /&gt;
     03:a7:85:a5:0c:84:da:b3:45:14:81:98:6f:61:50:&lt;br /&gt;
     50:04:5e:2f:84:7c:48:57:02:71:9d:3f:46:c2:2e:&lt;br /&gt;
     17:33:52:65:16:65:47:a1:f5:83:ef:53:fa:0d:17:&lt;br /&gt;
     bb:8d:25:91:4b:70:ae:8c:fd:c0:13:db:e6:a5:63:&lt;br /&gt;
     31:b4:4d:43:f6:a2:e2:59:01&lt;br /&gt;
 exponent1:&lt;br /&gt;
     78:e3:92:f3:15:80:6f:ac:a8:d6:cf:88:88:e0:22:&lt;br /&gt;
     4a:14:d2:70:bc:6c:fe:89:77:f3:91:77:a1:83:b2:&lt;br /&gt;
     b3:91:5b:4c:01:84:81:d2:b8:d7:63:39:b7:27:69:&lt;br /&gt;
     2d:82:ae:fb:f2:79:fc:43:17:34:6a:0c:b6:18:48:&lt;br /&gt;
     a5:e8:6b:f3:63:ef:4c:80:04:3c:67:47:68:f6:04:&lt;br /&gt;
     ca:89:fe:b3:8c:b8:cf:ee:f9:07:6d:db:49:c6:cb:&lt;br /&gt;
     96:3e:81:2a:c0:c9:1d:82:a6:6b:7c:d6:c9:a7:43:&lt;br /&gt;
     b8:a5:57:5d:a2:f2:7f:6a:0b:5d:17:74:76:60:9f:&lt;br /&gt;
     96:f8:31:f4:1c:e7:e5:d5&lt;br /&gt;
 exponent2:&lt;br /&gt;
     59:cc:73:6c:c4:11:81:21:69:04:41:50:73:f5:81:&lt;br /&gt;
     73:b4:ae:8b:8f:08:8e:0b:f5:ed:bf:d1:03:cb:db:&lt;br /&gt;
     f4:01:27:3c:f1:06:ec:c7:e1:7d:4d:86:c2:3b:57:&lt;br /&gt;
     b3:ab:a8:e2:29:7b:47:e2:cb:b6:37:ab:7e:bd:23:&lt;br /&gt;
     69:28:d4:76:38:ad:09:67:e3:3d:1c:ef:65:5c:58:&lt;br /&gt;
     e0:98:29:06:c1:aa:b2:27:7c:20:4d:74:f5:96:2b:&lt;br /&gt;
     dd:f0:36:bd:a9:93:48:21:70:6a:aa:b6:d7:83:2d:&lt;br /&gt;
     5a:c8:05:b0:95:7e:c3:93:31:63:7f:71:9e:f2:ff:&lt;br /&gt;
     38:b8:03:6d:ec:3e:84:01&lt;br /&gt;
 coefficient:&lt;br /&gt;
     10:fc:dc:22:33:b2:a0:1f:7b:3f:37:7b:88:d8:a6:&lt;br /&gt;
     1a:29:fc:46:4c:17:22:21:46:48:7a:3c:bc:08:7b:&lt;br /&gt;
     e0:22:81:36:89:13:84:ce:74:39:43:66:e5:3d:9e:&lt;br /&gt;
     27:88:6e:cc:fa:68:c1:0f:88:0f:59:81:e4:48:c4:&lt;br /&gt;
     6a:2f:67:25:8f:65:97:77:14:a5:ac:22:20:85:bf:&lt;br /&gt;
     ea:e1:93:1f:25:df:bd:95:8d:b6:a1:18:5e:b5:49:&lt;br /&gt;
     e9:f7:03:68:a7:16:e3:2d:dc:a6:53:63:fd:22:5a:&lt;br /&gt;
     05:6f:07:5e:c5:bb:60:61:d6:df:31:ec:83:2e:c4:&lt;br /&gt;
     38:03:b3:3f:09:66:f6:81&lt;br /&gt;
&lt;br /&gt;
Keep in mind the above key was generated solely for pedagogical purposes; never give anyone access to your private keys.&lt;br /&gt;
&lt;br /&gt;
==Generating a Public Key==&lt;br /&gt;
&lt;br /&gt;
Having previously generated your private key, you may generate the corresponding public key using the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -out public-key.pem -pubout&lt;br /&gt;
&lt;br /&gt;
You may once again view the key details, using a slightly different command this time.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in public-key.pem -pubin -text&lt;br /&gt;
&lt;br /&gt;
The output for the public key will be shorter, as it carries much less information, and it will look something like this.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PUBLIC KEY-----&lt;br /&gt;
 MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Q+iDC0RZOAmhcNK4UYn&lt;br /&gt;
 p8LhORGesRRPHtwuU1YtfnfRJ4Yt/EYJMA+1JVsTxOgFoaeU95H6xVnWpNZWRVT6&lt;br /&gt;
 e/27Tii4ylK7teZy6AOACmLc/VvT4bDNHcsy3OhUOiuEXkGpuaRwqiNsxfNjMBPn&lt;br /&gt;
 iAHbr7qsqECyoiOtPBAK1mag7TFKQSc79FFRGL0XZzFqQsH86SPoTycsFQnE5TQk&lt;br /&gt;
 /3LRoASsiMfnQ7me20fTDZkluxq3iRG0x/kdd8U93XfyQpGtfi2ApeIdKqFoRT4T&lt;br /&gt;
 pL0M5pks1JmZQJUw0C79ngHSSK0HLJymd0rCDggv9yKasEs6Ynd/CJZeDsR+lyK1&lt;br /&gt;
 RQIDAQAB&lt;br /&gt;
 -----END PUBLIC KEY-----&lt;br /&gt;
 RSA Public-Key: (2048 bit)&lt;br /&gt;
 Modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 Exponent: 65537 (0x10001)&lt;br /&gt;
&lt;br /&gt;
For more information on generating keys, see the source code documentation, located in the &amp;lt;tt&amp;gt;doc/HOWTO/keys.txt&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Generating Keys Based on Elliptic Curves==&lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to generating a key:&lt;br /&gt;
&lt;br /&gt;
# Generate the parameters for the specific curve you are using&lt;br /&gt;
# Use those parameters to generate the key&lt;br /&gt;
&lt;br /&gt;
To see the list of curves instrinsically supported by openssl, you can use the &amp;lt;tt&amp;gt;-list_curves&amp;lt;/t&amp;gt; option when calling the &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -list_curves&lt;br /&gt;
   secp112r1 : SECG/WTLS curve over a 112 bit prime field&lt;br /&gt;
   secp112r2 : SECG curve over a 112 bit prime field&lt;br /&gt;
   secp128r1 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp128r2 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp160k1 : SECG curve over a 160 bit prime field&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
For this example I will use the &amp;lt;tt&amp;gt;prime256v1&amp;lt;/tt&amp;gt; curve, which is an &amp;lt;tt&amp;gt;X9.62/SECG&amp;lt;/tt&amp;gt; curve over a 256 bit prime field.&lt;br /&gt;
&lt;br /&gt;
===Generating the Curve Parameters===&lt;br /&gt;
&lt;br /&gt;
Having selected our curve, we now call &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; to generate our parameters file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -name prime256v1 -out prime256v1.pem&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters to Standard Out====&lt;br /&gt;
&lt;br /&gt;
You can print the generated curve parameters to the terminal output with the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -text&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters as C Code====&lt;br /&gt;
&lt;br /&gt;
Analogously, you may also output the generated curve parameters as C code. The parameters can then be loaded by calling the &amp;lt;tt&amp;gt;get_ec_group_XXX()&amp;lt;/tt&amp;gt; function. To print the C code to the current terminal's output, the following command may be used:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -C&lt;br /&gt;
&lt;br /&gt;
And here are the first few lines of the corresponding output:&lt;br /&gt;
&lt;br /&gt;
 EC_GROUP *get_ec_group_256(void)&lt;br /&gt;
 {&lt;br /&gt;
     static unsigned char ec_p_256[] = {&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,&lt;br /&gt;
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,&lt;br /&gt;
         ...&lt;br /&gt;
&lt;br /&gt;
===Generating the Key===&lt;br /&gt;
&lt;br /&gt;
With the curve parameters in hand, we are now free to generate the key. Just as with the [#Generating an RSA Private Key|RSA] example above, we may optionally specify a cipher algorithm with which to encrypt the private key. The call to generate the key using the elliptic curve parameters generated in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -paramfile prime256v1.pem -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
===Putting it All Together===&lt;br /&gt;
&lt;br /&gt;
The process of generation a curve based on elliptic-curves can be streamlined by calling the &amp;lt;tt&amp;gt;genpkey&amp;lt;/tt&amp;gt; command directly and specifying both the algorithm and the name of the curve to use for parameter generation. In it's simplest form, the command to generate a key based on the same curve as in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256&lt;br /&gt;
&lt;br /&gt;
This command will result in the generated key being printed to the terminal's output.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256&lt;br /&gt;
 &lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgqqYoJGowXJ5/GTkB&lt;br /&gt;
 SRLnBMNWLoQ2RM/QxrY+bfDDGRahRANCAASPY4eTANkwIIAWhh32eoFl2YFLJSWy&lt;br /&gt;
 bdITdZ82O5JDpDijmGmJ2hepe5afek9WVqxMPYjmbTwMPO3xMGbqUiJD&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
&lt;br /&gt;
Remember that you can specify a cipher algorithm to encrypt the key with, which something you may or may not want to do, depending on your specific use case. Here is a slightly more complete example showing a key generated with a password and written to a specific output file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
Just as with the previous example, you can use the &amp;lt;tt&amp;gt;pkey&amp;lt;/tt&amp;gt; command to inspect your newly-generated key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
 Enter pass phrase for private-key.pem:&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgEO7CxgTwi0hsjdbp&lt;br /&gt;
 sXWuU2x2flLthxqXabYDOqOZCvuhRANCAAQVTLkeCBJdvMnqwZKYJxrPvTTuanrD&lt;br /&gt;
 NkyAPQCARKsQ7bVrP6ky/5uAcAvjuZB0xKCcSp7roXLWRzD/y/ik8P5R&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 Private-Key: (256 bit)&lt;br /&gt;
 priv:&lt;br /&gt;
     10:ee:c2:c6:04:f0:8b:48:6c:8d:d6:e9:b1:75:ae:&lt;br /&gt;
     53:6c:76:7e:52:ed:87:1a:97:69:b6:03:3a:a3:99:&lt;br /&gt;
     0a:fb&lt;br /&gt;
 pub:&lt;br /&gt;
     04:15:4c:b9:1e:08:12:5d:bc:c9:ea:c1:92:98:27:&lt;br /&gt;
     1a:cf:bd:34:ee:6a:7a:c3:36:4c:80:3d:00:80:44:&lt;br /&gt;
     ab:10:ed:b5:6b:3f:a9:32:ff:9b:80:70:0b:e3:b9:&lt;br /&gt;
     90:74:c4:a0:9c:4a:9e:eb:a1:72:d6:47:30:ff:cb:&lt;br /&gt;
     f8:a4:f0:fe:51&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
For more details on elliptic curve cryptography or key generation, check out the [https://www.openssl.org/docs/manpages.html manpages].&lt;br /&gt;
&lt;br /&gt;
==Base64 Encoding Strings==&lt;br /&gt;
&lt;br /&gt;
For simple string encoding, you can use &amp;quot;here string&amp;quot; syntax with the [[Base64 Encoding|base64]] command as below. Intuitively, the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; flag specifies the action to be encoding.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -e &amp;lt;&amp;lt;&amp;lt; 'Welcome to openssl wiki'&lt;br /&gt;
 V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK&lt;br /&gt;
&lt;br /&gt;
Similarly, the base64 command's &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flag may be used to indicate decoding mode.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -d &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK'&lt;br /&gt;
 Welcome to openssl wiki&lt;br /&gt;
&lt;br /&gt;
==Generating a File Hash==&lt;br /&gt;
&lt;br /&gt;
One of the most basic uses of the [[dgst]] command (short for digest) is viewing the hash of a given file. To do this, simply invoke the command with the specified digest algorithm to use. For this example, I will be hashing an arbitrary file on my system using the [[MD5]], [[SHA1]], and [[SHA384]] algorithms.&lt;br /&gt;
&lt;br /&gt;
 $ openssl dgst -md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
For a list of the available digest algorithms, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-algorithms&lt;br /&gt;
 RSA-MD4 =&amp;gt; MD4&lt;br /&gt;
 RSA-MD5 =&amp;gt; MD5&lt;br /&gt;
 RSA-MDC2 =&amp;gt; MDC2&lt;br /&gt;
 RSA-RIPEMD160 =&amp;gt; RIPEMD160&lt;br /&gt;
 RSA-SHA1 =&amp;gt; SHA1&lt;br /&gt;
 RSA-SHA1-2 =&amp;gt; RSA-SHA1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use a similar command to see the available [[Digest Commands|digest commands]]:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-commands&lt;br /&gt;
 blake2b512        blake2s256        gost              md4               &lt;br /&gt;
 md5               mdc2              rmd160            sha1              &lt;br /&gt;
 sha224            sha256            sha3-224          sha3-256          &lt;br /&gt;
 sha3-384          sha3-512          sha384            sha512            &lt;br /&gt;
 sha512-224        sha512-256        shake128          shake256          &lt;br /&gt;
 sm3      &lt;br /&gt;
&lt;br /&gt;
Below are three sample invocations of the [[md5]], [[sha1]], and [[sha384]] digest commands using the same file as the [[dgst]] command invocation above.&lt;br /&gt;
&lt;br /&gt;
 $ openssl md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
==File Encryption and Decryption==&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates a simple file encryption and decryption using the [[enc]] command. The first argument is the cipher algorithm to use for encrypting the file. For this example I carefully selected the [[AES-256]] algorithm in [[CBC Mode]] by looking up the available ciphers and picking out the first one I saw. To see the list of available ciphers, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -ciphers&lt;br /&gt;
 Supported ciphers:&lt;br /&gt;
 -aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             &lt;br /&gt;
 -aes-128-cfb8              -aes-128-ctr               -aes-128-ecb              &lt;br /&gt;
 -aes-128-ofb               -aes-192-cbc               -aes-192-cfb              &lt;br /&gt;
 -aes-192-cfb1              -aes-192-cfb8              -aes-192-ctr&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
 AES-128-CBC&lt;br /&gt;
 AES-128-CBC-HMAC-SHA1&lt;br /&gt;
 AES-128-CBC-HMAC-SHA256&lt;br /&gt;
 id-aes128-CCM&lt;br /&gt;
 AES-128-CFB&lt;br /&gt;
 AES-128-CFB1&lt;br /&gt;
 AES-128-CFB8&lt;br /&gt;
 AES-128-CTR&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Having selected an encryption algorithm, you must then specify whether the action you are taking is either encryption or decryption via the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flags, respectively. The &amp;lt;tt&amp;gt;-iter&amp;lt;/tt&amp;gt; flag specifies the number of iterations on the password used for deriving the encryption key. A higher iteration count increases the time required to brute-force the resulting file. Using this option implies enabling use of the [[Password-Based Key Derivation Function 2]], usually set using the &amp;lt;tt&amp;gt;-pbkdf2&amp;lt;/tt&amp;gt; flag. We then use the &amp;lt;tt&amp;gt;-salt&amp;lt;/tt&amp;gt; flag to enable the use of a randomly generated salt in the key-derivation function.&lt;br /&gt;
&lt;br /&gt;
Putting it all together, you can see the command to encrypt a file and the corresponding output below. Note that the passwords entered by the user are blank, just as they would usually be in a terminal session.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -e -iter 1000 -salt -in primes.dat -out primes.enc&lt;br /&gt;
 enter aes-256-cbc encryption password:&lt;br /&gt;
 Verifying - enter aes-256-cbc encryption password:&lt;br /&gt;
&lt;br /&gt;
The analogous decryption command is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -d -iter 1000 -in primes.enc -out primes.dec&lt;br /&gt;
 enter aes-256-cbc decryption password:&lt;br /&gt;
&lt;br /&gt;
=Commands=&lt;br /&gt;
&lt;br /&gt;
There are three different kinds of commands. These are [[Standard commands|standard commands]], [[Cipher commands|cipher commands]], and [[Digest comands|digest commands]]. Calling the OpenSSL top-level &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt; command with no arguments will result in openssl printing all available commands by group, sorted alphabetically.&lt;br /&gt;
&lt;br /&gt;
==Standard Commands==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto; text-align: center; width: 65%;&amp;quot;&lt;br /&gt;
|+ Overview of OpenSSL's command line utilities&lt;br /&gt;
! style=&amp;quot;width: 25%; padding: 4px;&amp;quot; | Command&lt;br /&gt;
! style=&amp;quot;width: 75%; padding: 4px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/asn1parse.html asn1parse]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Parse an ASN.1 sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ca.html ca]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Authority (CA) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ciphers.html ciphers]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Cipher Suite Description Determination.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/cms.html cms]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CMS (Cryptographic Message Syntax) utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl.html crl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Revocation List (CRL) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl2pkcs7.html crl2pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CRL to PKCS#7 Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dgst.html dgst]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Digest calculation. MAC calculations are superseded by mac(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dhparam.html dhparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation and Management of Diffie-Hellman Parameters. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsa.html dsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsaparam.html dsaparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Parameter Generation and Management. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ec.html ec]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC (Elliptic curve) key processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ecparam.html ecparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC parameter manipulation and generation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/enc.html enc]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Encoding with Ciphers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/engine.html engine]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Engine (loadable module) information and manipulation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/errstr.html errstr]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Error Number to Error String Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/gendsa.html gendsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of DSA Private Key from Parameters. Superseded by genpkey(1) and pkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genpkey.html genpkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of Private Key or Parameters.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genrsa.html genrsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of RSA Private Key. Superseded by genpkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/info.html info]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Display diverse information built into the OpenSSL libraries.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/kdf.html kdf]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Key Derivation Functions.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/mac.html mac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Authentication Code Calculation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/nseq.html nseq]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create or examine a Netscape certificate sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ocsp.html ocsp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Online Certificate Status Protocol utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/passwd.html passwd]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of hashed passwords.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs12.html pkcs12]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#12 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs7.html pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#7 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs8.html pkcs8]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#8 format private key conversion tool.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkey.html pkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public and private key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyparam.html pkeyparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm parameter management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyutl.html pkeyutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm cryptographic operation utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/prime.html prime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Compute prime numbers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rand.html rand]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generate pseudo-random bytes.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rehash.html rehash]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create symbolic links to certificate and CRL files named by the hash values.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/req.html req]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#10 X.509 Certificate Signing Request (CSR) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsa.html rsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsautl.html rsautl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA utility for signing, verification, encryption, and decryption. Superseded by pkeyutl(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_client.html s_client]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_server.html s_server]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_time.html s_time]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Connection Timer.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/sess_id.html sess_id]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Session Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/smime.html smime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  S/MIME mail processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/speed.html speed]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Algorithm Speed Measurement.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/spkac.html spkac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SPKAC printing and generating utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/srp.html srp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Maintain SRP password file.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/storeutl.html storeutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Utility to list and display certificates, keys, CRLs, etc.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ts.html ts]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Time Stamping Authority tool (client/server).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/verify.html verify]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Verification.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/version.html version]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  OpenSSL Version Information.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/x509.html x509]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Data Management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Further reading =&lt;br /&gt;
&lt;br /&gt;
* Paul Heinlein. [https://www.madboa.com/geek/openssl/ &amp;quot;OpenSSL Command-Line HOWTO&amp;quot;]. Has many quick cookbook-style recipes for doing common tasks using the &amp;quot;oppenssl&amp;quot; command-line application.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:Shell level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=2846</id>
		<title>Talk:Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=2846"/>
		<updated>2019-07-30T15:27:51Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Replying to thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pretty significant rewrite ==&lt;br /&gt;
&lt;br /&gt;
I noticed a lot of the information on the page was essentially a print out of the program help menu, so I thought it would be more beneficial to provide a basic introduction to the command-line utilities in tutorial form, with links to the official documentation. It isn't finished, as there are a lot of topics I didn't cover (certificates being a significant topic I did not cover), but because of the magnitude of the changes, I thought it best to stop here and get feedback on the changes. I'm brand-new to the project and I'm excited contribute in a meaningful way, so please if there is any wrong information, the style is off, etc., please do pass that along.&lt;br /&gt;
&lt;br /&gt;
This rewrite is essentially a reformatting of the previous version, with a lot of additional explanations from the perldocs. The bulk of the changes come from the removing of the old code samples, which were essentially just the helps menus, and the addition of code examples which again come primarily from the perldocs. There's also a table with all of the standard commands which link to their respective manpage on the main openssl site. I thought this was better because now we only have to update one set of documentation, which itself is automatically generated from the pod files.&lt;br /&gt;
&lt;br /&gt;
--[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 03:35, 30 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: This new style page looks great!! Please continue with it.&lt;br /&gt;
: A point to note about the ec key generation stuff. It is not necessary to first create an ec params file. It is simpler just to generate the key directly using genpkey and passing the pkeyopt &amp;quot;ec_paramgen_curve&amp;quot;. See the man page for further details.&lt;br /&gt;
: --[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 08:27, 30 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: Awesome, I'll go ahead and add that in, thanks for the heads up. I'm glad you like the change; I was pretty nervous about it since it was a pretty big change and I'm still brand-new.&lt;br /&gt;
:: --[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 15:27, 30 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2843</id>
		<title>Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2843"/>
		<updated>2019-07-30T04:40:56Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Corrected spelling of the prime command&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''openssl''' program provides a rich variety of commands, each of which often has a wealth of options and arguments. Many commands use an external configuration file for some or all of their arguments and have a &amp;lt;code&amp;gt;-config&amp;lt;/code&amp;gt; option to specify that file. The environment variable [[OPENSSL_CONF]] can be used to specify the location of the configuration file. If the environment variable is not specified, a default file is created in the default certificate storage area called '''openssl.cnf'''. The settings in this default configuration file depend on the flags set when the version of OpenSSL being used was built.&lt;br /&gt;
&lt;br /&gt;
This article is an overview of the available tools provided by openssl. For all of the details on usage and implementation, you can find the [https://www.openssl.org/docs/manmaster/ manpages] which are automatically generated from the source code at the [https://www.openssl.org/ official OpenSSL project home]. Likewise, the source code itself may be found on the [https://www.openssl.org/source/ OpenSSL project home page], as well as on the [https://github.com/openssl/openssl OpenSSL Github]. The main OpenSSL site also includes an [https://www.openssl.org/docs/manmaster/man1/openssl.html overview of the command-line utilities], as well as links to all of their respective documentation.&lt;br /&gt;
&lt;br /&gt;
=Getting Started=&lt;br /&gt;
&lt;br /&gt;
The entry point for the OpenSSL library is the '''openssl''' binary, usually &amp;lt;tt&amp;gt;/usr/bin/openssl&amp;lt;/tt&amp;gt; on Linux. The general syntax for calling openssl is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl command [ command_options ] [ command_arguments ]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can call openssl without arguments to enter the interactive mode prompt. You may then enter commands directly, exiting with either a &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt; command or by issuing a termination signal with either &amp;lt;tt&amp;gt;Ctrl+C&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Ctrl+D&amp;lt;/tt&amp;gt;. The following is a sample interactive session in which the user invokes the [[prime]] command twice before using the &amp;lt;tt&amp;gt;quit&amp;lt;/tt&amp;gt; command to terminate the session.&lt;br /&gt;
&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 13467269&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 16651079&lt;br /&gt;
 OpenSSL&amp;gt; quit&lt;br /&gt;
&lt;br /&gt;
=Basic Tasks=&lt;br /&gt;
&lt;br /&gt;
This section is a brief tutorial on performing the most basic tasks using OpenSSL. For a detailed explanation of the rationale behind the syntax and semantics of the commands shown here, see the section on [[#Commands|Commands]].&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, the general syntax of a command is &amp;lt;code&amp;gt;openssl command [ command_options ] [ command_arguments ]&amp;lt;/code&amp;gt;. The help command is no different, but it does have its idiosyncrasies. To view the top-level help menu, you can call openssl as follows.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help&lt;br /&gt;
&lt;br /&gt;
This query will print all of the available commands, like so:&lt;br /&gt;
&lt;br /&gt;
 Standard commands&lt;br /&gt;
 asn1parse         ca                ciphers           cms               &lt;br /&gt;
 crl               crl2pkcs7         dgst              dhparam           &lt;br /&gt;
 dsa               dsaparam          ec                ecparam&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Note the above output was truncated, so only the first four lines of output are shown.&lt;br /&gt;
&lt;br /&gt;
A help menu for each command may be requested in two different ways. First, the same command used above may be repeated, followed by the name of the command to print help for.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
&lt;br /&gt;
The program will then display the valid options for the given command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
The second way of requesting the help menu for a particular command is by using the first option in the output shown above, namely &amp;lt;code&amp;gt;openssl command -help&amp;lt;/code&amp;gt;. Both commands will yield the same output; the help menu displayed will be exactly the same.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -help&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
For additional information on the usage of a particular command, the project [https://www.openssl.org/docs/manpages.html manpages] are a great source of information. Another excellent source of information is the project perldocs. [https://perldoc.perl.org/5.30.0/perldoc.html perldoc] is a utility included with most if not all [https://www.perl.org/ Perl] distributions, and it's capable of displaying documentation information in a variety of formats, one of which is as manpages. Not surprisingly, the project documentation is generated from the pod files located in the &amp;lt;tt&amp;gt;doc&amp;lt;/tt&amp;gt; directory of the source code.&lt;br /&gt;
&lt;br /&gt;
==Getting Library Version Information==&lt;br /&gt;
&lt;br /&gt;
 $ openssl version&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
&lt;br /&gt;
As mentioned above, the &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; command's help menu may be queried for additional options like so:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -help&lt;br /&gt;
 Usage: version [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help  Display this summary&lt;br /&gt;
  -a     Show all data&lt;br /&gt;
  -b     Show build date&lt;br /&gt;
  -d     Show configuration directory&lt;br /&gt;
  -e     Show engines directory&lt;br /&gt;
  -f     Show compiler flags used&lt;br /&gt;
  -o     Show some internal datatype options&lt;br /&gt;
  -p     Show target build platform&lt;br /&gt;
  -r     Show random seeding options&lt;br /&gt;
  -v     Show library version&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;tt&amp;gt;-a&amp;lt;/tt&amp;gt; option to show all version information yields the following output on my current machine:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -a&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
 built on: Tue May 28 16:23:39 2019 UTC&lt;br /&gt;
 platform: linux-x86_64&lt;br /&gt;
 options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) &lt;br /&gt;
 compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -D_FORTIFY_SOURCE=2&lt;br /&gt;
 OPENSSLDIR: &amp;quot;/etc/ssl&amp;quot;&lt;br /&gt;
 ENGINESDIR: &amp;quot;/usr/lib/engines-1.1&amp;quot;&lt;br /&gt;
 Seeding source: os-specific&lt;br /&gt;
&lt;br /&gt;
==Generating an RSA Private Key==&lt;br /&gt;
&lt;br /&gt;
Generating a private key can be done in a variety of different ways depending on the type of key, algorithm, bits, and other options your specific use case may require. In this example, we are generating a private key using RSA and a key size of 2048 bits.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
To generate a password protected private key, the previous command may be slightly amended as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
The addition of the &amp;lt;tt&amp;gt;-aes256&amp;lt;/tt&amp;gt; option specifies the cipher to use to encrypt the private key file. For a list of available ciphers in the library, you can run the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
&lt;br /&gt;
With your private key in hand, you can use the following command to see the key's details, such as its modulus and its constituent primes. Remember to change the name of the input file to the file name of your private key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
&lt;br /&gt;
The above command yields the following output in my specific case. Your output will differ but should be structurally similar.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDZD6IMLRFk4CaF&lt;br /&gt;
 w0rhRienwuE5EZ6xFE8e3C5TVi1+d9Enhi38RgkwD7UlWxPE6AWhp5T3kfrFWdak&lt;br /&gt;
 1lZFVPp7/btOKLjKUru15nLoA4AKYtz9W9PhsM0dyzLc6FQ6K4ReQam5pHCqI2zF&lt;br /&gt;
 82MwE+eIAduvuqyoQLKiI608EArWZqDtMUpBJzv0UVEYvRdnMWpCwfzpI+hPJywV&lt;br /&gt;
 CcTlNCT/ctGgBKyIx+dDuZ7bR9MNmSW7GreJEbTH+R13xT3dd/JCka1+LYCl4h0q&lt;br /&gt;
 oWhFPhOkvQzmmSzUmZlAlTDQLv2eAdJIrQcsnKZ3SsIOCC/3IpqwSzpid38Ill4O&lt;br /&gt;
 xH6XIrVFAgMBAAECggEBAJ2MC0JrM8TULSHJrf/0u7O4b2DMuTIuW386sSUr17mD&lt;br /&gt;
 nfviGF6TNvf7bq++e4rgHbZHvIg1HJ9Bpdne+J86HtUARYNlazru8fAFZEGiyLzB&lt;br /&gt;
 JUV/8TpO6ZJGepR8zSWrkFgZsOddw6i6LalADy5GRDcjoiDajZdR3lZxLrv5qOQU&lt;br /&gt;
 I1vKTf4Zs2Tl3gnaJ/Il1gBHIQ9W9xUH8jPBIwj51iXwCh8H0BiDPvFkU7cHIFCP&lt;br /&gt;
 sJhGsGp6OS3uSwwQuSE+NqbuPfVilysCcwgZduknyio0QO1YfMBL6+XoKE/bFHsn&lt;br /&gt;
 N+FzzczQg9sWyiwVR+3EeI9kp4JSElNh2nqG96i4QAECgYEA76OLUGrShHb4saoP&lt;br /&gt;
 aYnBAKLEdWj5K483JdY6BSbdd5RkDbJG8ExmcbfTas/BGdKc4iVCkxV3ysxKnX18&lt;br /&gt;
 PfxATHDLL8NMa+gGgZY5oTKUsrXEpS132HhCJ9T9LoesQjRb4kOZH8POVqm6O4Xf&lt;br /&gt;
 lCt0y1+M1eQHI1NPO9CmPBgouEUCgYEA5+F4SS8RMyYRkU/kx195fwh0hhaOElzr&lt;br /&gt;
 E8mZou3NFL/XT6/9t+2+7sMTuiQCP9zIa6s+/rrXdjWtrTcDp4WlDITas0UUgZhv&lt;br /&gt;
 YVBQBF4vhHxIVwJxnT9Gwi4XM1JlFmVHofWD71P6DRe7jSWRS3CujP3AE9vmpWMx&lt;br /&gt;
 tE1D9qLiWQECgYB445LzFYBvrKjWz4iI4CJKFNJwvGz+iXfzkXehg7KzkVtMAYSB&lt;br /&gt;
 0rjXYzm3J2ktgq778nn8Qxc0agy2GEil6GvzY+9MgAQ8Z0do9gTKif6zjLjP7vkH&lt;br /&gt;
 bdtJxsuWPoEqwMkdgqZrfNbJp0O4pVddovJ/agtdF3R2YJ+W+DH0HOfl1QKBgFnM&lt;br /&gt;
 c2zEEYEhaQRBUHP1gXO0rouPCI4L9e2/0QPL2/QBJzzxBuzH4X1NhsI7V7OrqOIp&lt;br /&gt;
 e0fiy7Y3q369I2ko1HY4rQln4z0c72VcWOCYKQbBqrInfCBNdPWWK93wNr2pk0gh&lt;br /&gt;
 cGqqtteDLVrIBbCVfsOTMWN/cZ7y/zi4A23sPoQBAoGAEPzcIjOyoB97Pzd7iNim&lt;br /&gt;
 Gin8RkwXIiFGSHo8vAh74CKBNokThM50OUNm5T2eJ4huzPpowQ+ID1mB5EjEai9n&lt;br /&gt;
 JY9ll3cUpawiIIW/6uGTHyXfvZWNtqEYXrVJ6fcDaKcW4y3cplNj/SJaBW8HXsW7&lt;br /&gt;
 YGHW3zHsgy7EOAOzPwlm9oE=&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 RSA Private-Key: (2048 bit, 2 primes)&lt;br /&gt;
 modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 publicExponent: 65537 (0x10001)&lt;br /&gt;
 privateExponent:&lt;br /&gt;
     00:9d:8c:0b:42:6b:33:c4:d4:2d:21:c9:ad:ff:f4:&lt;br /&gt;
     bb:b3:b8:6f:60:cc:b9:32:2e:5b:7f:3a:b1:25:2b:&lt;br /&gt;
     d7:b9:83:9d:fb:e2:18:5e:93:36:f7:fb:6e:af:be:&lt;br /&gt;
     7b:8a:e0:1d:b6:47:bc:88:35:1c:9f:41:a5:d9:de:&lt;br /&gt;
     f8:9f:3a:1e:d5:00:45:83:65:6b:3a:ee:f1:f0:05:&lt;br /&gt;
     64:41:a2:c8:bc:c1:25:45:7f:f1:3a:4e:e9:92:46:&lt;br /&gt;
     7a:94:7c:cd:25:ab:90:58:19:b0:e7:5d:c3:a8:ba:&lt;br /&gt;
     2d:a9:40:0f:2e:46:44:37:23:a2:20:da:8d:97:51:&lt;br /&gt;
     de:56:71:2e:bb:f9:a8:e4:14:23:5b:ca:4d:fe:19:&lt;br /&gt;
     b3:64:e5:de:09:da:27:f2:25:d6:00:47:21:0f:56:&lt;br /&gt;
     f7:15:07:f2:33:c1:23:08:f9:d6:25:f0:0a:1f:07:&lt;br /&gt;
     d0:18:83:3e:f1:64:53:b7:07:20:50:8f:b0:98:46:&lt;br /&gt;
     b0:6a:7a:39:2d:ee:4b:0c:10:b9:21:3e:36:a6:ee:&lt;br /&gt;
     3d:f5:62:97:2b:02:73:08:19:76:e9:27:ca:2a:34:&lt;br /&gt;
     40:ed:58:7c:c0:4b:eb:e5:e8:28:4f:db:14:7b:27:&lt;br /&gt;
     37:e1:73:cd:cc:d0:83:db:16:ca:2c:15:47:ed:c4:&lt;br /&gt;
     78:8f:64:a7:82:52:12:53:61:da:7a:86:f7:a8:b8:&lt;br /&gt;
     40:01&lt;br /&gt;
 prime1:&lt;br /&gt;
     00:ef:a3:8b:50:6a:d2:84:76:f8:b1:aa:0f:69:89:&lt;br /&gt;
     c1:00:a2:c4:75:68:f9:2b:8f:37:25:d6:3a:05:26:&lt;br /&gt;
     dd:77:94:64:0d:b2:46:f0:4c:66:71:b7:d3:6a:cf:&lt;br /&gt;
     c1:19:d2:9c:e2:25:42:93:15:77:ca:cc:4a:9d:7d:&lt;br /&gt;
     7c:3d:fc:40:4c:70:cb:2f:c3:4c:6b:e8:06:81:96:&lt;br /&gt;
     39:a1:32:94:b2:b5:c4:a5:2d:77:d8:78:42:27:d4:&lt;br /&gt;
     fd:2e:87:ac:42:34:5b:e2:43:99:1f:c3:ce:56:a9:&lt;br /&gt;
     ba:3b:85:df:94:2b:74:cb:5f:8c:d5:e4:07:23:53:&lt;br /&gt;
     4f:3b:d0:a6:3c:18:28:b8:45&lt;br /&gt;
 prime2:&lt;br /&gt;
     00:e7:e1:78:49:2f:11:33:26:11:91:4f:e4:c7:5f:&lt;br /&gt;
     79:7f:08:74:86:16:8e:12:5c:eb:13:c9:99:a2:ed:&lt;br /&gt;
     cd:14:bf:d7:4f:af:fd:b7:ed:be:ee:c3:13:ba:24:&lt;br /&gt;
     02:3f:dc:c8:6b:ab:3e:fe:ba:d7:76:35:ad:ad:37:&lt;br /&gt;
     03:a7:85:a5:0c:84:da:b3:45:14:81:98:6f:61:50:&lt;br /&gt;
     50:04:5e:2f:84:7c:48:57:02:71:9d:3f:46:c2:2e:&lt;br /&gt;
     17:33:52:65:16:65:47:a1:f5:83:ef:53:fa:0d:17:&lt;br /&gt;
     bb:8d:25:91:4b:70:ae:8c:fd:c0:13:db:e6:a5:63:&lt;br /&gt;
     31:b4:4d:43:f6:a2:e2:59:01&lt;br /&gt;
 exponent1:&lt;br /&gt;
     78:e3:92:f3:15:80:6f:ac:a8:d6:cf:88:88:e0:22:&lt;br /&gt;
     4a:14:d2:70:bc:6c:fe:89:77:f3:91:77:a1:83:b2:&lt;br /&gt;
     b3:91:5b:4c:01:84:81:d2:b8:d7:63:39:b7:27:69:&lt;br /&gt;
     2d:82:ae:fb:f2:79:fc:43:17:34:6a:0c:b6:18:48:&lt;br /&gt;
     a5:e8:6b:f3:63:ef:4c:80:04:3c:67:47:68:f6:04:&lt;br /&gt;
     ca:89:fe:b3:8c:b8:cf:ee:f9:07:6d:db:49:c6:cb:&lt;br /&gt;
     96:3e:81:2a:c0:c9:1d:82:a6:6b:7c:d6:c9:a7:43:&lt;br /&gt;
     b8:a5:57:5d:a2:f2:7f:6a:0b:5d:17:74:76:60:9f:&lt;br /&gt;
     96:f8:31:f4:1c:e7:e5:d5&lt;br /&gt;
 exponent2:&lt;br /&gt;
     59:cc:73:6c:c4:11:81:21:69:04:41:50:73:f5:81:&lt;br /&gt;
     73:b4:ae:8b:8f:08:8e:0b:f5:ed:bf:d1:03:cb:db:&lt;br /&gt;
     f4:01:27:3c:f1:06:ec:c7:e1:7d:4d:86:c2:3b:57:&lt;br /&gt;
     b3:ab:a8:e2:29:7b:47:e2:cb:b6:37:ab:7e:bd:23:&lt;br /&gt;
     69:28:d4:76:38:ad:09:67:e3:3d:1c:ef:65:5c:58:&lt;br /&gt;
     e0:98:29:06:c1:aa:b2:27:7c:20:4d:74:f5:96:2b:&lt;br /&gt;
     dd:f0:36:bd:a9:93:48:21:70:6a:aa:b6:d7:83:2d:&lt;br /&gt;
     5a:c8:05:b0:95:7e:c3:93:31:63:7f:71:9e:f2:ff:&lt;br /&gt;
     38:b8:03:6d:ec:3e:84:01&lt;br /&gt;
 coefficient:&lt;br /&gt;
     10:fc:dc:22:33:b2:a0:1f:7b:3f:37:7b:88:d8:a6:&lt;br /&gt;
     1a:29:fc:46:4c:17:22:21:46:48:7a:3c:bc:08:7b:&lt;br /&gt;
     e0:22:81:36:89:13:84:ce:74:39:43:66:e5:3d:9e:&lt;br /&gt;
     27:88:6e:cc:fa:68:c1:0f:88:0f:59:81:e4:48:c4:&lt;br /&gt;
     6a:2f:67:25:8f:65:97:77:14:a5:ac:22:20:85:bf:&lt;br /&gt;
     ea:e1:93:1f:25:df:bd:95:8d:b6:a1:18:5e:b5:49:&lt;br /&gt;
     e9:f7:03:68:a7:16:e3:2d:dc:a6:53:63:fd:22:5a:&lt;br /&gt;
     05:6f:07:5e:c5:bb:60:61:d6:df:31:ec:83:2e:c4:&lt;br /&gt;
     38:03:b3:3f:09:66:f6:81&lt;br /&gt;
&lt;br /&gt;
Keep in mind the above key was generated solely for pedagogical purposes; never give anyone access to your private keys.&lt;br /&gt;
&lt;br /&gt;
==Generating a Public Key==&lt;br /&gt;
&lt;br /&gt;
Having previously generated your private key, you may generate the corresponding public key using the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -out public-key.pem -pubout&lt;br /&gt;
&lt;br /&gt;
You may once again view the key details, using a slightly different command this time.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in public-key.pem -pubin -text&lt;br /&gt;
&lt;br /&gt;
The output for the public key will be shorter, as it carries much less information, and it will look something like this.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PUBLIC KEY-----&lt;br /&gt;
 MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Q+iDC0RZOAmhcNK4UYn&lt;br /&gt;
 p8LhORGesRRPHtwuU1YtfnfRJ4Yt/EYJMA+1JVsTxOgFoaeU95H6xVnWpNZWRVT6&lt;br /&gt;
 e/27Tii4ylK7teZy6AOACmLc/VvT4bDNHcsy3OhUOiuEXkGpuaRwqiNsxfNjMBPn&lt;br /&gt;
 iAHbr7qsqECyoiOtPBAK1mag7TFKQSc79FFRGL0XZzFqQsH86SPoTycsFQnE5TQk&lt;br /&gt;
 /3LRoASsiMfnQ7me20fTDZkluxq3iRG0x/kdd8U93XfyQpGtfi2ApeIdKqFoRT4T&lt;br /&gt;
 pL0M5pks1JmZQJUw0C79ngHSSK0HLJymd0rCDggv9yKasEs6Ynd/CJZeDsR+lyK1&lt;br /&gt;
 RQIDAQAB&lt;br /&gt;
 -----END PUBLIC KEY-----&lt;br /&gt;
 RSA Public-Key: (2048 bit)&lt;br /&gt;
 Modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 Exponent: 65537 (0x10001)&lt;br /&gt;
&lt;br /&gt;
For more information on generating keys, see the source code documentation, located in the &amp;lt;tt&amp;gt;doc/HOWTO/keys.txt&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Generating Keys Based on Elliptic Curves==&lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to generating a key:&lt;br /&gt;
&lt;br /&gt;
# Generate the parameters for the specific curve you are using&lt;br /&gt;
# Use those parameters to generate the key&lt;br /&gt;
&lt;br /&gt;
To see the list of curves instrinsically supported by openssl, you can use the &amp;lt;tt&amp;gt;-list_curves&amp;lt;/t&amp;gt; option when calling the &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -list_curves&lt;br /&gt;
   secp112r1 : SECG/WTLS curve over a 112 bit prime field&lt;br /&gt;
   secp112r2 : SECG curve over a 112 bit prime field&lt;br /&gt;
   secp128r1 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp128r2 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp160k1 : SECG curve over a 160 bit prime field&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
For this example I will use the &amp;lt;tt&amp;gt;prime256v1&amp;lt;/tt&amp;gt; curve, which is an &amp;lt;tt&amp;gt;X9.62/SECG&amp;lt;/tt&amp;gt; curve over a 256 bit prime field.&lt;br /&gt;
&lt;br /&gt;
===Generating the Curve Parameters===&lt;br /&gt;
&lt;br /&gt;
Having selected our curve, we now call &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; to generate our parameters file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -name prime256v1 -out prime256v1.pem&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters to Standard Out====&lt;br /&gt;
&lt;br /&gt;
You can print the generated curve parameters to the terminal output with the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -text&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters as C Code====&lt;br /&gt;
&lt;br /&gt;
Analogously, you may also output the generated curve parameters as C code. The parameters can then be loaded by calling the &amp;lt;tt&amp;gt;get_ec_group_XXX()&amp;lt;/tt&amp;gt; function. To print the C code to the current terminal's output, the following command may be used:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -C&lt;br /&gt;
&lt;br /&gt;
And here are the first few lines of the corresponding output:&lt;br /&gt;
&lt;br /&gt;
 EC_GROUP *get_ec_group_256(void)&lt;br /&gt;
 {&lt;br /&gt;
     static unsigned char ec_p_256[] = {&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,&lt;br /&gt;
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,&lt;br /&gt;
         ...&lt;br /&gt;
&lt;br /&gt;
===Generating the Key===&lt;br /&gt;
&lt;br /&gt;
With the curve parameters in hand, we are now free to generate the key. Just as with the [#Generating an RSA Private Key|RSA] example above, we may optionally specify a cipher algorithm with which to encrypt the private key. The call to generate the key using the elliptic curve parameters generated in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -paramfile prime256v1.pem -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
==Base64 Encoding Strings==&lt;br /&gt;
&lt;br /&gt;
For simple string encoding, you can use &amp;quot;here string&amp;quot; syntax with the [[Base64 Encoding|base64]] command as below. Intuitively, the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; flag specifies the action to be encoding.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -e &amp;lt;&amp;lt;&amp;lt; 'Welcome to openssl wiki'&lt;br /&gt;
 V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK&lt;br /&gt;
&lt;br /&gt;
Similarly, the base64 command's &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flag may be used to indicate decoding mode.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -d &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK'&lt;br /&gt;
 Welcome to openssl wiki&lt;br /&gt;
&lt;br /&gt;
==Generating a File Hash==&lt;br /&gt;
&lt;br /&gt;
One of the most basic uses of the [[dgst]] command (short for digest) is viewing the hash of a given file. To do this, simply invoke the command with the specified digest algorithm to use. For this example, I will be hashing an arbitrary file on my system using the [[MD5]], [[SHA1]], and [[SHA384]] algorithms.&lt;br /&gt;
&lt;br /&gt;
 $ openssl dgst -md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
For a list of the available digest algorithms, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-algorithms&lt;br /&gt;
 RSA-MD4 =&amp;gt; MD4&lt;br /&gt;
 RSA-MD5 =&amp;gt; MD5&lt;br /&gt;
 RSA-MDC2 =&amp;gt; MDC2&lt;br /&gt;
 RSA-RIPEMD160 =&amp;gt; RIPEMD160&lt;br /&gt;
 RSA-SHA1 =&amp;gt; SHA1&lt;br /&gt;
 RSA-SHA1-2 =&amp;gt; RSA-SHA1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use a similar command to see the available [[Digest Commands|digest commands]]:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-commands&lt;br /&gt;
 blake2b512        blake2s256        gost              md4               &lt;br /&gt;
 md5               mdc2              rmd160            sha1              &lt;br /&gt;
 sha224            sha256            sha3-224          sha3-256          &lt;br /&gt;
 sha3-384          sha3-512          sha384            sha512            &lt;br /&gt;
 sha512-224        sha512-256        shake128          shake256          &lt;br /&gt;
 sm3      &lt;br /&gt;
&lt;br /&gt;
Below are three sample invocations of the [[md5]], [[sha1]], and [[sha384]] digest commands using the same file as the [[dgst]] command invocation above.&lt;br /&gt;
&lt;br /&gt;
 $ openssl md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
==File Encryption and Decryption==&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates a simple file encryption and decryption using the [[enc]] command. The first argument is the cipher algorithm to use for encrypting the file. For this example I carefully selected the [[AES-256]] algorithm in [[CBC Mode]] by looking up the available ciphers and picking out the first one I saw. To see the list of available ciphers, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -ciphers&lt;br /&gt;
 Supported ciphers:&lt;br /&gt;
 -aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             &lt;br /&gt;
 -aes-128-cfb8              -aes-128-ctr               -aes-128-ecb              &lt;br /&gt;
 -aes-128-ofb               -aes-192-cbc               -aes-192-cfb              &lt;br /&gt;
 -aes-192-cfb1              -aes-192-cfb8              -aes-192-ctr&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
 AES-128-CBC&lt;br /&gt;
 AES-128-CBC-HMAC-SHA1&lt;br /&gt;
 AES-128-CBC-HMAC-SHA256&lt;br /&gt;
 id-aes128-CCM&lt;br /&gt;
 AES-128-CFB&lt;br /&gt;
 AES-128-CFB1&lt;br /&gt;
 AES-128-CFB8&lt;br /&gt;
 AES-128-CTR&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Having selected an encryption algorithm, you must then specify whether the action you are taking is either encryption or decryption via the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flags, respectively. The &amp;lt;tt&amp;gt;-iter&amp;lt;/tt&amp;gt; flag specifies the number of iterations on the password used for deriving the encryption key. A higher iteration count increases the time required to brute-force the resulting file. Using this option implies enabling use of the [[Password-Based Key Derivation Function 2]], usually set using the &amp;lt;tt&amp;gt;-pbkdf2&amp;lt;/tt&amp;gt; flag. We then use the &amp;lt;tt&amp;gt;-salt&amp;lt;/tt&amp;gt; flag to enable the use of a randomly generated salt in the key-derivation function.&lt;br /&gt;
&lt;br /&gt;
Putting it all together, you can see the command to encrypt a file and the corresponding output below. Note that the passwords entered by the user are blank, just as they would usually be in a terminal session.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -e -iter 1000 -salt -in primes.dat -out primes.enc&lt;br /&gt;
 enter aes-256-cbc encryption password:&lt;br /&gt;
 Verifying - enter aes-256-cbc encryption password:&lt;br /&gt;
&lt;br /&gt;
The analogous decryption command is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -d -iter 1000 -in primes.enc -out primes.dec&lt;br /&gt;
 enter aes-256-cbc decryption password:&lt;br /&gt;
&lt;br /&gt;
=Commands=&lt;br /&gt;
&lt;br /&gt;
There are three different kinds of commands. These are [[Standard commands|standard commands]], [[Cipher commands|cipher commands]], and [[Digest comands|digest commands]]. Calling the OpenSSL top-level &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt; command with no arguments will result in openssl printing all available commands by group, sorted alphabetically.&lt;br /&gt;
&lt;br /&gt;
==Standard Commands==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto; text-align: center; width: 65%;&amp;quot;&lt;br /&gt;
|+ Overview of OpenSSL's command line utilities&lt;br /&gt;
! style=&amp;quot;width: 25%; padding: 4px;&amp;quot; | Command&lt;br /&gt;
! style=&amp;quot;width: 75%; padding: 4px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/asn1parse.html asn1parse]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Parse an ASN.1 sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ca.html ca]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Authority (CA) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ciphers.html ciphers]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Cipher Suite Description Determination.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/cms.html cms]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CMS (Cryptographic Message Syntax) utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl.html crl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Revocation List (CRL) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl2pkcs7.html crl2pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CRL to PKCS#7 Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dgst.html dgst]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Digest calculation. MAC calculations are superseded by mac(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dhparam.html dhparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation and Management of Diffie-Hellman Parameters. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsa.html dsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsaparam.html dsaparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Parameter Generation and Management. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ec.html ec]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC (Elliptic curve) key processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ecparam.html ecparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC parameter manipulation and generation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/enc.html enc]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Encoding with Ciphers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/engine.html engine]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Engine (loadable module) information and manipulation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/errstr.html errstr]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Error Number to Error String Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/gendsa.html gendsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of DSA Private Key from Parameters. Superseded by genpkey(1) and pkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genpkey.html genpkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of Private Key or Parameters.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genrsa.html genrsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of RSA Private Key. Superseded by genpkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/info.html info]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Display diverse information built into the OpenSSL libraries.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/kdf.html kdf]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Key Derivation Functions.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/mac.html mac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Authentication Code Calculation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/nseq.html nseq]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create or examine a Netscape certificate sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ocsp.html ocsp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Online Certificate Status Protocol utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/passwd.html passwd]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of hashed passwords.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs12.html pkcs12]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#12 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs7.html pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#7 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs8.html pkcs8]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#8 format private key conversion tool.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkey.html pkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public and private key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyparam.html pkeyparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm parameter management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyutl.html pkeyutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm cryptographic operation utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/prime.html prime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Compute prime numbers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rand.html rand]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generate pseudo-random bytes.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rehash.html rehash]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create symbolic links to certificate and CRL files named by the hash values.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/req.html req]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#10 X.509 Certificate Signing Request (CSR) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsa.html rsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsautl.html rsautl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA utility for signing, verification, encryption, and decryption. Superseded by pkeyutl(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_client.html s_client]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_server.html s_server]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_time.html s_time]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Connection Timer.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/sess_id.html sess_id]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Session Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/smime.html smime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  S/MIME mail processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/speed.html speed]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Algorithm Speed Measurement.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/spkac.html spkac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SPKAC printing and generating utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/srp.html srp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Maintain SRP password file.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/storeutl.html storeutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Utility to list and display certificates, keys, CRLs, etc.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ts.html ts]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Time Stamping Authority tool (client/server).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/verify.html verify]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Verification.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/version.html version]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  OpenSSL Version Information.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/x509.html x509]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Data Management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Further reading =&lt;br /&gt;
&lt;br /&gt;
* Paul Heinlein. [https://www.madboa.com/geek/openssl/ &amp;quot;OpenSSL Command-Line HOWTO&amp;quot;]. Has many quick cookbook-style recipes for doing common tasks using the &amp;quot;oppenssl&amp;quot; command-line application.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:Shell level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=2842</id>
		<title>Talk:Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Command_Line_Utilities&amp;diff=2842"/>
		<updated>2019-07-30T03:35:18Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* Pretty significant rewrite */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Pretty significant rewrite ==&lt;br /&gt;
&lt;br /&gt;
I noticed a lot of the information on the page was essentially a print out of the program help menu, so I thought it would be more beneficial to provide a basic introduction to the command-line utilities in tutorial form, with links to the official documentation. It isn't finished, as there are a lot of topics I didn't cover (certificates being a significant topic I did not cover), but because of the magnitude of the changes, I thought it best to stop here and get feedback on the changes. I'm brand-new to the project and I'm excited contribute in a meaningful way, so please if there is any wrong information, the style is off, etc., please do pass that along.&lt;br /&gt;
&lt;br /&gt;
This rewrite is essentially a reformatting of the previous version, with a lot of additional explanations from the perldocs. The bulk of the changes come from the removing of the old code samples, which were essentially just the helps menus, and the addition of code examples which again come primarily from the perldocs. There's also a table with all of the standard commands which link to their respective manpage on the main openssl site. I thought this was better because now we only have to update one set of documentation, which itself is automatically generated from the pod files.&lt;br /&gt;
&lt;br /&gt;
--[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 03:35, 30 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2841</id>
		<title>Command Line Utilities</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Command_Line_Utilities&amp;diff=2841"/>
		<updated>2019-07-30T03:35:14Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Pretty significant rewrite, details in discussion&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''openssl''' program provides a rich variety of commands, each of which often has a wealth of options and arguments. Many commands use an external configuration file for some or all of their arguments and have a &amp;lt;code&amp;gt;-config&amp;lt;/code&amp;gt; option to specify that file. The environment variable [[OPENSSL_CONF]] can be used to specify the location of the configuration file. If the environment variable is not specified, a default file is created in the default certificate storage area called '''openssl.cnf'''. The settings in this default configuration file depend on the flags set when the version of OpenSSL being used was built.&lt;br /&gt;
&lt;br /&gt;
This article is an overview of the available tools provided by openssl. For all of the details on usage and implementation, you can find the [https://www.openssl.org/docs/manmaster/ manpages] which are automatically generated from the source code at the [https://www.openssl.org/ official OpenSSL project home]. Likewise, the source code itself may be found on the [https://www.openssl.org/source/ OpenSSL project home page], as well as on the [https://github.com/openssl/openssl OpenSSL Github]. The main OpenSSL site also includes an [https://www.openssl.org/docs/manmaster/man1/openssl.html overview of the command-line utilities], as well as links to all of their respective documentation.&lt;br /&gt;
&lt;br /&gt;
=Getting Started=&lt;br /&gt;
&lt;br /&gt;
The entry point for the OpenSSL library is the '''openssl''' binary, usually &amp;lt;tt&amp;gt;/usr/bin/openssl&amp;lt;/tt&amp;gt; on Linux. The general syntax for calling openssl is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl command [ command_options ] [ command_arguments ]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can call openssl without arguments to enter the interactive mode prompt. You may then enter commands directly, exiting with either a &amp;lt;code&amp;gt;quit&amp;lt;/code&amp;gt; command or by issuing a termination signal with either &amp;lt;tt&amp;gt;Ctrl+C&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Ctrl+D&amp;lt;/tt&amp;gt;. The following is a sample interactive session in which the user invokes the [[primes]] command twice before using the &amp;lt;tt&amp;gt;quit&amp;lt;/tt&amp;gt; command to terminate the session.&lt;br /&gt;
&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 13467269&lt;br /&gt;
 OpenSSL&amp;gt; prime -generate -bits 24&lt;br /&gt;
 16651079&lt;br /&gt;
 OpenSSL&amp;gt; quit&lt;br /&gt;
&lt;br /&gt;
=Basic Tasks=&lt;br /&gt;
&lt;br /&gt;
This section is a brief tutorial on performing the most basic tasks using OpenSSL. For a detailed explanation of the rationale behind the syntax and semantics of the commands shown here, see the section on [[#Commands|Commands]].&lt;br /&gt;
&lt;br /&gt;
==Getting Help==&lt;br /&gt;
&lt;br /&gt;
As mentioned previously, the general syntax of a command is &amp;lt;code&amp;gt;openssl command [ command_options ] [ command_arguments ]&amp;lt;/code&amp;gt;. The help command is no different, but it does have its idiosyncrasies. To view the top-level help menu, you can call openssl as follows.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help&lt;br /&gt;
&lt;br /&gt;
This query will print all of the available commands, like so:&lt;br /&gt;
&lt;br /&gt;
 Standard commands&lt;br /&gt;
 asn1parse         ca                ciphers           cms               &lt;br /&gt;
 crl               crl2pkcs7         dgst              dhparam           &lt;br /&gt;
 dsa               dsaparam          ec                ecparam&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Note the above output was truncated, so only the first four lines of output are shown.&lt;br /&gt;
&lt;br /&gt;
A help menu for each command may be requested in two different ways. First, the same command used above may be repeated, followed by the name of the command to print help for.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
&lt;br /&gt;
The program will then display the valid options for the given command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl help genpkey&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
The second way of requesting the help menu for a particular command is by using the first option in the output shown above, namely &amp;lt;code&amp;gt;openssl command -help&amp;lt;/code&amp;gt;. Both commands will yield the same output; the help menu displayed will be exactly the same.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -help&lt;br /&gt;
 Usage: genpkey [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help              Display this summary&lt;br /&gt;
  -out outfile       Output file&lt;br /&gt;
  -outform PEM|DER   output format (DER or PEM)&lt;br /&gt;
  -pass val          Output file pass phrase source&lt;br /&gt;
  -paramfile infile  Parameters file&lt;br /&gt;
  -algorithm val     The public key algorithm&lt;br /&gt;
  -pkeyopt val       Set the public key algorithm option as opt:value&lt;br /&gt;
  -genparam          Generate parameters, not key&lt;br /&gt;
  -text              Print the in text&lt;br /&gt;
  -*                 Cipher to use to encrypt the key&lt;br /&gt;
  -engine val        Use engine, possibly a hardware device&lt;br /&gt;
 Order of options may be important!  See the documentation.&lt;br /&gt;
&lt;br /&gt;
For additional information on the usage of a particular command, the project [https://www.openssl.org/docs/manpages.html manpages] are a great source of information. Another excellent source of information is the project perldocs. [https://perldoc.perl.org/5.30.0/perldoc.html perldoc] is a utility included with most if not all [https://www.perl.org/ Perl] distributions, and it's capable of displaying documentation information in a variety of formats, one of which is as manpages. Not surprisingly, the project documentation is generated from the pod files located in the &amp;lt;tt&amp;gt;doc&amp;lt;/tt&amp;gt; directory of the source code.&lt;br /&gt;
&lt;br /&gt;
==Getting Library Version Information==&lt;br /&gt;
&lt;br /&gt;
 $ openssl version&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
&lt;br /&gt;
As mentioned above, the &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; command's help menu may be queried for additional options like so:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -help&lt;br /&gt;
 Usage: version [options]&lt;br /&gt;
 Valid options are:&lt;br /&gt;
  -help  Display this summary&lt;br /&gt;
  -a     Show all data&lt;br /&gt;
  -b     Show build date&lt;br /&gt;
  -d     Show configuration directory&lt;br /&gt;
  -e     Show engines directory&lt;br /&gt;
  -f     Show compiler flags used&lt;br /&gt;
  -o     Show some internal datatype options&lt;br /&gt;
  -p     Show target build platform&lt;br /&gt;
  -r     Show random seeding options&lt;br /&gt;
  -v     Show library version&lt;br /&gt;
&lt;br /&gt;
Using the &amp;lt;tt&amp;gt;-a&amp;lt;/tt&amp;gt; option to show all version information yields the following output on my current machine:&lt;br /&gt;
&lt;br /&gt;
 $ openssl version -a&lt;br /&gt;
 OpenSSL 1.1.1c  28 May 2019&lt;br /&gt;
 built on: Tue May 28 16:23:39 2019 UTC&lt;br /&gt;
 platform: linux-x86_64&lt;br /&gt;
 options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) &lt;br /&gt;
 compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG -D_FORTIFY_SOURCE=2&lt;br /&gt;
 OPENSSLDIR: &amp;quot;/etc/ssl&amp;quot;&lt;br /&gt;
 ENGINESDIR: &amp;quot;/usr/lib/engines-1.1&amp;quot;&lt;br /&gt;
 Seeding source: os-specific&lt;br /&gt;
&lt;br /&gt;
==Generating an RSA Private Key==&lt;br /&gt;
&lt;br /&gt;
Generating a private key can be done in a variety of different ways depending on the type of key, algorithm, bits, and other options your specific use case may require. In this example, we are generating a private key using RSA and a key size of 2048 bits.&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
To generate a password protected private key, the previous command may be slightly amended as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private-key.pem&lt;br /&gt;
&lt;br /&gt;
The addition of the &amp;lt;tt&amp;gt;-aes256&amp;lt;/tt&amp;gt; option specifies the cipher to use to encrypt the private key file. For a list of available ciphers in the library, you can run the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
&lt;br /&gt;
With your private key in hand, you can use the following command to see the key's details, such as its modulus and its constituent primes. Remember to change the name of the input file to the file name of your private key.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -text&lt;br /&gt;
&lt;br /&gt;
The above command yields the following output in my specific case. Your output will differ but should be structurally similar.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PRIVATE KEY-----&lt;br /&gt;
 MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDZD6IMLRFk4CaF&lt;br /&gt;
 w0rhRienwuE5EZ6xFE8e3C5TVi1+d9Enhi38RgkwD7UlWxPE6AWhp5T3kfrFWdak&lt;br /&gt;
 1lZFVPp7/btOKLjKUru15nLoA4AKYtz9W9PhsM0dyzLc6FQ6K4ReQam5pHCqI2zF&lt;br /&gt;
 82MwE+eIAduvuqyoQLKiI608EArWZqDtMUpBJzv0UVEYvRdnMWpCwfzpI+hPJywV&lt;br /&gt;
 CcTlNCT/ctGgBKyIx+dDuZ7bR9MNmSW7GreJEbTH+R13xT3dd/JCka1+LYCl4h0q&lt;br /&gt;
 oWhFPhOkvQzmmSzUmZlAlTDQLv2eAdJIrQcsnKZ3SsIOCC/3IpqwSzpid38Ill4O&lt;br /&gt;
 xH6XIrVFAgMBAAECggEBAJ2MC0JrM8TULSHJrf/0u7O4b2DMuTIuW386sSUr17mD&lt;br /&gt;
 nfviGF6TNvf7bq++e4rgHbZHvIg1HJ9Bpdne+J86HtUARYNlazru8fAFZEGiyLzB&lt;br /&gt;
 JUV/8TpO6ZJGepR8zSWrkFgZsOddw6i6LalADy5GRDcjoiDajZdR3lZxLrv5qOQU&lt;br /&gt;
 I1vKTf4Zs2Tl3gnaJ/Il1gBHIQ9W9xUH8jPBIwj51iXwCh8H0BiDPvFkU7cHIFCP&lt;br /&gt;
 sJhGsGp6OS3uSwwQuSE+NqbuPfVilysCcwgZduknyio0QO1YfMBL6+XoKE/bFHsn&lt;br /&gt;
 N+FzzczQg9sWyiwVR+3EeI9kp4JSElNh2nqG96i4QAECgYEA76OLUGrShHb4saoP&lt;br /&gt;
 aYnBAKLEdWj5K483JdY6BSbdd5RkDbJG8ExmcbfTas/BGdKc4iVCkxV3ysxKnX18&lt;br /&gt;
 PfxATHDLL8NMa+gGgZY5oTKUsrXEpS132HhCJ9T9LoesQjRb4kOZH8POVqm6O4Xf&lt;br /&gt;
 lCt0y1+M1eQHI1NPO9CmPBgouEUCgYEA5+F4SS8RMyYRkU/kx195fwh0hhaOElzr&lt;br /&gt;
 E8mZou3NFL/XT6/9t+2+7sMTuiQCP9zIa6s+/rrXdjWtrTcDp4WlDITas0UUgZhv&lt;br /&gt;
 YVBQBF4vhHxIVwJxnT9Gwi4XM1JlFmVHofWD71P6DRe7jSWRS3CujP3AE9vmpWMx&lt;br /&gt;
 tE1D9qLiWQECgYB445LzFYBvrKjWz4iI4CJKFNJwvGz+iXfzkXehg7KzkVtMAYSB&lt;br /&gt;
 0rjXYzm3J2ktgq778nn8Qxc0agy2GEil6GvzY+9MgAQ8Z0do9gTKif6zjLjP7vkH&lt;br /&gt;
 bdtJxsuWPoEqwMkdgqZrfNbJp0O4pVddovJ/agtdF3R2YJ+W+DH0HOfl1QKBgFnM&lt;br /&gt;
 c2zEEYEhaQRBUHP1gXO0rouPCI4L9e2/0QPL2/QBJzzxBuzH4X1NhsI7V7OrqOIp&lt;br /&gt;
 e0fiy7Y3q369I2ko1HY4rQln4z0c72VcWOCYKQbBqrInfCBNdPWWK93wNr2pk0gh&lt;br /&gt;
 cGqqtteDLVrIBbCVfsOTMWN/cZ7y/zi4A23sPoQBAoGAEPzcIjOyoB97Pzd7iNim&lt;br /&gt;
 Gin8RkwXIiFGSHo8vAh74CKBNokThM50OUNm5T2eJ4huzPpowQ+ID1mB5EjEai9n&lt;br /&gt;
 JY9ll3cUpawiIIW/6uGTHyXfvZWNtqEYXrVJ6fcDaKcW4y3cplNj/SJaBW8HXsW7&lt;br /&gt;
 YGHW3zHsgy7EOAOzPwlm9oE=&lt;br /&gt;
 -----END PRIVATE KEY-----&lt;br /&gt;
 RSA Private-Key: (2048 bit, 2 primes)&lt;br /&gt;
 modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 publicExponent: 65537 (0x10001)&lt;br /&gt;
 privateExponent:&lt;br /&gt;
     00:9d:8c:0b:42:6b:33:c4:d4:2d:21:c9:ad:ff:f4:&lt;br /&gt;
     bb:b3:b8:6f:60:cc:b9:32:2e:5b:7f:3a:b1:25:2b:&lt;br /&gt;
     d7:b9:83:9d:fb:e2:18:5e:93:36:f7:fb:6e:af:be:&lt;br /&gt;
     7b:8a:e0:1d:b6:47:bc:88:35:1c:9f:41:a5:d9:de:&lt;br /&gt;
     f8:9f:3a:1e:d5:00:45:83:65:6b:3a:ee:f1:f0:05:&lt;br /&gt;
     64:41:a2:c8:bc:c1:25:45:7f:f1:3a:4e:e9:92:46:&lt;br /&gt;
     7a:94:7c:cd:25:ab:90:58:19:b0:e7:5d:c3:a8:ba:&lt;br /&gt;
     2d:a9:40:0f:2e:46:44:37:23:a2:20:da:8d:97:51:&lt;br /&gt;
     de:56:71:2e:bb:f9:a8:e4:14:23:5b:ca:4d:fe:19:&lt;br /&gt;
     b3:64:e5:de:09:da:27:f2:25:d6:00:47:21:0f:56:&lt;br /&gt;
     f7:15:07:f2:33:c1:23:08:f9:d6:25:f0:0a:1f:07:&lt;br /&gt;
     d0:18:83:3e:f1:64:53:b7:07:20:50:8f:b0:98:46:&lt;br /&gt;
     b0:6a:7a:39:2d:ee:4b:0c:10:b9:21:3e:36:a6:ee:&lt;br /&gt;
     3d:f5:62:97:2b:02:73:08:19:76:e9:27:ca:2a:34:&lt;br /&gt;
     40:ed:58:7c:c0:4b:eb:e5:e8:28:4f:db:14:7b:27:&lt;br /&gt;
     37:e1:73:cd:cc:d0:83:db:16:ca:2c:15:47:ed:c4:&lt;br /&gt;
     78:8f:64:a7:82:52:12:53:61:da:7a:86:f7:a8:b8:&lt;br /&gt;
     40:01&lt;br /&gt;
 prime1:&lt;br /&gt;
     00:ef:a3:8b:50:6a:d2:84:76:f8:b1:aa:0f:69:89:&lt;br /&gt;
     c1:00:a2:c4:75:68:f9:2b:8f:37:25:d6:3a:05:26:&lt;br /&gt;
     dd:77:94:64:0d:b2:46:f0:4c:66:71:b7:d3:6a:cf:&lt;br /&gt;
     c1:19:d2:9c:e2:25:42:93:15:77:ca:cc:4a:9d:7d:&lt;br /&gt;
     7c:3d:fc:40:4c:70:cb:2f:c3:4c:6b:e8:06:81:96:&lt;br /&gt;
     39:a1:32:94:b2:b5:c4:a5:2d:77:d8:78:42:27:d4:&lt;br /&gt;
     fd:2e:87:ac:42:34:5b:e2:43:99:1f:c3:ce:56:a9:&lt;br /&gt;
     ba:3b:85:df:94:2b:74:cb:5f:8c:d5:e4:07:23:53:&lt;br /&gt;
     4f:3b:d0:a6:3c:18:28:b8:45&lt;br /&gt;
 prime2:&lt;br /&gt;
     00:e7:e1:78:49:2f:11:33:26:11:91:4f:e4:c7:5f:&lt;br /&gt;
     79:7f:08:74:86:16:8e:12:5c:eb:13:c9:99:a2:ed:&lt;br /&gt;
     cd:14:bf:d7:4f:af:fd:b7:ed:be:ee:c3:13:ba:24:&lt;br /&gt;
     02:3f:dc:c8:6b:ab:3e:fe:ba:d7:76:35:ad:ad:37:&lt;br /&gt;
     03:a7:85:a5:0c:84:da:b3:45:14:81:98:6f:61:50:&lt;br /&gt;
     50:04:5e:2f:84:7c:48:57:02:71:9d:3f:46:c2:2e:&lt;br /&gt;
     17:33:52:65:16:65:47:a1:f5:83:ef:53:fa:0d:17:&lt;br /&gt;
     bb:8d:25:91:4b:70:ae:8c:fd:c0:13:db:e6:a5:63:&lt;br /&gt;
     31:b4:4d:43:f6:a2:e2:59:01&lt;br /&gt;
 exponent1:&lt;br /&gt;
     78:e3:92:f3:15:80:6f:ac:a8:d6:cf:88:88:e0:22:&lt;br /&gt;
     4a:14:d2:70:bc:6c:fe:89:77:f3:91:77:a1:83:b2:&lt;br /&gt;
     b3:91:5b:4c:01:84:81:d2:b8:d7:63:39:b7:27:69:&lt;br /&gt;
     2d:82:ae:fb:f2:79:fc:43:17:34:6a:0c:b6:18:48:&lt;br /&gt;
     a5:e8:6b:f3:63:ef:4c:80:04:3c:67:47:68:f6:04:&lt;br /&gt;
     ca:89:fe:b3:8c:b8:cf:ee:f9:07:6d:db:49:c6:cb:&lt;br /&gt;
     96:3e:81:2a:c0:c9:1d:82:a6:6b:7c:d6:c9:a7:43:&lt;br /&gt;
     b8:a5:57:5d:a2:f2:7f:6a:0b:5d:17:74:76:60:9f:&lt;br /&gt;
     96:f8:31:f4:1c:e7:e5:d5&lt;br /&gt;
 exponent2:&lt;br /&gt;
     59:cc:73:6c:c4:11:81:21:69:04:41:50:73:f5:81:&lt;br /&gt;
     73:b4:ae:8b:8f:08:8e:0b:f5:ed:bf:d1:03:cb:db:&lt;br /&gt;
     f4:01:27:3c:f1:06:ec:c7:e1:7d:4d:86:c2:3b:57:&lt;br /&gt;
     b3:ab:a8:e2:29:7b:47:e2:cb:b6:37:ab:7e:bd:23:&lt;br /&gt;
     69:28:d4:76:38:ad:09:67:e3:3d:1c:ef:65:5c:58:&lt;br /&gt;
     e0:98:29:06:c1:aa:b2:27:7c:20:4d:74:f5:96:2b:&lt;br /&gt;
     dd:f0:36:bd:a9:93:48:21:70:6a:aa:b6:d7:83:2d:&lt;br /&gt;
     5a:c8:05:b0:95:7e:c3:93:31:63:7f:71:9e:f2:ff:&lt;br /&gt;
     38:b8:03:6d:ec:3e:84:01&lt;br /&gt;
 coefficient:&lt;br /&gt;
     10:fc:dc:22:33:b2:a0:1f:7b:3f:37:7b:88:d8:a6:&lt;br /&gt;
     1a:29:fc:46:4c:17:22:21:46:48:7a:3c:bc:08:7b:&lt;br /&gt;
     e0:22:81:36:89:13:84:ce:74:39:43:66:e5:3d:9e:&lt;br /&gt;
     27:88:6e:cc:fa:68:c1:0f:88:0f:59:81:e4:48:c4:&lt;br /&gt;
     6a:2f:67:25:8f:65:97:77:14:a5:ac:22:20:85:bf:&lt;br /&gt;
     ea:e1:93:1f:25:df:bd:95:8d:b6:a1:18:5e:b5:49:&lt;br /&gt;
     e9:f7:03:68:a7:16:e3:2d:dc:a6:53:63:fd:22:5a:&lt;br /&gt;
     05:6f:07:5e:c5:bb:60:61:d6:df:31:ec:83:2e:c4:&lt;br /&gt;
     38:03:b3:3f:09:66:f6:81&lt;br /&gt;
&lt;br /&gt;
Keep in mind the above key was generated solely for pedagogical purposes; never give anyone access to your private keys.&lt;br /&gt;
&lt;br /&gt;
==Generating a Public Key==&lt;br /&gt;
&lt;br /&gt;
Having previously generated your private key, you may generate the corresponding public key using the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in private-key.pem -out public-key.pem -pubout&lt;br /&gt;
&lt;br /&gt;
You may once again view the key details, using a slightly different command this time.&lt;br /&gt;
&lt;br /&gt;
 $ openssl pkey -in public-key.pem -pubin -text&lt;br /&gt;
&lt;br /&gt;
The output for the public key will be shorter, as it carries much less information, and it will look something like this.&lt;br /&gt;
&lt;br /&gt;
 -----BEGIN PUBLIC KEY-----&lt;br /&gt;
 MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Q+iDC0RZOAmhcNK4UYn&lt;br /&gt;
 p8LhORGesRRPHtwuU1YtfnfRJ4Yt/EYJMA+1JVsTxOgFoaeU95H6xVnWpNZWRVT6&lt;br /&gt;
 e/27Tii4ylK7teZy6AOACmLc/VvT4bDNHcsy3OhUOiuEXkGpuaRwqiNsxfNjMBPn&lt;br /&gt;
 iAHbr7qsqECyoiOtPBAK1mag7TFKQSc79FFRGL0XZzFqQsH86SPoTycsFQnE5TQk&lt;br /&gt;
 /3LRoASsiMfnQ7me20fTDZkluxq3iRG0x/kdd8U93XfyQpGtfi2ApeIdKqFoRT4T&lt;br /&gt;
 pL0M5pks1JmZQJUw0C79ngHSSK0HLJymd0rCDggv9yKasEs6Ynd/CJZeDsR+lyK1&lt;br /&gt;
 RQIDAQAB&lt;br /&gt;
 -----END PUBLIC KEY-----&lt;br /&gt;
 RSA Public-Key: (2048 bit)&lt;br /&gt;
 Modulus:&lt;br /&gt;
     00:d9:0f:a2:0c:2d:11:64:e0:26:85:c3:4a:e1:46:&lt;br /&gt;
     27:a7:c2:e1:39:11:9e:b1:14:4f:1e:dc:2e:53:56:&lt;br /&gt;
     2d:7e:77:d1:27:86:2d:fc:46:09:30:0f:b5:25:5b:&lt;br /&gt;
     13:c4:e8:05:a1:a7:94:f7:91:fa:c5:59:d6:a4:d6:&lt;br /&gt;
     56:45:54:fa:7b:fd:bb:4e:28:b8:ca:52:bb:b5:e6:&lt;br /&gt;
     72:e8:03:80:0a:62:dc:fd:5b:d3:e1:b0:cd:1d:cb:&lt;br /&gt;
     32:dc:e8:54:3a:2b:84:5e:41:a9:b9:a4:70:aa:23:&lt;br /&gt;
     6c:c5:f3:63:30:13:e7:88:01:db:af:ba:ac:a8:40:&lt;br /&gt;
     b2:a2:23:ad:3c:10:0a:d6:66:a0:ed:31:4a:41:27:&lt;br /&gt;
     3b:f4:51:51:18:bd:17:67:31:6a:42:c1:fc:e9:23:&lt;br /&gt;
     e8:4f:27:2c:15:09:c4:e5:34:24:ff:72:d1:a0:04:&lt;br /&gt;
     ac:88:c7:e7:43:b9:9e:db:47:d3:0d:99:25:bb:1a:&lt;br /&gt;
     b7:89:11:b4:c7:f9:1d:77:c5:3d:dd:77:f2:42:91:&lt;br /&gt;
     ad:7e:2d:80:a5:e2:1d:2a:a1:68:45:3e:13:a4:bd:&lt;br /&gt;
     0c:e6:99:2c:d4:99:99:40:95:30:d0:2e:fd:9e:01:&lt;br /&gt;
     d2:48:ad:07:2c:9c:a6:77:4a:c2:0e:08:2f:f7:22:&lt;br /&gt;
     9a:b0:4b:3a:62:77:7f:08:96:5e:0e:c4:7e:97:22:&lt;br /&gt;
     b5:45&lt;br /&gt;
 Exponent: 65537 (0x10001)&lt;br /&gt;
&lt;br /&gt;
For more information on generating keys, see the source code documentation, located in the &amp;lt;tt&amp;gt;doc/HOWTO/keys.txt&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
==Generating Keys Based on Elliptic Curves==&lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to generating a key:&lt;br /&gt;
&lt;br /&gt;
# Generate the parameters for the specific curve you are using&lt;br /&gt;
# Use those parameters to generate the key&lt;br /&gt;
&lt;br /&gt;
To see the list of curves instrinsically supported by openssl, you can use the &amp;lt;tt&amp;gt;-list_curves&amp;lt;/t&amp;gt; option when calling the &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -list_curves&lt;br /&gt;
   secp112r1 : SECG/WTLS curve over a 112 bit prime field&lt;br /&gt;
   secp112r2 : SECG curve over a 112 bit prime field&lt;br /&gt;
   secp128r1 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp128r2 : SECG curve over a 128 bit prime field&lt;br /&gt;
   secp160k1 : SECG curve over a 160 bit prime field&lt;br /&gt;
   ...&lt;br /&gt;
&lt;br /&gt;
For this example I will use the &amp;lt;tt&amp;gt;prime256v1&amp;lt;/tt&amp;gt; curve, which is an &amp;lt;tt&amp;gt;X9.62/SECG&amp;lt;/tt&amp;gt; curve over a 256 bit prime field.&lt;br /&gt;
&lt;br /&gt;
===Generating the Curve Parameters===&lt;br /&gt;
&lt;br /&gt;
Having selected our curve, we now call &amp;lt;tt&amp;gt;ecparam&amp;lt;/tt&amp;gt; to generate our parameters file.&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -name prime256v1 -out prime256v1.pem&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters to Standard Out====&lt;br /&gt;
&lt;br /&gt;
You can print the generated curve parameters to the terminal output with the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -text&lt;br /&gt;
 ASN1 OID: prime256v1&lt;br /&gt;
 NIST CURVE: P-256&lt;br /&gt;
&lt;br /&gt;
====Printing Parameters as C Code====&lt;br /&gt;
&lt;br /&gt;
Analogously, you may also output the generated curve parameters as C code. The parameters can then be loaded by calling the &amp;lt;tt&amp;gt;get_ec_group_XXX()&amp;lt;/tt&amp;gt; function. To print the C code to the current terminal's output, the following command may be used:&lt;br /&gt;
&lt;br /&gt;
 $ openssl ecparam -in prime256v1.pem -noout -C&lt;br /&gt;
&lt;br /&gt;
And here are the first few lines of the corresponding output:&lt;br /&gt;
&lt;br /&gt;
 EC_GROUP *get_ec_group_256(void)&lt;br /&gt;
 {&lt;br /&gt;
     static unsigned char ec_p_256[] = {&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,&lt;br /&gt;
         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,&lt;br /&gt;
         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,&lt;br /&gt;
         ...&lt;br /&gt;
&lt;br /&gt;
===Generating the Key===&lt;br /&gt;
&lt;br /&gt;
With the curve parameters in hand, we are now free to generate the key. Just as with the [#Generating an RSA Private Key|RSA] example above, we may optionally specify a cipher algorithm with which to encrypt the private key. The call to generate the key using the elliptic curve parameters generated in the example above looks like this:&lt;br /&gt;
&lt;br /&gt;
 $ openssl genpkey -aes256 -paramfile prime256v1.pem -out private-key.pem&lt;br /&gt;
 Enter PEM pass phrase:&lt;br /&gt;
 Verifying - Enter PEM pass phrase:&lt;br /&gt;
&lt;br /&gt;
==Base64 Encoding Strings==&lt;br /&gt;
&lt;br /&gt;
For simple string encoding, you can use &amp;quot;here string&amp;quot; syntax with the [[Base64 Encoding|base64]] command as below. Intuitively, the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; flag specifies the action to be encoding.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -e &amp;lt;&amp;lt;&amp;lt; 'Welcome to openssl wiki'&lt;br /&gt;
 V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK&lt;br /&gt;
&lt;br /&gt;
Similarly, the base64 command's &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flag may be used to indicate decoding mode.&lt;br /&gt;
&lt;br /&gt;
 $ openssl base64 -d &amp;lt;&amp;lt;&amp;lt; 'V2VsY29tZSB0byBvcGVuc3NsIHdpa2kK'&lt;br /&gt;
 Welcome to openssl wiki&lt;br /&gt;
&lt;br /&gt;
==Generating a File Hash==&lt;br /&gt;
&lt;br /&gt;
One of the most basic uses of the [[dgst]] command (short for digest) is viewing the hash of a given file. To do this, simply invoke the command with the specified digest algorithm to use. For this example, I will be hashing an arbitrary file on my system using the [[MD5]], [[SHA1]], and [[SHA384]] algorithms.&lt;br /&gt;
&lt;br /&gt;
 $ openssl dgst -md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl dgst -sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
For a list of the available digest algorithms, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-algorithms&lt;br /&gt;
 RSA-MD4 =&amp;gt; MD4&lt;br /&gt;
 RSA-MD5 =&amp;gt; MD5&lt;br /&gt;
 RSA-MDC2 =&amp;gt; MDC2&lt;br /&gt;
 RSA-RIPEMD160 =&amp;gt; RIPEMD160&lt;br /&gt;
 RSA-SHA1 =&amp;gt; SHA1&lt;br /&gt;
 RSA-SHA1-2 =&amp;gt; RSA-SHA1&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use a similar command to see the available [[Digest Commands|digest commands]]:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -digest-commands&lt;br /&gt;
 blake2b512        blake2s256        gost              md4               &lt;br /&gt;
 md5               mdc2              rmd160            sha1              &lt;br /&gt;
 sha224            sha256            sha3-224          sha3-256          &lt;br /&gt;
 sha3-384          sha3-512          sha384            sha512            &lt;br /&gt;
 sha512-224        sha512-256        shake128          shake256          &lt;br /&gt;
 sm3      &lt;br /&gt;
&lt;br /&gt;
Below are three sample invocations of the [[md5]], [[sha1]], and [[sha384]] digest commands using the same file as the [[dgst]] command invocation above.&lt;br /&gt;
&lt;br /&gt;
 $ openssl md5 primes.dat&lt;br /&gt;
 MD5(primes.dat)= 7710839bb87d2c4c15a86c2b2c805664&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha1 primes.dat&lt;br /&gt;
 SHA1(primes.dat)= 5dfab70ce825591689f4a3f65910870a9022cd32&lt;br /&gt;
 &lt;br /&gt;
 $ openssl sha384 primes.dat&lt;br /&gt;
 SHA384(primes.dat)= 41399bdffe6850f5a44852d967f3db415654f20dc2eb6cd231772f6ea411876d85d44091ebbc6b1f4ce8673e64617271&lt;br /&gt;
&lt;br /&gt;
==File Encryption and Decryption==&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates a simple file encryption and decryption using the [[enc]] command. The first argument is the cipher algorithm to use for encrypting the file. For this example I carefully selected the [[AES-256]] algorithm in [[CBC Mode]] by looking up the available ciphers and picking out the first one I saw. To see the list of available ciphers, you can use the following command.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -ciphers&lt;br /&gt;
 Supported ciphers:&lt;br /&gt;
 -aes-128-cbc               -aes-128-cfb               -aes-128-cfb1             &lt;br /&gt;
 -aes-128-cfb8              -aes-128-ctr               -aes-128-ecb              &lt;br /&gt;
 -aes-128-ofb               -aes-192-cbc               -aes-192-cfb              &lt;br /&gt;
 -aes-192-cfb1              -aes-192-cfb8              -aes-192-ctr&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can also use the following command:&lt;br /&gt;
&lt;br /&gt;
 $ openssl list -cipher-algorithms&lt;br /&gt;
 AES-128-CBC&lt;br /&gt;
 AES-128-CBC-HMAC-SHA1&lt;br /&gt;
 AES-128-CBC-HMAC-SHA256&lt;br /&gt;
 id-aes128-CCM&lt;br /&gt;
 AES-128-CFB&lt;br /&gt;
 AES-128-CFB1&lt;br /&gt;
 AES-128-CFB8&lt;br /&gt;
 AES-128-CTR&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Having selected an encryption algorithm, you must then specify whether the action you are taking is either encryption or decryption via the &amp;lt;tt&amp;gt;-e&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; flags, respectively. The &amp;lt;tt&amp;gt;-iter&amp;lt;/tt&amp;gt; flag specifies the number of iterations on the password used for deriving the encryption key. A higher iteration count increases the time required to brute-force the resulting file. Using this option implies enabling use of the [[Password-Based Key Derivation Function 2]], usually set using the &amp;lt;tt&amp;gt;-pbkdf2&amp;lt;/tt&amp;gt; flag. We then use the &amp;lt;tt&amp;gt;-salt&amp;lt;/tt&amp;gt; flag to enable the use of a randomly generated salt in the key-derivation function.&lt;br /&gt;
&lt;br /&gt;
Putting it all together, you can see the command to encrypt a file and the corresponding output below. Note that the passwords entered by the user are blank, just as they would usually be in a terminal session.&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -e -iter 1000 -salt -in primes.dat -out primes.enc&lt;br /&gt;
 enter aes-256-cbc encryption password:&lt;br /&gt;
 Verifying - enter aes-256-cbc encryption password:&lt;br /&gt;
&lt;br /&gt;
The analogous decryption command is as follows:&lt;br /&gt;
&lt;br /&gt;
 $ openssl enc -aes-256-cbc -d -iter 1000 -in primes.enc -out primes.dec&lt;br /&gt;
 enter aes-256-cbc decryption password:&lt;br /&gt;
&lt;br /&gt;
=Commands=&lt;br /&gt;
&lt;br /&gt;
There are three different kinds of commands. These are [[Standard commands|standard commands]], [[Cipher commands|cipher commands]], and [[Digest comands|digest commands]]. Calling the OpenSSL top-level &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt; command with no arguments will result in openssl printing all available commands by group, sorted alphabetically.&lt;br /&gt;
&lt;br /&gt;
==Standard Commands==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin:auto; text-align: center; width: 65%;&amp;quot;&lt;br /&gt;
|+ Overview of OpenSSL's command line utilities&lt;br /&gt;
! style=&amp;quot;width: 25%; padding: 4px;&amp;quot; | Command&lt;br /&gt;
! style=&amp;quot;width: 75%; padding: 4px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/asn1parse.html asn1parse]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Parse an ASN.1 sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ca.html ca]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Authority (CA) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ciphers.html ciphers]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Cipher Suite Description Determination.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/cms.html cms]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CMS (Cryptographic Message Syntax) utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl.html crl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Certificate Revocation List (CRL) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/crl2pkcs7.html crl2pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  CRL to PKCS#7 Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dgst.html dgst]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Digest calculation. MAC calculations are superseded by mac(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dhparam.html dhparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation and Management of Diffie-Hellman Parameters. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsa.html dsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/dsaparam.html dsaparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  DSA Parameter Generation and Management. Superseded by genpkey(1) and pkeyparam(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ec.html ec]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC (Elliptic curve) key processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ecparam.html ecparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  EC parameter manipulation and generation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/enc.html enc]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Encoding with Ciphers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/engine.html engine]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Engine (loadable module) information and manipulation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/errstr.html errstr]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Error Number to Error String Conversion.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/gendsa.html gendsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of DSA Private Key from Parameters. Superseded by genpkey(1) and pkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genpkey.html genpkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of Private Key or Parameters.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/genrsa.html genrsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of RSA Private Key. Superseded by genpkey(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/info.html info]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Display diverse information built into the OpenSSL libraries.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/kdf.html kdf]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Key Derivation Functions.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/mac.html mac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Message Authentication Code Calculation.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/nseq.html nseq]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create or examine a Netscape certificate sequence.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ocsp.html ocsp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Online Certificate Status Protocol utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/passwd.html passwd]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generation of hashed passwords.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs12.html pkcs12]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#12 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs7.html pkcs7]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#7 Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkcs8.html pkcs8]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#8 format private key conversion tool.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkey.html pkey]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public and private key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyparam.html pkeyparam]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm parameter management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/pkeyutl.html pkeyutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Public key algorithm cryptographic operation utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/prime.html prime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Compute prime numbers.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rand.html rand]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Generate pseudo-random bytes.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rehash.html rehash]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Create symbolic links to certificate and CRL files named by the hash values.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/req.html req]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  PKCS#10 X.509 Certificate Signing Request (CSR) Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsa.html rsa]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA key management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/rsautl.html rsautl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  RSA utility for signing, verification, encryption, and decryption. Superseded by pkeyutl(1).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_client.html s_client]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS client which can establish a transparent connection to a remote server speaking SSL/TLS.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_server.html s_server]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  This implements a generic SSL/TLS server which accepts connections from remote clients speaking SSL/TLS. &lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/s_time.html s_time]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Connection Timer.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/sess_id.html sess_id]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SSL Session Data Management.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/smime.html smime]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  S/MIME mail processing.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/speed.html speed]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Algorithm Speed Measurement.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/spkac.html spkac]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  SPKAC printing and generating utility.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/srp.html srp]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Maintain SRP password file.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/storeutl.html storeutl]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Utility to list and display certificates, keys, CRLs, etc.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/ts.html ts]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  Time Stamping Authority tool (client/server).&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/verify.html verify]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Verification.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/version.html version]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  OpenSSL Version Information.&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; | [https://www.openssl.org/docs/manmaster/man1/x509.html x509]&lt;br /&gt;
|style=&amp;quot;padding: 4px;&amp;quot; |  X.509 Certificate Data Management.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Further reading =&lt;br /&gt;
&lt;br /&gt;
* Paul Heinlein. [https://www.madboa.com/geek/openssl/ &amp;quot;OpenSSL Command-Line HOWTO&amp;quot;]. Has many quick cookbook-style recipes for doing common tasks using the &amp;quot;oppenssl&amp;quot; command-line application.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:Shell level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Diffie-Hellman_parameters&amp;diff=2837</id>
		<title>Diffie-Hellman parameters</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Diffie-Hellman_parameters&amp;diff=2837"/>
		<updated>2019-07-29T20:54:33Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added page to examples category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To use [http://blog.ivanristic.com/2013/06/ssl-labs-deploying-forward-secrecy.html perfect forward secrecy] cipher suites, you must set up [[Diffie Hellman|Diffie-Hellman]] parameters ([http://www.mail-archive.com/openssl-users@openssl.org/msg71878.html on the server side]), or the PFS cipher suites will be silently ignored.&lt;br /&gt;
&lt;br /&gt;
== Diffie-Hellman ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;SSL_CTX_set_tmp_dh&amp;lt;/code&amp;gt; is used to set the Diffie-Hellman parameters for a context.  One of the easiest ways to get Diffie-Hellman parameters to use with this function is to generate random Diffie-Hellman parameters with the [https://www.openssl.org/docs/apps/dhparam.html dhparam] command-line program with the &amp;lt;code&amp;gt;-C&amp;lt;/code&amp;gt; option, and embed the resulting code fragment in your program.  For example, &amp;lt;code&amp;gt;openssl dhparam -C 2236&amp;lt;/code&amp;gt; might result in:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#ifndef HEADER_DH_H&lt;br /&gt;
#include &amp;lt;openssl/dh.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
DH *get_dh2236()&lt;br /&gt;
	{&lt;br /&gt;
	static unsigned char dh2236_p[]={&lt;br /&gt;
		0x0F,0x52,0xE5,0x24,0xF5,0xFA,0x9D,0xDC,0xC6,0xAB,0xE6,0x04,&lt;br /&gt;
		0xE4,0x20,0x89,0x8A,0xB4,0xBF,0x27,0xB5,0x4A,0x95,0x57,0xA1,&lt;br /&gt;
		0x06,0xE7,0x30,0x73,0x83,0x5E,0xC9,0x23,0x11,0xED,0x42,0x45,&lt;br /&gt;
		0xAC,0x49,0xD3,0xE3,0xF3,0x34,0x73,0xC5,0x7D,0x00,0x3C,0x86,&lt;br /&gt;
		0x63,0x74,0xE0,0x75,0x97,0x84,0x1D,0x0B,0x11,0xDA,0x04,0xD0,&lt;br /&gt;
		0xFE,0x4F,0xB0,0x37,0xDF,0x57,0x22,0x2E,0x96,0x42,0xE0,0x7C,&lt;br /&gt;
		0xD7,0x5E,0x46,0x29,0xAF,0xB1,0xF4,0x81,0xAF,0xFC,0x9A,0xEF,&lt;br /&gt;
		0xFA,0x89,0x9E,0x0A,0xFB,0x16,0xE3,0x8F,0x01,0xA2,0xC8,0xDD,&lt;br /&gt;
		0xB4,0x47,0x12,0xF8,0x29,0x09,0x13,0x6E,0x9D,0xA8,0xF9,0x5D,&lt;br /&gt;
		0x08,0x00,0x3A,0x8C,0xA7,0xFF,0x6C,0xCF,0xE3,0x7C,0x3B,0x6B,&lt;br /&gt;
		0xB4,0x26,0xCC,0xDA,0x89,0x93,0x01,0x73,0xA8,0x55,0x3E,0x5B,&lt;br /&gt;
		0x77,0x25,0x8F,0x27,0xA3,0xF1,0xBF,0x7A,0x73,0x1F,0x85,0x96,&lt;br /&gt;
		0x0C,0x45,0x14,0xC1,0x06,0xB7,0x1C,0x75,0xAA,0x10,0xBC,0x86,&lt;br /&gt;
		0x98,0x75,0x44,0x70,0xD1,0x0F,0x20,0xF4,0xAC,0x4C,0xB3,0x88,&lt;br /&gt;
		0x16,0x1C,0x7E,0xA3,0x27,0xE4,0xAD,0xE1,0xA1,0x85,0x4F,0x1A,&lt;br /&gt;
		0x22,0x0D,0x05,0x42,0x73,0x69,0x45,0xC9,0x2F,0xF7,0xC2,0x48,&lt;br /&gt;
		0xE3,0xCE,0x9D,0x74,0x58,0x53,0xE7,0xA7,0x82,0x18,0xD9,0x3D,&lt;br /&gt;
		0xAF,0xAB,0x40,0x9F,0xAA,0x4C,0x78,0x0A,0xC3,0x24,0x2D,0xDB,&lt;br /&gt;
		0x12,0xA9,0x54,0xE5,0x47,0x87,0xAC,0x52,0xFE,0xE8,0x3D,0x0B,&lt;br /&gt;
		0x56,0xED,0x9C,0x9F,0xFF,0x39,0xE5,0xE5,0xBF,0x62,0x32,0x42,&lt;br /&gt;
		0x08,0xAE,0x6A,0xED,0x88,0x0E,0xB3,0x1A,0x4C,0xD3,0x08,0xE4,&lt;br /&gt;
		0xC4,0xAA,0x2C,0xCC,0xB1,0x37,0xA5,0xC1,0xA9,0x64,0x7E,0xEB,&lt;br /&gt;
		0xF9,0xD3,0xF5,0x15,0x28,0xFE,0x2E,0xE2,0x7F,0xFE,0xD9,0xB9,&lt;br /&gt;
		0x38,0x42,0x57,0x03,&lt;br /&gt;
		};&lt;br /&gt;
	static unsigned char dh2236_g[]={&lt;br /&gt;
		0x02,&lt;br /&gt;
		};&lt;br /&gt;
	DH *dh;&lt;br /&gt;
&lt;br /&gt;
	if ((dh=DH_new()) == NULL) return(NULL);&lt;br /&gt;
	dh-&amp;gt;p=BN_bin2bn(dh2236_p,sizeof(dh2236_p),NULL);&lt;br /&gt;
	dh-&amp;gt;g=BN_bin2bn(dh2236_g,sizeof(dh2236_g),NULL);&lt;br /&gt;
	if ((dh-&amp;gt;p == NULL) || (dh-&amp;gt;g == NULL))&lt;br /&gt;
		{ DH_free(dh); return(NULL); }&lt;br /&gt;
	return(dh);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which can then be used like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DH *dh = get_dh2236 ();&lt;br /&gt;
if (1 != SSL_CTX_set_tmp_dh (ctx, dh))&lt;br /&gt;
  error ();&lt;br /&gt;
DH_free (dh);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Be sure to choose a bit length [http://www.keylength.com/en/3/ appropriate to the security level you want to achieve], although keep in mind that Diffie-Hellman parameters longer than 2236 bits may be [https://bugzilla.mozilla.org/show_bug.cgi?id=636802 incompatible with older versions of NSS].  Even worse, it appears that [http://stackoverflow.com/questions/6851461/java-why-does-ssl-handshake-give-could-not-generate-dh-keypair-exception versions of Java prior to 1.7 don't support Diffie-Hellman parameters longer than 1024 bits]!&lt;br /&gt;
&lt;br /&gt;
== Validating Parameters ==&lt;br /&gt;
&lt;br /&gt;
The Diffie-Hellman parameters should be validated after loading. To perform paramter validation, you call &amp;lt;tt&amp;gt;DH_check&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;DH_check&amp;lt;/tt&amp;gt; returns 0 or a bitmask values of the following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;DH_CHECK_P_NOT_PRIME&amp;lt;/tt&amp;gt; (0x01)&lt;br /&gt;
* &amp;lt;tt&amp;gt;DH_CHECK_P_NOT_SAFE_PRIME&amp;lt;/tt&amp;gt; (0x02)&lt;br /&gt;
* &amp;lt;tt&amp;gt;DH_UNABLE_TO_CHECK_GENERATOR&amp;lt;/tt&amp;gt; (0x04)&lt;br /&gt;
* &amp;lt;tt&amp;gt;DH_NOT_SUITABLE_GENERATOR&amp;lt;/tt&amp;gt; (0x08)&lt;br /&gt;
&lt;br /&gt;
The validation code might look as follows (error checking omitted for clarity):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;BIO* bio = ...;&lt;br /&gt;
DH* dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);&lt;br /&gt;
&lt;br /&gt;
int rc, codes = 0;&lt;br /&gt;
rc = DH_check(dh, &amp;amp;codes);&lt;br /&gt;
assert(rc == 1);&lt;br /&gt;
&lt;br /&gt;
if(BN_is_word(dh-&amp;gt;g, DH_GENERATOR_2))&lt;br /&gt;
{&lt;br /&gt;
    long residue = BN_mod_word(dh-&amp;gt;p, 24);&lt;br /&gt;
    if(residue == 11 || residue == 23) {&lt;br /&gt;
        codes &amp;amp;= ~DH_NOT_SUITABLE_GENERATOR;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if (codes &amp;amp; DH_UNABLE_TO_CHECK_GENERATOR)&lt;br /&gt;
    printf(&amp;quot;DH_check: failed to test generator\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
if (codes &amp;amp; DH_NOT_SUITABLE_GENERATOR)&lt;br /&gt;
    printf(&amp;quot;DH_check: g is not a suitable generator\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
if (codes &amp;amp; DH_CHECK_P_NOT_PRIME)&lt;br /&gt;
    printf(&amp;quot;DH_check: p is not prime\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
if (codes &amp;amp; DH_CHECK_P_NOT_SAFE_PRIME)&lt;br /&gt;
    printf(&amp;quot;DH_check: p is not a safe prime\n&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The additional call to &amp;lt;tt&amp;gt;BN_mod_word(dh-&amp;gt;p, 24)&amp;lt;/tt&amp;gt; (and unmasking of &amp;lt;tt&amp;gt;DH_NOT_SUITABLE_GENERATOR&amp;lt;/tt&amp;gt;) is performed to ensure your program accepts IETF group parameters. OpenSSL checks the prime is congruent to 11 when &amp;lt;tt&amp;gt;g = 2&amp;lt;/tt&amp;gt;; while the IETF's primes are congruent to 23 when &amp;lt;tt&amp;gt;g = 2&amp;lt;/tt&amp;gt;. Without the test, the IETF parameters would fail validation. For details, see [http://crypto.stackexchange.com/questions/12961/diffie-hellman-parameter-check-when-g-2-must-p-mod-24-11 Diffie-Hellman Parameter Check (when g = 2, must p mod 24 == 11?)].&lt;br /&gt;
&lt;br /&gt;
== Elliptic curve Diffie-Hellman ==&lt;br /&gt;
&lt;br /&gt;
For [[Elliptic Curve Diffie Hellman|elliptic curve Diffie-Hellman]], you can do something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
EC_KEY *ecdh = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);&lt;br /&gt;
if (! ecdh)&lt;br /&gt;
  error ();&lt;br /&gt;
if (1 != SSL_CTX_set_tmp_ecdh (ctx, ecdh))&lt;br /&gt;
  error ();&lt;br /&gt;
EC_KEY_free (ecdh);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, in OpenSSL 1.0.2 (not yet released, as of Feb 2013) and higher, you should be able to do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SSL_CTX_set_ecdh_auto (ctx, 1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Elliptic Curve Diffie Hellman]] and [[Elliptic Curve Cryptography]].&lt;br /&gt;
&lt;br /&gt;
== RFC 3526 PEM Encoded Groups ==&lt;br /&gt;
&lt;br /&gt;
Below are three Diffie-Hellman MODP groups specified in [http://tools.ietf.org/html/rfc3526 RFC 3526, More Modular Exponential (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)] (the 1024-bit parameter is from RFC 2409). They can be used with &amp;lt;tt&amp;gt;PEM_read_bio_DHparams&amp;lt;/tt&amp;gt; and a memory &amp;lt;tt&amp;gt;BIO&amp;lt;/tt&amp;gt;. RFC 3526 also offers 1536-bit, 6144-bit and 8192-bit primes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;static const char g_dh1024_sz[] =&lt;br /&gt;
    &amp;quot;-----BEGIN DH PARAMETERS-----\n&amp;quot;&lt;br /&gt;
    &amp;quot;MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR\n&amp;quot;&lt;br /&gt;
    &amp;quot;Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL\n&amp;quot;&lt;br /&gt;
    &amp;quot;/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC\n&amp;quot;&lt;br /&gt;
    &amp;quot;-----END DH PARAMETERS-----&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
static const char g_dh1536_sz[] = &amp;quot;-----BEGIN DH PARAMETERS-----\n&amp;quot;&lt;br /&gt;
    &amp;quot;MIHHAoHBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR\n&amp;quot;&lt;br /&gt;
    &amp;quot;Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL\n&amp;quot;&lt;br /&gt;
    &amp;quot;/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7ORbPcIAfLihY78FmNpINhxV05pp\n&amp;quot;&lt;br /&gt;
    &amp;quot;Fj+o/STPX4NlXSPco62WHGLzViCFUrue1SkHcJaWbWcMNU5KvJgE8XRsCMojcyf/\n&amp;quot;&lt;br /&gt;
    &amp;quot;/////////wIBAg==\n&amp;quot;&lt;br /&gt;
    &amp;quot;-----END DH PARAMETERS-----&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
static const char g_dh2048_sz[] =&lt;br /&gt;
    &amp;quot;-----BEGIN DH PARAMETERS-----\n&amp;quot;&lt;br /&gt;
    &amp;quot;MIIBCAKCAQEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb\n&amp;quot;&lt;br /&gt;
    &amp;quot;IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft\n&amp;quot;&lt;br /&gt;
    &amp;quot;awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT\n&amp;quot;&lt;br /&gt;
    &amp;quot;mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh\n&amp;quot;&lt;br /&gt;
    &amp;quot;fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq\n&amp;quot;&lt;br /&gt;
    &amp;quot;5RXSJhiY+gUQFXKOWoqsqmj//////////wIBAg==\n&amp;quot;&lt;br /&gt;
    &amp;quot;-----END DH PARAMETERS-----&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
static const char g_dh3072_sz[] =&lt;br /&gt;
    &amp;quot;-----BEGIN DH PARAMETERS-----\n&amp;quot;&lt;br /&gt;
    &amp;quot;MIIBiAKCAYEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb\n&amp;quot;&lt;br /&gt;
    &amp;quot;IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft\n&amp;quot;&lt;br /&gt;
    &amp;quot;awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT\n&amp;quot;&lt;br /&gt;
    &amp;quot;mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh\n&amp;quot;&lt;br /&gt;
    &amp;quot;fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq\n&amp;quot;&lt;br /&gt;
    &amp;quot;5RXSJhiY+gUQFXKOWoqqxC2tMxcNBFB6M6hVIavfHLpk7PuFBFjb7wqK6nFXXQYM\n&amp;quot;&lt;br /&gt;
    &amp;quot;fbOXD4Wm4eTHq/WujNsJM9cejJTgSiVhnc7j0iYa0u5r8S/6BtmKCGTYdgJzPshq\n&amp;quot;&lt;br /&gt;
    &amp;quot;ZFIfKxgXeyAMu+EXV3phXWx3CYjAutlG4gjiT6B05asxQ9tb/OD9EI5LgtEgqTrS\n&amp;quot;&lt;br /&gt;
    &amp;quot;yv//////////AgEC\n&amp;quot;&lt;br /&gt;
    &amp;quot;-----END DH PARAMETERS-----&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
static const char g_dh4096_sz[] =&lt;br /&gt;
    &amp;quot;-----BEGIN DH PARAMETERS-----\n&amp;quot;&lt;br /&gt;
    &amp;quot;MIICCAKCAgEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb\n&amp;quot;&lt;br /&gt;
    &amp;quot;IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft\n&amp;quot;&lt;br /&gt;
    &amp;quot;awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT\n&amp;quot;&lt;br /&gt;
    &amp;quot;mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh\n&amp;quot;&lt;br /&gt;
    &amp;quot;fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq\n&amp;quot;&lt;br /&gt;
    &amp;quot;5RXSJhiY+gUQFXKOWoqqxC2tMxcNBFB6M6hVIavfHLpk7PuFBFjb7wqK6nFXXQYM\n&amp;quot;&lt;br /&gt;
    &amp;quot;fbOXD4Wm4eTHq/WujNsJM9cejJTgSiVhnc7j0iYa0u5r8S/6BtmKCGTYdgJzPshq\n&amp;quot;&lt;br /&gt;
    &amp;quot;ZFIfKxgXeyAMu+EXV3phXWx3CYjAutlG4gjiT6B05asxQ9tb/OD9EI5LgtEgqSEI\n&amp;quot;&lt;br /&gt;
    &amp;quot;ARpyPBKnh+bXiHGaEL26WyaZwycYavTiPBqUaDS2FQvaJYPpyirUTOjbu8LbBN6O\n&amp;quot;&lt;br /&gt;
    &amp;quot;+S6O/BQfvsqmKHxZR05rwF2ZspZPoJDDoiM7oYZRW+ftH2EpcM7i16+4G912IXBI\n&amp;quot;&lt;br /&gt;
    &amp;quot;HNAGkSfVsFqpk7TqmI2P3cGG/7fckKbAj030Nck0BjGZ//////////8CAQI=\n&amp;quot;&lt;br /&gt;
    &amp;quot;-----END DH PARAMETERS-----&amp;quot;;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Library_Initialization&amp;diff=2836</id>
		<title>Library Initialization</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Library_Initialization&amp;diff=2836"/>
		<updated>2019-07-29T20:52:52Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Removed the empty errata section and added page to the examples category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page discusses OpenSSL library initialization when using the &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;libcrypto&amp;lt;/tt&amp;gt; components.&lt;br /&gt;
&lt;br /&gt;
There are two ways to initialize the OpenSSL library, and they depend on the version of the library you are using. If you are using OpenSSL 1.0.2 or below, then you would use &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt;. If you are using OpenSSL 1.1.0 or above, then the library will initialize itself automatically. Optionally you can explicitly initialise it using &amp;lt;tt&amp;gt;OPENSSL_init_ssl&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_init_crypto&amp;lt;/tt&amp;gt;. A compatibility macro exists in &amp;lt;tt&amp;gt;ssl.h&amp;lt;/tt&amp;gt; that maps &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;OPENSSL_init_ssl&amp;lt;/tt&amp;gt;, so you can continue to use &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; if desired. Also see ''[http://mta.openssl.org/pipermail/openssl-dev/2016-February/005491.html SSL_library_init]'' on the OpenSSL-dev mailing list.&lt;br /&gt;
&lt;br /&gt;
The rest of this page discusses initializing the library in 1.0.2. If you are using 1.1.0 or above then you don't need to take any further steps.&lt;br /&gt;
&lt;br /&gt;
If you fail to initialize the library in 1.0.2, then you will experience unexplained errors like &amp;lt;tt&amp;gt;SSL_CTX_new&amp;lt;/tt&amp;gt; returning &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt;, error messages like &amp;lt;tt&amp;gt;SSL_CTX_new:library has no ciphers&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;alert handshake failure&amp;lt;/tt&amp;gt; with no shared ciphers.&lt;br /&gt;
&lt;br /&gt;
Below is a list of some initialization calls you might encounter in code or documentation. Unfortunately, all the initialization function return a useless values (for example, always 1) or are void functions. There is no way to determine if a failure occurred.&lt;br /&gt;
&lt;br /&gt;
* SSL_library_init&lt;br /&gt;
* OpenSSL_add_ssl_algorithms&lt;br /&gt;
* OpenSSL_add_all_algorithms&lt;br /&gt;
* SSL_load_error_strings&lt;br /&gt;
* ERR_load_crypto_strings&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== libssl Initialization ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt; should be initialized with calls to &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;SSL_load_error_strings&amp;lt;/tt&amp;gt;. If your program is multi-threaded, you should install the static locks. If you need (or don't need) configuration from &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;, then you should call &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you are supporting both pre-1.1.0 and post-1.1.0 version of the OpenSSL library and you want to take control of &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPENSSL_init_ssl&amp;lt;/tt&amp;gt;, then you can perform:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;openssl/opensslv.h&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
#if OPENSSL_VERSION_NUMBER &amp;lt; 0x10100000L&lt;br /&gt;
SSL_library_init();&lt;br /&gt;
#else&lt;br /&gt;
OPENSSL_init_ssl(0, NULL);&lt;br /&gt;
#endif&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you call &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt;, the function will also initialize &amp;lt;tt&amp;gt;libcrypto&amp;lt;/tt&amp;gt; components. There are two corner cases discussed in later sections. The first corner case is static locks, and second is &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSSL_add_ssl_algorithms&amp;lt;/tt&amp;gt; is a &amp;lt;tt&amp;gt;#define&amp;lt;/tt&amp;gt; for &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt;. You only need to call one or the other. If you want to print error strings using OpenSSL's built in functions, then call &amp;lt;tt&amp;gt;SSL_load_error_strings&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; function loads the algorithms use by &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt;. Below is an excerpt from &amp;lt;tt&amp;gt;ssl_algs.c&amp;lt;/tt&amp;gt; (with some additional formatting for clarity).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int SSL_library_init(void)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
#ifndef OPENSSL_NO_DES&lt;br /&gt;
    EVP_add_cipher(EVP_des_cbc());&lt;br /&gt;
    EVP_add_cipher(EVP_des_ede3_cbc());&lt;br /&gt;
#endif&lt;br /&gt;
#ifndef OPENSSL_NO_IDEA&lt;br /&gt;
    EVP_add_cipher(EVP_idea_cbc());&lt;br /&gt;
#endif&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
#ifndef OPENSSL_NO_COMP&lt;br /&gt;
    (void)SSL_COMP_get_compression_methods();&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
    /* initialize cipher/digest methods table */&lt;br /&gt;
    ssl_load_ciphers();&lt;br /&gt;
&lt;br /&gt;
    return(1);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The call to &amp;lt;tt&amp;gt;ssl_load_ciphers&amp;lt;/tt&amp;gt; simply builds a table for use in the library. The following is from &amp;lt;tt&amp;gt;ssl_ciph.c&amp;lt;/tt&amp;gt; (with some additional formatting for clarity).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void ssl_load_ciphers(void)&lt;br /&gt;
{&lt;br /&gt;
    ssl_cipher_methods[SSL_ENC_DES_IDX] = EVP_get_cipherbyname(SN_des_cbc);&lt;br /&gt;
    ssl_cipher_methods[SSL_ENC_3DES_IDX] = EVP_get_cipherbyname(SN_des_ede3_cbc);&lt;br /&gt;
    ...&lt;br /&gt;
    ssl_digest_methods[SSL_MD_MD5_IDX] = EVP_get_digestbyname(SN_md5);&lt;br /&gt;
    ssl_mac_secret_size[SSL_MD_MD5_IDX] = EVP_MD_size(ssl_digest_methods[SSL_MD_MD5_IDX]);&lt;br /&gt;
    ...&lt;br /&gt;
    ssl_digest_methods[SSL_MD_SHA384_IDX] = EVP_get_digestbyname(SN_sha384);&lt;br /&gt;
    ssl_mac_secret_size[SSL_MD_SHA384_IDX] = EVP_MD_size(ssl_digest_methods[SSL_MD_SHA384_IDX]);&lt;br /&gt;
    ...&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Library Apps ===&lt;br /&gt;
&lt;br /&gt;
The following examines how the OpenSSL development team uses initialization in the OpenSSL utilities.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;s_client&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_ssl_algorithms&lt;br /&gt;
* SSL_load_error_strings&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;s_server&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* SSL_load_error_strings();&lt;br /&gt;
* OpenSSL_add_ssl_algorithms();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;s_time&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_ssl_algorithms();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;state_machine&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* SSL_library_init();&lt;br /&gt;
* OpenSSL_add_ssl_algorithms();&lt;br /&gt;
* SSL_load_error_strings();&lt;br /&gt;
* ERR_load_crypto_strings();&lt;br /&gt;
&lt;br /&gt;
== libcrypto Initialization ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;libcrypto&amp;lt;/tt&amp;gt; should be initialized with calls to &amp;lt;tt&amp;gt;OpenSSL_add_all_algorithms&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ERR_load_crypto_strings&amp;lt;/tt&amp;gt;. If your program is multi-threaded, you should install the static locks. If you need (or don't need) configuration from &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;, then you should call &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;OPENSSL_add_all_algorithms&amp;lt;/tt&amp;gt; function is &amp;lt;tt&amp;gt;#define&amp;lt;/tt&amp;gt;'d to either &amp;lt;tt&amp;gt;OPENSSL_add_all_algorithms_conf&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_add_all_algorithms_noconf&amp;lt;/tt&amp;gt; depending upon the value of &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt;. A typical installation does ''not'' define &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt;, which means &amp;lt;tt&amp;gt;OPENSSL_add_all_algorithms_noconf&amp;lt;/tt&amp;gt; is used. Below is an excerpt from &amp;lt;tt&amp;gt;c_all.c&amp;lt;/tt&amp;gt; (with some additional formatting for clarity).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void OPENSSL_add_all_algorithms_noconf(void)&lt;br /&gt;
{&lt;br /&gt;
    /*&lt;br /&gt;
     * For the moment OPENSSL_cpuid_setup does something&lt;br /&gt;
     * only on IA-32, but we reserve the option for all&lt;br /&gt;
     * platforms...&lt;br /&gt;
     */&lt;br /&gt;
    OPENSSL_cpuid_setup();&lt;br /&gt;
    OpenSSL_add_all_ciphers();&lt;br /&gt;
    OpenSSL_add_all_digests();&lt;br /&gt;
    ...&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;OpenSSL_add_all_ciphers&amp;lt;/tt&amp;gt; looks a lot like &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; from the &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt; initialization routines (sans the call to &amp;lt;tt&amp;gt;ssl_load_ciphers&amp;lt;/tt&amp;gt;). Below is an excerpt from &amp;lt;tt&amp;gt;c_allc.c&amp;lt;/tt&amp;gt; (with some additional formatting for clarity).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void OpenSSL_add_all_ciphers(void)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
#ifndef OPENSSL_NO_DES&lt;br /&gt;
    EVP_add_cipher(EVP_des_cfb());&lt;br /&gt;
    EVP_add_cipher(EVP_des_cfb1());&lt;br /&gt;
    EVP_add_cipher(EVP_des_cfb8());&lt;br /&gt;
    EVP_add_cipher(EVP_des_ede_cfb());&lt;br /&gt;
    EVP_add_cipher(EVP_des_ede3_cfb());&lt;br /&gt;
    EVP_add_cipher(EVP_des_ede3_cfb1());&lt;br /&gt;
    EVP_add_cipher(EVP_des_ede3_cfb8());&lt;br /&gt;
    ...&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#ifndef OPENSSL_NO_RC4&lt;br /&gt;
    EVP_add_cipher(EVP_rc4());&lt;br /&gt;
    EVP_add_cipher(EVP_rc4_40());&lt;br /&gt;
# ifndef OPENSSL_NO_MD5&lt;br /&gt;
    EVP_add_cipher(EVP_rc4_hmac_md5());&lt;br /&gt;
# endif&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
    ...&lt;br /&gt;
&lt;br /&gt;
    /* Note: there is no call to ssl_load_ciphers() here */&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, [http://www.openssl.org/docs/crypto/OpenSSL_add_all_algorithms.html &amp;lt;tt&amp;gt;OpenSSL_add_all_algorithms(3)&amp;lt;/tt&amp;gt;] offers the following advice:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Calling OpenSSL_add_all_algorithms() links in all algorithms: as a result a statically linked executable can be quite large. If this is important it is possible to just add the required ciphers and digests.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want the small footprint, then call &amp;lt;tt&amp;gt;EVP_add_cipher&amp;lt;/tt&amp;gt; with the ciphers and algorithms you need (and nothing more).&lt;br /&gt;
&lt;br /&gt;
=== Library Apps ===&lt;br /&gt;
&lt;br /&gt;
The following examines how the OpenSSL development team uses initialization in the OpenSSL utilities.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;enc&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_all_algorithms();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;dec&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_all_algorithms();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;pkcs8&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* ERR_load_crypto_strings();&lt;br /&gt;
* OpenSSL_add_all_algorithms();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;cms_sign&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_all_algorithms();&lt;br /&gt;
* ERR_load_crypto_strings();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;cms_ver&amp;lt;/tt&amp;gt; initializes itself with the following calls:&lt;br /&gt;
* OpenSSL_add_all_algorithms();&lt;br /&gt;
* ERR_load_crypto_strings();&lt;br /&gt;
&lt;br /&gt;
== ENGINEs and RDRAND ==&lt;br /&gt;
&lt;br /&gt;
A call to &amp;lt;tt&amp;gt;ENGINE_load_builtin_engines&amp;lt;/tt&amp;gt; loads all built-in engines, including those for &amp;lt;tt&amp;gt;AES_NI&amp;lt;/tt&amp;gt; instructions and &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt;. After the call, OpenSSL will use the engines for AES encryption and random number generation, if available. In this case, &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt; will be the only source of random numbers.&lt;br /&gt;
&lt;br /&gt;
If you are concerned over possible &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt; tampering, then you should explicitly call &amp;lt;tt&amp;gt;RAND_set_rand_engine(NULL)&amp;lt;/tt&amp;gt; after loading all engines. If another module in the program happens to call &amp;lt;tt&amp;gt;ENGINE_load_builtin_engines&amp;lt;/tt&amp;gt; again, then you will go back to using &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can also call &amp;lt;tt&amp;gt;ENGINE_unregister_RAND&amp;lt;/tt&amp;gt; followed by &amp;lt;tt&amp;gt;ENGINE_register_all_complete&amp;lt;/tt&amp;gt; to unregister &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt; as default random number generator implementation.&lt;br /&gt;
&lt;br /&gt;
To avoid accidental use of &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt;, you can build OpenSSL with &amp;lt;tt&amp;gt;OPENSSL_NO_RDRAND&amp;lt;/tt&amp;gt; defined. This is the preferred method to avoid all use of &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Future version of the library will change the default behavior. That is, in the future, you will have to explicitly call &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt; if you want to use &amp;lt;tt&amp;gt;RDRAND&amp;lt;/tt&amp;gt;. The change has been checked in, but its only available through &amp;lt;tt&amp;gt;git&amp;lt;/tt&amp;gt; at the moment.&lt;br /&gt;
&lt;br /&gt;
For the full discussion, see coderman's ''[http://seclists.org/fulldisclosure/2013/Dec/99 RDRAND used directly when default engines loaded in openssl-1.0.1-beta1 through openssl-1.0.1e]''.&lt;br /&gt;
&lt;br /&gt;
== Static Locks ==&lt;br /&gt;
&lt;br /&gt;
If your program is multi-threaded, then you will need to install the static locks. The static locks are used for extensively for &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt;, and used in the random number generator for &amp;lt;tt&amp;gt;libcrypto&amp;lt;/tt&amp;gt;. The locks should be installed '''''after''''' the calling:&lt;br /&gt;
&lt;br /&gt;
* SSL_library_init&lt;br /&gt;
* OpenSSL_add_ssl_algorithms&lt;br /&gt;
* OpenSSL_add_all_algorithms&lt;br /&gt;
* SSL_load_error_strings&lt;br /&gt;
* ERR_load_crypto_strings&lt;br /&gt;
&lt;br /&gt;
See [http://stackoverflow.com/a/42856544/608639 Multithreaded program using OpenSSL and locks randomly crashes] on Stack Overflow and [http://www.openssl.org/docs/crypto/threads.html threads(3)] for details until the wiki is updated with an example.&lt;br /&gt;
&lt;br /&gt;
== OPENSSL_config ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt; loads and unloads &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;. More correctly, a call to &amp;lt;tt&amp;gt;OPENSSL_config(NULL)&amp;lt;/tt&amp;gt; loads the default configuration in &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;OPENSSL_config(filename)&amp;lt;/tt&amp;gt; loads another configuration, and &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt; unlods a configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; may (or may not) be called depending upon how the OpenSSL library was configured, and it depends on whether &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt; was defined. Because &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; may (or may not) be called, your program may or may not need to make the call to &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt;. If, for example, your program is dynamically loading an ENGINE from &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt;, then you will need to ensure a call to &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can check the value of &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt; by &amp;lt;tt&amp;gt;cat&amp;lt;/tt&amp;gt;'ing you&amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;openssl/opensslconf.h&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;. You can then decide to call &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt; based upon the definition (or lack threof) for &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cat /usr/local/ssl/include/openssl/opensslconf.h | grep -i load&lt;br /&gt;
$&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the rules you should observe. In either case, your program should not depend upon the OpenSSL library and get into a known state.&lt;br /&gt;
&lt;br /&gt;
* If you need something from &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;, then call &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt;. Don't depend on the library to do it for you.&lt;br /&gt;
* If you don't need something from &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt; (or its mucking up you program), then call &amp;lt;tt&amp;gt;OPENSSL_noconfig&amp;lt;/tt&amp;gt;. The library may have called &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; for you.&lt;br /&gt;
&lt;br /&gt;
== Engines ==&lt;br /&gt;
&lt;br /&gt;
If your application needs to use engines, then it should either call call &amp;lt;tt&amp;gt;ENGINE_load_builtin_engines&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; to load the built-in engines (including dynamically configured engines from &amp;lt;tt&amp;gt;openssl.cnf&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Engines are are automatically loaded (or not loaded) based on the definition of &amp;lt;tt&amp;gt;OPENSSL_LOAD_CONF&amp;lt;/tt&amp;gt; (or lack of definition). You should not depend on library behavior, so you should call &amp;lt;tt&amp;gt;OPENSSL_config&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;ENGINE_load_builtin_engines&amp;lt;/tt&amp;gt; if you need engines.&lt;br /&gt;
&lt;br /&gt;
You can also load a particular engine if you know what you want to use. &amp;lt;tt&amp;gt;eng_all.c&amp;lt;/tt&amp;gt; lists the built-in engines you can load. For example, the following loads the &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; engine provided for some Intel CPUs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;unsigned long err = 0;&lt;br /&gt;
int rc = 0;&lt;br /&gt;
&lt;br /&gt;
OPENSSL_cpuid_setup();&lt;br /&gt;
ENGINE_load_rdrand();&lt;br /&gt;
&lt;br /&gt;
ENGINE* eng = ENGINE_by_id(&amp;quot;rdrand&amp;quot;);&lt;br /&gt;
if(NULL == eng) handleFailure();&lt;br /&gt;
&lt;br /&gt;
rc = ENGINE_init(eng);&lt;br /&gt;
if(1 != rc) handleFailure();&lt;br /&gt;
&lt;br /&gt;
rc = ENGINE_set_default(eng, ENGINE_METHOD_RAND);&lt;br /&gt;
if(1 != rc) handleFailure();&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
ENGINE_finish(eng);&lt;br /&gt;
ENGINE_free(eng);&lt;br /&gt;
ENGINE_cleanup();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want an engine to provide all incumbent functionality for the OpenSSL library, then then call &amp;lt;tt&amp;gt;ENGINE_register_complete&amp;lt;/tt&amp;gt; after loading the engine. Incumbent functionality is determined by the manufacturer and includes includes RSA, DSA, DH, ECDH, MD, and RAND operations. See &amp;lt;tt&amp;gt;eng_all.c&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;eng_fat.c&amp;lt;/tt&amp;gt;, and [http://www.openssl.org/docs/crypto/engine.html engine(3)] for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;ENGINE* eng = ENGINE_by_id(&amp;quot;XXX&amp;quot;);&lt;br /&gt;
if(!(eng-&amp;gt;flags &amp;amp; ENGINE_FLAGS_NO_REGISTER_ALL))&lt;br /&gt;
    ENGINE_register_complete(eng);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Cleanup ==&lt;br /&gt;
&lt;br /&gt;
How to cleanup the library arises on occasion. Its often in the context of running a program under a memory checker like Valgrind.&lt;br /&gt;
&lt;br /&gt;
OpenSSL does not provide a &amp;lt;tt&amp;gt;SSL_library_uninit&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;SSL_library_cleanup&amp;lt;/tt&amp;gt; function (also see [http://rt.openssl.org/Ticket/Display.html?id=3824&amp;amp;user=guest&amp;amp;pass=guest Issue #3824, FEATURE: Please provide a function to unintialize the library]). To cleanup the library the library call the following functions:&lt;br /&gt;
&lt;br /&gt;
* FIPS_mode_set(0);&lt;br /&gt;
* ENGINE_cleanup();&lt;br /&gt;
* CONF_modules_unload(1);&lt;br /&gt;
* EVP_cleanup();&lt;br /&gt;
* CRYPTO_cleanup_all_ex_data();&lt;br /&gt;
* ERR_remove_state();&lt;br /&gt;
* ERR_free_strings();&lt;br /&gt;
&lt;br /&gt;
'''Note:''' ERR_remove_state() was deprecated in OpenSSL 1.0.0 when ERR_remove_thread_state() was introduced. ERR_remove_thread_state() was deprecated in OpenSSL 1.1.0 when the thread handling functionality was entirely rewritten.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;CRYPTO_cleanup_all_ex_data&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;ERR_remove_state&amp;lt;/tt&amp;gt; should be called on each thread, and not just the main thread.&lt;br /&gt;
&lt;br /&gt;
The above list is a minimum to call. You will still need to cleanup Diffie-Hellman parameters, server contexts, static locks, etc.&lt;br /&gt;
&lt;br /&gt;
After cleanup, you may have some memory leaks due to dynamic allocation of private static variables like &amp;lt;tt&amp;gt;ssl_comp_methods&amp;lt;/tt&amp;gt;. This is a well known issue (see [http://rt.openssl.org/Ticket/Display.html?id=2561&amp;amp;user=guest&amp;amp;pass=guest Issue #2561, Memory leak with SSL built-in compressions]).&lt;br /&gt;
&lt;br /&gt;
==Autoconf==&lt;br /&gt;
&lt;br /&gt;
OpenSSL uses its own configuration system, and does not use Autoconf. However, a number of popular projects use both OpenSSL and Autoconf, and it would be usful to detect either &amp;lt;tt&amp;gt;OPENSSL_init_ssl&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;libssl&amp;lt;/tt&amp;gt;. To craft a feature test for OpenSSL that recognizes both &amp;lt;tt&amp;gt;OPENSSL_init_ssl&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;SSL_library_init&amp;lt;/tt&amp;gt;, you can use the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if test &amp;quot;$with_openssl&amp;quot; = yes ; then&lt;br /&gt;
  dnl Order matters!&lt;br /&gt;
  if test &amp;quot;$PORTNAME&amp;quot; != &amp;quot;win32&amp;quot;; then&lt;br /&gt;
     AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])&lt;br /&gt;
     FOUND_SSL_LIB=&amp;quot;no&amp;quot;&lt;br /&gt;
     AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB=&amp;quot;yes&amp;quot;])&lt;br /&gt;
     AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB=&amp;quot;yes&amp;quot;])&lt;br /&gt;
     AS_IF([test &amp;quot;x$FOUND_SSL_LIB&amp;quot; = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])&lt;br /&gt;
  else&lt;br /&gt;
     AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])&lt;br /&gt;
     FOUND_SSL_LIB=&amp;quot;no&amp;quot;&lt;br /&gt;
     AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB=&amp;quot;yes&amp;quot;])&lt;br /&gt;
     AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB=&amp;quot;yes&amp;quot;])&lt;br /&gt;
     AS_IF([test &amp;quot;x$FOUND_SSL_LIB&amp;quot; = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])&lt;br /&gt;
  fi&lt;br /&gt;
fi&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many thanks to the Postgres folks for donating part of their &amp;lt;tt&amp;gt;configure.in&amp;lt;/tt&amp;gt;. Also see [http://stackoverflow.com/q/39285733 How to tell Autoconf “require symbol A or B” from LIB?] on Stack Overflow.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template:Expert_Review&amp;diff=2835</id>
		<title>Template:Expert Review</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template:Expert_Review&amp;diff=2835"/>
		<updated>2019-07-29T20:50:59Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created template for request expert reviews&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sup&amp;gt;[[:Category:Expert Review|[Expert Review Required]]]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
==Overview==&lt;br /&gt;
The purpose of this template is to be able to quickly and efficiently group the articles that require attention from experts.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
Generating random numbers is essential to cryptographically-secure applications&amp;lt;nowiki&amp;gt;{{Expert Review}}&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Simple_TLS_Server&amp;diff=2834</id>
		<title>Simple TLS Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Simple_TLS_Server&amp;diff=2834"/>
		<updated>2019-07-29T20:10:41Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added page to the Examples and C level categories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The code below is a complete implementation of a minimal TLS server. The first thing we do is initialise openssl in the ''init_openssl()'' function  by loading the strings used for error messages, and setting up the algorithms needed for TLS. We then create an ''SSL_CTX'' or SSL context. This is created using the ''SSLv23_server_method'' which despite its name actually creates a server that will negotiate the highest version of SSL/TLS supported by the client it is connecting to. The context is then configured - we use ''SSL_CTX_set_ecdh_auto'' to tell openssl to handle selecting the right elliptic curves for us (this function isn't available in older versions of openssl which required this to be done manually). The final step of configuring the context is to specify the certificate and private key to use.&lt;br /&gt;
&lt;br /&gt;
Next we perform some normal socket programming and create a new server socket, there's nothing openssl specific about this code. Whenever we get a new connection we call ''accept'' as normal. To handle the TLS we create a new ''SSL'' structure, this holds the information related to this particular connection. We use ''SSL_set_fd'' to tell openssl the file descriptor to use for the communication. In this example, we call ''SSL_accept'' to handle the server side of the TLS handshake, then use ''SSL_write()'' to send our message. Finally we clean up the various structures.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/socket.h&amp;gt;&lt;br /&gt;
#include &amp;lt;arpa/inet.h&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/ssl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/err.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int create_socket(int port)&lt;br /&gt;
{&lt;br /&gt;
    int s;&lt;br /&gt;
    struct sockaddr_in addr;&lt;br /&gt;
&lt;br /&gt;
    addr.sin_family = AF_INET;&lt;br /&gt;
    addr.sin_port = htons(port);&lt;br /&gt;
    addr.sin_addr.s_addr = htonl(INADDR_ANY);&lt;br /&gt;
&lt;br /&gt;
    s = socket(AF_INET, SOCK_STREAM, 0);&lt;br /&gt;
    if (s &amp;lt; 0) {&lt;br /&gt;
	perror(&amp;quot;Unable to create socket&amp;quot;);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (bind(s, (struct sockaddr*)&amp;amp;addr, sizeof(addr)) &amp;lt; 0) {&lt;br /&gt;
	perror(&amp;quot;Unable to bind&amp;quot;);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (listen(s, 1) &amp;lt; 0) {&lt;br /&gt;
	perror(&amp;quot;Unable to listen&amp;quot;);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return s;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void init_openssl()&lt;br /&gt;
{ &lt;br /&gt;
    SSL_load_error_strings();	&lt;br /&gt;
    OpenSSL_add_ssl_algorithms();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void cleanup_openssl()&lt;br /&gt;
{&lt;br /&gt;
    EVP_cleanup();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
SSL_CTX *create_context()&lt;br /&gt;
{&lt;br /&gt;
    const SSL_METHOD *method;&lt;br /&gt;
    SSL_CTX *ctx;&lt;br /&gt;
&lt;br /&gt;
    method = SSLv23_server_method();&lt;br /&gt;
&lt;br /&gt;
    ctx = SSL_CTX_new(method);&lt;br /&gt;
    if (!ctx) {&lt;br /&gt;
	perror(&amp;quot;Unable to create SSL context&amp;quot;);&lt;br /&gt;
	ERR_print_errors_fp(stderr);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    return ctx;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void configure_context(SSL_CTX *ctx)&lt;br /&gt;
{&lt;br /&gt;
    SSL_CTX_set_ecdh_auto(ctx, 1);&lt;br /&gt;
&lt;br /&gt;
    /* Set the key and cert */&lt;br /&gt;
    if (SSL_CTX_use_certificate_file(ctx, &amp;quot;cert.pem&amp;quot;, SSL_FILETYPE_PEM) &amp;lt;= 0) {&lt;br /&gt;
        ERR_print_errors_fp(stderr);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (SSL_CTX_use_PrivateKey_file(ctx, &amp;quot;key.pem&amp;quot;, SSL_FILETYPE_PEM) &amp;lt;= 0 ) {&lt;br /&gt;
        ERR_print_errors_fp(stderr);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    int sock;&lt;br /&gt;
    SSL_CTX *ctx;&lt;br /&gt;
&lt;br /&gt;
    init_openssl();&lt;br /&gt;
    ctx = create_context();&lt;br /&gt;
&lt;br /&gt;
    configure_context(ctx);&lt;br /&gt;
&lt;br /&gt;
    sock = create_socket(4433);&lt;br /&gt;
&lt;br /&gt;
    /* Handle connections */&lt;br /&gt;
    while(1) {&lt;br /&gt;
        struct sockaddr_in addr;&lt;br /&gt;
        uint len = sizeof(addr);&lt;br /&gt;
        SSL *ssl;&lt;br /&gt;
        const char reply[] = &amp;quot;test\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
        int client = accept(sock, (struct sockaddr*)&amp;amp;addr, &amp;amp;len);&lt;br /&gt;
        if (client &amp;lt; 0) {&lt;br /&gt;
            perror(&amp;quot;Unable to accept&amp;quot;);&lt;br /&gt;
            exit(EXIT_FAILURE);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        ssl = SSL_new(ctx);&lt;br /&gt;
        SSL_set_fd(ssl, client);&lt;br /&gt;
&lt;br /&gt;
        if (SSL_accept(ssl) &amp;lt;= 0) {&lt;br /&gt;
            ERR_print_errors_fp(stderr);&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            SSL_write(ssl, reply, strlen(reply));&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        SSL_free(ssl);&lt;br /&gt;
        close(client);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    close(sock);&lt;br /&gt;
    SSL_CTX_free(ctx);&lt;br /&gt;
    cleanup_openssl();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Session Reuse ==&lt;br /&gt;
&lt;br /&gt;
According to Viktor Dukhovni at [http://mta.openssl.org/pipermail/openssl-users/2016-September/004564.html Possible to control session reuse from the client]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;gt; For performance testing purposes, I would like to turn off session&lt;br /&gt;
&amp;gt; reuse in the (homegrown) client I use for testing. Is there a function&lt;br /&gt;
&amp;gt; in the openssl library to do it?&lt;br /&gt;
&amp;gt; &lt;br /&gt;
&amp;gt; I tried googling for &amp;quot;openssl client don't send session id&amp;quot; but I didn't&lt;br /&gt;
&amp;gt; find anything useful.&lt;br /&gt;
&lt;br /&gt;
Just do nothing.  Client sessions are not reused unless you explicitly&lt;br /&gt;
arrange for reuse of a session by calling SSL_set_session() before&lt;br /&gt;
SSL_connect().  If you're trying to avoid wasting memory on storing&lt;br /&gt;
client-side sessions that you'll never reuse then this may help:&lt;br /&gt;
&lt;br /&gt;
   SSL_CTX_set_session_cache_mode(client_ctx, SSL_SESS_CACHE_OFF);&lt;br /&gt;
&lt;br /&gt;
but note this is also the default state, so is also not needed unless&lt;br /&gt;
some other code has explicitly enabled client-side caching of sessions.&lt;br /&gt;
&lt;br /&gt;
Only the server-side cache is enabled by default.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 0-RTT ==&lt;br /&gt;
&lt;br /&gt;
0-RTT is specified in XXX (TODO). 0-RTT allows an application to immediately resume a previous session at the expense of consuming unauthenticated data. You should avoid 0-RTT if possible. In fact, an organization's data security policy may not allow it for some higher data sensitivity levels.&lt;br /&gt;
&lt;br /&gt;
Care should be taken if enabling 0-RTT at the server because a number of protections must be enabled. Additionally, some of the protections are required higher up in the stack, outside of the secure socket layer. Below is a list of potential problems from [http://www.ietf.org/mail-archive/web/tls/current/msg23561.html Closing on 0-RTT] on the IETF TLS working group mailing list.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT without stateful anti-replay allows for very high number of replays, breaking rate limiting systems, even high-performance ones, resulting in an opening for DDoS attacks.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT without stateful anti-replay allows for very high number of replays, allowing exploiting timing side channels for information leakage. Very few if any applications are engineered to mitigate or eliminate such side channels.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT without global anti-replay allows leaking information from the 0-RTT data via cache timing attacks. HTTP GET URLs sent to CDNs are especially vulnerable.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT without global anti-replay allows non-idempotent actions contained in 0-RTT data to be repeated potentially lots of times. Abuse of HTTP GET for non-idempotent actions is fairly common.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT allows easily reordering request with re-transmission from the client. This can lead to various unexpected application behavior if possibility of such reordering is not taken into account. &amp;quot;Eventually consistent&amp;quot; datastores are especially vulnerable.&lt;br /&gt;
&lt;br /&gt;
* 0-RTT exporters are not safe for authentication unless the server does global anti-replay on 0-RTT.&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;br /&gt;
[[Category:C level]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Multiprecision_arithmetic_internals&amp;diff=2832</id>
		<title>Talk:Multiprecision arithmetic internals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Multiprecision_arithmetic_internals&amp;diff=2832"/>
		<updated>2019-07-29T14:58:19Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Replying to thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BN Library Broken Link ==&lt;br /&gt;
&lt;br /&gt;
It looks like [https://www.openssl.org/docs/man1.0.2/man3/bn.html this] is the documentation the first link was supposed to point to, but this documentation module is not in version 1.1.1. Since &lt;br /&gt;
I would assume this means either the module or the interface is deprecated, what is the recommendation in this scenario where we're updating the documentation regarding a deprecated function or library?&lt;br /&gt;
Should I keep the broken link notice and not even list it to prevent new users from using a deprecated feature, at least until we finish modernizing the documentation? Or do I add it in and simply&lt;br /&gt;
append a notice stating the feature is part of a deprecated API?&lt;br /&gt;
&lt;br /&gt;
--[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 06:25, 29 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Actually the BN API is not deprecated. It's just that there's been quite a lot of work over time on trying to improve the documentation and lots of stuff got moved around. It looks like at some point this overview page got deleted - I'm not entirely sure why. I'd suggest we could direct users to some of the key BIGNUM pages instead, such as [https://www.openssl.org/docs/man1.1.1/man3/BN_new.html BN_new()], [https://www.openssl.org/docs/man1.1.1/man3/BN_add.html BN_add()], etc.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 07:57, 29 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: Ah, okay, that's good to know. I'll go ahead and add links to those pages.&lt;br /&gt;
:&lt;br /&gt;
:--[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 14:58, 29 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2829</id>
		<title>Template:Broken Link</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2829"/>
		<updated>2019-07-29T07:27:28Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added an overview for the template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sup&amp;gt;[[:Category:Broken Links|[Broken Link]]]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
==Overview==&lt;br /&gt;
The purpose of this template is to group all of the outstanding broken links in the wiki into the [[:Category:Broken Links|broken links]] category.&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Broken Links]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=RC4&amp;diff=2828</id>
		<title>RC4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=RC4&amp;diff=2828"/>
		<updated>2019-07-29T07:13:17Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added a source for the weaknesses in the WEP protocol&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''RC4''' algorithm is a [[Stream Cipher|stream cipher]] developed by [https://en.wikipedia.org/wiki/Ron_Rivest Ron Rivest] in 1987. [https://en.wikipedia.org/wiki/RC4 RC4] was a trade secret [http://web.archive.org/web/20061024160937/http://cypherpunks.venona.com/date/1994/09/msg00304.html famously leaked] in 1994 to the [https://en.wikipedia.org/wiki/Cypherpunk cypherpunks] mailing list. A little over a year after RC4 was leaked, Andrew Roos posted a [https://netfuture.ch/1995/09/weak-keys-in-rc4/ paper] to the [https://en.wikipedia.org/wiki/Cryptography_newsgroups sci.crypt] newsgroup claiming he discovered a weakness in RC4's keystream generation. Specifically, Roo claimed to have found [https://blog.cryptographyengineering.com/2011/12/15/whats-deal-with-rc4/ evidence to suggest] the concatenated initialization vectors used by the stream cipher were a significant vulnerability. Roo was proven right years later, with the [https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy#Weak_security infamous] [https://eprint.iacr.org/2007/471 failure] of the new (at the time) [https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy WEP] standard.&lt;br /&gt;
&lt;br /&gt;
[[Category:Cryptographic Algorithm]]&lt;br /&gt;
[[Category:Stream Cipher]]&lt;br /&gt;
[[Category:Secret Key Algorithm]]&lt;br /&gt;
[[Category:Legal]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Stream_Cipher&amp;diff=2827</id>
		<title>Stream Cipher</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Stream_Cipher&amp;diff=2827"/>
		<updated>2019-07-29T06:58:28Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Reorganized the page a bit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A '''stream cipher''' is a cipher operating on a flow of data (a ''stream''), as opposed to a block at a time.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [[Block Cipher]]&lt;br /&gt;
* [[:Category:Block Cipher|Block Ciphers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Cryptographic Algorithm]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=RC4&amp;diff=2826</id>
		<title>RC4</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=RC4&amp;diff=2826"/>
		<updated>2019-07-29T06:54:36Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added some background information on RC4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''RC4''' algorithm is a [[Stream Cipher|stream cipher]] developed by [https://en.wikipedia.org/wiki/Ron_Rivest Ron Rivest] in 1987. [https://en.wikipedia.org/wiki/RC4 RC4] was a trade secret [http://web.archive.org/web/20061024160937/http://cypherpunks.venona.com/date/1994/09/msg00304.html famously leaked] in 1994 to the [https://en.wikipedia.org/wiki/Cypherpunk cypherpunks] mailing list. A little over a year after RC4 was leaked, Andrew Roos posted a [https://netfuture.ch/1995/09/weak-keys-in-rc4/ paper] to the [https://en.wikipedia.org/wiki/Cryptography_newsgroups sci.crypt] newsgroup claiming he discovered a weakness in RC4's keystream generation. Specifically, Roo claimed to have found [https://blog.cryptographyengineering.com/2011/12/15/whats-deal-with-rc4/ evidence to suggest] the concatenated initialization vectors used by the stream cipher were a significant vulnerability. Roo was proven right years later, with the [https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy#Weak_security infamous failure] of the new (at the time) [https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy WEP] standard.&lt;br /&gt;
&lt;br /&gt;
[[Category:Cryptographic Algorithm]]&lt;br /&gt;
[[Category:Stream Cipher]]&lt;br /&gt;
[[Category:Secret Key Algorithm]]&lt;br /&gt;
[[Category:Legal]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Multiprecision_arithmetic_internals&amp;diff=2825</id>
		<title>Talk:Multiprecision arithmetic internals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Multiprecision_arithmetic_internals&amp;diff=2825"/>
		<updated>2019-07-29T06:25:19Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* BN Library Broken Link */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== BN Library Broken Link ==&lt;br /&gt;
&lt;br /&gt;
It looks like [https://www.openssl.org/docs/man1.0.2/man3/bn.html this] is the documentation the first link was supposed to point to, but this documentation module is not in version 1.1.1. Since &lt;br /&gt;
I would assume this means either the module or the interface is deprecated, what is the recommendation in this scenario where we're updating the documentation regarding a deprecated function or library?&lt;br /&gt;
Should I keep the broken link notice and not even list it to prevent new users from using a deprecated feature, at least until we finish modernizing the documentation? Or do I add it in and simply&lt;br /&gt;
append a notice stating the feature is part of a deprecated API?&lt;br /&gt;
&lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 06:25, 29 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Multiprecision_arithmetic_internals&amp;diff=2824</id>
		<title>Multiprecision arithmetic internals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Multiprecision_arithmetic_internals&amp;diff=2824"/>
		<updated>2019-07-29T06:16:45Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added a second broken link note&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenSSL includes an implementation of multiprecision arithmetic,&lt;br /&gt;
used for dealing with the large numbers used in public-key cryptography and a few other cryptographic algorithms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.openssl.org/docs/crypto/bn.html &amp;quot;bn(3) overview&amp;quot;]{{Broken Link}}&lt;br /&gt;
&lt;br /&gt;
[http://www.openssl.org/docs/crypto/bn_internal.html &amp;quot;bn_internal(3)&amp;quot;]{{Broken Link}},&lt;br /&gt;
BIGNUM library internal functions &amp;quot;to facilitate debugging and extending the library.&lt;br /&gt;
They are not to be used by applications.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Other popular [http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic multiprecision libraries and tools] that perhaps might be useful for testing OpenSSL's multiprecision implementation include:&lt;br /&gt;
[http://gmplib.org/ GMP],&lt;br /&gt;
the [http://en.wikipedia.org/wiki/bc_(programming_language) bc programming language],&lt;br /&gt;
etc.&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2823</id>
		<title>Template:Broken Link</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2823"/>
		<updated>2019-07-29T06:00:59Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added Broken Links category link to facilitate tracking of pages with broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sup&amp;gt;[[:Category:Broken Links|[Broken Link]]]&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Broken Links]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Multiprecision_arithmetic_internals&amp;diff=2822</id>
		<title>Multiprecision arithmetic internals</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Multiprecision_arithmetic_internals&amp;diff=2822"/>
		<updated>2019-07-29T05:57:34Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added broken link note to bn(3) overview&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;OpenSSL includes an implementation of multiprecision arithmetic,&lt;br /&gt;
used for dealing with the large numbers used in public-key cryptography and a few other cryptographic algorithms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://www.openssl.org/docs/crypto/bn.html &amp;quot;bn(3) overview&amp;quot;]{{Broken Link}}&lt;br /&gt;
&lt;br /&gt;
[http://www.openssl.org/docs/crypto/bn_internal.html &amp;quot;bn_internal(3)&amp;quot;],&lt;br /&gt;
BIGNUM library internal functions &amp;quot;to facilitate debugging and extending the library.&lt;br /&gt;
They are not to be used by applications.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Other popular [http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic multiprecision libraries and tools] that perhaps might be useful for testing OpenSSL's multiprecision implementation include:&lt;br /&gt;
[http://gmplib.org/ GMP],&lt;br /&gt;
the [http://en.wikipedia.org/wiki/bc_(programming_language) bc programming language],&lt;br /&gt;
etc.&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Category:Broken_Links&amp;diff=2821</id>
		<title>Category:Broken Links</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Category:Broken_Links&amp;diff=2821"/>
		<updated>2019-07-29T05:56:51Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created category for pages with broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2820</id>
		<title>Template:Broken Link</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template:Broken_Link&amp;diff=2820"/>
		<updated>2019-07-29T05:56:41Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Created template for broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sup&amp;gt;[[:Category:Broken Links|[Broken Link]]]&amp;lt;/sup&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Mailing_Lists&amp;diff=2819</id>
		<title>Mailing Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Mailing_Lists&amp;diff=2819"/>
		<updated>2019-07-29T05:24:57Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: My previous rewrite sounded a little weird&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We have several community mailing lists. See the OpenSSL Community [https://www.openssl.org/community/mailinglists.html Mailing Lists] page for more information.&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Elliptic_Curve_Cryptography&amp;diff=2818</id>
		<title>Talk:Elliptic Curve Cryptography</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Elliptic_Curve_Cryptography&amp;diff=2818"/>
		<updated>2019-07-29T03:37:24Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Replying to thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Source Code Highlighting ==&lt;br /&gt;
&lt;br /&gt;
I messed around with the sample code and came up with some basic highlighting that I thought made the code easier to read. This is a sample of what I would be changing the sample code to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue;&amp;quot;&amp;gt;#include &amp;lt;&amp;lt;/span&amp;gt;openssl/obj_mac.h&amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue;&amp;quot;&amp;gt;#include &amp;lt;&amp;lt;/span&amp;gt;openssl/ec.h&amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: green;&amp;quot;&amp;gt;/* Other things up here... */&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #000000;&amp;quot;&amp;gt;EC_GROUP&amp;lt;/span&amp;gt; *curve;&lt;br /&gt;
  &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;if&amp;lt;/span&amp;gt;(&amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;NULL&amp;lt;/span&amp;gt; == (curve = EC_GROUP_new_by_curve_name(&amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;NID_secp224r1&amp;lt;/span&amp;gt;)))&lt;br /&gt;
     handleErrors();&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have no strong feelings towards the specific colors, I just picked something I thought was simple and clean. By all means if you have a suggestion regarding the theme I'm all ears. As I said, the point of this change is to make the code easier to read, and since I know theme selection and taste are pretty arbitrary and some people might prefer the code as it is, I thought it best to leave the sample code on live as it was for now. &lt;br /&gt;
 &lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 02:50, 29 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: I believe mediawiki has colorizers to do that; see [https://www.mediawiki.org/wiki/Category:Syntax_highlighting_extensions Syntax highlighting extensions]. Maybe you can ping Richard and ask him to install one.&lt;br /&gt;
: If there is a pain point, it will likely be CentOS. Red Hat provides ancient software (even with SCL enabled) so OpenSSL mediawiki software is old. You may have a hard time finding an acceptable extension because mediawiki is too old.&lt;br /&gt;
:&lt;br /&gt;
: [[User:Jwalton|Jwalton]] ([[User talk:Jwalton|talk]]) 03:24, 29 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
:: I was wondering about that, actually. I did see there were extensions for this, but I wasn't sure whom to ask so I was about to send Matt an email to ask if he could point me in the&lt;br /&gt;
:: right direction. I'll send Richard an email and see what he says. Thanks for the heads up.&lt;br /&gt;
:: &lt;br /&gt;
:: [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 03:37, 29 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Libcrypto_API&amp;diff=2816</id>
		<title>Talk:Libcrypto API</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Libcrypto_API&amp;diff=2816"/>
		<updated>2019-07-29T03:27:49Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Replying to thread&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Current Discussions==&lt;br /&gt;
&lt;br /&gt;
=== Initialization, OPENSSL_conf and engines? ===&lt;br /&gt;
&lt;br /&gt;
Should the recommended initialization code include a call to ENGINE_load_builtin_engines?  (Or to OPENSSL_config, which calls ENGINE_load_builtin_engines.)  Otherwise, the RdRand engine for getting better random numbers from newer Intel chips (as one example) won't be used.&lt;br /&gt;
&lt;br /&gt;
(My own thoughts on OpenSSL initialization are [https://en.wikibooks.org/wiki/OpenSSL/Initialization here].)&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 18:05, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Hmmm - I've not come across this as a recommendation before. What is the original source for your recommendation?&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 22:15, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
It's not from any existing documentation source, other than gleaning some information from the [https://www.openssl.org/docs/crypto/engine.html#Application_requirements engine] manpage (see &amp;quot;Automatically using builtin ENGINE implementations&amp;quot;) and the CHANGES file.  But mostly it's my own conclusion, based on reading the source code and performing experiments.&lt;br /&gt;
&lt;br /&gt;
The basic question I was trying to answer was, on modern Intel processors which support AES-NI and RdRand, is OpenSSL taking advantage of these hardware features.  The answer appears to be different for the two different features.  For AES-NI, it appears from the source code (and was recently [http://marc.info/?l=openssl-users&amp;amp;m=136209324829507&amp;amp;w=2 confirmed] on the mailing list) that AES-NI is automatically used if it is available, without needing to do anything special.&lt;br /&gt;
&lt;br /&gt;
However, for RdRand, it appears that the answer is different.  In the source code, there is a separate RdRand engine.  If the RdRand engine is not used, then the default pool implementation in md_rand.c is used, and you don't get the benefits of RdRand.&lt;br /&gt;
&lt;br /&gt;
From the section I already mentioned in the &amp;quot;engine&amp;quot; manpage, it sounded like no engines are used by default, and you must enable them by calling ENGINE_load_builtin_engines() followed by ENGINE_register_all_complete().  Although the CHANGES file partially contradicts this advice, saying:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  *) Add call to ENGINE_register_all_complete() to&lt;br /&gt;
     ENGINE_load_builtin_engines(), so some implementations get used&lt;br /&gt;
     automatically instead of needing explicit application support.&lt;br /&gt;
     [Steve Henson]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I did some experiments on a machine with RdRand.  I wrote the following little bit of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ENGINE *rnd = ENGINE_get_default_RAND ();&lt;br /&gt;
  if (rnd)&lt;br /&gt;
    printf (&amp;quot;default rand engine: %s\n&amp;quot;, ENGINE_get_name (rnd));&lt;br /&gt;
  else&lt;br /&gt;
    printf (&amp;quot;no default rand engine\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If I initialize OpenSSL the typical way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  SSL_load_error_strings();                /* readable error messages */&lt;br /&gt;
  SSL_library_init();                      /* initialize library */&lt;br /&gt;
  OpenSSL_add_all_algorithms();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
without calling any ENGINE functions, then my little code fragment will print &amp;quot;no default rand engine&amp;quot;, indicating the implementation from md_rand.c is being used.  But if I call ENGINE_load_builtin_engines() after the other initialization functions, and before my little test, it then prints out that RdRand is the default rand engine.&lt;br /&gt;
&lt;br /&gt;
So, this is how I drew the conclusion that it's necessary to call ENGINE_load_builtin_engines() as part of your initialization, if you want to get RdRand support.&lt;br /&gt;
&lt;br /&gt;
However, this is all made a little bit trickier by the fact that OpenSSL_add_all_algorithms() can actually mean one of two vastly different things, depending on a #define at compile time.  If OPENSSL_LOAD_CONF is defined, then OpenSSL_add_all_algorithms() is really OPENSSL_add_all_algorithms_conf(), but if OPENSSL_LOAD_CONF is not defined (which is the default), then OpenSSL_add_all_algorithms() is really OPENSSL_add_all_algorithms_noconf().&lt;br /&gt;
&lt;br /&gt;
OPENSSL_add_all_algorithms_conf() is a two-line function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void OPENSSL_add_all_algorithms_conf(void)&lt;br /&gt;
	{&lt;br /&gt;
	OPENSSL_add_all_algorithms_noconf();&lt;br /&gt;
	OPENSSL_config(NULL);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the difference is that if OPENSSL_LOAD_CONF is defined, then OPENSSL_config() is called, when it otherwise wouldn't be.  What does this have to do with RdRand?  The thing is that OPENSSL_config() calls ENGINE_load_builtin_engines().  (And then ENGINE_load_builtin_engines() in turn calls ENGINE_register_all_complete(), as mentioned in the CHANGES entry.)&lt;br /&gt;
&lt;br /&gt;
So, to get RdRand support, you can either #define OPENSSL_LOAD_CONF when building your program, or you can call either ENGINE_load_builtin_engines() or OPENSSL_config() in your initialization sequence.  However, it appears that calling ENGINE_load_builtin_engines() more than once will leak memory, so ideally you don't want to call ENGINE_load_builtin_engines() if you also plan on calling OPENSSL_config(), or if you've defined OPENSSL_LOAD_CONF.  (Of course, since it's just a small fixed-size leak at initialization, this wouldn't really be a practical problem, but still makes me feel icky.)&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 04:33, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
: &amp;gt; For AES-NI, it appears from the source code&lt;br /&gt;
: &amp;gt; (and was recently confirmed on the mailing list)&lt;br /&gt;
: &amp;gt; that AES-NI is automatically used if it is&lt;br /&gt;
: &amp;gt; available, without needing to do anything special.&lt;br /&gt;
: &amp;gt; However, for RdRand, it appears that the answer is&lt;br /&gt;
: &amp;gt; different.&lt;br /&gt;
: Perhaps it is because the hardware support for AES-NI and RDRAND was provided at different times. Its somewhat odd the Change Log shows them being cut-in at the same time in March, 2012 (http://www.openssl.org/news/changelog.html).&lt;br /&gt;
: AES-NI and PCLMULQDQ was introduced with Sandy Bridge in January, 2011. Confer, http://en.wikipedia.org/wiki/Sandy_Bridge_(microarchitecture). RdRand was introduced with 3rd generation i5's and i7's via Ivy Bridge in April, 2012. Confer, http://en.wikipedia.org/wiki/Ivy_Bridge_(computer_processor).&lt;br /&gt;
: [[User:Jwalton|Jwalton]] 04:00, 7 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Note that the use of OPENSSL_config() '''is''' recommended during initialisation: this is mentioned in the manual page. Currently the routines associated with OPENSSL_config() can be used for adding OIDs and configuring ENGINEs. In future it may well do much more and calling OPENSSL_config() (or the actual conf library if finer control is needed) will automatically take advantage of that.&lt;br /&gt;
&lt;br /&gt;
Here's an example of what I mean. Suppose you have a user who wants to do something weird with an ENGINE: perhaps load an unusual one that needs various ctrls to get it to work. Maybe they want to do something peculiar like use RSA with one ENGINE and DSA with another. You'd have to delve quite deep into the way ENGINE works to support that kind of thing and would it be worth it for something hardly anyone would use?&lt;br /&gt;
&lt;br /&gt;
If instead you called OPENSSL_config() that user can just set up the config file to do what they want and the application writer doesn't have to worry about all the messy ENGINE calls.&lt;br /&gt;
&lt;br /&gt;
--[[User:Steve|Steve]] 13:37, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
So, I've added a call to OPENSSL_config() during the initialisation example. This I think covers both Steve's point above, and Patrick's concern about loading the builtin engines.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 21:01, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&lt;br /&gt;
Note that not all of the libcrypto functions return 0 for error and 1 for success. There '''are''' exceptions which can trip up the unwary. For example if you want to check a signature with some functions you get 1 if the signature is correct, 0 if it is not correct and -1 if something bad happened like a memory allocation failure. So if you do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 if (some_verify_function())&lt;br /&gt;
    /* signature successful */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and someone can induce the &amp;quot;something bad happened&amp;quot; condition you end up behaving as though a bad signature is good. This one cropped up in the library internals at one point and was fixed in a security release. Currently you should check the manual pages or the source to be sure. It would be '''really''' useful if the exceptions were all documented, double checking with the source.&lt;br /&gt;
&lt;br /&gt;
--[[User:Steve|Steve]] 13:57, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I've added this to the error handling section&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 21:05, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yeah, I've noticed this, and in my own code I've chosen to always compare OpenSSL return values against 1 explicitly.  In the spirit of &amp;quot;be bold&amp;quot;, I've gone ahead and added this as a recommendation on the page itself.  But if anyone thinks this is not a good approach, feel free to change it.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 00:37, 5 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I'm happy with that...but now I'm wondering whether for consistency we should use this throughout the examples that we post on the wiki.&lt;br /&gt;
&lt;br /&gt;
Also, the way the page now reads it looks like we are only recommending your idiom for those functions which might return something other than 0 or 1. Would it not be better to recommend this for all functions even if they do only return 0 or 1. By getting into the habit of always checking in this way it probably means you are less likely to inadvertently go wrong.&lt;br /&gt;
&lt;br /&gt;
Finally, is it not the case that most of the time the if statement is checking of an error condition. Therefore shouldn't we write the code more like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(1 != some_function())&lt;br /&gt;
    /* handle the error */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--[[User:Matt|Matt]] 22:31, 5 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I agree on both points.  I'd meant &amp;quot;this idiom can be used to avoid having to worry about whether a particular function can return more than just 0 or 1 or not&amp;quot;, and I always use that idiom in my own code for precisely that reason.  But I don't think I made my meaning clear enough on the page.  I've rephrased it a bit now, but the phrasing still feels a bit awkward, so feel free to improve it to be clearer.&lt;br /&gt;
&lt;br /&gt;
And yes, I agree about flipping the sense of the check.  I'd just been trying to be symmetrical with the example right above it.&lt;br /&gt;
&lt;br /&gt;
But I've now flipped the sense, and I've also modified the earlier example (demonstrating &amp;quot;goto&amp;quot;) to use the &amp;quot;1 !=&amp;quot; idiom.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 01:25, 6 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Old Discussions==&lt;br /&gt;
&lt;br /&gt;
=== Best practices for printing errors ===&lt;br /&gt;
&lt;br /&gt;
I'm curious about the recommendation to do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 err:&lt;br /&gt;
   unsigned long errCode;&lt;br /&gt;
   while(errCode = ERR_get_error())&lt;br /&gt;
   {&lt;br /&gt;
     char *err = ERR_error_string(errCode, NULL);&lt;br /&gt;
     printf(&amp;quot;%s\n&amp;quot;, err);&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wouldn't it be much simpler to just do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 err:&lt;br /&gt;
  ERR_print_errors_fp(stderr);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, if one really does want to iterate through each line of the error queue individually, wouldn't it still be better for us to recommend using ERR_error_string_n with an explicit buffer?  ERR_error_string with a NULL argument is not thread-safe.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 18:12, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Either way does the trick, but I agree yours is simpler. I'll change it.,&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 22:16, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
ERR_print_errors_fp is the best &amp;quot;call it and forget it&amp;quot; method for errors if it&lt;br /&gt;
is appropriate to use an fp. Calling the ERR routines directly can be done but&lt;br /&gt;
it's trickier and the example given is incomplete: I'd have to check it further&lt;br /&gt;
to see how best to call all the routines. [per Steve Henson]&lt;br /&gt;
&lt;br /&gt;
--[[User:Stevem|Stevem]] 14:27, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
== OPENSSL_config deprecated ==&lt;br /&gt;
&lt;br /&gt;
The sample code includes a call to &amp;lt;code&amp;gt;OPENSSL_config&amp;lt;/code&amp;gt; which was deprecated in 1.1.0. I'm still familiarizing myself with the codebase and the documentation, and I therefore do not have a replacement suggestion yet, but if anyone is willing to impart their wisdom I'd be much obliged.&lt;br /&gt;
&lt;br /&gt;
  /* Load config file, and other important initialisation */&lt;br /&gt;
  OPENSSL_config(NULL);&lt;br /&gt;
&lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 23:28, 26 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
The preferred approach to loading the default config file is:&lt;br /&gt;
&lt;br /&gt;
    OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);&lt;br /&gt;
&lt;br /&gt;
This must be the first OpenSSL call you make (typically at the beginning of your application).&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] ([[User talk:Matt|talk]]) 09:38, 28 July 2019 (UTC)&lt;br /&gt;
&lt;br /&gt;
: Hey, thanks, Matt, that helped a lot; I was able to use that to grep right to the file where this is all defined. I'll post back here again once I'm confident I have some sample code that's both simple enough to be digestible as an introduction, but not so contrived it isn't useful.&lt;br /&gt;
&lt;br /&gt;
: [[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 03:27, 29 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Mailing_Lists&amp;diff=2814</id>
		<title>Mailing Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Mailing_Lists&amp;diff=2814"/>
		<updated>2019-07-29T03:03:08Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Fixed mismatched brace causing link to display incorrectly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We have several community mailing lists, see the OpenSSL Community [https://www.openssl.org/community/mailinglists.html Mailing Lists].&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Elliptic_Curve_Cryptography&amp;diff=2813</id>
		<title>Talk:Elliptic Curve Cryptography</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Elliptic_Curve_Cryptography&amp;diff=2813"/>
		<updated>2019-07-29T02:50:05Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* Source Code Highlighting */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Source Code Highlighting ==&lt;br /&gt;
&lt;br /&gt;
I messed around with the sample code and came up with some basic highlighting that I thought made the code easier to read. This is a sample of what I would be changing the sample code to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue;&amp;quot;&amp;gt;#include &amp;lt;&amp;lt;/span&amp;gt;openssl/obj_mac.h&amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue;&amp;quot;&amp;gt;#include &amp;lt;&amp;lt;/span&amp;gt;openssl/ec.h&amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: green;&amp;quot;&amp;gt;/* Other things up here... */&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: #000000;&amp;quot;&amp;gt;EC_GROUP&amp;lt;/span&amp;gt; *curve;&lt;br /&gt;
  &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color: blue&amp;quot;&amp;gt;if&amp;lt;/span&amp;gt;(&amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;NULL&amp;lt;/span&amp;gt; == (curve = EC_GROUP_new_by_curve_name(&amp;lt;span style=&amp;quot;color: purple&amp;quot;&amp;gt;NID_secp224r1&amp;lt;/span&amp;gt;)))&lt;br /&gt;
     handleErrors();&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have no strong feelings towards the specific colors, I just picked something I thought was simple and clean. By all means if you have a suggestion regarding the theme I'm all ears. As I said, the point of this change is to make the code easier to read, and since I know theme selection and taste are pretty arbitrary and some people might prefer the code as it is, I thought it best to leave the sample code on live as it was for now. &lt;br /&gt;
 &lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 02:50, 29 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Elliptic_Curve_Cryptography&amp;diff=2811</id>
		<title>Elliptic Curve Cryptography</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Elliptic_Curve_Cryptography&amp;diff=2811"/>
		<updated>2019-07-29T02:17:56Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added some links in the introduction and formatted the key size table. The changes to the sample code will be documented in the talk page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The OpenSSL '''EC''' library provides support for [https://en.wikipedia.org/wiki/Elliptic-curve_cryptography '''Elliptic Curve Cryptography'''] ('''ECC'''). It is the basis for the OpenSSL implementation of the [https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm Elliptic Curve Digital Signature Algorithm] (ECDSA) and [https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman Elliptic Curve Diffie-Hellman] (ECDH).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;strong&amp;gt;Note:&amp;lt;/strong&amp;gt; This page provides an overview of what ECC is, as well as a description of the low-level OpenSSL API for working with Elliptic Curves. If all you need is support for normal ECDSA and ECDH operations then you should normally use the high-level [[EVP|EVP API]]. Refer to [[EVP Signing and Verifying]] for how to perform digital signature operations (including using ECDSA), [[EVP Key Derivation]] for how to derive shared secrets using Diffie-Hellman and Elliptic Curve Diffie-Hellman, and [[EVP Key and Parameter Generation]] for details of how to create EC Keys.&lt;br /&gt;
&lt;br /&gt;
== Why use Elliptic Curves? ==&lt;br /&gt;
&lt;br /&gt;
The primary advantage of using Elliptic Curve based cryptography is reduced key size and hence speed. Elliptic curve based algorithms use significantly smaller key sizes than their non elliptic curve equivalents. The difference in equivalent key sizes increases dramatically as the key sizes increase. The approximate equivalence in security strength for symmetric algorithms compared to standard asymmetric algorithms and elliptic curve algorithms is shown in the table below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div name=&amp;quot;div-table&amp;quot; style=&amp;quot;margin: 24px;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: auto; width: 40%; text-align: center; padding: 8px;&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Symmetric Key Length !! Standard asymmetric Key Length !! Elliptic Curve Key Length&lt;br /&gt;
|-&lt;br /&gt;
| 80 || 1024 || 160&lt;br /&gt;
|-&lt;br /&gt;
| 112 || 2048 || 224&lt;br /&gt;
|-&lt;br /&gt;
| 128 || 3072 || 256&lt;br /&gt;
|-&lt;br /&gt;
| 192 || 7680 || 384&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 15360 || 512&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As can be seen, to get equivalent strength to a 256 bit symmetric key, a standard asymmetric algorithm would have to use an enormous key of 15360 bits. Keys of this size are typically not practical due to the amount of processing power that would be required, and therefore the speed of the operations. However, with elliptic curve algorithms, the equivalent key length is 512 bits, which is entirely practical. &lt;br /&gt;
&lt;br /&gt;
== What is an Elliptic Curve? ==&lt;br /&gt;
&lt;br /&gt;
First of all some terminology. We need to define what is meant by a field. In essence a field is a '''set''' of elements with operations defined for the elements of that set that equate to something like addition, substraction, multiplication and division. The elements could be numbers, or they could be something else entirely. In order to be a field the following conditions also have to be met:&lt;br /&gt;
* Both addition and multiplicaiton are closed over the set, so for example if a and b are in the set then so are a + b and a * b&lt;br /&gt;
* Addition and multiplication must be associative: so a + (b + c) = (a + b) + c and similarly for multiplication&lt;br /&gt;
* Addition and multiplication must be commutative: so a + b = b + a and similarly for multiplication&lt;br /&gt;
* Both addition and multiplication must have identity elements. So, for example 0 and 1 where: a + 0 = a, and a * 1 = a&lt;br /&gt;
* There must be additive and multiplicative inverses for all elements in the set. So, for example, for every element a in the set there is also a -a so that a + (-a) = 0 (where 0 is the identity element for addition). Similarly for multiplication.&lt;br /&gt;
* Multiplication distributes over addition. So if a, b and c are in the set then a * (b + c) = (a * b) + (a * c)&lt;br /&gt;
&lt;br /&gt;
A finite field is simply a field where the set has a finite number of elements. So, for example, the set of all integers could not be used as the basis for a finite field because there are an infinite number of them. However the set of integers from 0 to 100 could form the basis of a finite field.&lt;br /&gt;
&lt;br /&gt;
So now we can define what an Elliptic Curve is. In general an Elliptic Curve is one of the form:&lt;br /&gt;
y&amp;amp;sup2; = x&amp;amp;sup3; + ax + b, where x, y, a and b are elements of some Field&lt;br /&gt;
&lt;br /&gt;
In Elliptic Curve Cryptography we further restrict this such that x, y, a and b are elements of a '''finite''' field.&lt;br /&gt;
&lt;br /&gt;
Contrary to its name Elliptic Curves do not form an ellipse!&lt;br /&gt;
&lt;br /&gt;
Ok, so far so good - but now it gets a bit more complicated! As well as the points on our curve we add an additional &amp;quot;special&amp;quot; point known as infinity. Using this set of points (i.e. all the points on the curve and infinity), we can define some operations on this set, which we call Point Addition and Point Multiplication. &lt;br /&gt;
&lt;br /&gt;
Points on a curve are given in terms of their x and y co-ordinates, (x, y). Point Addition is essentially an operation which takes any two given points on a curve and yields a third point which is also on the curve. The maths behind this gets a bit complicated but think of it in these terms. Plot two points on an elliptic curve. Now draw a straight line which goes through both points. That line will intersect the curve at some third point. That third point is the result of the addition operation. Point Doubling is similar and can be thought of as adding a point to itself. Imagine a point on the curve and draw a straight line which is a tangent to the curve at that point. The result of the Point Doubling operation is where that tangent line intersects the curve at some other point.&lt;br /&gt;
&lt;br /&gt;
Point multiplication is the operation of taking a point on the curve and &amp;quot;multiplying&amp;quot; it by some number. In practice this is achieved through repeated addition and doubling operations. &lt;br /&gt;
&lt;br /&gt;
So with our set of points on a curve (plus the special point, infinity) we can start doing something useful. First of all we pick a point on the curve called the '''generator''' (we'll call it g).&lt;br /&gt;
&lt;br /&gt;
Now:&lt;br /&gt;
* 0g = infinity&lt;br /&gt;
* 1g = g&lt;br /&gt;
* 2g = g + g&lt;br /&gt;
* 3g = g + g + g (or 2g + g)&lt;br /&gt;
* and so on.&lt;br /&gt;
&lt;br /&gt;
Remember g, 2g and 3g are all points on the curve, and '''+''' in this context means point addition as defined above. If you keep going in this way you will eventually come to some number (lets call it '''n'''), such that ng = infinity. The set of points generated by repeatedly adding g to itself, along with the Point Addition operation together form a mathematical structure known as a '''group'''.&lt;br /&gt;
&lt;br /&gt;
If you are lucky then you may have chosen a curve and a g, such that continually adding g to itself will eventually visit all of the possible points on the curve - but often this is not the case. The number '''n''' as defined above, is called the '''order''' of g. For various complicated mathematical reasons it also turns out that the total number of points that exist on the curve is divisble by n. Dividing the total number of points by n gives you another number known as the cofactor.&lt;br /&gt;
&lt;br /&gt;
The security of Elliptic Curve Cryptography comes from the fact that given some point on the curve kg, (where k is a number and g is the known generator point), it is difficult to work out what the value of '''k''' is. This is known as the '''discrete logarithm problem'''. In the Elliptic Curve Cryptography algorithms ECDH and ECDSA, the point kg would be a public key, and the number k would be the private key.&lt;br /&gt;
&lt;br /&gt;
== Types of Field ==&lt;br /&gt;
&lt;br /&gt;
In principle there are many different types of field that could be used for the values x and y of a point (x, y). In practice however there are two primary ones used, and these are the two that are supported by the OpenSSL EC library.&lt;br /&gt;
&lt;br /&gt;
The simplest is typically referred to as the prime field F&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt; where p is a prime number. In cryptographic applications p must be a very large prime number. The elements of the set are simply the numbers 0 through to p-1, and addition and multiplication over the field have the normal meaning for modular (or clock) arithmetic. So, if p=7 then the elements of the set are {0, 1, 2, 3, 4, 5, 6} and:&lt;br /&gt;
&lt;br /&gt;
0 + 1 = 1&lt;br /&gt;
&lt;br /&gt;
2 + 3 = 5&lt;br /&gt;
&lt;br /&gt;
3 + 3 = 6&lt;br /&gt;
&lt;br /&gt;
4 + 3 = 0&lt;br /&gt;
&lt;br /&gt;
5 + 4 = 2&lt;br /&gt;
&lt;br /&gt;
and so on.&lt;br /&gt;
&lt;br /&gt;
The next common type of field is referred to as the binary field F&amp;lt;sub&amp;gt;2&amp;lt;sup&amp;gt;m&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;. Elements of a binary field are typically represented as polynomials and not as numbers. So for example an element could be:&lt;br /&gt;
&lt;br /&gt;
x&amp;lt;sup&amp;gt;4&amp;lt;/sup&amp;gt;+x&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;+1&lt;br /&gt;
&lt;br /&gt;
This can then be expressed as a binary number ({1 0 1 0 1} in this case), where each term represents one bit in the binary representation. Addition of such polynomials is done as normal but with the result of each term reduced modulo 2. So for example:&lt;br /&gt;
&lt;br /&gt;
(x&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + 1) + (x&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + x) = 2x&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + x + 1&lt;br /&gt;
&lt;br /&gt;
Each term is then reduced modulo 2 to give an answer 0x&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; + x +1 = x + 1&lt;br /&gt;
&lt;br /&gt;
In binary representation this sum could be expressed as follows:&lt;br /&gt;
&lt;br /&gt;
{1 0 1} + {1 1 0} = {0 1 1}&lt;br /&gt;
&lt;br /&gt;
Note then that addition is just a simple XOR operation.&lt;br /&gt;
&lt;br /&gt;
Multiplication in the binary field is done respective to an '''irreducible polynomial'''. Multiplication of polynomials is done in the normal way and the result is then divided by the irreducible polynomial. The remainder is the result of the multiplication. See [http://en.wikipedia.org/wiki/Finite_field_arithmetic Finite Field Arithmetic], for a discussion of binary field arithmetic.&lt;br /&gt;
&lt;br /&gt;
== Defining Curves ==&lt;br /&gt;
&lt;br /&gt;
The parameters necessary for performing cryptographic operations for ECDH and ECDSA are simply the parameters required to set up the curve. Namely, the type of field e.g. prime (F&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;) or binary (F&amp;lt;sub&amp;gt;2&amp;lt;sup&amp;gt;m&amp;lt;/sup&amp;gt;&amp;lt;/sub&amp;gt;), the value p for a prime field, the irreducible polynomial for a binary field, the values a and b from the curve equation, the generator point (g), the order, and the cofactor.&lt;br /&gt;
&lt;br /&gt;
Fortunately, unless you are defining a new curve (not recommended unless you know what you are doing), or you are using an unusual curve that OpenSSL does not have support for, you can usually utilise one of the '''named''' curves that are built-in to OpenSSL. These are a set of well known and widely used curves. The complete collection of curve parameters can be set in one go simply by selecting the appropriate named curve using [[Manual:EC_GROUP_new(3)|EC_GROUP_new_by_curve_name]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;openssl/obj_mac.h&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/ec.h&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
EC_GROUP *curve;&lt;br /&gt;
 &lt;br /&gt;
if(NULL == (curve = EC_GROUP_new_by_curve_name(NID_secp224r1)))&lt;br /&gt;
    handleErrors();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If a custom curve needs to be created, then it can be done as follows. This example code creates the same curve as the code above, but creates it &amp;quot;manually&amp;quot;. In this example a prime field is being used, and the prime number is provided in the variable p. If a binary field was being created instead then a bit string representing the irreducible polynomial would have been provided in the p variable. For further information on the low level EC functions being used refer to the [[Manual:Ec(3)|EC]] manual pages:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
 EC_GROUP *create_curve(void)&lt;br /&gt;
 {&lt;br /&gt;
     BN_CTX *ctx;&lt;br /&gt;
     EC_GROUP *curve;&lt;br /&gt;
     BIGNUM *a, *b, *p, *order, *x, *y;&lt;br /&gt;
     EC_POINT *generator;&lt;br /&gt;
 &lt;br /&gt;
     /* Binary data for the curve parameters */&lt;br /&gt;
     unsigned char a_bin[28] =&lt;br /&gt;
         {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,&lt;br /&gt;
             0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,&lt;br /&gt;
             0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE};&lt;br /&gt;
     unsigned char b_bin[28] =&lt;br /&gt;
         {0xB4,0x05,0x0A,0x85,0x0C,0x04,0xB3,0xAB,0xF5,0x41,&lt;br /&gt;
             0x32,0x56,0x50,0x44,0xB0,0xB7,0xD7,0xBF,0xD8,0xBA,&lt;br /&gt;
             0x27,0x0B,0x39,0x43,0x23,0x55,0xFF,0xB4};&lt;br /&gt;
     unsigned char p_bin[28] =&lt;br /&gt;
         {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,&lt;br /&gt;
             0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,&lt;br /&gt;
             0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};&lt;br /&gt;
     unsigned char order_bin[28] =&lt;br /&gt;
         {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,&lt;br /&gt;
             0xFF,0xFF,0xFF,0xFF,0x16,0xA2,0xE0,0xB8,0xF0,0x3E,&lt;br /&gt;
             0x13,0xDD,0x29,0x45,0x5C,0x5C,0x2A,0x3D };&lt;br /&gt;
     unsigned char x_bin[28] =&lt;br /&gt;
         {0xB7,0x0E,0x0C,0xBD,0x6B,0xB4,0xBF,0x7F,0x32,0x13,&lt;br /&gt;
             0x90,0xB9,0x4A,0x03,0xC1,0xD3,0x56,0xC2,0x11,0x22,&lt;br /&gt;
             0x34,0x32,0x80,0xD6,0x11,0x5C,0x1D,0x21};&lt;br /&gt;
     unsigned char y_bin[28] =&lt;br /&gt;
         {0xbd,0x37,0x63,0x88,0xb5,0xf7,0x23,0xfb,0x4c,0x22,&lt;br /&gt;
             0xdf,0xe6,0xcd,0x43,0x75,0xa0,0x5a,0x07,0x47,0x64,&lt;br /&gt;
             0x44,0xd5,0x81,0x99,0x85,0x00,0x7e,0x34};&lt;br /&gt;
 &lt;br /&gt;
     /* Set up the BN_CTX */&lt;br /&gt;
     if(NULL == (ctx = BN_CTX_new())) handleErrors();&lt;br /&gt;
 &lt;br /&gt;
     /* Set the values for the various parameters */&lt;br /&gt;
     if(NULL == (a = BN_bin2bn(a_bin, 28, NULL))) handleErrors();&lt;br /&gt;
     if(NULL == (b = BN_bin2bn(b_bin, 28, NULL))) handleErrors();&lt;br /&gt;
     if(NULL == (p = BN_bin2bn(p_bin, 28, NULL))) handleErrors();&lt;br /&gt;
     if(NULL == (order = BN_bin2bn(order_bin, 28, NULL))) handleErrors();&lt;br /&gt;
     if(NULL == (x = BN_bin2bn(x_bin, 28, NULL))) handleErrors();&lt;br /&gt;
     if(NULL == (y = BN_bin2bn(y_bin, 28, NULL))) handleErrors();&lt;br /&gt;
 &lt;br /&gt;
     /* Create the curve */&lt;br /&gt;
     if(NULL == (curve = EC_GROUP_new_curve_GFp(p, a, b, ctx))) handleErrors();&lt;br /&gt;
 &lt;br /&gt;
     /* Create the generator */&lt;br /&gt;
     if(NULL == (generator = EC_POINT_new(curve))) handleErrors();&lt;br /&gt;
     if(1 != EC_POINT_set_affine_coordinates_GFp(curve, generator, x, y, ctx))&lt;br /&gt;
         handleErrors();&lt;br /&gt;
 &lt;br /&gt;
     /* Set the generator and the order */&lt;br /&gt;
     if(1 != EC_GROUP_set_generator(curve, generator, order, NULL))&lt;br /&gt;
         handleErrors();&lt;br /&gt;
 &lt;br /&gt;
     EC_POINT_free(generator);&lt;br /&gt;
     BN_free(y);&lt;br /&gt;
     BN_free(x);&lt;br /&gt;
     BN_free(order);&lt;br /&gt;
     BN_free(p);&lt;br /&gt;
     BN_free(b);&lt;br /&gt;
     BN_free(a);&lt;br /&gt;
     BN_CTX_free(ctx); &lt;br /&gt;
 &lt;br /&gt;
     return curve;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Working with Keys==&lt;br /&gt;
&lt;br /&gt;
Keys for ECDH and ECDSA are represented using an [[Manual:EC_KEY_new(3)|EC_KEY]] structure in the low level [[Manual:Ec(3)|EC]] API. If you are using the preferred high-level [[EVP]] API then this EC_KEY structure will be wrapped in an [[EVP#EVP Working with EVP_PKEYs|EVP_PKEY]] object.&lt;br /&gt;
&lt;br /&gt;
Creating a new EC_KEY is a process of creating a curve as described above, creating a new EC_KEY object, and then setting the key to use the curve using the [[Manual:EC_KEY_new(3)|EC_KEY_set_group]] function. Alternatively, the creation of the curve and the key can be done in one step as shown below using [[Manual:EC_KEY_new(3)|EC_KEY_new_by_curve_name]]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;openssl/obj_mac.h&amp;gt;&lt;br /&gt;
#include &amp;lt;openssl/ec.h&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
EC_KEY *key;&lt;br /&gt;
&lt;br /&gt;
if(NULL == (key = EC_KEY_new_by_curve_name(NID_secp224r1)))&lt;br /&gt;
    handleErrors();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point the EC_KEY object has been set up and associated with the curve - but it is empty. There is no key data in it. In order to generate new keys for use with the EVP interface see [[EVP Key and Parameter Generation]]. To generate them using the low level API this can be done as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	if(1 != EC_KEY_generate_key(key)) handleErrors();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that this operation generates a public and private key '''pair'''. Alternatively you may already know either the private key, the public key, or both. Setting the private key and/or public key is done as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;BIGNUM *prv;&lt;br /&gt;
EC_POINT *pub;&lt;br /&gt;
&lt;br /&gt;
/* Set up private key in prv */&lt;br /&gt;
/* Set up public key in pub */&lt;br /&gt;
&lt;br /&gt;
if(1 != EC_KEY_set_private_key(key, prv)) handleErrors();&lt;br /&gt;
if(1 != EC_KEY_set_public_key(key, pub)) handleErrors();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you set the private key then you '''must''' also set the public key. There have been occasional questions on the openssl-users email list from people who only have the private key but do not know the public key. Fortunately calculating the public key is simply a matter of multiplying the private key by the generator for the curve using [[Manual:EC_POINT_add(3)|EC_POINT_mul]]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (1 != EC_POINT_mul(curve, pub, prv, NULL, NULL, ctx))&lt;br /&gt;
    handleErrors();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, it is possible to convert a low-level EC_KEY object into an EVP_PKEY object using the EVP_PKEY_set1_EC_KEY function described in the manual here: [[Manual:EVP_PKEY_set1_RSA(3)]]&lt;br /&gt;
&lt;br /&gt;
==Named Curves==&lt;br /&gt;
&lt;br /&gt;
If you want to save a key and later load it with &amp;lt;tt&amp;gt;SSL_CTX_use_PrivateKey_file&amp;lt;/tt&amp;gt;, then you '''must''' set the &amp;lt;tt&amp;gt;OPENSSL_EC_NAMED_CURVE&amp;lt;/tt&amp;gt; flag on the key. You do that by calling &amp;lt;tt&amp;gt;EC_KEY_set_asn1_flag(ecKey, OPENSSL_EC_NAMED_CURVE)&amp;lt;/tt&amp;gt;. Failure to do so will result in a SSL error of 0x1408a0c1 (no shared cipher) at the server.&lt;br /&gt;
&lt;br /&gt;
As an example, the following creates a elliptic curve key and saves it using a named curve rather than an expanded list of group paramters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;EC_KEY *key = NULL;&lt;br /&gt;
&lt;br /&gt;
key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);&lt;br /&gt;
EC_KEY_set_asn1_flag(key, OPENSSL_EC_NAMED_CURVE);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to detect the flags after reading a key or certificate from disk, then use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int EC_KEY_get_asn1_flag(const EC_KEY* key)&lt;br /&gt;
{&lt;br /&gt;
  if (key)&lt;br /&gt;
  {&lt;br /&gt;
    const EC_GROUP* group = EC_KEY_get0_group(key);&lt;br /&gt;
    if (group)&lt;br /&gt;
      return EC_GROUP_get_asn1_flag(group);&lt;br /&gt;
&lt;br /&gt;
    return 0;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
int flags = EC_KEY_get_asn1_flag(ecKey);&lt;br /&gt;
ASSERT(flags &amp;amp; OPENSSL_EC_NAMED_CURVE);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The certificates below were dumped with &amp;lt;tt&amp;gt;openssl x509 -in server-ecdsa-cert.pem -text -noout&amp;lt;/tt&amp;gt;. The certificate on the left was created with a key using &amp;lt;tt&amp;gt;OPENSSL_EC_NAMED_CURVE&amp;lt;/tt&amp;gt;, while the certificate on the right was not. Notice the certificate on the left includes '''ASN1 OID: prime256v1'''. The certificate on the left can be used with SSL server using ECDSA, but the certificate on the right cannot because it will result in 0x1408a0c1 at the server.&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;center&amp;quot;&lt;br /&gt;
| [[File:cert-with-flag.png|thumb|350px|Figure 1: Key with OPENSSL_EC_NAMED_CURVE]]&lt;br /&gt;
| [[File:cert-without-flag.png|thumb|350px|Figure 2: Key without OPENSSL_EC_NAMED_CURVE]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you use a key or certificate without without the &amp;lt;tt&amp;gt;OPENSSL_EC_NAMED_CURVE&amp;lt;/tt&amp;gt; flag (i.e., one that looks like the image on the right), then the SSL connection will fail with the following symptoms:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Client (s_client):&lt;br /&gt;
&lt;br /&gt;
139925962778272:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1256:SSL alert number 40&lt;br /&gt;
139925962778272:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:596:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Server (s_server):&lt;br /&gt;
&lt;br /&gt;
140339533272744:error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher:s3_srvr.c:1353:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that OpenSSL's &amp;lt;tt&amp;gt;X509_verify&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;X509_verify_cert&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SSL_CTX_check_private_key&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SSL_CTX_use_PrivateKey_file&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;SSL_CTX_use_certificate_chain_file&amp;lt;/tt&amp;gt; will not return a failure when using a key or certificate in the wrong format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Elliptic Curve Diffie Hellman]]&lt;br /&gt;
* [[Command Line Elliptic Curve Operations]]&lt;br /&gt;
* [[Manual:ec(3)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:C level]]&lt;br /&gt;
[[Category:Cryptographic Algorithm]]&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Random_Numbers&amp;diff=2807</id>
		<title>Random Numbers</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Random_Numbers&amp;diff=2807"/>
		<updated>2019-07-27T02:33:12Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Corrected the second hyperlink I added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Random Numbers]] are a cryptographic primitive and cornerstone to nearly all cryptographic systems. They are used in almost all areas of cryptography, from key agreement and transport to session keys for bulk encryption. A quality source of random bits and proper use of OpenSSL APIs will help ensure your program is cryptographically sound. On the other hand, a poor source of randomness or incorrect library usage could result in loss of security. This article will help you use random number generation routines correctly when programming with the OpenSSL library.&lt;br /&gt;
&lt;br /&gt;
OpenSSL provides a number of software based random number generators based on a variety of sources.  A software based random number generator creates random numbers by executing a software algorithm. There are a number of algorithms specified by a number of standard bodies including NIST, ANSI X9 committee (X9.17 and X9.31) and XXX. In addition, the library can use custom hardware if the hardware has an &amp;lt;tt&amp;gt;ENIGNE&amp;lt;/tt&amp;gt; interface. &lt;br /&gt;
&lt;br /&gt;
Good random numbers are notoriously hard to produce from deterministic processes such as a computer executing instructions. A number of cryptographic attacks have been developed because they are so hard to acquire&amp;lt;sup&amp;gt;[https://wiki.openssl.org/index.php?title=Random_Numbers#References]&amp;lt;/sup&amp;gt;. Especially vulnerable are headless servers, embedded devices, and mobile devices, and you may have to take extra steps to ensure an adequate supply of entropy is available&amp;lt;sup&amp;gt;[https://wiki.openssl.org/index.php?title=Random_Numbers#References]&amp;lt;/sup&amp;gt;. The extra steps could include ''Hedging'' on a headless server or embedded device, and ''Finger Painting'' on a mobile device. For recent attacks on low entropy devices (such as headless servers and mobile devices), see for example, ''[http://pages.cs.wisc.edu/~rist/papers/sslhedge.html When Good Randomness Goes Bad: Virtual Machine Reset Vulnerabilities and Hedging Deployed Cryptography ]'', ''[https://factorable.net/paper.html Mining Your Ps and Qs: Detection of Widespread Weak Keys in Network Devices]'', and ''[http://www.csoonline.com/article/723229/traffic-sensor-flaw-that-could-allow-driver-tracking-fixed Traffic sensor flaw that could allow driver tracking fixed]''.&lt;br /&gt;
&lt;br /&gt;
== Entropy ==&lt;br /&gt;
&lt;br /&gt;
Entropy is the measure of &amp;quot;randomness&amp;quot; in a sequence of bits. Different sources have different entropy. For example, a physical process in nature may have 100% entropy which appears purely random. On the other hand, the written English language provides about 3 bits/byte (or character) which is at most 38%. Some estimates have shown English characters provide only 1 bit/byte (or 12%). Other sources used as a random stream will have different estimates of entropy, and you will have to determine the quality.&lt;br /&gt;
&lt;br /&gt;
Random number generators require quality entropy for input (a ''seed'', discussed below) and must produce quality output (''quod vide''). When using OpenSSL's APIs, you will be asked to estimate entropy when seeding or reseeding (input). When estimating entropy you should error on the low side to ensure proper fitness of the generator. When receiving bytes, you will receive a code indicating the success/failure of the operation and quality of the bytes (output).&lt;br /&gt;
&lt;br /&gt;
=== Sources ===&lt;br /&gt;
&lt;br /&gt;
Sometimes the operating system offers block access to hardware random number generators via &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; can be a low volume device, and could potentially block. For example, the [http://www.portwell.com.tw/download/sbc/catalog/Intel_80802_FWH.pdf Intel 82802 Firmware Hub] used with the and i840 chipset produces one byte of data in its register. At other times, &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; can be a high volume device, such as Intel's [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key Technology]. In virtualized environments, &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; might actually be a [http://wiki.qemu.org/Features-Done/VirtIORNG VirtIO RNG].&lt;br /&gt;
&lt;br /&gt;
Entropy is important for a healthy program, and you should investigate hardware modules to help acquire it, especially if poor entropy or entropy depletion are a concern. There are a number of inexpensive and high quality hardware modules on the market, including a $40UK [http://www.entropykey.co.uk EntropyKey]. There are also a number of high quality and high priced hardware modules and accelerators.&lt;br /&gt;
&lt;br /&gt;
If you lack &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt; and cannot procure a hardware random number generator, you can also consider an alternate entropy gather such as the [http://egd.sourceforge.net Entropy Gathering Daemon (EGD)]. EGD is an userspace substitute for &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;. OpenSSL provides native support for EGD via &amp;lt;tt&amp;gt;[[Manual:RAND_egd(3)|RAND_egd]]&amp;lt;/tt&amp;gt; to connect to the Unix domain socket, and &amp;lt;tt&amp;gt;[[Manual:RAND_egd(3)|RAND_egd_bytes]]&amp;lt;/tt&amp;gt; to extract bytes from the daemon.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
It is not possible to assess whether a source of randomness is truly random by merely examining its bits. An &amp;quot;ideal&amp;quot; source of truly random data can be thought of as a sequence of binary digits where each 1 or 0 is the result of flipping a perfectly fair, unbiased coin. Such a sequence of digits would have the following properties:&lt;br /&gt;
&lt;br /&gt;
* Each digit would have exactly 0.5 probability of being 1 and 0.5 probability of being 0&lt;br /&gt;
* The production of any one digit would be entirely independent of any other digits&lt;br /&gt;
&lt;br /&gt;
Given any arbitrary sequence of binary digits it is possible to examine it using statistical techniques. There are various suites of statistical tests available such as STS (Statistical Test Suite) available from NIST's ''[http://csrc.nist.gov/groups/ST/toolkit/rng/index.html RANDOM NUMBER GENERATION]'' page. This suite provides a number of different tests including:&lt;br /&gt;
&lt;br /&gt;
* The Frequency (Monobit) Test: Checks whether the proportion of 0s and 1s in a given  sequence are approximately as one would expect&lt;br /&gt;
* The Runs Test: Tests whether the number of runs of consecutive identical digits of varying lengths within a given sequence is as expected&lt;br /&gt;
* The Longest Run of Ones in a block: Confirms whether the longest single run of ones within a sequence is as would be expected&lt;br /&gt;
&lt;br /&gt;
Examining random data using the tests above cannot determine whether a data source is truly random or not. However, it '''can''' indicate whether data is '''likely''' to be non-random.&lt;br /&gt;
&lt;br /&gt;
== Generators ==&lt;br /&gt;
&lt;br /&gt;
By default, OpenSSL uses the &amp;lt;tt&amp;gt;md_rand&amp;lt;/tt&amp;gt; generator. &amp;lt;tt&amp;gt;md_rand&amp;lt;/tt&amp;gt; uses the MD5 hash as the pseudorandom function. The source code is located in &amp;lt;tt&amp;gt;crypto/rand/md_rand.c&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can test for the generator with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;RAND_METHOD* rm = RAND_get_rand_method();&lt;br /&gt;
if(rm == RAND_SSLeay())&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;Using default generator\n&amp;quot;);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can change the random method using the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;RAND_METHOD* rm = ...;&lt;br /&gt;
if(rm != NULL)&lt;br /&gt;
{&lt;br /&gt;
    rc = RAND_set_rand_method(rm);&lt;br /&gt;
    ASSERT(rc == 1);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Seeds ==&lt;br /&gt;
&lt;br /&gt;
Most random number generators require a seed. A seed is a secret, unpredictable sequence of bytes that is transformed and then used to set the initial state of the generator. The seed ensures that each unique instance of a generator produces a unique stream of bits. No two generators should ever produce the same sequence of random numbers, even when faced with Virtual Machine (VM) rollback attacks (which could happen accidentally by a data center operator).&lt;br /&gt;
&lt;br /&gt;
You should always seed a generator unless the docs state they don't require a seed. Even if the docs state a seed is not needed, you should seed it anyway. When seeding your generators, you should use at least 256 bits (32 bytes) of material. You can verify the required number of bits by grepping the source files for &amp;lt;tt&amp;gt;#define ENTROPY_NEEDED&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
OpenSSL will attempt to seed the random number generator automatically upon instantiation by calling &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt;. If the generator is not initialized and &amp;lt;tt&amp;gt;RAND_bytes&amp;lt;/tt&amp;gt; is called, then the generator will also call &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; (from &amp;lt;tt&amp;gt;ssleay_rand_bytes&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;crypto/rand/md_rand.c&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (!initialized)&lt;br /&gt;
    {&lt;br /&gt;
    RAND_poll();&lt;br /&gt;
    initialized = 1;&lt;br /&gt;
    }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; seeds the random number generator using a system-specific entropy source, which is &amp;lt;tt&amp;gt;/dev/urandom&amp;lt;/tt&amp;gt; on UNIX-like operating systems, and is a combination of [http://msdn.microsoft.com/en-us/library/windows/desktop/aa379942(v=vs.85).aspx &amp;lt;tt&amp;gt;CryptGenRandom&amp;lt;/tt&amp;gt;] and other sources of entropy on Windows.&lt;br /&gt;
&lt;br /&gt;
Be careful when deferring to &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; on some Unix systems because it does not seed the generator. See the code guarded with &amp;lt;tt&amp;gt;OPENSSL_SYS_VXWORKS&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;rand_unix.c&amp;lt;/tt&amp;gt;. Additionally, &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; can have negative interactions on newer Windows platforms, so your program could hang or crash depending on the potential issue. See [[#Windows_Issues|Windows Issues]] below.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;urandom&amp;lt;/tt&amp;gt; device may lack sufficient entropy for your needs, and you might want to reseed it immediately from &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;. On Unix and other operating systems that provide the block device, you can use &amp;lt;tt&amp;gt;[[Manual:RAND_load_file(3)|RAND_load_file]]&amp;lt;/tt&amp;gt; to load directly from &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int rc = RAND_load_file(&amp;quot;/dev/random&amp;quot;, 32);&lt;br /&gt;
if(rc != 32) {&lt;br /&gt;
    /* RAND_load_file failed */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reseed ===&lt;br /&gt;
&lt;br /&gt;
The OpenSSL API allows you to provide a seed and refresh the generator's state with reseeds at anytime during the program's execution. Two functions are provided for seeding and reseeding: &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; accepts a buffer and size; while &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; accepts a buffer, size, and entropy estimate in bytes. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; will call &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; assuming 100% entropy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; is shown below. The function is &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt;, so it &amp;lt;nowiki&amp;gt;[apparently]&amp;lt;/nowiki&amp;gt; cannot fail (or convey failures). Though the example uses the actual number of bytes written to the buffer, the entire buffer can be used to increase entropy with hopes the unused bytes in the buffer has entropy to extract. Even though you can use uninitialized bytes as input, you should not expect any entropy in the uninitialized bytes. Finally, the function &amp;lt;tt&amp;gt;get_random_bytes&amp;lt;/tt&amp;gt; is a placeholder for an application supplied function which gathers random data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[32];&lt;br /&gt;
int written = get_random_bytes(buffer, sizeof(buffer));&lt;br /&gt;
&lt;br /&gt;
RAND_seed(buffer, written);&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; is similar to &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; but requires an entropy estimate. The estimate should be the number of full bytes of entropy in the buffer. If you have a 32 byte buffer with about 50% entropy, you should provide 16 as the entropy estimate. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; is also a &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt; function, so it cannot fail (or convey failures). The example also uses the actual number of bytes written to the buffer, but the entire buffer can be used to increase entropy. Note that &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; takes a &amp;lt;tt&amp;gt;double&amp;lt;/tt&amp;gt;, so be sure to '''avoid''' integer math. Otherwise, the entropy estimate calculation could result in 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;char phrase[64];&lt;br /&gt;
int written = get_random_phrase(phrase, sizeof(phrase));&lt;br /&gt;
&lt;br /&gt;
RAND_add(phrase, written, 0.12f * written /* 12% */);&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows machines, you can also use &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_screen]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_event]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_screen]]&amp;lt;/tt&amp;gt; will mix the contents of the screen into the generator. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_event]]&amp;lt;/tt&amp;gt; can be used with programs that process [http://msdn.microsoft.com/en-us/library/windows/desktop/ff381405(v=vs.85).aspx Windows Messages]. Both methods should only be used with interactive programs, and not services nor drivers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; can be used to reseed the generator using the system entropy source.&lt;br /&gt;
&lt;br /&gt;
=== Persisting ===&lt;br /&gt;
&lt;br /&gt;
If you are worried about slow starts - or the time it takes to get the random number generator in good working order - you can write out a future seed and use it at next program execution. To save the future seed, use the library's &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; function. When using &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt;, you only need to specify a filename. &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; returns the number of bytes written or -1 to indicate bytes were written without an appropriate seed (failure).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int written = RAND_write_file(&amp;quot;prng.seed&amp;quot;);&lt;br /&gt;
if(written &amp;lt;= 0)&lt;br /&gt;
    /* RAND_write_file failed */&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At program startup, you can attempt to read the saved seed with &amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt;. You can specify the number of bytes to read, or -1 to indicate the entire file should be used. The bytes read are automatically added to the generator. &amp;lt;tt&amp;gt;[[Manual:RAND_load_file(3)|RAND_load_file]]&amp;lt;/tt&amp;gt; returns the number of bytes read.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int read = RAND_load_file(&amp;quot;prng.seed&amp;quot;, -1);&lt;br /&gt;
if(read &amp;lt;= 0)&lt;br /&gt;
    /* RAND_load_file failed */&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If possible, you should use protected storage offered by the operating system. For example, you should avoid writing the file and store the seed in the [http://developer.apple.com/library/ios/#documentation/security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html iOS Keychain], [http://developer.android.com/reference/android/security/KeyChain.html Android KeyChain], or [http://msdn.microsoft.com/en-us/library/ms995355.aspx Windows DPAPI]. When writing the seed to the filesystem, be sure to protect the the seed through the file system's permission scheme (Linux has not realized userland needs help from the kernel when storing secrets).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; are documented at the [http://www.openssl.org/docs/manmaster/crypto/RAND_load_file.html &amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt; man page].&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
After the generator has been seeded and is in good working order, you can extract bytes. You have three functions to extract bytes. First is &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; and the second is &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;. Both are software based and produce a pseudo-random stream. The third method is hardware based and it reuses &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the random number generator is not properly seeded, then it will refuse to deliver random bytes and a &amp;quot;PRNG not seeded error&amp;quot; will occur.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; will fetch cryptographically strong random bytes. Cryptographically strong bytes are suitable for high integrity needs, such as long term key generation. If your generator is using a software algorithm, then the bytes will be pseudo-random (but still cryptographically strong). &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; returns 1 for success, and 0 otherwise. If you changed the &amp;lt;tt&amp;gt;RAND_METHOD&amp;lt;/tt&amp;gt; and it is not supported, then the function will return -1. In case of error, you can call &amp;lt;tt&amp;gt;[[Manual:ERR_get_error(3)|ERR_get_error]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[128];&lt;br /&gt;
&lt;br /&gt;
int rc = RAND_bytes(buffer, sizeof(buffer));&lt;br /&gt;
unsigned long err = ERR_get_error();&lt;br /&gt;
&lt;br /&gt;
if(rc != 1) {&lt;br /&gt;
    /* RAND_bytes failed */&lt;br /&gt;
    /* `err` is valid    */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt; returns pseudo-random bytes which ''can'' be cryptographically strong. The function returns 1 if the bytes are cryptographically strong, and 0 otherwise. If your application has high integrity requirements, it should ''not'' use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When using &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;, both 0 and 1 indicate success. If you change the &amp;lt;tt&amp;gt;RAND_METHOD&amp;lt;/tt&amp;gt; and it is not supported, then the function will return -1. In case of error, you can call &amp;lt;tt&amp;gt;[[Manual:ERR_get_error(3)|ERR_get_error]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[32];&lt;br /&gt;
&lt;br /&gt;
int rc = RAND_pseudo_bytes(buffer, sizeof(buffer));&lt;br /&gt;
unsigned long err = ERR_get_error();&lt;br /&gt;
&lt;br /&gt;
if(rc != 0 &amp;amp;&amp;amp; rc != 1) {&lt;br /&gt;
    /* RAND_pseudo_bytes failed */&lt;br /&gt;
    /* `err` is valid           */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
Hardware random number generators are almost always better to use than a software based generator. Hardware generators are often called True Random Number generators (TRNG) or Non-Deterministic Random Number Generators since they don't rely on the deterministic behavior of executing software instructions. Their bits streams are nearly always indistinguishable from random streams, and their entropy is always nearly 100%.&lt;br /&gt;
&lt;br /&gt;
Some hardware generators are easier to use than other. For example, an [http://www.entropykey.co.uk EntropyKey] will provide a driver that replenishes &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;, so an application does not have to do anything special other than reading from the device. Other generators, such as Intel's [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key], must be integrated into an application. When integrating generators using OpenSSL, you will use the library's &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&lt;br /&gt;
To integrate a hardware based random number generator, you should load the apporpriate &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; for the hardware based implementation. Once loaded, set the engine's &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; method as default with &amp;lt;tt&amp;gt;ENGINE_METHOD_RAND&amp;lt;/tt&amp;gt;. After you load the engine and set &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; for the hardware generator, you simply use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; as discussed earlier. There are no special steps necessary after the configuration.&lt;br /&gt;
&lt;br /&gt;
If you have OpenSSL 1.0.1 and a machine with [http://semiaccurate.com/2012/04/23/intel-launches-ivy-bridge-amid-crushing-marketing-buzzwords/ 3rd generation Core i5 or i7 processor (Ivy Bridge)], then the Intel [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key Technology] (formerly called Bull Mountain) [[Commercial Product Disclaimer|&amp;lt;nowiki&amp;gt;[disclaimer]&amp;lt;/nowiki&amp;gt;]] is available to you. The hardware generator is accessed through the &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; API and wraps the &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; instruction. Also see [http://software.intel.com/en-us/blogs/2014/10/03/changes-to-rdrand-integration-in-openssl Changes to RDRAND integration in OpenSSL] on the Intel blog.&lt;br /&gt;
&lt;br /&gt;
To ensure &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; uses the hardware engine, you must perform three steps:&lt;br /&gt;
&lt;br /&gt;
* load the &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; engine&lt;br /&gt;
* acquire a handle to the engine&lt;br /&gt;
* set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; to the engine&lt;br /&gt;
&lt;br /&gt;
The code below shows you how to load the Intel random number generator engine and set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt;. The code is available for download at [[Media:test-rdrand.c|test-rdrand.c]]. While you can call &amp;lt;tt&amp;gt;[[Manual:engine(3)|ENGINE_load_builtin_engines]]&amp;lt;/tt&amp;gt; to make all engines available, the code below focuses on the one engine of interest and loads it via &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;. Before the call to &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;, be sure to call &amp;lt;tt&amp;gt;OPENSSL_cpuid_setup&amp;lt;/tt&amp;gt; to load the proper CPU capabilities. See [[Manual:Engine(3)|OpenSSL's engine(3)]] for more details on engines, their loading, and operation.&lt;br /&gt;
&lt;br /&gt;
Displaying the error code in hexadecimal gives you an error that is easily consumed by &amp;lt;tt&amp;gt;openssl errstr&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; 1    unsigned long err = 0;&lt;br /&gt;
 2    int rc = 0;&lt;br /&gt;
 3&lt;br /&gt;
 4    OPENSSL_cpuid_setup();&lt;br /&gt;
 5    ENGINE_load_rdrand();&lt;br /&gt;
 6&lt;br /&gt;
 7    ENGINE* eng = ENGINE_by_id(&amp;quot;rdrand&amp;quot;);&lt;br /&gt;
 8    err = ERR_get_error();&lt;br /&gt;
 9&lt;br /&gt;
10    if(NULL == eng) {&lt;br /&gt;
11        fprintf(stderr, &amp;quot;ENGINE_load_rdrand failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
12        abort(); /* failed */&lt;br /&gt;
13    }&lt;br /&gt;
14&lt;br /&gt;
15    rc = ENGINE_init(eng);&lt;br /&gt;
16    err = ERR_get_error();&lt;br /&gt;
17&lt;br /&gt;
18    if(0 == rc) {&lt;br /&gt;
19        fprintf(stderr, &amp;quot;ENGINE_init failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
20        abort(); /* failed */&lt;br /&gt;
21    }&lt;br /&gt;
22  &lt;br /&gt;
23    rc = ENGINE_set_default(eng, ENGINE_METHOD_RAND);&lt;br /&gt;
24    err = ERR_get_error();&lt;br /&gt;
25&lt;br /&gt;
26    if(0 == rc) {&lt;br /&gt;
27        fprintf(stderr, &amp;quot;ENGINE_set_default failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
28        abort(); /* failed */&lt;br /&gt;
29    }&lt;br /&gt;
30&lt;br /&gt;
31    /* OK to proceed */&lt;br /&gt;
32&lt;br /&gt;
33    ...&lt;br /&gt;
34    ENGINE_finish(eng);&lt;br /&gt;
35    ENGINE_free(eng);&lt;br /&gt;
36    ENGINE_cleanup();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you hardware does not support the Intel generator, you will receive a &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt; pointer at line 7 and encounter error 0x2606c043 at line 8. The error can then be fed to &amp;lt;tt&amp;gt;openssl errstr&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ./test-rdrand.exe&lt;br /&gt;
...&lt;br /&gt;
ENGINE_load_rdrand failed, err = 0x2606c043&lt;br /&gt;
$ openssl errstr 0x2606c043&lt;br /&gt;
error:2606C043:engine routines:ENGINE_FREE_UTIL:passed a null parameter&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:test-rdrand.png|thumb|250px|right|Verifying rdrand code path]]  Line 13 attempts to set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; to that provided by the engine using &amp;lt;tt&amp;gt;[[Manual:engine(3)|ENGINE_set_default]]&amp;lt;/tt&amp;gt; with &amp;lt;tt&amp;gt;ENGINE_METHOD_RAND&amp;lt;/tt&amp;gt;. Upon success, OpenSSL will internally use &amp;lt;tt&amp;gt;OPENSSL_ia32_rdrand&amp;lt;/tt&amp;gt; for random number generation. To verify code correctness, simply set a breakpoint on the function and wait for the debugger to snap as shown in the figure to the right.&lt;br /&gt;
&lt;br /&gt;
The 0x2606c043 error is actually caused by &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;. The function will verify the capabilities of the hardware and load the generator's engine if available. &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt; is a &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt; function, so it cannot fail or cannot convey failures (which we know is incorrect from a test run). The source code can be found in &amp;lt;tt&amp;gt;eng_rdrand.c&amp;lt;/tt&amp;gt; and is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void ENGINE_load_rdrand (void)&lt;br /&gt;
{&lt;br /&gt;
    extern unsigned int OPENSSL_ia32cap_P[];&lt;br /&gt;
&lt;br /&gt;
    if (OPENSSL_ia32cap_P[1] &amp;amp; (1&amp;lt;&amp;lt;(62-32)))&lt;br /&gt;
    {&lt;br /&gt;
        ENGINE *toadd = ENGINE_rdrand();&lt;br /&gt;
        if(!toadd) return;&lt;br /&gt;
        ENGINE_add(toadd);&lt;br /&gt;
        ENGINE_free(toadd);&lt;br /&gt;
        ERR_clear_error();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A patch is available to provide &amp;lt;tt&amp;gt;ENGINE_R_NO_SUCH_ENGINE&amp;lt;/tt&amp;gt; error code for non-RdRand CPUs. See ''[https://rt.openssl.org/Ticket/Display.html?id=3143 &amp;lt;nowiki&amp;gt;[openssl.org #3143]: ENGINE_load_rdrand sane failure code&amp;lt;/nowiki&amp;gt;]'' for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ./test-rdrand.exe&lt;br /&gt;
...&lt;br /&gt;
ENGINE_load_rdrand failed, err = 0x26077074&lt;br /&gt;
$ openssl errstr 0x26077074&lt;br /&gt;
error:26077074:engine routines:ENGINE_init:no such engine&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://software.intel.com/en-us/articles/performance-impact-of-intel-secure-key-on-openssl Intel documentation], the random number generator does not need to be seeded via the &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; function because the generator is self-seeding. For optimal performance, code that is aware of the underlying random engine can forgo gathering entropy.&lt;br /&gt;
&lt;br /&gt;
Additionally (or more importantly), the following will not cause a crash when using the hardware random number generator (and it fails silently so all looks good from outside the fishbowl):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Bad - don't do this in production */&lt;br /&gt;
byte seed[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;br /&gt;
RAND_seed(seed, sizeof(seed));&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, you can test if your Mac OS X system has &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; available with the following (thanks to Dave Zarzycki):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sysctl hw.optional.rdrand&lt;br /&gt;
hw.optional.rdrand: 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Linux, you can &amp;lt;tt&amp;gt;cat&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;cpuinfo&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cat /proc/cpuinfo | grep -i rdrand&lt;br /&gt;
rdrand	: 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Windows Issues ==&lt;br /&gt;
&lt;br /&gt;
Windows platforms offer two potential problems to OpenSSL's &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt;. First is a hang due to the heap walk, and second is Application Verifier failures due to use of Windows' API call &amp;lt;tt&amp;gt;netstatget&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
See [http://rt.openssl.org/Ticket/Display.html?id=2100&amp;amp;user=guest&amp;amp;pass=guest Bug 2100] for details on the heap walk issue. See [https://groups.google.com/forum/#!topic/mailing.openssl.users/uEO5roA55Wg UAC related errors on windows 7 64-bit with Application Verifier] for details and a workaround for the Application Verifier issue.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
Two miscellaneous items remaining are generator cleanup  and status. &amp;lt;tt&amp;gt;[[Manual:RAND_cleanup(3)|RAND_cleanup]]&amp;lt;/tt&amp;gt; securely erases the memory used by the random number generator.&lt;br /&gt;
&lt;br /&gt;
You can query the generator's state with &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_status]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_status]]&amp;lt;/tt&amp;gt; returns 1 if the generator is in good working order. If your generator is not in good working order, you should reseed it with at least 256 bits (32 bytes) of entropy. The function [http://www.mail-archive.com/openssl-dev@openssl.org/msg04212.html purposefully hides the number of bytes needed] for the reseed operation.&lt;br /&gt;
&lt;br /&gt;
On Android, take care to specify &amp;lt;tt&amp;gt;-mfloat-abi=softfp&amp;lt;/tt&amp;gt; when building the library for use via JNI. If you specify &amp;lt;tt&amp;gt;-mfloat-abi=hard&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-mhard-float&amp;lt;/tt&amp;gt; (even if the hardware support a floating point unit), then the entropy estimate passed to &amp;lt;tt&amp;gt;RAND_add&amp;lt;/tt&amp;gt; will always be 0.0f. See [https://groups.google.com/d/msg/android-ndk/NbUq9FDDZOo/TJJsAS6nM7wJ Hard-float and JNI] for details.&lt;br /&gt;
&lt;br /&gt;
By default, OpenSSL will use the &amp;lt;tt&amp;gt;RDRANG&amp;lt;/tt&amp;gt; engine to generate random numbers if the hardware is available. The behavior has been changed, but the change is only available through git at the moment. If you are concerned with &amp;lt;tt&amp;gt;RDRANG&amp;lt;/tt&amp;gt; tampering, then see the discussion of [[Library_Initialization#ENGINEs_and_RDRAND | ENGINEs and RDRAND]].&lt;br /&gt;
&lt;br /&gt;
== FIPS Mode ==&lt;br /&gt;
&lt;br /&gt;
FIPS mode is a special mode of operation which specifies the library should operate according to the security policies and procedures specified in [http://csrc.nist.gov/publications/fips/fips140-2/fips1402.pdf FIPS 140-2]. The mode requires use of the FIPS Capable OpenSSL library, and must be enabled with a call to &amp;lt;tt&amp;gt;FIPS_mode_set&amp;lt;/tt&amp;gt;. Once in FIPS mode, a ''default DRBG'' is used as specified in [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf SP800-90].&lt;br /&gt;
&lt;br /&gt;
The default DRBG is 256-bit CTR AES using a derivation function, and is decided by the application and not the library module. In the case of an OpenSSL application it is specified in &amp;lt;tt&amp;gt;rand_lib.c&amp;lt;/tt&amp;gt; via the &amp;lt;tt&amp;gt;OPENSSL_DRBG_DEFAULT_TYPE&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPENSSL_DRBG_DEFAULT_FLAGS&amp;lt;/tt&amp;gt; preprocessor macros to allow them to be overridden by local compilation options or at runtime.&lt;br /&gt;
&lt;br /&gt;
To use the FIPS random number generator, simply use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; as described earlier. Note that the call to &amp;lt;tt&amp;gt;FIPS_mode_set&amp;lt;/tt&amp;gt; must succeed in order to operate in FIPS 140 mode.&lt;br /&gt;
&lt;br /&gt;
== Thread Safety ==&lt;br /&gt;
&lt;br /&gt;
The random number generators (among other parts of OpenSSL) are not thread safe by default. To ensure thread safety, you must call &amp;lt;tt&amp;gt;[[Manual:Threads(3)|CRYPTO_set_locking_callback]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Fork Safety ==&lt;br /&gt;
&lt;br /&gt;
OpenSSL's random number generator is not [[Random_fork-safety|fork-safe]], so the issue should be carefully understood and remediated if necessary. See [[Random_fork-safety|Random Fork-Safety]] for details.&lt;br /&gt;
&lt;br /&gt;
[[Category:Expert Review]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[EVP]]&lt;br /&gt;
* [[Libcrypto API]]&lt;br /&gt;
* [http://jbp.io/2014/01/16/openssl-rand-api/ Analysis of the OpenSSL random API]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# Lenstra, A. K., Hughes, J. P., Augier, M., Bos, J. W., Kleinjung, T., &amp;amp; Wachter, C. (2012, February 14). Ron was wrong, Whit is right. p.17. Retrieved from the Cryptology ePrint Archive: [https://eprint.iacr.org/2012/064 Report 2012/064].&lt;br /&gt;
# Heninger, N. (2012, February 15). New research: There’s no need to panic over factorable keys-just mind your Ps and Qs. Retrieved from [https://freedom-to-tinker.com/2012/02/15/new-research-theres-no-need-panic-over-factorable-keys-just-mind-your-ps-and-qs/ link].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Cryptography]]&lt;br /&gt;
[[Category:Crypto API]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Random_Numbers&amp;diff=2806</id>
		<title>Random Numbers</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Random_Numbers&amp;diff=2806"/>
		<updated>2019-07-27T02:31:56Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added two sources to the introduction for further reading&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Random Numbers]] are a cryptographic primitive and cornerstone to nearly all cryptographic systems. They are used in almost all areas of cryptography, from key agreement and transport to session keys for bulk encryption. A quality source of random bits and proper use of OpenSSL APIs will help ensure your program is cryptographically sound. On the other hand, a poor source of randomness or incorrect library usage could result in loss of security. This article will help you use random number generation routines correctly when programming with the OpenSSL library.&lt;br /&gt;
&lt;br /&gt;
OpenSSL provides a number of software based random number generators based on a variety of sources.  A software based random number generator creates random numbers by executing a software algorithm. There are a number of algorithms specified by a number of standard bodies including NIST, ANSI X9 committee (X9.17 and X9.31) and XXX. In addition, the library can use custom hardware if the hardware has an &amp;lt;tt&amp;gt;ENIGNE&amp;lt;/tt&amp;gt; interface. &lt;br /&gt;
&lt;br /&gt;
Good random numbers are notoriously hard to produce from deterministic processes such as a computer executing instructions. A number of cryptographic attacks have been developed because they are so hard to acquire&amp;lt;sup&amp;gt;[https://wiki.openssl.org/index.php?title=Random_Numbers#References]&amp;lt;/sup&amp;gt;. Especially vulnerable are headless servers, embedded devices, and mobile devices, and you may have to take extra steps to ensure an adequate supply of entropy is available&amp;lt;sup&amp;gt;[https://wiki.openssl.org/index.php?title=?Random_Numbers#References]&amp;lt;/sup&amp;gt;. The extra steps could include ''Hedging'' on a headless server or embedded device, and ''Finger Painting'' on a mobile device. For recent attacks on low entropy devices (such as headless servers and mobile devices), see for example, ''[http://pages.cs.wisc.edu/~rist/papers/sslhedge.html When Good Randomness Goes Bad: Virtual Machine Reset Vulnerabilities and Hedging Deployed Cryptography ]'', ''[https://factorable.net/paper.html Mining Your Ps and Qs: Detection of Widespread Weak Keys in Network Devices]'', and ''[http://www.csoonline.com/article/723229/traffic-sensor-flaw-that-could-allow-driver-tracking-fixed Traffic sensor flaw that could allow driver tracking fixed]''.&lt;br /&gt;
&lt;br /&gt;
== Entropy ==&lt;br /&gt;
&lt;br /&gt;
Entropy is the measure of &amp;quot;randomness&amp;quot; in a sequence of bits. Different sources have different entropy. For example, a physical process in nature may have 100% entropy which appears purely random. On the other hand, the written English language provides about 3 bits/byte (or character) which is at most 38%. Some estimates have shown English characters provide only 1 bit/byte (or 12%). Other sources used as a random stream will have different estimates of entropy, and you will have to determine the quality.&lt;br /&gt;
&lt;br /&gt;
Random number generators require quality entropy for input (a ''seed'', discussed below) and must produce quality output (''quod vide''). When using OpenSSL's APIs, you will be asked to estimate entropy when seeding or reseeding (input). When estimating entropy you should error on the low side to ensure proper fitness of the generator. When receiving bytes, you will receive a code indicating the success/failure of the operation and quality of the bytes (output).&lt;br /&gt;
&lt;br /&gt;
=== Sources ===&lt;br /&gt;
&lt;br /&gt;
Sometimes the operating system offers block access to hardware random number generators via &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; can be a low volume device, and could potentially block. For example, the [http://www.portwell.com.tw/download/sbc/catalog/Intel_80802_FWH.pdf Intel 82802 Firmware Hub] used with the and i840 chipset produces one byte of data in its register. At other times, &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; can be a high volume device, such as Intel's [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key Technology]. In virtualized environments, &amp;lt;tt&amp;gt;/dev/hwrng&amp;lt;/tt&amp;gt; might actually be a [http://wiki.qemu.org/Features-Done/VirtIORNG VirtIO RNG].&lt;br /&gt;
&lt;br /&gt;
Entropy is important for a healthy program, and you should investigate hardware modules to help acquire it, especially if poor entropy or entropy depletion are a concern. There are a number of inexpensive and high quality hardware modules on the market, including a $40UK [http://www.entropykey.co.uk EntropyKey]. There are also a number of high quality and high priced hardware modules and accelerators.&lt;br /&gt;
&lt;br /&gt;
If you lack &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt; and cannot procure a hardware random number generator, you can also consider an alternate entropy gather such as the [http://egd.sourceforge.net Entropy Gathering Daemon (EGD)]. EGD is an userspace substitute for &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;. OpenSSL provides native support for EGD via &amp;lt;tt&amp;gt;[[Manual:RAND_egd(3)|RAND_egd]]&amp;lt;/tt&amp;gt; to connect to the Unix domain socket, and &amp;lt;tt&amp;gt;[[Manual:RAND_egd(3)|RAND_egd_bytes]]&amp;lt;/tt&amp;gt; to extract bytes from the daemon.&lt;br /&gt;
&lt;br /&gt;
=== Testing ===&lt;br /&gt;
&lt;br /&gt;
It is not possible to assess whether a source of randomness is truly random by merely examining its bits. An &amp;quot;ideal&amp;quot; source of truly random data can be thought of as a sequence of binary digits where each 1 or 0 is the result of flipping a perfectly fair, unbiased coin. Such a sequence of digits would have the following properties:&lt;br /&gt;
&lt;br /&gt;
* Each digit would have exactly 0.5 probability of being 1 and 0.5 probability of being 0&lt;br /&gt;
* The production of any one digit would be entirely independent of any other digits&lt;br /&gt;
&lt;br /&gt;
Given any arbitrary sequence of binary digits it is possible to examine it using statistical techniques. There are various suites of statistical tests available such as STS (Statistical Test Suite) available from NIST's ''[http://csrc.nist.gov/groups/ST/toolkit/rng/index.html RANDOM NUMBER GENERATION]'' page. This suite provides a number of different tests including:&lt;br /&gt;
&lt;br /&gt;
* The Frequency (Monobit) Test: Checks whether the proportion of 0s and 1s in a given  sequence are approximately as one would expect&lt;br /&gt;
* The Runs Test: Tests whether the number of runs of consecutive identical digits of varying lengths within a given sequence is as expected&lt;br /&gt;
* The Longest Run of Ones in a block: Confirms whether the longest single run of ones within a sequence is as would be expected&lt;br /&gt;
&lt;br /&gt;
Examining random data using the tests above cannot determine whether a data source is truly random or not. However, it '''can''' indicate whether data is '''likely''' to be non-random.&lt;br /&gt;
&lt;br /&gt;
== Generators ==&lt;br /&gt;
&lt;br /&gt;
By default, OpenSSL uses the &amp;lt;tt&amp;gt;md_rand&amp;lt;/tt&amp;gt; generator. &amp;lt;tt&amp;gt;md_rand&amp;lt;/tt&amp;gt; uses the MD5 hash as the pseudorandom function. The source code is located in &amp;lt;tt&amp;gt;crypto/rand/md_rand.c&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can test for the generator with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;RAND_METHOD* rm = RAND_get_rand_method();&lt;br /&gt;
if(rm == RAND_SSLeay())&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;Using default generator\n&amp;quot;);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can change the random method using the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;RAND_METHOD* rm = ...;&lt;br /&gt;
if(rm != NULL)&lt;br /&gt;
{&lt;br /&gt;
    rc = RAND_set_rand_method(rm);&lt;br /&gt;
    ASSERT(rc == 1);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Seeds ==&lt;br /&gt;
&lt;br /&gt;
Most random number generators require a seed. A seed is a secret, unpredictable sequence of bytes that is transformed and then used to set the initial state of the generator. The seed ensures that each unique instance of a generator produces a unique stream of bits. No two generators should ever produce the same sequence of random numbers, even when faced with Virtual Machine (VM) rollback attacks (which could happen accidentally by a data center operator).&lt;br /&gt;
&lt;br /&gt;
You should always seed a generator unless the docs state they don't require a seed. Even if the docs state a seed is not needed, you should seed it anyway. When seeding your generators, you should use at least 256 bits (32 bytes) of material. You can verify the required number of bits by grepping the source files for &amp;lt;tt&amp;gt;#define ENTROPY_NEEDED&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
&lt;br /&gt;
OpenSSL will attempt to seed the random number generator automatically upon instantiation by calling &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt;. If the generator is not initialized and &amp;lt;tt&amp;gt;RAND_bytes&amp;lt;/tt&amp;gt; is called, then the generator will also call &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; (from &amp;lt;tt&amp;gt;ssleay_rand_bytes&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;crypto/rand/md_rand.c&amp;lt;/tt&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;if (!initialized)&lt;br /&gt;
    {&lt;br /&gt;
    RAND_poll();&lt;br /&gt;
    initialized = 1;&lt;br /&gt;
    }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; seeds the random number generator using a system-specific entropy source, which is &amp;lt;tt&amp;gt;/dev/urandom&amp;lt;/tt&amp;gt; on UNIX-like operating systems, and is a combination of [http://msdn.microsoft.com/en-us/library/windows/desktop/aa379942(v=vs.85).aspx &amp;lt;tt&amp;gt;CryptGenRandom&amp;lt;/tt&amp;gt;] and other sources of entropy on Windows.&lt;br /&gt;
&lt;br /&gt;
Be careful when deferring to &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; on some Unix systems because it does not seed the generator. See the code guarded with &amp;lt;tt&amp;gt;OPENSSL_SYS_VXWORKS&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;rand_unix.c&amp;lt;/tt&amp;gt;. Additionally, &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; can have negative interactions on newer Windows platforms, so your program could hang or crash depending on the potential issue. See [[#Windows_Issues|Windows Issues]] below.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;urandom&amp;lt;/tt&amp;gt; device may lack sufficient entropy for your needs, and you might want to reseed it immediately from &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;. On Unix and other operating systems that provide the block device, you can use &amp;lt;tt&amp;gt;[[Manual:RAND_load_file(3)|RAND_load_file]]&amp;lt;/tt&amp;gt; to load directly from &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int rc = RAND_load_file(&amp;quot;/dev/random&amp;quot;, 32);&lt;br /&gt;
if(rc != 32) {&lt;br /&gt;
    /* RAND_load_file failed */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reseed ===&lt;br /&gt;
&lt;br /&gt;
The OpenSSL API allows you to provide a seed and refresh the generator's state with reseeds at anytime during the program's execution. Two functions are provided for seeding and reseeding: &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; accepts a buffer and size; while &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; accepts a buffer, size, and entropy estimate in bytes. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; will call &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; assuming 100% entropy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; is shown below. The function is &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt;, so it &amp;lt;nowiki&amp;gt;[apparently]&amp;lt;/nowiki&amp;gt; cannot fail (or convey failures). Though the example uses the actual number of bytes written to the buffer, the entire buffer can be used to increase entropy with hopes the unused bytes in the buffer has entropy to extract. Even though you can use uninitialized bytes as input, you should not expect any entropy in the uninitialized bytes. Finally, the function &amp;lt;tt&amp;gt;get_random_bytes&amp;lt;/tt&amp;gt; is a placeholder for an application supplied function which gathers random data.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[32];&lt;br /&gt;
int written = get_random_bytes(buffer, sizeof(buffer));&lt;br /&gt;
&lt;br /&gt;
RAND_seed(buffer, written);&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; is similar to &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; but requires an entropy estimate. The estimate should be the number of full bytes of entropy in the buffer. If you have a 32 byte buffer with about 50% entropy, you should provide 16 as the entropy estimate. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; is also a &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt; function, so it cannot fail (or convey failures). The example also uses the actual number of bytes written to the buffer, but the entire buffer can be used to increase entropy. Note that &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_add]]&amp;lt;/tt&amp;gt; takes a &amp;lt;tt&amp;gt;double&amp;lt;/tt&amp;gt;, so be sure to '''avoid''' integer math. Otherwise, the entropy estimate calculation could result in 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;char phrase[64];&lt;br /&gt;
int written = get_random_phrase(phrase, sizeof(phrase));&lt;br /&gt;
&lt;br /&gt;
RAND_add(phrase, written, 0.12f * written /* 12% */);&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows machines, you can also use &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_screen]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_event]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_screen]]&amp;lt;/tt&amp;gt; will mix the contents of the screen into the generator. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_event]]&amp;lt;/tt&amp;gt; can be used with programs that process [http://msdn.microsoft.com/en-us/library/windows/desktop/ff381405(v=vs.85).aspx Windows Messages]. Both methods should only be used with interactive programs, and not services nor drivers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt; can be used to reseed the generator using the system entropy source.&lt;br /&gt;
&lt;br /&gt;
=== Persisting ===&lt;br /&gt;
&lt;br /&gt;
If you are worried about slow starts - or the time it takes to get the random number generator in good working order - you can write out a future seed and use it at next program execution. To save the future seed, use the library's &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; function. When using &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt;, you only need to specify a filename. &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; returns the number of bytes written or -1 to indicate bytes were written without an appropriate seed (failure).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int written = RAND_write_file(&amp;quot;prng.seed&amp;quot;);&lt;br /&gt;
if(written &amp;lt;= 0)&lt;br /&gt;
    /* RAND_write_file failed */&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At program startup, you can attempt to read the saved seed with &amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt;. You can specify the number of bytes to read, or -1 to indicate the entire file should be used. The bytes read are automatically added to the generator. &amp;lt;tt&amp;gt;[[Manual:RAND_load_file(3)|RAND_load_file]]&amp;lt;/tt&amp;gt; returns the number of bytes read.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;int read = RAND_load_file(&amp;quot;prng.seed&amp;quot;, -1);&lt;br /&gt;
if(read &amp;lt;= 0)&lt;br /&gt;
    /* RAND_load_file failed */&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If possible, you should use protected storage offered by the operating system. For example, you should avoid writing the file and store the seed in the [http://developer.apple.com/library/ios/#documentation/security/Conceptual/keychainServConcepts/iPhoneTasks/iPhoneTasks.html iOS Keychain], [http://developer.android.com/reference/android/security/KeyChain.html Android KeyChain], or [http://msdn.microsoft.com/en-us/library/ms995355.aspx Windows DPAPI]. When writing the seed to the filesystem, be sure to protect the the seed through the file system's permission scheme (Linux has not realized userland needs help from the kernel when storing secrets).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;RAND_write_file&amp;lt;/tt&amp;gt; are documented at the [http://www.openssl.org/docs/manmaster/crypto/RAND_load_file.html &amp;lt;tt&amp;gt;RAND_load_file&amp;lt;/tt&amp;gt; man page].&lt;br /&gt;
&lt;br /&gt;
== Generation ==&lt;br /&gt;
&lt;br /&gt;
After the generator has been seeded and is in good working order, you can extract bytes. You have three functions to extract bytes. First is &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; and the second is &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;. Both are software based and produce a pseudo-random stream. The third method is hardware based and it reuses &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the random number generator is not properly seeded, then it will refuse to deliver random bytes and a &amp;quot;PRNG not seeded error&amp;quot; will occur.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; will fetch cryptographically strong random bytes. Cryptographically strong bytes are suitable for high integrity needs, such as long term key generation. If your generator is using a software algorithm, then the bytes will be pseudo-random (but still cryptographically strong). &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; returns 1 for success, and 0 otherwise. If you changed the &amp;lt;tt&amp;gt;RAND_METHOD&amp;lt;/tt&amp;gt; and it is not supported, then the function will return -1. In case of error, you can call &amp;lt;tt&amp;gt;[[Manual:ERR_get_error(3)|ERR_get_error]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[128];&lt;br /&gt;
&lt;br /&gt;
int rc = RAND_bytes(buffer, sizeof(buffer));&lt;br /&gt;
unsigned long err = ERR_get_error();&lt;br /&gt;
&lt;br /&gt;
if(rc != 1) {&lt;br /&gt;
    /* RAND_bytes failed */&lt;br /&gt;
    /* `err` is valid    */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt; returns pseudo-random bytes which ''can'' be cryptographically strong. The function returns 1 if the bytes are cryptographically strong, and 0 otherwise. If your application has high integrity requirements, it should ''not'' use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
When using &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_pseudo_bytes]]&amp;lt;/tt&amp;gt;, both 0 and 1 indicate success. If you change the &amp;lt;tt&amp;gt;RAND_METHOD&amp;lt;/tt&amp;gt; and it is not supported, then the function will return -1. In case of error, you can call &amp;lt;tt&amp;gt;[[Manual:ERR_get_error(3)|ERR_get_error]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;byte buffer[32];&lt;br /&gt;
&lt;br /&gt;
int rc = RAND_pseudo_bytes(buffer, sizeof(buffer));&lt;br /&gt;
unsigned long err = ERR_get_error();&lt;br /&gt;
&lt;br /&gt;
if(rc != 0 &amp;amp;&amp;amp; rc != 1) {&lt;br /&gt;
    /* RAND_pseudo_bytes failed */&lt;br /&gt;
    /* `err` is valid           */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* OK to proceed */&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
Hardware random number generators are almost always better to use than a software based generator. Hardware generators are often called True Random Number generators (TRNG) or Non-Deterministic Random Number Generators since they don't rely on the deterministic behavior of executing software instructions. Their bits streams are nearly always indistinguishable from random streams, and their entropy is always nearly 100%.&lt;br /&gt;
&lt;br /&gt;
Some hardware generators are easier to use than other. For example, an [http://www.entropykey.co.uk EntropyKey] will provide a driver that replenishes &amp;lt;tt&amp;gt;/dev/random&amp;lt;/tt&amp;gt;, so an application does not have to do anything special other than reading from the device. Other generators, such as Intel's [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key], must be integrated into an application. When integrating generators using OpenSSL, you will use the library's &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; API.&lt;br /&gt;
&lt;br /&gt;
To integrate a hardware based random number generator, you should load the apporpriate &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; for the hardware based implementation. Once loaded, set the engine's &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; method as default with &amp;lt;tt&amp;gt;ENGINE_METHOD_RAND&amp;lt;/tt&amp;gt;. After you load the engine and set &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; for the hardware generator, you simply use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; as discussed earlier. There are no special steps necessary after the configuration.&lt;br /&gt;
&lt;br /&gt;
If you have OpenSSL 1.0.1 and a machine with [http://semiaccurate.com/2012/04/23/intel-launches-ivy-bridge-amid-crushing-marketing-buzzwords/ 3rd generation Core i5 or i7 processor (Ivy Bridge)], then the Intel [http://software.intel.com/en-us/blogs/2012/05/14/what-is-intelr-secure-key-technology Secure Key Technology] (formerly called Bull Mountain) [[Commercial Product Disclaimer|&amp;lt;nowiki&amp;gt;[disclaimer]&amp;lt;/nowiki&amp;gt;]] is available to you. The hardware generator is accessed through the &amp;lt;tt&amp;gt;ENGINE&amp;lt;/tt&amp;gt; API and wraps the &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; instruction. Also see [http://software.intel.com/en-us/blogs/2014/10/03/changes-to-rdrand-integration-in-openssl Changes to RDRAND integration in OpenSSL] on the Intel blog.&lt;br /&gt;
&lt;br /&gt;
To ensure &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; uses the hardware engine, you must perform three steps:&lt;br /&gt;
&lt;br /&gt;
* load the &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; engine&lt;br /&gt;
* acquire a handle to the engine&lt;br /&gt;
* set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; to the engine&lt;br /&gt;
&lt;br /&gt;
The code below shows you how to load the Intel random number generator engine and set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt;. The code is available for download at [[Media:test-rdrand.c|test-rdrand.c]]. While you can call &amp;lt;tt&amp;gt;[[Manual:engine(3)|ENGINE_load_builtin_engines]]&amp;lt;/tt&amp;gt; to make all engines available, the code below focuses on the one engine of interest and loads it via &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;. Before the call to &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;, be sure to call &amp;lt;tt&amp;gt;OPENSSL_cpuid_setup&amp;lt;/tt&amp;gt; to load the proper CPU capabilities. See [[Manual:Engine(3)|OpenSSL's engine(3)]] for more details on engines, their loading, and operation.&lt;br /&gt;
&lt;br /&gt;
Displaying the error code in hexadecimal gives you an error that is easily consumed by &amp;lt;tt&amp;gt;openssl errstr&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; 1    unsigned long err = 0;&lt;br /&gt;
 2    int rc = 0;&lt;br /&gt;
 3&lt;br /&gt;
 4    OPENSSL_cpuid_setup();&lt;br /&gt;
 5    ENGINE_load_rdrand();&lt;br /&gt;
 6&lt;br /&gt;
 7    ENGINE* eng = ENGINE_by_id(&amp;quot;rdrand&amp;quot;);&lt;br /&gt;
 8    err = ERR_get_error();&lt;br /&gt;
 9&lt;br /&gt;
10    if(NULL == eng) {&lt;br /&gt;
11        fprintf(stderr, &amp;quot;ENGINE_load_rdrand failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
12        abort(); /* failed */&lt;br /&gt;
13    }&lt;br /&gt;
14&lt;br /&gt;
15    rc = ENGINE_init(eng);&lt;br /&gt;
16    err = ERR_get_error();&lt;br /&gt;
17&lt;br /&gt;
18    if(0 == rc) {&lt;br /&gt;
19        fprintf(stderr, &amp;quot;ENGINE_init failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
20        abort(); /* failed */&lt;br /&gt;
21    }&lt;br /&gt;
22  &lt;br /&gt;
23    rc = ENGINE_set_default(eng, ENGINE_METHOD_RAND);&lt;br /&gt;
24    err = ERR_get_error();&lt;br /&gt;
25&lt;br /&gt;
26    if(0 == rc) {&lt;br /&gt;
27        fprintf(stderr, &amp;quot;ENGINE_set_default failed, err = 0x%lx\n&amp;quot;, err);&lt;br /&gt;
28        abort(); /* failed */&lt;br /&gt;
29    }&lt;br /&gt;
30&lt;br /&gt;
31    /* OK to proceed */&lt;br /&gt;
32&lt;br /&gt;
33    ...&lt;br /&gt;
34    ENGINE_finish(eng);&lt;br /&gt;
35    ENGINE_free(eng);&lt;br /&gt;
36    ENGINE_cleanup();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you hardware does not support the Intel generator, you will receive a &amp;lt;tt&amp;gt;NULL&amp;lt;/tt&amp;gt; pointer at line 7 and encounter error 0x2606c043 at line 8. The error can then be fed to &amp;lt;tt&amp;gt;openssl errstr&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ./test-rdrand.exe&lt;br /&gt;
...&lt;br /&gt;
ENGINE_load_rdrand failed, err = 0x2606c043&lt;br /&gt;
$ openssl errstr 0x2606c043&lt;br /&gt;
error:2606C043:engine routines:ENGINE_FREE_UTIL:passed a null parameter&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:test-rdrand.png|thumb|250px|right|Verifying rdrand code path]]  Line 13 attempts to set the default &amp;lt;tt&amp;gt;RAND_method&amp;lt;/tt&amp;gt; to that provided by the engine using &amp;lt;tt&amp;gt;[[Manual:engine(3)|ENGINE_set_default]]&amp;lt;/tt&amp;gt; with &amp;lt;tt&amp;gt;ENGINE_METHOD_RAND&amp;lt;/tt&amp;gt;. Upon success, OpenSSL will internally use &amp;lt;tt&amp;gt;OPENSSL_ia32_rdrand&amp;lt;/tt&amp;gt; for random number generation. To verify code correctness, simply set a breakpoint on the function and wait for the debugger to snap as shown in the figure to the right.&lt;br /&gt;
&lt;br /&gt;
The 0x2606c043 error is actually caused by &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt;. The function will verify the capabilities of the hardware and load the generator's engine if available. &amp;lt;tt&amp;gt;ENGINE_load_rdrand&amp;lt;/tt&amp;gt; is a &amp;lt;tt&amp;gt;void&amp;lt;/tt&amp;gt; function, so it cannot fail or cannot convey failures (which we know is incorrect from a test run). The source code can be found in &amp;lt;tt&amp;gt;eng_rdrand.c&amp;lt;/tt&amp;gt; and is shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void ENGINE_load_rdrand (void)&lt;br /&gt;
{&lt;br /&gt;
    extern unsigned int OPENSSL_ia32cap_P[];&lt;br /&gt;
&lt;br /&gt;
    if (OPENSSL_ia32cap_P[1] &amp;amp; (1&amp;lt;&amp;lt;(62-32)))&lt;br /&gt;
    {&lt;br /&gt;
        ENGINE *toadd = ENGINE_rdrand();&lt;br /&gt;
        if(!toadd) return;&lt;br /&gt;
        ENGINE_add(toadd);&lt;br /&gt;
        ENGINE_free(toadd);&lt;br /&gt;
        ERR_clear_error();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A patch is available to provide &amp;lt;tt&amp;gt;ENGINE_R_NO_SUCH_ENGINE&amp;lt;/tt&amp;gt; error code for non-RdRand CPUs. See ''[https://rt.openssl.org/Ticket/Display.html?id=3143 &amp;lt;nowiki&amp;gt;[openssl.org #3143]: ENGINE_load_rdrand sane failure code&amp;lt;/nowiki&amp;gt;]'' for details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ ./test-rdrand.exe&lt;br /&gt;
...&lt;br /&gt;
ENGINE_load_rdrand failed, err = 0x26077074&lt;br /&gt;
$ openssl errstr 0x26077074&lt;br /&gt;
error:26077074:engine routines:ENGINE_init:no such engine&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
According to [http://software.intel.com/en-us/articles/performance-impact-of-intel-secure-key-on-openssl Intel documentation], the random number generator does not need to be seeded via the &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_seed]]&amp;lt;/tt&amp;gt; function because the generator is self-seeding. For optimal performance, code that is aware of the underlying random engine can forgo gathering entropy.&lt;br /&gt;
&lt;br /&gt;
Additionally (or more importantly), the following will not cause a crash when using the hardware random number generator (and it fails silently so all looks good from outside the fishbowl):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/* Bad - don't do this in production */&lt;br /&gt;
byte seed[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;br /&gt;
RAND_seed(seed, sizeof(seed));&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, you can test if your Mac OS X system has &amp;lt;tt&amp;gt;rdrand&amp;lt;/tt&amp;gt; available with the following (thanks to Dave Zarzycki):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ sysctl hw.optional.rdrand&lt;br /&gt;
hw.optional.rdrand: 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Linux, you can &amp;lt;tt&amp;gt;cat&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;cpuinfo&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cat /proc/cpuinfo | grep -i rdrand&lt;br /&gt;
rdrand	: 1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Windows Issues ==&lt;br /&gt;
&lt;br /&gt;
Windows platforms offer two potential problems to OpenSSL's &amp;lt;tt&amp;gt;RAND_poll&amp;lt;/tt&amp;gt;. First is a hang due to the heap walk, and second is Application Verifier failures due to use of Windows' API call &amp;lt;tt&amp;gt;netstatget&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
See [http://rt.openssl.org/Ticket/Display.html?id=2100&amp;amp;user=guest&amp;amp;pass=guest Bug 2100] for details on the heap walk issue. See [https://groups.google.com/forum/#!topic/mailing.openssl.users/uEO5roA55Wg UAC related errors on windows 7 64-bit with Application Verifier] for details and a workaround for the Application Verifier issue.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
Two miscellaneous items remaining are generator cleanup  and status. &amp;lt;tt&amp;gt;[[Manual:RAND_cleanup(3)|RAND_cleanup]]&amp;lt;/tt&amp;gt; securely erases the memory used by the random number generator.&lt;br /&gt;
&lt;br /&gt;
You can query the generator's state with &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_status]]&amp;lt;/tt&amp;gt;. &amp;lt;tt&amp;gt;[[Manual:RAND_add(3)|RAND_status]]&amp;lt;/tt&amp;gt; returns 1 if the generator is in good working order. If your generator is not in good working order, you should reseed it with at least 256 bits (32 bytes) of entropy. The function [http://www.mail-archive.com/openssl-dev@openssl.org/msg04212.html purposefully hides the number of bytes needed] for the reseed operation.&lt;br /&gt;
&lt;br /&gt;
On Android, take care to specify &amp;lt;tt&amp;gt;-mfloat-abi=softfp&amp;lt;/tt&amp;gt; when building the library for use via JNI. If you specify &amp;lt;tt&amp;gt;-mfloat-abi=hard&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;-mhard-float&amp;lt;/tt&amp;gt; (even if the hardware support a floating point unit), then the entropy estimate passed to &amp;lt;tt&amp;gt;RAND_add&amp;lt;/tt&amp;gt; will always be 0.0f. See [https://groups.google.com/d/msg/android-ndk/NbUq9FDDZOo/TJJsAS6nM7wJ Hard-float and JNI] for details.&lt;br /&gt;
&lt;br /&gt;
By default, OpenSSL will use the &amp;lt;tt&amp;gt;RDRANG&amp;lt;/tt&amp;gt; engine to generate random numbers if the hardware is available. The behavior has been changed, but the change is only available through git at the moment. If you are concerned with &amp;lt;tt&amp;gt;RDRANG&amp;lt;/tt&amp;gt; tampering, then see the discussion of [[Library_Initialization#ENGINEs_and_RDRAND | ENGINEs and RDRAND]].&lt;br /&gt;
&lt;br /&gt;
== FIPS Mode ==&lt;br /&gt;
&lt;br /&gt;
FIPS mode is a special mode of operation which specifies the library should operate according to the security policies and procedures specified in [http://csrc.nist.gov/publications/fips/fips140-2/fips1402.pdf FIPS 140-2]. The mode requires use of the FIPS Capable OpenSSL library, and must be enabled with a call to &amp;lt;tt&amp;gt;FIPS_mode_set&amp;lt;/tt&amp;gt;. Once in FIPS mode, a ''default DRBG'' is used as specified in [http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A.pdf SP800-90].&lt;br /&gt;
&lt;br /&gt;
The default DRBG is 256-bit CTR AES using a derivation function, and is decided by the application and not the library module. In the case of an OpenSSL application it is specified in &amp;lt;tt&amp;gt;rand_lib.c&amp;lt;/tt&amp;gt; via the &amp;lt;tt&amp;gt;OPENSSL_DRBG_DEFAULT_TYPE&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPENSSL_DRBG_DEFAULT_FLAGS&amp;lt;/tt&amp;gt; preprocessor macros to allow them to be overridden by local compilation options or at runtime.&lt;br /&gt;
&lt;br /&gt;
To use the FIPS random number generator, simply use &amp;lt;tt&amp;gt;[[Manual:RAND_bytes(3)|RAND_bytes]]&amp;lt;/tt&amp;gt; as described earlier. Note that the call to &amp;lt;tt&amp;gt;FIPS_mode_set&amp;lt;/tt&amp;gt; must succeed in order to operate in FIPS 140 mode.&lt;br /&gt;
&lt;br /&gt;
== Thread Safety ==&lt;br /&gt;
&lt;br /&gt;
The random number generators (among other parts of OpenSSL) are not thread safe by default. To ensure thread safety, you must call &amp;lt;tt&amp;gt;[[Manual:Threads(3)|CRYPTO_set_locking_callback]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Fork Safety ==&lt;br /&gt;
&lt;br /&gt;
OpenSSL's random number generator is not [[Random_fork-safety|fork-safe]], so the issue should be carefully understood and remediated if necessary. See [[Random_fork-safety|Random Fork-Safety]] for details.&lt;br /&gt;
&lt;br /&gt;
[[Category:Expert Review]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[EVP]]&lt;br /&gt;
* [[Libcrypto API]]&lt;br /&gt;
* [http://jbp.io/2014/01/16/openssl-rand-api/ Analysis of the OpenSSL random API]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# Lenstra, A. K., Hughes, J. P., Augier, M., Bos, J. W., Kleinjung, T., &amp;amp; Wachter, C. (2012, February 14). Ron was wrong, Whit is right. p.17. Retrieved from the Cryptology ePrint Archive: [https://eprint.iacr.org/2012/064 Report 2012/064].&lt;br /&gt;
# Heninger, N. (2012, February 15). New research: There’s no need to panic over factorable keys-just mind your Ps and Qs. Retrieved from [https://freedom-to-tinker.com/2012/02/15/new-research-theres-no-need-panic-over-factorable-keys-just-mind-your-ps-and-qs/ link].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Cryptography]]&lt;br /&gt;
[[Category:Crypto API]]&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Template_talk:TODO&amp;diff=2805</id>
		<title>Template talk:TODO</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Template_talk:TODO&amp;diff=2805"/>
		<updated>2019-07-27T01:55:19Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Added a border to the template and centered it at the top of the page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I think tweaking this template to appear more like a notice or notification makes it look cleaner and more impactful. This is the current template for the &amp;lt;code&amp;gt;TODO&amp;lt;/code&amp;gt; category:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot; align=&amp;quot;left&amp;quot;|[[Image:Sticky.png|left|70px]]&lt;br /&gt;
|align=&amp;quot;left&amp;quot; valign=&amp;quot;bottom&amp;quot; style=&amp;quot;font-size:1.5em; color:#777777;&amp;quot;|'''TODO'''&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;left&amp;quot; valign=&amp;quot;top&amp;quot; style=&amp;quot;color:#aaaaaa;&amp;quot;|{{{1|Please consider contributing to this section}}}.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;[[Category: TODO]]&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the change I'm proposing:&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border: 1px solid #A1A1A1; background-color: #FFFFFF; margin: auto; width: 30%; text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;|[[Image:Sticky.png|center|70px]]&lt;br /&gt;
|align=&amp;quot;left&amp;quot; valign=&amp;quot;bottom&amp;quot; style=&amp;quot;font-size:1.5em; color:#777777;&amp;quot;|'''TODO'''&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;left&amp;quot; valign=&amp;quot;top&amp;quot; style=&amp;quot;color:#aaaaaa;&amp;quot;|{{{1|Please consider contributing to this section}}}.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;[[Category: TODO]]&amp;lt;/includeonly&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 01:55, 27 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Code_Quality&amp;diff=2804</id>
		<title>Code Quality</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Code_Quality&amp;diff=2804"/>
		<updated>2019-07-26T23:30:21Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: Fixed typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Code Quality can be discussed.&lt;br /&gt;
&lt;br /&gt;
Having a code of good quality should help to have a secure code.&lt;br /&gt;
&lt;br /&gt;
Classical buffer overflows by example are a matter of good coding practice.&lt;br /&gt;
Maintaining Code is of course easier if code is readable.&lt;br /&gt;
&lt;br /&gt;
Should discussions about code quality done in discussion tab or on dev mailling list or ... ?&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
	<entry>
		<id>https://wiki.openssl.org/index.php?title=Talk:Libcrypto_API&amp;diff=2803</id>
		<title>Talk:Libcrypto API</title>
		<link rel="alternate" type="text/html" href="https://wiki.openssl.org/index.php?title=Talk:Libcrypto_API&amp;diff=2803"/>
		<updated>2019-07-26T23:28:35Z</updated>

		<summary type="html">&lt;p&gt;Jflopezfernandez: /* OPENSSL_config deprecated */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Current Discussions==&lt;br /&gt;
&lt;br /&gt;
=== Initialization, OPENSSL_conf and engines? ===&lt;br /&gt;
&lt;br /&gt;
Should the recommended initialization code include a call to ENGINE_load_builtin_engines?  (Or to OPENSSL_config, which calls ENGINE_load_builtin_engines.)  Otherwise, the RdRand engine for getting better random numbers from newer Intel chips (as one example) won't be used.&lt;br /&gt;
&lt;br /&gt;
(My own thoughts on OpenSSL initialization are [https://en.wikibooks.org/wiki/OpenSSL/Initialization here].)&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 18:05, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Hmmm - I've not come across this as a recommendation before. What is the original source for your recommendation?&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 22:15, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
It's not from any existing documentation source, other than gleaning some information from the [https://www.openssl.org/docs/crypto/engine.html#Application_requirements engine] manpage (see &amp;quot;Automatically using builtin ENGINE implementations&amp;quot;) and the CHANGES file.  But mostly it's my own conclusion, based on reading the source code and performing experiments.&lt;br /&gt;
&lt;br /&gt;
The basic question I was trying to answer was, on modern Intel processors which support AES-NI and RdRand, is OpenSSL taking advantage of these hardware features.  The answer appears to be different for the two different features.  For AES-NI, it appears from the source code (and was recently [http://marc.info/?l=openssl-users&amp;amp;m=136209324829507&amp;amp;w=2 confirmed] on the mailing list) that AES-NI is automatically used if it is available, without needing to do anything special.&lt;br /&gt;
&lt;br /&gt;
However, for RdRand, it appears that the answer is different.  In the source code, there is a separate RdRand engine.  If the RdRand engine is not used, then the default pool implementation in md_rand.c is used, and you don't get the benefits of RdRand.&lt;br /&gt;
&lt;br /&gt;
From the section I already mentioned in the &amp;quot;engine&amp;quot; manpage, it sounded like no engines are used by default, and you must enable them by calling ENGINE_load_builtin_engines() followed by ENGINE_register_all_complete().  Although the CHANGES file partially contradicts this advice, saying:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  *) Add call to ENGINE_register_all_complete() to&lt;br /&gt;
     ENGINE_load_builtin_engines(), so some implementations get used&lt;br /&gt;
     automatically instead of needing explicit application support.&lt;br /&gt;
     [Steve Henson]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I did some experiments on a machine with RdRand.  I wrote the following little bit of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ENGINE *rnd = ENGINE_get_default_RAND ();&lt;br /&gt;
  if (rnd)&lt;br /&gt;
    printf (&amp;quot;default rand engine: %s\n&amp;quot;, ENGINE_get_name (rnd));&lt;br /&gt;
  else&lt;br /&gt;
    printf (&amp;quot;no default rand engine\n&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If I initialize OpenSSL the typical way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  SSL_load_error_strings();                /* readable error messages */&lt;br /&gt;
  SSL_library_init();                      /* initialize library */&lt;br /&gt;
  OpenSSL_add_all_algorithms();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
without calling any ENGINE functions, then my little code fragment will print &amp;quot;no default rand engine&amp;quot;, indicating the implementation from md_rand.c is being used.  But if I call ENGINE_load_builtin_engines() after the other initialization functions, and before my little test, it then prints out that RdRand is the default rand engine.&lt;br /&gt;
&lt;br /&gt;
So, this is how I drew the conclusion that it's necessary to call ENGINE_load_builtin_engines() as part of your initialization, if you want to get RdRand support.&lt;br /&gt;
&lt;br /&gt;
However, this is all made a little bit trickier by the fact that OpenSSL_add_all_algorithms() can actually mean one of two vastly different things, depending on a #define at compile time.  If OPENSSL_LOAD_CONF is defined, then OpenSSL_add_all_algorithms() is really OPENSSL_add_all_algorithms_conf(), but if OPENSSL_LOAD_CONF is not defined (which is the default), then OpenSSL_add_all_algorithms() is really OPENSSL_add_all_algorithms_noconf().&lt;br /&gt;
&lt;br /&gt;
OPENSSL_add_all_algorithms_conf() is a two-line function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
void OPENSSL_add_all_algorithms_conf(void)&lt;br /&gt;
	{&lt;br /&gt;
	OPENSSL_add_all_algorithms_noconf();&lt;br /&gt;
	OPENSSL_config(NULL);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So the difference is that if OPENSSL_LOAD_CONF is defined, then OPENSSL_config() is called, when it otherwise wouldn't be.  What does this have to do with RdRand?  The thing is that OPENSSL_config() calls ENGINE_load_builtin_engines().  (And then ENGINE_load_builtin_engines() in turn calls ENGINE_register_all_complete(), as mentioned in the CHANGES entry.)&lt;br /&gt;
&lt;br /&gt;
So, to get RdRand support, you can either #define OPENSSL_LOAD_CONF when building your program, or you can call either ENGINE_load_builtin_engines() or OPENSSL_config() in your initialization sequence.  However, it appears that calling ENGINE_load_builtin_engines() more than once will leak memory, so ideally you don't want to call ENGINE_load_builtin_engines() if you also plan on calling OPENSSL_config(), or if you've defined OPENSSL_LOAD_CONF.  (Of course, since it's just a small fixed-size leak at initialization, this wouldn't really be a practical problem, but still makes me feel icky.)&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 04:33, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
: &amp;gt; For AES-NI, it appears from the source code&lt;br /&gt;
: &amp;gt; (and was recently confirmed on the mailing list)&lt;br /&gt;
: &amp;gt; that AES-NI is automatically used if it is&lt;br /&gt;
: &amp;gt; available, without needing to do anything special.&lt;br /&gt;
: &amp;gt; However, for RdRand, it appears that the answer is&lt;br /&gt;
: &amp;gt; different.&lt;br /&gt;
: Perhaps it is because the hardware support for AES-NI and RDRAND was provided at different times. Its somewhat odd the Change Log shows them being cut-in at the same time in March, 2012 (http://www.openssl.org/news/changelog.html).&lt;br /&gt;
: AES-NI and PCLMULQDQ was introduced with Sandy Bridge in January, 2011. Confer, http://en.wikipedia.org/wiki/Sandy_Bridge_(microarchitecture). RdRand was introduced with 3rd generation i5's and i7's via Ivy Bridge in April, 2012. Confer, http://en.wikipedia.org/wiki/Ivy_Bridge_(computer_processor).&lt;br /&gt;
: [[User:Jwalton|Jwalton]] 04:00, 7 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Note that the use of OPENSSL_config() '''is''' recommended during initialisation: this is mentioned in the manual page. Currently the routines associated with OPENSSL_config() can be used for adding OIDs and configuring ENGINEs. In future it may well do much more and calling OPENSSL_config() (or the actual conf library if finer control is needed) will automatically take advantage of that.&lt;br /&gt;
&lt;br /&gt;
Here's an example of what I mean. Suppose you have a user who wants to do something weird with an ENGINE: perhaps load an unusual one that needs various ctrls to get it to work. Maybe they want to do something peculiar like use RSA with one ENGINE and DSA with another. You'd have to delve quite deep into the way ENGINE works to support that kind of thing and would it be worth it for something hardly anyone would use?&lt;br /&gt;
&lt;br /&gt;
If instead you called OPENSSL_config() that user can just set up the config file to do what they want and the application writer doesn't have to worry about all the messy ENGINE calls.&lt;br /&gt;
&lt;br /&gt;
--[[User:Steve|Steve]] 13:37, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
So, I've added a call to OPENSSL_config() during the initialisation example. This I think covers both Steve's point above, and Patrick's concern about loading the builtin engines.&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 21:01, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
=== Return values ===&lt;br /&gt;
&lt;br /&gt;
Note that not all of the libcrypto functions return 0 for error and 1 for success. There '''are''' exceptions which can trip up the unwary. For example if you want to check a signature with some functions you get 1 if the signature is correct, 0 if it is not correct and -1 if something bad happened like a memory allocation failure. So if you do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 if (some_verify_function())&lt;br /&gt;
    /* signature successful */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and someone can induce the &amp;quot;something bad happened&amp;quot; condition you end up behaving as though a bad signature is good. This one cropped up in the library internals at one point and was fixed in a security release. Currently you should check the manual pages or the source to be sure. It would be '''really''' useful if the exceptions were all documented, double checking with the source.&lt;br /&gt;
&lt;br /&gt;
--[[User:Steve|Steve]] 13:57, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I've added this to the error handling section&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 21:05, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Yeah, I've noticed this, and in my own code I've chosen to always compare OpenSSL return values against 1 explicitly.  In the spirit of &amp;quot;be bold&amp;quot;, I've gone ahead and added this as a recommendation on the page itself.  But if anyone thinks this is not a good approach, feel free to change it.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 00:37, 5 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I'm happy with that...but now I'm wondering whether for consistency we should use this throughout the examples that we post on the wiki.&lt;br /&gt;
&lt;br /&gt;
Also, the way the page now reads it looks like we are only recommending your idiom for those functions which might return something other than 0 or 1. Would it not be better to recommend this for all functions even if they do only return 0 or 1. By getting into the habit of always checking in this way it probably means you are less likely to inadvertently go wrong.&lt;br /&gt;
&lt;br /&gt;
Finally, is it not the case that most of the time the if statement is checking of an error condition. Therefore shouldn't we write the code more like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if(1 != some_function())&lt;br /&gt;
    /* handle the error */&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
--[[User:Matt|Matt]] 22:31, 5 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
I agree on both points.  I'd meant &amp;quot;this idiom can be used to avoid having to worry about whether a particular function can return more than just 0 or 1 or not&amp;quot;, and I always use that idiom in my own code for precisely that reason.  But I don't think I made my meaning clear enough on the page.  I've rephrased it a bit now, but the phrasing still feels a bit awkward, so feel free to improve it to be clearer.&lt;br /&gt;
&lt;br /&gt;
And yes, I agree about flipping the sense of the check.  I'd just been trying to be symmetrical with the example right above it.&lt;br /&gt;
&lt;br /&gt;
But I've now flipped the sense, and I've also modified the earlier example (demonstrating &amp;quot;goto&amp;quot;) to use the &amp;quot;1 !=&amp;quot; idiom.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 01:25, 6 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
==Old Discussions==&lt;br /&gt;
&lt;br /&gt;
=== Best practices for printing errors ===&lt;br /&gt;
&lt;br /&gt;
I'm curious about the recommendation to do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 err:&lt;br /&gt;
   unsigned long errCode;&lt;br /&gt;
   while(errCode = ERR_get_error())&lt;br /&gt;
   {&lt;br /&gt;
     char *err = ERR_error_string(errCode, NULL);&lt;br /&gt;
     printf(&amp;quot;%s\n&amp;quot;, err);&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wouldn't it be much simpler to just do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 err:&lt;br /&gt;
  ERR_print_errors_fp(stderr);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, if one really does want to iterate through each line of the error queue individually, wouldn't it still be better for us to recommend using ERR_error_string_n with an explicit buffer?  ERR_error_string with a NULL argument is not thread-safe.&lt;br /&gt;
&lt;br /&gt;
--[[User:Ppelleti|Ppelleti]] 18:12, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
Either way does the trick, but I agree yours is simpler. I'll change it.,&lt;br /&gt;
&lt;br /&gt;
--[[User:Matt|Matt]] 22:16, 3 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
ERR_print_errors_fp is the best &amp;quot;call it and forget it&amp;quot; method for errors if it&lt;br /&gt;
is appropriate to use an fp. Calling the ERR routines directly can be done but&lt;br /&gt;
it's trickier and the example given is incomplete: I'd have to check it further&lt;br /&gt;
to see how best to call all the routines. [per Steve Henson]&lt;br /&gt;
&lt;br /&gt;
--[[User:Stevem|Stevem]] 14:27, 4 March 2013 (UTC)&lt;br /&gt;
&lt;br /&gt;
== OPENSSL_config deprecated ==&lt;br /&gt;
&lt;br /&gt;
The sample code includes a call to &amp;lt;code&amp;gt;OPENSSL_config&amp;lt;/code&amp;gt; which was deprecated in 1.1.0. I'm still familiarizing myself with the codebase and the documentation, and I therefore do not have a replacement suggestion yet, but if anyone is willing to impart their wisdom I'd be much obliged.&lt;br /&gt;
&lt;br /&gt;
  /* Load config file, and other important initialisation */&lt;br /&gt;
  OPENSSL_config(NULL);&lt;br /&gt;
&lt;br /&gt;
[[User:Jflopezfernandez|Jflopezfernandez]] ([[User talk:Jflopezfernandez|talk]]) 23:28, 26 July 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Jflopezfernandez</name></author>
	</entry>
</feed>