1*b0d17251Schristos=pod 2*b0d17251Schristos 3*b0d17251Schristos=head1 NAME 4*b0d17251Schristos 5*b0d17251SchristosOPENSSL_VERSION_MAJOR, OPENSSL_VERSION_MINOR, OPENSSL_VERSION_PATCH, 6*b0d17251SchristosOPENSSL_VERSION_PRE_RELEASE, OPENSSL_VERSION_BUILD_METADATA, 7*b0d17251SchristosOPENSSL_VERSION_TEXT, OPENSSL_VERSION_PREREQ, OPENSSL_version_major, 8*b0d17251SchristosOPENSSL_version_minor, OPENSSL_version_patch, OPENSSL_version_pre_release, 9*b0d17251SchristosOPENSSL_version_build_metadata, OpenSSL_version, OPENSSL_VERSION_NUMBER, 10*b0d17251SchristosOpenSSL_version_num, OPENSSL_info 11*b0d17251Schristos- get OpenSSL version number and other information 12*b0d17251Schristos 13*b0d17251Schristos=head1 SYNOPSIS 14*b0d17251Schristos 15*b0d17251Schristos #include <openssl/opensslv.h> 16*b0d17251Schristos 17*b0d17251Schristos #define OPENSSL_VERSION_MAJOR x 18*b0d17251Schristos #define OPENSSL_VERSION_MINOR y 19*b0d17251Schristos #define OPENSSL_VERSION_PATCH z 20*b0d17251Schristos 21*b0d17251Schristos /* The definitions here are typical release values */ 22*b0d17251Schristos #define OPENSSL_VERSION_PRE_RELEASE "" 23*b0d17251Schristos #define OPENSSL_VERSION_BUILD_METADATA "" 24*b0d17251Schristos 25*b0d17251Schristos #define OPENSSL_VERSION_TEXT "OpenSSL x.y.z xx XXX xxxx" 26*b0d17251Schristos 27*b0d17251Schristos #define OPENSSL_VERSION_PREREQ(maj,min) 28*b0d17251Schristos 29*b0d17251Schristos #include <openssl/crypto.h> 30*b0d17251Schristos 31*b0d17251Schristos unsigned int OPENSSL_version_major(void); 32*b0d17251Schristos unsigned int OPENSSL_version_minor(void); 33*b0d17251Schristos unsigned int OPENSSL_version_patch(void); 34*b0d17251Schristos const char *OPENSSL_version_pre_release(void); 35*b0d17251Schristos const char *OPENSSL_version_build_metadata(void); 36*b0d17251Schristos 37*b0d17251Schristos const char *OpenSSL_version(int t); 38*b0d17251Schristos 39*b0d17251Schristos const char *OPENSSL_info(int t); 40*b0d17251Schristos 41*b0d17251Schristos /* from openssl/opensslv.h */ 42*b0d17251Schristos #define OPENSSL_VERSION_NUMBER 0xnnnnnnnnL 43*b0d17251Schristos 44*b0d17251Schristos /* from openssl/crypto.h */ 45*b0d17251Schristos unsigned long OpenSSL_version_num(); 46*b0d17251Schristos 47*b0d17251Schristos=head1 DESCRIPTION 48*b0d17251Schristos 49*b0d17251Schristos=head2 Macros 50*b0d17251Schristos 51*b0d17251SchristosThe three macros B<OPENSSL_VERSION_MAJOR>, B<OPENSSL_VERSION_MINOR> and 52*b0d17251SchristosB<OPENSSL_VERSION_PATCH> represent the three parts of a version 53*b0d17251Schristosidentifier, B<I<MAJOR>.I<MINOR>.I<PATCH>>. 54*b0d17251Schristos 55*b0d17251SchristosThe macro B<OPENSSL_VERSION_PRE_RELEASE> is an added bit of text that 56*b0d17251Schristosindicates that this is a pre-release version, such as C<"-dev"> for an 57*b0d17251Schristosongoing development snapshot or C<"-alpha3"> for an alpha release. 58*b0d17251SchristosThe value must be a string. 59*b0d17251Schristos 60*b0d17251SchristosThe macro B<OPENSSL_VERSION_BUILD_METADATA> is extra information, reserved 61*b0d17251Schristosfor other parties, such as C<"+fips">, or C<"+vendor.1">). 62*b0d17251SchristosThe OpenSSL project will not touch this macro (will leave it an empty string). 63*b0d17251SchristosThe value must be a string. 64*b0d17251Schristos 65*b0d17251SchristosB<OPENSSL_VERSION_STR> is a convenience macro to get the short version 66*b0d17251Schristosidentifier string, C<"I<MAJOR>.I<MINOR>.I<PATCH>">. 67*b0d17251Schristos 68*b0d17251SchristosB<OPENSSL_FULL_VERSION_STR> is a convenience macro to get the longer 69*b0d17251Schristosversion identifier string, which combines B<OPENSSL_VERSION_STR>, 70*b0d17251SchristosB<OPENSSL_VERSION_PRE_RELEASE> and B<OPENSSL_VERSION_BUILD_METADATA>. 71*b0d17251Schristos 72*b0d17251SchristosB<OPENSSL_VERSION_TEXT> is a convenience macro to get a full descriptive 73*b0d17251Schristosversion text, which includes B<OPENSSL_FULL_VERSION_STR> and the release 74*b0d17251Schristosdate. 75*b0d17251Schristos 76*b0d17251SchristosB<OPENSSL_VERSION_PREREQ> is a useful macro for checking whether the OpenSSL 77*b0d17251Schristosversion for the headers in use is at least at the given pre-requisite major 78*b0d17251Schristos(B<maj>) and minor (B<min>) number or not. It will evaluate to true if the 79*b0d17251Schristosheader version number (B<OPENSSL_VERSION_MAJOR>.B<OPENSSL_VERSION_MINOR>) is 80*b0d17251Schristosgreater than or equal to B<maj>.B<min>. 81*b0d17251Schristos 82*b0d17251SchristosB<OPENSSL_VERSION_NUMBER> is a combination of the major, minor and 83*b0d17251Schristospatch version into a single integer 0xMNN00PP0L, where: 84*b0d17251Schristos 85*b0d17251Schristos=over 4 86*b0d17251Schristos 87*b0d17251Schristos=item M 88*b0d17251Schristos 89*b0d17251Schristosis the number from B<OPENSSL_VERSION_MAJOR>, in hexadecimal notation 90*b0d17251Schristos 91*b0d17251Schristos=item NN 92*b0d17251Schristos 93*b0d17251Schristosis the number from B<OPENSSL_VERSION_MINOR>, in hexadecimal notation 94*b0d17251Schristos 95*b0d17251Schristos=item PP 96*b0d17251Schristos 97*b0d17251Schristosis the number from B<OPENSSL_VERSION_PATCH>, in hexadecimal notation 98*b0d17251Schristos 99*b0d17251Schristos=back 100*b0d17251Schristos 101*b0d17251Schristos=head2 Functions 102*b0d17251Schristos 103*b0d17251SchristosOPENSSL_version_major(), OPENSSL_version_minor(), OPENSSL_version_patch(), 104*b0d17251SchristosOPENSSL_version_pre_release(), and OPENSSL_version_build_metadata() return 105*b0d17251Schristosthe values of the macros above for the build of the library, respectively. 106*b0d17251Schristos 107*b0d17251SchristosOpenSSL_version() returns different strings depending on I<t>: 108*b0d17251Schristos 109*b0d17251Schristos=over 4 110*b0d17251Schristos 111*b0d17251Schristos=item OPENSSL_VERSION 112*b0d17251Schristos 113*b0d17251SchristosThe value of B<OPENSSL_VERSION_TEXT> 114*b0d17251Schristos 115*b0d17251Schristos=item OPENSSL_VERSION_STRING 116*b0d17251Schristos 117*b0d17251SchristosThe value of B<OPENSSL_VERSION_STR> 118*b0d17251Schristos 119*b0d17251Schristos=item OPENSSL_FULL_VERSION_STRING 120*b0d17251Schristos 121*b0d17251SchristosThe value of B<OPENSSL_FULL_VERSION_STR> 122*b0d17251Schristos 123*b0d17251Schristos=item OPENSSL_CFLAGS 124*b0d17251Schristos 125*b0d17251SchristosThe compiler flags set for the compilation process in the form 126*b0d17251SchristosC<compiler: ...> if available, or C<compiler: information not available> 127*b0d17251Schristosotherwise. 128*b0d17251Schristos 129*b0d17251Schristos=item OPENSSL_BUILT_ON 130*b0d17251Schristos 131*b0d17251SchristosThe date of the build process in the form C<built on: ...> if available 132*b0d17251Schristosor C<built on: date not available> otherwise. 133*b0d17251SchristosThe date would not be available in a reproducible build, for example. 134*b0d17251Schristos 135*b0d17251Schristos=item OPENSSL_PLATFORM 136*b0d17251Schristos 137*b0d17251SchristosThe "Configure" target of the library build in the form C<platform: ...> 138*b0d17251Schristosif available, or C<platform: information not available> otherwise. 139*b0d17251Schristos 140*b0d17251Schristos=item OPENSSL_DIR 141*b0d17251Schristos 142*b0d17251SchristosThe B<OPENSSLDIR> setting of the library build in the form C<OPENSSLDIR: "..."> 143*b0d17251Schristosif available, or C<OPENSSLDIR: N/A> otherwise. 144*b0d17251Schristos 145*b0d17251Schristos=item OPENSSL_ENGINES_DIR 146*b0d17251Schristos 147*b0d17251SchristosThe B<ENGINESDIR> setting of the library build in the form C<ENGINESDIR: "..."> 148*b0d17251Schristosif available, or C<ENGINESDIR: N/A> otherwise. This option is deprecated in 149*b0d17251SchristosOpenSSL 3.0. 150*b0d17251Schristos 151*b0d17251Schristos=item OPENSSL_MODULES_DIR 152*b0d17251Schristos 153*b0d17251SchristosThe B<MODULESDIR> setting of the library build in the form C<MODULESDIR: "..."> 154*b0d17251Schristosif available, or C<MODULESDIR: N/A> otherwise. 155*b0d17251Schristos 156*b0d17251Schristos=item OPENSSL_CPU_INFO 157*b0d17251Schristos 158*b0d17251SchristosThe current OpenSSL cpu settings. 159*b0d17251SchristosThis is the current setting of the cpu capability flags. It is usually 160*b0d17251Schristosautomatically configured but may be set via an environment variable. 161*b0d17251SchristosThe value has the same syntax as the environment variable. 162*b0d17251SchristosFor x86 the string looks like C<CPUINFO: OPENSSL_ia32cap=0x123:0x456> 163*b0d17251Schristosor C<CPUINFO: N/A> if not available. 164*b0d17251Schristos 165*b0d17251Schristos=back 166*b0d17251Schristos 167*b0d17251SchristosFor an unknown I<t>, the text C<not available> is returned. 168*b0d17251Schristos 169*b0d17251SchristosOPENSSL_info() also returns different strings depending on I<t>: 170*b0d17251Schristos 171*b0d17251Schristos=over 4 172*b0d17251Schristos 173*b0d17251Schristos=item OPENSSL_INFO_CONFIG_DIR 174*b0d17251Schristos 175*b0d17251SchristosThe configured C<OPENSSLDIR>, which is the default location for 176*b0d17251SchristosOpenSSL configuration files. 177*b0d17251Schristos 178*b0d17251Schristos=item OPENSSL_INFO_ENGINES_DIR 179*b0d17251Schristos 180*b0d17251SchristosThe configured C<ENGINESDIR>, which is the default location for 181*b0d17251SchristosOpenSSL engines. 182*b0d17251Schristos 183*b0d17251Schristos=item OPENSSL_INFO_MODULES_DIR 184*b0d17251Schristos 185*b0d17251SchristosThe configured C<MODULESDIR>, which is the default location for 186*b0d17251Schristosdynamically loadable OpenSSL modules other than engines. 187*b0d17251Schristos 188*b0d17251Schristos=item OPENSSL_INFO_DSO_EXTENSION 189*b0d17251Schristos 190*b0d17251SchristosThe configured dynamically loadable module extension. 191*b0d17251Schristos 192*b0d17251Schristos=item OPENSSL_INFO_DIR_FILENAME_SEPARATOR 193*b0d17251Schristos 194*b0d17251SchristosThe separator between a directory specification and a filename. 195*b0d17251SchristosNote that on some operating systems, this is not the same as the 196*b0d17251Schristosseparator between directory elements. 197*b0d17251Schristos 198*b0d17251Schristos=item OPENSSL_INFO_LIST_SEPARATOR 199*b0d17251Schristos 200*b0d17251SchristosThe OpenSSL list separator. 201*b0d17251SchristosThis is typically used in strings that are lists of items, such as the 202*b0d17251Schristosvalue of the environment variable C<$PATH> on Unix (where the 203*b0d17251Schristosseparator is C<:>) or C<%PATH%> on Windows (where the separator is 204*b0d17251SchristosC<;>). 205*b0d17251Schristos 206*b0d17251Schristos=item OPENSSL_INFO_CPU_SETTINGS 207*b0d17251Schristos 208*b0d17251SchristosThe current OpenSSL cpu settings. 209*b0d17251SchristosThis is the current setting of the cpu capability flags. It is usually 210*b0d17251Schristosautomatically configured but may be set via an environment variable. 211*b0d17251SchristosThe value has the same syntax as the environment variable. 212*b0d17251SchristosFor x86 the string looks like C<OPENSSL_ia32cap=0x123:0x456>. 213*b0d17251Schristos 214*b0d17251Schristos=back 215*b0d17251Schristos 216*b0d17251SchristosFor an unknown I<t>, NULL is returned. 217*b0d17251Schristos 218*b0d17251SchristosOpenSSL_version_num() returns the value of B<OPENSSL_VERSION_NUMBER>. 219*b0d17251Schristos 220*b0d17251Schristos=head1 RETURN VALUES 221*b0d17251Schristos 222*b0d17251SchristosOPENSSL_version_major(), OPENSSL_version_minor() and OPENSSL_version_patch() 223*b0d17251Schristosreturn the version number parts as integers. 224*b0d17251Schristos 225*b0d17251SchristosOPENSSL_version_pre_release() and OPENSSL_version_build_metadata() return 226*b0d17251Schristosthe values of B<OPENSSL_VERSION_PRE_RELEASE> and 227*b0d17251SchristosB<OPENSSL_VERSION_BUILD_METADATA> respectively as constant strings. 228*b0d17251SchristosFor any of them that is undefined, the empty string is returned. 229*b0d17251Schristos 230*b0d17251SchristosOpenSSL_version() returns constant strings. 231*b0d17251Schristos 232*b0d17251Schristos=head1 SEE ALSO 233*b0d17251Schristos 234*b0d17251SchristosL<crypto(7)> 235*b0d17251Schristos 236*b0d17251Schristos=head1 HISTORY 237*b0d17251Schristos 238*b0d17251SchristosThe macros and functions described here were added in OpenSSL 3.0, 239*b0d17251Schristosexcept for OPENSSL_VERSION_NUMBER and OpenSSL_version_num(). 240*b0d17251Schristos 241*b0d17251Schristos=head1 COPYRIGHT 242*b0d17251Schristos 243*b0d17251SchristosCopyright 2018-2022 The OpenSSL Project Authors. All Rights Reserved. 244*b0d17251Schristos 245*b0d17251SchristosLicensed under the Apache License 2.0 (the "License"). You may not use 246*b0d17251Schristosthis file except in compliance with the License. You can obtain a copy 247*b0d17251Schristosin the file LICENSE in the source distribution or at 248*b0d17251SchristosL<https://www.openssl.org/source/license.html>. 249*b0d17251Schristos 250*b0d17251Schristos=cut 251