Latest update.

This commit is contained in:
2020-01-17 19:45:12 +09:00
parent 016df9f433
commit 0f7abb4eb6
1100 changed files with 47785 additions and 16292 deletions
+5 -7
View File
@@ -80,15 +80,15 @@ Label "label", and Context "context".
EVP_KDF_free(kdf);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST,
"SHA256", 0);
"SHA2-256", 0);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC,
"HMAC", 0);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
"secret", strlen("secret"))
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
"context", strlen("context"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
"label", strlen("label"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
"context", strlen("context"));
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_CTX_set_params(kctx, params) <= 0)
error("EVP_KDF_CTX_set_params");
@@ -116,9 +116,9 @@ Label "label", and IV "sixteen bytes iv".
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
"secret", strlen("secret"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
"context", strlen("context"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
"label", strlen("label"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO,
"context", strlen("context"));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SEED,
iv, strlen(iv));
*p = OSSL_PARAM_construct_end();
@@ -136,9 +136,7 @@ NIST SP800-108, IETF RFC 6803, IETF RFC 8009.
=head1 SEE ALSO
L<EVP_KDF(3)>,
L<EVP_KDF_CTX_new_id(3)>,
L<EVP_KDF_CTX_free(3)>,
L<EVP_KDF_ctrl(3)>,
L<EVP_KDF_size(3)>,
L<EVP_KDF_derive(3)>,
L<EVP_KDF(3)/PARAMETERS>
+120
View File
@@ -0,0 +1,120 @@
=pod
=head1 NAME
EVP_KDF-KRB5KDF - The RFC3961 Krb5 KDF EVP_KDF implementation
=head1 DESCRIPTION
Support for computing the B<KRB5KDF> KDF through the B<EVP_KDF> API.
The EVP_KDF-KRB5KDF algorithm implements the key derivation function defined
in RFC 3961, section 5.1 and is used by Krb5 to derive session keys.
Three inputs are required to perform key derivation: a cipher, (for example
AES-128-CBC), the initial key, and a constant.
=head2 Identity
"KRB5KDF" is the name for this implementation;
it can be used with the EVP_KDF_fetch() function.
=head2 Supported parameters
The supported parameters are:
=over 4
=item "properties" (B<OSSL_KDF_PARAM_PROPERTIES>) <UTF8 string>
=item "cipher" (B<OSSL_KDF_PARAM_CIPHER>) <UTF8 string>
=item "key" (B<OSSL_KDF_PARAM_KEY>) <octet string>
These parameters work as described in L<EVP_KDF(3)/PARAMETERS>.
=item "constant" (B<OSSL_KDF_PARAM_CONSTANT>) <octet string>
This parameter sets the constant value for the KDF.
If a value is already set, the contents are replaced.
=back
=head1 NOTES
A context for KRB5KDF can be obtained by calling:
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "KRB5KDF", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
The output length of the KRB5KDF derivation is specified via the I<keylen>
parameter to the L<EVP_KDF_derive(3)> function, and MUST match the key
length for the chosen cipher or an error is returned. Moreover the
constant's length must not exceed the block size of the cipher.
Since the KRB5KDF output length depends on the chosen cipher, calling
L<EVP_KDF_size(3)> to obtain the requisite length returns the correct length
only after the cipher is set. Prior to that B<EVP_MAX_KEY_LENGTH> is returned.
The caller must allocate a buffer of the correct length for the chosen
cipher, and pass that buffer to the L<EVP_KDF_derive(3)> function along
with that length.
=head1 EXAMPLES
This example derives a key using the AES-128-CBC cipher:
EVP_KDF *kdf;
EVP_KDF_CTX *kctx;
unsigned char key[16] = "01234...";
unsigned char constant[] = "I'm a constant";
unsigned char out[16];
size_t outlen = sizeof(out);
OSSL_PARAM params[4], *p = params;
kdf = EVP_KDF_fetch(NULL, "KRB5KDF", NULL);
kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);
*p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_CIPHER,
SN_aes_128_cbc,
strlen(SN_aes_128_cbc));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_KEY,
key, (size_t)16);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_CONSTANT,
constant, strlen(constant));
*p = OSSL_PARAM_construct_end();
if (EVP_KDF_set_params(kctx, params) <= 0)
/* Error */
if (EVP_KDF_derive(kctx, out, outlen) <= 0)
/* Error */
EVP_KDF_CTX_free(kctx);
=head1 CONFORMING TO
RFC 3961
=head1 SEE ALSO
L<EVP_KDF(3)>,
L<EVP_KDF_CTX_new_id(3)>,
L<EVP_KDF_CTX_free(3)>,
L<EVP_KDF_ctrl(3)>,
L<EVP_KDF_size(3)>,
L<EVP_KDF_derive(3)>,
L<EVP_KDF(3)/PARAMETERS>
=head1 HISTORY
This functionality was added to OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the OpenSSL license (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+3 -3
View File
@@ -34,7 +34,7 @@ may be used by scrypt defaults to 1025 MiB.
=head2 Identity
"ID-SCRYPT" is the name for this implementation; it
"SCRYPT" is the name for this implementation; it
can be used with the EVP_KDF_fetch() function.
=head2 Supported parameters
@@ -65,7 +65,7 @@ Both r and p are parameters of type B<uint32_t>.
A context for scrypt can be obtained by calling:
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "ID-SCRYPT", NULL);
EVP_KDF *kdf = EVP_KDF_fetch(NULL, "SCRYPT", NULL);
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new(kdf);
The output length of an scrypt key derivation is specified via the
@@ -81,7 +81,7 @@ This example derives a 64-byte long test vector using scrypt with the password
unsigned char out[64];
OSSL_PARAM params[6], *p = params;
kdf = EVP_KDF_fetch(NULL, "ID-SCRYPT", NULL);
kdf = EVP_KDF_fetch(NULL, "SCRYPT", NULL);
kctx = EVP_KDF_CTX_new(kdf);
EVP_KDF_free(kdf);
+1 -1
View File
@@ -91,7 +91,7 @@ A context for SSHKDF can be obtained by calling:
The output length of the SSHKDF derivation is specified via the I<keylen>
parameter to the L<EVP_KDF_derive(3)> function.
Since the SSHKDF output length is variable, calling L<EVP_KDF-size()>
Since the SSHKDF output length is variable, calling L<EVP_KDF_size(3)>
to obtain the requisite length is not meaningful. The caller must
allocate a buffer of the desired length, and pass that buffer to the
L<EVP_KDF_derive(3)> function along with the desired length.
+5 -5
View File
@@ -2,7 +2,7 @@
=head1 NAME
EVP_MAC-KMAC, EVP_MAC-KMAC256, EVP_MAC-KMAC256
EVP_MAC-KMAC, EVP_MAC-KMAC128, EVP_MAC-KMAC256
- The KMAC EVP_MAC implementations
=head1 DESCRIPTION
@@ -16,9 +16,9 @@ properties, to be used with EVP_MAC_fetch():
=over 4
=item "KMAC128", "default=yes"
=item "KMAC-128", "default=yes"
=item "KMAC256", "default=yes"
=item "KMAC-256", "default=yes"
=back
@@ -44,8 +44,8 @@ The length of the "size" parameter should not exceed that of a B<size_t>.
=back
The "xof" parameter value is exptect to be 1 or 0. Use 1 to enable XOF
mode. If XOF is enabled then the output len that is encoded as part of
The "xof" parameter value is expected to be 1 or 0. Use 1 to enable XOF
mode. If XOF is enabled then the output length that is encoded as part of
the input stream is set to zero.
=head1 SEE ALSO
+1 -1
View File
@@ -15,7 +15,7 @@ used with EVP_MAC_fetch():
=over 4
=item "Poly1305", "default=yes"
=item "POLY1305", "default=yes"
=back
+1 -1
View File
@@ -15,7 +15,7 @@ used with EVP_MAC_fetch():
=over 4
=item "Siphash", "default=yes"
=item "SIPHASH", "default=yes"
=back
+2 -1
View File
@@ -49,7 +49,8 @@ Ed25519 or Ed448 public keys can be set directly using
L<EVP_PKEY_new_raw_public_key(3)> or loaded from a SubjectPublicKeyInfo
structure in a PEM file using L<PEM_read_bio_PUBKEY(3)> (or similar function).
Ed25519 and Ed448 can be tested within L<speed(1)> application since version 1.1.1.
Ed25519 and Ed448 can be tested with the L<openssl-speed(1)> application
since version 1.1.1.
Valid algorithm names are B<ed25519>, B<ed448> and B<eddsa>. If B<eddsa> is
specified, then both Ed25519 and Ed448 are benchmarked.
+260
View File
@@ -0,0 +1,260 @@
=pod
=head1 NAME
OSSL_PROVIDER-FIPS - OPENSSL FIPS provider
=head1 DESCRIPTION
The OPENSSL FIPS provider is a special provider that conforms to the Federal
Information Processing Standards (FIPS) specified in FIPS 140-2. This 'module'
contains an approved set of cryptographic algorithms that is validated by an
accredited testing laboratory.
=head1 SELF TESTING
One of the requirements for the FIPS module is self testing. An optional callback
mechanism is available to return information to the user using
L<OSSL_SELF_TEST_set_callback(7)>.
The OPENSSL FIPS module uses the following mechanism to provide information
about the self tests as they run.
This is useful for debugging if a self test is failing.
The callback also allows forcing any self test to fail, in order to check that
it operates correctly on failure.
The 'args' parameter of B<OSSL_CALLBACK> contains the B<OPENSSL_CTX> associated
with the provider that is triggering the self test. This may be useful if
multiple fips providers are present.
The OSSL_PARAM names used are:
=over 4
=item "st-phase" (B<OSSL_PROV_PARAM_SELF_TEST_PHASE>) <UTF8 string>
Each self test calls the callback 3 times with the following string values
for the phase.
=over 4
=item "Start" (B<OSSL_SELF_TEST_PHASE_START>)
This is the initial phase before the self test has run.
This is used for informational purposes only.
The value returned by the callback is ignored.
=item "Corrupt" (B<OSSL_SELF_TEST_PHASE_CORRUPT>)
The corrupt phase is run after the self test has calculated its known value.
The callback may be used to force the self test to fail by returning a value
of 0 from the callback during this phase.
Returning any other value from the callback causes the self test to run normally.
=item "Pass" (B<OSSL_SELF_TEST_PHASE_PASS>)
=item "Fail" (B<OSSL_SELF_TEST_PHASE_FAIL>)
The final phase runs after the self test is complete and indicates if a self
test passed or failed. This is used for informational purposes only.
The value returned by the callback is ignored.
"Fail" should normally only be returned if any self test was forced to fail
during the "Corrupt" phase (or if there was an error such as the integrity
check of the module failed).
Note that all self tests run even if a self test failure occurs.
=back
=item "st-type" (B<OSSL_PROV_PARAM_SELF_TEST_TYPE>) <UTF8 string>
Used as a category to identify the type of self test being run.
It includes the following string values:
=over 4
=item "Module_Integrity" (B<OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY>)
Uses HMAC SHA256 on the module file to validate that the module has not been
modified. The integrity value is compared to a value written to a configuration
file during installation.
=item "Install_Integrity" (B<OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY>)
Uses HMAC SHA256 on a fixed string to validate that the installation process
has already been performed and the self test KATS have already been tested,
The integrity value is compared to a value written to a configuration
file after successfully running the self tests during installation.
=item "KAT_Cipher" (B<OSSL_SELF_TEST_TYPE_KAT_CIPHER>)
Known answer test for a symmetric cipher.
=item "KAT_Digest" (B<OSSL_SELF_TEST_TYPE_KAT_DIGEST>)
Known answer test for a digest.
=item "KAT_Signature" (B<OSSL_SELF_TEST_TYPE_KAT_SIGNATURE>)
Known answer test for a signature.
=item "KAT_KDF" (B<OSSL_SELF_TEST_TYPE_KAT_KDF>)
Known answer test for a key derivation function.
=item "KAT_KA" (B<OSSL_SELF_TEST_TYPE_KAT_KA>)
Known answer test for key agreement.
=item "DRBG" (B<OSSL_SELF_TEST_TYPE_DRBG>)
Known answer test for a Deterministic Random Bit Generator.
=item "Pairwise_Consistency_Test" (B<OSSL_SELF_TEST_TYPE_PCT>)
Conditional test that is run during the generation of key pairs.
=back
The "Module_Integrity" self test is always run at startup.
The "Install_Integrity" self test is used to check if the self tests have
already been run at installation time. If they have already run then the
self tests are not run on subsequent startups.
All other self test categories are run once at installation time, except for the
"Pairwise_Consistency_Test".
There is only one instance of the "Module_Integrity" and "Install_Integrity"
self tests. All other self tests may have multiple instances.
=item "st-desc" (B<OSSL_PROV_PARAM_SELF_TEST_DESC>) <UTF8 string>
Used as a sub category to identify an individual self test.
The following description strings are used.
=over 4
=item "HMAC" (B<OSSL_SELF_TEST_DESC_INTEGRITY_HMAC>)
"Module_Integrity" and "Install_Integrity" use this.
=item "RSA" (B<OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1>)
=item "ECDSA" (B<OSSL_SELF_TEST_DESC_PCT_ECDSA>)
=item "DSA" (B<OSSL_SELF_TEST_DESC_PCT_DSA>)
Key generation tests used with the "Pairwise_Consistency_Test" type.
=item "AES_GCM" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_GCM>)
=item "TDES" (B<OSSL_SELF_TEST_DESC_CIPHER_TDES>)
Symmetric cipher tests used with the "KAT_Cipher" type.
=item "SHA1" (B<OSSL_SELF_TEST_DESC_MD_SHA1>)
=item "SHA2" (B<OSSL_SELF_TEST_DESC_MD_SHA2>)
=item "SHA3" (B<OSSL_SELF_TEST_DESC_MD_SHA3>)
Digest tests used with the "KAT_Digest" type.
=item "DSA" (B<OSSL_SELF_TEST_DESC_SIGN_DSA>)
=item "RSA" (B<OSSL_SELF_TEST_DESC_SIGN_RSA>)
=item "ECDSA" (B<OSSL_SELF_TEST_DESC_SIGN_ECDSA>)
Signature tests used with the "KAT_Signature" type.
=item "ECDH" (B<OSSL_SELF_TEST_DESC_KA_ECDH>)
=item "ECDSA" (B<OSSL_SELF_TEST_DESC_KA_ECDSA>)
Key agreement tests used with the "KAT_KA" type.
=item "HKDF" (B<OSSL_SELF_TEST_DESC_KDF_HKDF>)
Key Derivation Function tests used with the "KAT_KDF" type.
=item "CTR" (B<OSSL_SELF_TEST_DESC_DRBG_CTR>)
=item "HASH" (B<OSSL_SELF_TEST_DESC_DRBG_HASH>)
=item "HMAC" (B<OSSL_SELF_TEST_DESC_DRBG_HMAC>)
DRBG tests used with the "DRBG" type.
=back
=back
=head1 EXAMPLES
A simple self test callback is shown below for illustrative purposes.
#include <openssl/self_test.h>
static OSSL_CALLBACK self_test_cb;
static int self_test_cb(const OSSL_PARAM params[], void *arg)
{
int ret = 0;
const OSSL_PARAM *p = NULL;
const char *phase = NULL, *type = NULL, *desc = NULL;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
phase = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
desc = (const char *)p->data;
p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
goto err;
type = (const char *)p->data;
/* Do some logging */
if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
BIO_printf(bio_out, "%s : (%s) : ", desc, type);
if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
|| strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
BIO_printf(bio_out, "%s\n", phase);
/* Corrupt the SHA1 self test during the 'corrupt' phase by returning 0 */
if (strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0
&& strcmp(desc, OSSL_SELF_TEST_DESC_MD_SHA1) == 0) {
BIO_printf(bio_out, "%s %s", phase, desc);
return 0;
}
ret = 1;
err:
return ret;
}
=head1 SEE ALSO
L<openssl-fipsinstall(1)>,
L<fips_config(5)>,
L<OSSL_SELF_TEST_set_callback(7)>,
L<OSSL_PARAM(3)>,
L<openssl-core.h(7)>
=head1 HISTORY
The type and functions described here were added in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+2 -2
View File
@@ -41,8 +41,8 @@ done by calling:
And normally there is no need to pass a B<pctx> parameter to EVP_DigestSignInit()
or EVP_DigestVerifyInit() in such a scenario.
SM2 can be tested within L<speed(1)> application since version 3.0.0. At current
stage, the only valid algorithm name is B<sm2>.
SM2 can be tested with the L<openssl-speed(1)> application since version 3.0.0.
Currently, the only valid algorithm name is B<sm2>.
=head1 EXAMPLES
+35 -2
View File
@@ -10,7 +10,7 @@ openssl/core.h - OpenSSL Core types
=head1 DESCRIPTION
The <openssl/core.h> header file defines a number of public types that
The F<< <openssl/core.h> >> header defines a number of public types that
are used to communicate between the OpenSSL libraries and
implementation providers.
These types are designed to minimise the need for intimate knowledge
@@ -30,7 +30,7 @@ Arrays of this type must be terminated with a tuple having function
identity zero and function pointer NULL.
The available function identities and corresponding function
signatures are defined by L<openssl-core_numbers.h(7)>.
signatures are defined in L<openssl-core_numbers.h(7)>.
Any function identity not recognised by the recipient of this type
will be ignored.
@@ -74,6 +74,39 @@ parameters, and to describe parameters.
B<OSSL_PARAM> is further described in L<OSSL_PARAM(3)>
=item B<OSSL_CALLBACK>
This is a function type for a generic feedback callback function:
typedef int (OSSL_CALLBACK)(const OSSL_PARAM params[], void *arg);
A function that takes a pointer of this type should also take a
pointer to caller data. When calling this callback, the function is
expected to build an B<OSSL_PARAM> array of data it wants or is
expected to pass back, and pass that as I<params>, as well as
the caller data pointer it received, as I<arg>.
=item B<OSSL_PASSPHRASE_CALLBACK>
This is a function type for a generic pass phrase callback function:
typedef int (OSSL_PASSPHRASE_CALLBACK)(char *pass, size_t pass_size,
size_t *pass_len,
const OSSL_PARAM params[],
void *arg);
This callback can be used to prompt the user for a passphrase. When
calling it, a buffer to store the pass phrase needs to be given with
I<pass>, and its size with I<pass_size>. The length of the prompted
pass phrase will be given back in I<*pass_len>.
Additional parameters can be passed with the B<OSSL_PARAM> array
I<params>.
A function that takes a pointer of this type should also take a
pointer to caller data, which should be passed as I<arg> to this
callback.
=back
=head1 SEE ALSO
+81
View File
@@ -0,0 +1,81 @@
=pod
=head1 NAME
openssl-env - OpenSSL environment variables
=head1 DESCRIPTION
The OpenSSL libraries use environment variables to override the
compiled-in default paths for various data.
To avoid security risks, the environment is usually not consulted when
the executable is set-user-ID or set-group-ID.
=over 4
=item B<CTLOG_FILE>
Specifies the path to a certificate transparency log list.
See L<CTLOG_STORE_new(3)>.
=item B<OPENSSL>
Specifies the path to the B<openssl> executable. Only used by
the B<rehash> script.
See L<openssl-rehash(1)/Script Configuration>.
=item B<OPENSSL_CONF>
Specifies the path to a configuration file.
See L<openssl(1)> and L<config(5)>.
=item B<OPENSSL_ENGINES>
Specifies the directory from which dynamic engines are loaded.
See L<openssl-engine(1)>.
=item B<OPENSSL_MALLOC_FD>, B<OPENSSL_MALLOC_FAILURES>
If built with debugging, this allows memory allocation to fail.
See L<OPENSSSL_malloc(3)>.
=item B<OPENSSL_MODULES>
Specifies the directory from which cryptographic providers are loaded.
See L<openssl-provider(1)>.
=item B<OPENSSL_WIN32_UTF8>
If set, then L<UI_OpenSSL(3)> returns UTF-8 encoded strings, rather than
ones encoded in the current code page, and
the L<openssl(1)> program also transcodes the command-line parameters
from the current code page to UTF-8.
This environment variable is only checked on Microsoft Windows platforms.
=item B<RANDFILE>
The state file for the random number generator.
This should not be needed in normal use.
See L<RAND_load_file(3)>.
=item B<SSL_CERT_DIR>, B<SSL_CERT_FILE>
Specify the default directory or file containing CA certificates.
See L<SSL_CTX_load_verify_locations(3)>.
=item B<TSGET>
Additional arguments for the L<tsget(1)> command.
=back
=head1 COPYRIGHT
Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+21 -19
View File
@@ -23,21 +23,16 @@ user defined macros.
=item B<OPENSSL_API_COMPAT>
The value is a version number similar to the
L<OPENSSL_VERSION_NUMBER(3)> macro. Any symbol that is deprecated in
versions up to and including the version given in this macro will not
be declared.
The version number assigned to this macro can take one of two forms:
The value is a version number, given in one of the following two forms:
=over 4
=item C<0xMNNFF000L>
This is the form supported for all versions up 1.1.x, where C<M>
This is the form supported for all versions up to 1.1.x, where C<M>
represents the major number, C<NN> represents the minor number, and
C<FF> represents the fix number. For version 1.1.0, that's
C<0x10100000L>.
C<FF> represents the fix number, as a hexadecimal number. For version
1.1.0, that's C<0x10100000L>.
Any version number may be given, but these numbers are
the current known major deprecation points, making them the most
@@ -57,32 +52,39 @@ For convenience, higher numbers are accepted as well, as long as
feasible. For example, C<0x60000000L> will work as expected.
However, it is recommended to start using the second form instead:
=item C<m>
=item C<mmnnpp>
This form is a simple number that represents the major version number
and is supported for version 3.0 and up. For extra convenience,
these numbers are also available:
This form is a simple decimal number calculated with this formula:
I<major> * 10000 + I<minor> * 100 + I<patch>
where I<major>, I<minor> and I<patch> are the desired major,
minor and patch components of the version number. For example:
=over 4
=item Z<>0 (C<0x00908000L>, i.e. version 0.9.8)
=item 30000 corresponds to version 3.0.0
=item Z<>1 (C<0x10000000L>, i.e. version 1.0.0)
=item 10002 corresponds to version 1.0.2
=item Z<>2 (C<0x10100000L>, i.e. version 1.1.0)
=item 420101 corresponds to version 42.1.1
=back
For all other numbers C<m>, they are equivalent to version m.0.0.
=back
If not set, this macro will default to
C<{- join('', map { my @x = split /=/,$_; $x[1] }
grep /^OPENSSL_MIN_API=/, @{$config{openssl_api_defines} // []})
grep /^OPENSSL_CONFIGURED_API=/, @{$config{openssl_api_defines} // []})
|| '0x00000000L'
-}>.
=item B<OPENSSL_NO_DEPRECATED>
If this macro is defined, all deprecated public symbols in all OpenSSL
versions up to and including the version given by B<OPENSSL_API_COMPAT>
will be hidden.
=back
=head1 COPYRIGHT
+1 -1
View File
@@ -116,7 +116,7 @@ encoded using UTF-8.
This is default on most modern Unixes, but may involve an effort on other
platforms.
Specifically for Windows, setting the environment variable
C<OPENSSL_WIN32_UTF8> will have anything entered on [Windows] console prompt
B<OPENSSL_WIN32_UTF8> will have anything entered on [Windows] console prompt
converted to UTF-8 (command line and separately prompted pass phrases alike).
=head2 Opening existing objects
+259
View File
@@ -0,0 +1,259 @@
=pod
=head1 NAME
provider-asym_cipher - The asym_cipher library E<lt>-E<gt> provider functions
=head1 SYNOPSIS
=for openssl multiple includes
#include <openssl/core_numbers.h>
#include <openssl/core_names.h>
/*
* None of these are actual functions, but are displayed like this for
* the function signatures for functions that are offered as function
* pointers in OSSL_DISPATCH arrays.
*/
/* Context management */
void *OP_asym_cipher_newctx(void *provctx);
void OP_asym_cipher_freectx(void *ctx);
void *OP_asym_cipher_dupctx(void *ctx);
/* Encryption */
int OP_asym_cipher_encrypt_init(void *ctx, void *provkey);
int OP_asym_cipher_encrypt(void *ctx, unsigned char *out, size_t *outlen,
size_t outsize, const unsigned char *in,
size_t inlen);
/* Decryption */
int OP_asym_cipher_decrypt_init(void *ctx, void *provkey);
int OP_asym_cipher_decrypt(void *ctx, unsigned char *out, size_t *outlen,
size_t outsize, const unsigned char *in,
size_t inlen);
/* Asymmetric Cipher parameters */
int OP_asym_cipher_get_ctx_params(void *ctx, OSSL_PARAM params[]);
const OSSL_PARAM *OP_asym_cipher_gettable_ctx_params(void);
int OP_asym_cipher_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
const OSSL_PARAM *OP_asym_cipher_settable_ctx_params(void);
=head1 DESCRIPTION
This documentation is primarily aimed at provider authors. See L<provider(7)>
for further information.
The asymmetric cipher (OSSL_OP_ASYM_CIPHER) operation enables providers to
implement asymmetric cipher algorithms and make them available to applications
via the API functions L<EVP_PKEY_encrypt_init_ex(3)>, L<EVP_PKEY_encrypt(3)>,
L<EVP_PKEY_decrypt_init_ex(3)>, L<EVP_PKEY_decrypt(3)> (as well
as other related functions).
All "functions" mentioned here are passed as function pointers between
F<libcrypto> and the provider in B<OSSL_DISPATCH> arrays via
B<OSSL_ALGORITHM> arrays that are returned by the provider's
provider_query_operation() function
(see L<provider-base(7)/Provider Functions>).
All these "functions" have a corresponding function type definition
named B<OSSL_{name}_fn>, and a helper function to retrieve the
function pointer from an B<OSSL_DISPATCH> element named
B<OSSL_get_{name}>.
For example, the "function" OP_asym_cipher_newctx() has these:
typedef void *(OSSL_OP_asym_cipher_newctx_fn)(void *provctx);
static ossl_inline OSSL_OP_asym_cipher_newctx_fn
OSSL_get_OP_asym_cipher_newctx(const OSSL_DISPATCH *opf);
B<OSSL_DISPATCH> arrays are indexed by numbers that are provided as
macros in L<openssl-core_numbers.h(7)>, as follows:
OP_asym_cipher_newctx OSSL_FUNC_ASYM_CIPHER_NEWCTX
OP_asym_cipher_freectx OSSL_FUNC_ASYM_CIPHER_FREECTX
OP_asym_cipher_dupctx OSSL_FUNC_ASYM_CIPHER_DUPCTX
OP_asym_cipher_encrypt_init OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT
OP_asym_cipher_encrypt OSSL_FUNC_ASYM_CIPHER_ENCRYPT
OP_asym_cipher_decrypt_init OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT
OP_asym_cipher_decrypt OSSL_FUNC_ASYM_CIPHER_DECRYPT
OP_asym_cipher_get_ctx_params OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS
OP_asym_cipher_gettable_ctx_params OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS
OP_asym_cipher_set_ctx_params OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS
OP_asym_cipher_settable_ctx_params OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS
An asymmetric cipher algorithm implementation may not implement all of these
functions.
In order to be a consistent set of functions a provider must implement
OP_asym_cipher_newctx and OP_asym_cipher_freectx.
It must also implement both of OP_asym_cipher_encrypt_init and
OP_asym_cipher_encrypt, or both of OP_asym_cipher_decrypt_init and
OP_asym_cipher_decrypt.
OP_asym_cipher_get_ctx_params is optional but if it is present then so must
OP_asym_cipher_gettable_ctx_params.
Similarly, OP_asym_cipher_set_ctx_params is optional but if it is present then
so must OP_asym_cipher_settable_ctx_params.
An asymmetric cipher algorithm must also implement some mechanism for generating,
loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
See L<provider-keymgmt(7)> for further details.
=head2 Context Management Functions
OP_asym_cipher_newctx() should create and return a pointer to a provider side
structure for holding context information during an asymmetric cipher operation.
A pointer to this context will be passed back in a number of the other
asymmetric cipher operation function calls.
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
OP_asym_cipher_freectx() is passed a pointer to the provider side asymmetric
cipher context in the I<ctx> parameter.
This function should free any resources associated with that context.
OP_asym_cipher_dupctx() should duplicate the provider side asymmetric cipher
context in the I<ctx> parameter and return the duplicate copy.
=head2 Encryption Functions
OP_asym_cipher_encrypt_init() initialises a context for an asymmetric encryption
given a provider side asymmetric cipher context in the I<ctx> parameter, and a
pointer to a provider key object in the I<provkey> parameter.
The key object should have been previously generated, loaded or imported into
the provider using the key management (OSSL_OP_KEYMGMT) operation (see
provider-keymgmt(7)>.
OP_asym_cipher_encrypt() performs the actual encryption itself.
A previously initialised asymmetric cipher context is passed in the I<ctx>
parameter.
The data to be encrypted is pointed to by the I<in> parameter which is I<inlen>
bytes long.
Unless I<out> is NULL, the encrypted data should be written to the location
pointed to by the I<out> parameter and it should not exceed I<outsize> bytes in
length.
The length of the encrypted data should be written to I<*outlen>.
If I<out> is NULL then the maximum length of the encrypted data should be
written to I<*outlen>.
=head2 Decryption Functions
OP_asym_cipher_decrypt_init() initialises a context for an asymmetric decryption
given a provider side asymmetric cipher context in the I<ctx> parameter, and a
pointer to a provider key object in the I<provkey> parameter.
The key object should have been previously generated, loaded or imported into
the provider using the key management (OSSL_OP_KEYMGMT) operation (see
provider-keymgmt(7)>.
OP_asym_cipher_decrypt() performs the actual decryption itself.
A previously initialised asymmetric cipher context is passed in the I<ctx>
parameter.
The data to be decrypted is pointed to by the I<in> parameter which is I<inlen>
bytes long.
Unless I<out> is NULL, the decrypted data should be written to the location
pointed to by the I<out> parameter and it should not exceed I<outsize> bytes in
length.
The length of the decrypted data should be written to I<*outlen>.
If I<out> is NULL then the maximum length of the decrypted data should be
written to I<*outlen>.
=head2 Asymmetric Cipher Parameters
See L<OSSL_PARAM(3)> for further details on the parameters structure used by
the OP_asym_cipher_get_ctx_params() and OP_asym_cipher_set_ctx_params()
functions.
OP_asym_cipher_get_ctx_params() gets asymmetric cipher parameters associated
with the given provider side asymmetric cipher context I<ctx> and stores them in
I<params>.
OP_asym_cipher_set_ctx_params() sets the asymmetric cipher parameters associated
with the given provider side asymmetric cipher context I<ctx> to I<params>.
Any parameter settings are additional to any that were previously set.
Parameters currently recognised by built-in asymmetric cipher algorithms are as
follows.
Not all parameters are relevant to, or are understood by all asymmetric cipher
algorithms:
=over 4
=item "pad-mode" (B<OSSL_ASYM_CIPHER_PARAM_PAD_MODE>) <integer>
The type of padding to be used. The interpretation of this value will depend
on the algorithm in use. The default provider understands these RSA padding
modes: 1 (RSA_PKCS1_PADDING), 2 (RSA_SSLV23_PADDING), 3 (RSA_NO_PADDING),
4 (RSA_PKCS1_OAEP_PADDING), 5 (RSA_X931_PADDING), 6 (RSA_PKCS1_PSS_PADDING) and
7 (RSA_PKCS1_WITH_TLS_PADDING). See L<EVP_PKEY_CTX_set_rsa_padding(3)> for
further details.
=item "digest" (B<OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST>) <UTF8 string>
Gets or sets the name of the OAEP digest algorithm used when OAEP padding is in
use.
=item "digest-props" (B<OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS>) <UTF8 string>
Gets or sets the properties to use when fetching the OAEP digest algorithm.
=item "mgf1-digest" (B<OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST>) <UTF8 string>
Gets or sets the name of the MGF1 digest algorithm used when OAEP or PSS padding
is in use.
=item "mgf1-digest-props" (B<OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS>) <UTF8 string>
Gets or sets the properties to use when fetching the MGF1 digest algorithm.
=item "oaep-label" (B<OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL>) <octet string>
Gets or sets the OAEP label used when OAEP padding is in use.
=item "oaep-label-len" (B<OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL_LEN>) <size_t>
Gets the length of an OAEP label when OAEP padding is in use.
=item "tls-client-version" (B<OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION>) <unsigned integer>
The TLS protocol version first requested by the client. See
B<RSA_PKCS1_WITH_TLS_PADDING> on the page L<EVP_PKEY_CTX_set_rsa_padding(3)>.
=item "tls-negotiated-version" (B<OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION>) <unsigned integer>
The negotiated TLS protocol version. See
B<RSA_PKCS1_WITH_TLS_PADDING> on the page L<EVP_PKEY_CTX_set_rsa_padding(3)>.
=back
OP_asym_cipher_gettable_ctx_params() and OP_asym_cipher_settable_ctx_params()
get a constant B<OSSL_PARAM> array that describes the gettable and settable
parameters, i.e. parameters that can be used with OP_asym_cipherget_ctx_params()
and OP_asym_cipher_set_ctx_params() respectively.
See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
=head1 RETURN VALUES
OP_asym_cipher_newctx() and OP_asym_cipher_dupctx() should return the newly
created provider side asymmetric cipher context, or NULL on failure.
All other functions should return 1 for success or 0 on error.
=head1 SEE ALSO
L<provider(7)>
=head1 HISTORY
The provider ASYM_CIPHER interface was introduced in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+8 -4
View File
@@ -112,8 +112,10 @@ provider):
BIO_new_mem_buf OSSL_FUNC_BIO_NEW_MEMBUF
BIO_read_ex OSSL_FUNC_BIO_READ_EX
BIO_free OSSL_FUNC_BIO_FREE
BIO_vprintf OSSL_FUNC_BIO_VPRINTF
OPENSSL_cleanse OSSL_FUNC_OPENSSL_CLEANSE
OPENSSL_hexstr2buf OSSL_FUNC_OPENSSL_HEXSTR2BUF
OSSL_SELF_TEST_set_callback OSSL_FUNC_SELF_TEST_CB
For I<*out> (the B<OSSL_DISPATCH> array passed from the provider to
F<libcrypto>):
@@ -157,7 +159,7 @@ This corresponds to the OpenSSL function L<ERR_new(3)>.
sets debugging information in the current thread specific error
record.
The debugging information includes the name of the file I<file>, the
line I<line> and the function name I<func> where the error occured.
line I<line> and the function name I<func> where the error occurred.
This corresponds to the OpenSSL function L<ERR_set_debug(3)>.
@@ -171,7 +173,7 @@ The additional data is given as a format string I<fmt> and a set of
arguments I<args>, which are treated in the same manner as with
BIO_vsnprintf().
I<file> and I<line> may also be passed to indicate exactly where the
error occured or was reported.
error occurred or was reported.
This corresponds to the OpenSSL function L<ERR_vset_error(3)>.
@@ -183,10 +185,12 @@ CRYPTO_realloc(), CRYPTO_clear_realloc(), CRYPTO_secure_malloc(),
CRYPTO_secure_zalloc(), CRYPTO_secure_free(),
CRYPTO_secure_clear_free(), CRYPTO_secure_allocated(),
BIO_new_file(), BIO_new_mem_buf(), BIO_read_ex(), BIO_free(),
OPENSSL_cleanse(), and OPENSSL_hexstr2buf() correspond exactly to the
public functions with the same name.
BIO_vprintf(), OPENSSL_cleanse(), and OPENSSL_hexstr2buf()
correspond exactly to the public functions with the same name.
As a matter of fact, the pointers in the B<OSSL_DISPATCH> array are
direct pointers to those public functions.
OSSL_SELF_TEST_set_callback() is used to set an optional callback that can be
passed into a provider. This may be ignored by a provider.
=head2 Provider functions
+71 -3
View File
@@ -112,7 +112,7 @@ structure for holding context information during a cipher operation.
A pointer to this context will be passed back in a number of the other cipher
operation function calls.
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
initialisation (see L<provider(7)>).
OP_cipher_freectx() is passed a pointer to the provider side cipher context in
the I<cctx> parameter.
@@ -159,7 +159,7 @@ L<EVP_EncryptFinal(3)> and L<EVP_DecryptFinal(3)>.
OP_cipher_cipher() performs encryption/decryption using the provider side cipher
context in the I<cctx> parameter that should have been previously initialised via
a call to OP_cipher_encrypt_init() or OP_cipher_decrypt_init.
a call to OP_cipher_encrypt_init() or OP_cipher_decrypt_init().
This should call the raw underlying cipher function without any padding.
This will be invoked in the provider as a result of the application calling
L<EVP_Cipher(3)>.
@@ -288,7 +288,7 @@ that varies with every record.
Setting a TLS fixed IV changes a cipher to encrypt/decrypt TLS records.
TLS records are encrypted/decrypted using a single OP_cipher_cipher call per
record.
For a record decryption the first bytes of the input buffer will be the explict
For a record decryption the first bytes of the input buffer will be the explicit
part of the IV and the final bytes of the input buffer will be the AEAD tag.
The length of the explicit part of the IV and the tag length will depend on the
cipher in use and will be defined in the RFC for the relevant ciphersuite.
@@ -342,6 +342,74 @@ This is used by the RC5 cipher.
Gets or sets the effective keybits used for a RC2 cipher.
The length of the "keybits" parameter should not exceed that of a B<size_t>.
=item "speed" (B<OSSL_CIPHER_PARAM_SPEED>) <unsigned integer>
Sets the speed option for the associated cipher ctx. This is only supported
by AES SIV ciphers which disallow multiple operations by default.
Setting "speed" to 1 allows another encrypt or decrypt operation to be
performed. This is used for performance testing.
=item "tlsivgen" (B<OSSL_CIPHER_PARAM_AEAD_TLS1_GET_IV_GEN>) <octet string>
Gets the invocation field generated for encryption.
Can only be called after "tlsivfixed" is set.
This is only used for GCM mode.
=item "tlsivinv" (B<OSSL_CIPHER_PARAM_AEAD_TLS1_SET_IV_INV>) <octet string>
Sets the invocation field used for decryption.
Can only be called after "tlsivfixed" is set.
This is only used for GCM mode.
=item "tls1multi_enc" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC>) <octet string>
Triggers a multiblock tls1 encrypt operation for a tls1 aware cipher that supports
sending 4 or 8 records in one go.
The cipher performs both the MAC and encrypt stages and constructs the record
headers itself.
"tls1multi_enc" supplies the output buffer for the encrypt operation,
"tls1multi_encin" & "tls1multi_interleave" must also be set in order to supply
values to the encrypt operation.
=item "tls1multi_enclen" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_LEN>) <unsigned integer>
Get the total length of the record returned from the "tls1multi_enc" operation.
=item "tls1multi_interleave" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_INTERLEAVE>) <unsigned integer>
Sets or gets the number of records being sent in one go for a tls1 multiblock
cipher operation (either 4 or 8 records).
=item "tls1multi_encin" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_ENC_IN>) <octet string>
Supplies the data to encrypt for a tls1 multiblock cipher operation.
=item "tls1multi_maxsndfrag" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_SEND_FRAGMENT>) <unsigned integer>
Sets the maximum send fragment size for a tls1 multiblock cipher operation.
It must be set before using "tls1multi_maxbufsz".
The length of the "tls1multi_maxsndfrag" parameter should not exceed that of a B<size_t>.
=item "tls1multi_maxbufsz" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_MAX_BUFSIZE>) <unsigned integer>
Gets the maximum record length for a tls1 multiblock cipher operation.
The length of the "tls1multi_maxbufsz" parameter should not exceed that of a B<size_t>.
=item "tls1multi_aad" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD>) <octet string>
Sets the authenticated additional data used by a tls1 multiblock cipher operation.
The supplied data consists of 13 bytes of record data containing:
Bytes 0-7: The sequence number of the first record
Byte 8: The record type
Byte 9-10: The protocol version
Byte 11-12: Input length (Always 0)
"tls1multi_interleave" must also be set for this operation.
=item "tls1multi_aadpacklen" (B<OSSL_CIPHER_PARAM_TLS1_MULTIBLOCK_AAD_PACKLEN>) <unsigned integer>
Gets the result of running the "tls1multi_aad" operation.
=back
=head1 RETURN VALUES
+5 -5
View File
@@ -30,11 +30,11 @@ provider-digest - The digest library E<lt>-E<gt> provider functions
unsigned char *out, size_t *outl, size_t outsz);
/* Digest parameter descriptors */
const OSSL_PARAM *OP_cipher_gettable_params(void);
const OSSL_PARAM *OP_digest_gettable_params(void);
/* Digest operation parameter descriptors */
const OSSL_PARAM *OP_cipher_gettable_ctx_params(void);
const OSSL_PARAM *OP_cipher_settable_ctx_params(void);
const OSSL_PARAM *OP_digest_gettable_ctx_params(void);
const OSSL_PARAM *OP_digest_settable_ctx_params(void);
/* Digest parameters */
int OP_digest_get_params(OSSL_PARAM params[]);
@@ -100,7 +100,7 @@ structure for holding context information during a digest operation.
A pointer to this context will be passed back in a number of the other digest
operation function calls.
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
initialisation (see L<provider(7)>).
OP_digest_freectx() is passed a pointer to the provider side digest context in
the I<dctx> parameter.
@@ -132,7 +132,7 @@ The digest should not exceed I<outsz> bytes.
OP_digest_digest() is a "oneshot" digest function.
No provider side digest context is used.
Instead the provider context that was created during provider initialisation is
passed in the I<provctx> parameter (see L<provider(3)>).
passed in the I<provctx> parameter (see L<provider(7)>).
I<inl> bytes at I<in> should be digested and the result should be stored at
I<out>. The length of the digest should be stored in I<*outl> which should not
exceed I<outsz> bytes.
+4 -4
View File
@@ -87,8 +87,8 @@ OP_keyexch_newctx() should create and return a pointer to a provider side
structure for holding context information during a key exchange operation.
A pointer to this context will be passed back in a number of the other key
exchange operation function calls.
The paramater I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(7)>).
OP_keyexch_freectx() is passed a pointer to the provider side key exchange
context in the I<ctx> parameter.
@@ -100,7 +100,7 @@ the I<ctx> parameter and return the duplicate copy.
=head2 Shared Secret Derivation Functions
OP_keyexch_init() initialises a key exchange operation given a provider side key
exchange context in the I<ctx> paramter, and a pointer to a provider key object
exchange context in the I<ctx> parameter, and a pointer to a provider key object
in the I<provkey> parameter. The key object should have been previously
generated, loaded or imported into the provider using the key management
(OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>.
@@ -153,7 +153,7 @@ possible secret size.
=back
OP_keyexch_settable_ctx_params() gets a constant B<OSSL_PARAM> array that
decribes the settable parameters, i.e. parameters that can be used with
describes the settable parameters, i.e. parameters that can be used with
OP_signature_set_ctx_params().
See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
+79 -6
View File
@@ -26,6 +26,10 @@ provider-keymgmt - The KEYMGMT library E<lt>-E<gt> provider functions
const OSSL_PARAM *OP_keymgmt_importdomparam_types(void);
const OSSL_PARAM *OP_keymgmt_exportdomparam_types(void);
/* Key domain parameter information */
int OP_keymgmt_get_domparam_params(void *domparams, OSSL_PARAM params[]);
const OSSL_PARAM *OP_keymgmt_gettable_domparam_params(void);
/* Key creation and destruction */
void *OP_keymgmt_importkey(void *provctx, const OSSL_PARAM params[]);
void *OP_keymgmt_genkey(void *provctx,
@@ -40,6 +44,13 @@ provider-keymgmt - The KEYMGMT library E<lt>-E<gt> provider functions
const OSSL_PARAM *OP_keymgmt_importkey_types(void);
const OSSL_PARAM *OP_keymgmt_exportkey_types(void);
/* Key information */
int OP_keymgmt_get_key_params(void *key, OSSL_PARAM params[]);
const OSSL_PARAM *OP_keymgmt_gettable_key_params(void);
/* Discovery of supported operations */
const char *OP_keymgmt_query_operation_name(int operation_id);
=head1 DESCRIPTION
The KEYMGMT operation doesn't have much public visibility in OpenSSL
@@ -81,6 +92,9 @@ macros in L<openssl-core_numbers.h(7)>, as follows:
OP_keymgmt_exportdomparams OSSL_FUNC_KEYMGMT_EXPORTDOMPARAMS
OP_keymgmt_importdomparam_types OSSL_FUNC_KEYMGMT_IMPORTDOMPARAM_TYPES
OP_keymgmt_exportdomparam_types OSSL_FUNC_KEYMGMT_EXPORTDOMPARAM_TYPES
OP_keymgmt_get_domparam_params OSSL_FUNC_KEYMGMT_GET_DOMPARAM_PARAMS
OP_keymgmt_gettable_domparam_params
OSSL_FUNC_KEYMGMT_GETTABLE_DOMPARAM_PARAMS
OP_keymgmt_importkey OSSL_FUNC_KEYMGMT_IMPORTKEY
OP_keymgmt_genkey OSSL_FUNC_KEYMGMT_GENKEY
@@ -89,6 +103,10 @@ macros in L<openssl-core_numbers.h(7)>, as follows:
OP_keymgmt_exportkey OSSL_FUNC_KEYMGMT_EXPORTKEY
OP_keymgmt_importkey_types OSSL_FUNC_KEYMGMT_IMPORTKEY_TYPES
OP_keymgmt_exportkey_types OSSL_FUNC_KEYMGMT_EXPORTKEY_TYPES
OP_keymgmt_get_key_params OSSL_FUNC_KEYMGMT_GET_KEY_PARAMS
OP_keymgmt_gettable_key_params OSSL_FUNC_KEYMGMT_GETTABLE_KEY_PARAMS
OP_keymgmt_query_operation_name OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME
=head2 Domain Parameter Functions
@@ -113,13 +131,18 @@ OP_keymgmt_importdomparam_types() should return a constant array of
descriptor B<OSSL_PARAM>, for parameters that OP_keymgmt_importdomparams()
can handle.
=for comment There should be one corresponding to OP_keymgmt_gendomparams()
as well...
OP_keymgmt_exportdomparam_types() should return a constant array of
descriptor B<OSSL_PARAM>, for parameters that can be exported with
OP_keymgmt_exportdomparams().
OP_keymgmt_get_domparam_params() should extract information data
associated with the given I<domparams>,
see L</Information Parameters>.
OP_keymgmt_gettable_domparam_params() should return a constant array
of descriptor B<OSSL_PARAM>, for parameters that
OP_keymgmt_get_domparam_params() can handle.
=head2 Key functions
OP_keymgmt_importkey() should create a provider side structure
@@ -151,13 +174,63 @@ OP_keymgmt_importkey_types() should return a constant array of
descriptor B<OSSL_PARAM>, for parameters that OP_keymgmt_importkey()
can handle.
=for comment There should be one corresponding to OP_keymgmt_genkey()
as well...
OP_keymgmt_exportkey_types() should return a constant array of
descriptor B<OSSL_PARAM>, for parameters that can be exported with
OP_keymgmt_exportkeys().
OP_keymgmt_get_key_params() should extract information data associated
with the given I<key>, see L</Information Parameters>.
OP_keymgmt_gettable_key_params() should return a constant array of
descriptor B<OSSL_PARAM>, for parameters that
OP_keymgmt_get_key_params() can handle.
=head2 Supported operations
OP_keymgmt_query_operation_name() should return the name of the
supported algorithm for the operation I<operation_id>. This is
similar to provider_query_operation() (see L<provider-base(7)>),
but only works as an advisory. If this function is not present, or
returns NULL, the caller is free to assume that there's an algorithm
from the same provider, of the same name as the one used to fetch the
keymgmt and try to use that.
=head2 Information Parameters
See L<OSSL_PARAM(3)> for further details on the parameters structure.
Parameters currently recognised by built-in keymgmt algorithms'
OP_keymgmt_get_domparams_params() and OP_keymgmt_get_key_params()
are:
=over 4
=item "bits" (B<OSSL_PKEY_PARAM_BITS>) <integer>
The value should be the cryptographic length of the cryptosystem to
which the key belongs, in bits. The definition of cryptographic
length is specific to the key cryptosystem.
=item "max-size" (B<OSSL_PKEY_PARAM_MAX_SIZE>) <integer>
The value should be the maximum size that a caller should allocate to
safely store a signature (called I<sig> in L<provider-signature(7)>),
the result of asymmmetric encryption / decryption (I<out> in
L<provider-asym_cipher(7)>, a derived secret (I<secret> in
L<provider-keyexch(7)>, and similar data).
Because an EVP_KEYMGMT method is always tightly bound to another method
(signature, asymmetric cipher, key exchange, ...) and must be of the
same provider, this number only needs to be synchronised with the
dimensions handled in the rest of the same provider.
=item "security-bits" (B<OSSL_PKEY_PARAM_SECURITY_BITS>) <integer>
The value should be the number of security bits of the given key.
Bits of security is defined in SP800-57.
=back
=head1 SEE ALSO
L<provider(7)>
+4 -4
View File
@@ -44,7 +44,7 @@ for further information.
The MAC operation enables providers to implement mac algorithms and make
them available to applications via the API functions L<EVP_MAC_init(3)>,
L<EVP_MACM_update(3)> and L<EVP_MAC_final(3)>.
L<EVP_MAC_update(3)> and L<EVP_MAC_final(3)>.
All "functions" mentioned here are passed as function pointers between
F<libcrypto> and the provider in B<OSSL_DISPATCH> arrays via
@@ -93,8 +93,8 @@ OP_mac_newctx() should create and return a pointer to a provider side
structure for holding context information during a mac operation.
A pointer to this context will be passed back in a number of the other mac
operation function calls.
The paramater I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(7)>).
OP_mac_freectx() is passed a pointer to the provider side mac context in
the I<mctx> parameter.
@@ -108,7 +108,7 @@ I<mctx> parameter and return the duplicate copy.
=head2 Encryption/Decryption Functions
OP_mac_init() initialises a mac operation given a newly created provider
side mac context in the I<mctx> paramter.
side mac context in the I<mctx> parameter.
OP_mac_update() is called to supply data for MAC computation of a previously
initialised mac operation.
+276
View File
@@ -0,0 +1,276 @@
=pod
=head1 NAME
provider-serializer - The SERIALIZER library E<lt>-E<gt> provider functions
=head1 SYNOPSIS
=begin comment
Future development will also include deserializing functions.
=end comment
#include <openssl/core_numbers.h>
/*
* None of these are actual functions, but are displayed like this for
* the function signatures for functions that are offered as function
* pointers in OSSL_DISPATCH arrays.
*/
/* Functions to construct / destruct / manipulate the serializer context */
void *OP_serializer_newctx(void *provctx);
void OP_serializer_freectx(void *ctx);
int OP_serializer_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
const OSSL_PARAM *OP_serializer_settable_ctx_params(void)
/* Functions to serialize object data */
int OP_serializer_serialize_data(void *ctx, const OSSL_PARAM *data,
BIO *out,
OSSL_PASSPHRASE_CALLBACK *cb,
void *cbarg);
int OP_serializer_serialize_object(void *ctx, void *obj, BIO *out,
OSSL_PASSPHRASE_CALLBACK *cb,
void *cbarg);
=head1 DESCRIPTION
The SERIALIZER is a generic method to serialize any set of object data
in L<OSSL_PARAM(3)> array form, or any provider side object into
serialized form, and write it to the given BIO. If the caller wants
to get the serialized stream to memory, it should provide a
L<BIO_s_membuf(3)>.
The serializer doesn't need to know more about the B<BIO> pointer than
being able to pass it to the appropriate BIO upcalls (see
L<provider-base(7)/Core functions>).
The serialization using the L<OSSL_PARAM(3)> array form allows a
serializer to be used for data that's been exported from another
provider, and thereby allow them to exist independently of each
other.
The serialization using a provider side object can only be safely used
with provider data coming from the same provider, for example keys
with the L<KEYMGMT|provider-keymgmt(7)> provider.
All "functions" mentioned here are passed as function pointers between
F<libcrypto> and the provider in B<OSSL_DISPATCH> arrays via
B<OSSL_ALGORITHM> arrays that are returned by the provider's
provider_query_operation() function
(see L<provider-base(7)/Provider Functions>).
All these "functions" have a corresponding function type definition
named B<OSSL_{name}_fn>, and a helper function to retrieve the
function pointer from a B<OSSL_DISPATCH> element named
B<OSSL_get_{name}>.
For example, the "function" OP_serializer_serialize_data() has these:
typedef int
(OSSL_OP_serializer_serialize_data_fn)(void *provctx,
const OSSL_PARAM params[],
BIO *out);
static ossl_inline OSSL_OP_serializer_serialize_data_fn
OSSL_get_OP_serializer_serialize_data(const OSSL_DISPATCH *opf);
B<OSSL_DISPATCH> arrays are indexed by numbers that are provided as
macros in L<openssl-core_numbers.h(7)>, as follows:
OP_serializer_newctx OSSL_FUNC_SERIALIZER_NEWCTX
OP_serializer_freectx OSSL_FUNC_SERIALIZER_FREECTX
OP_serializer_set_ctx_params OSSL_FUNC_SERIALIZER_SET_CTX_PARAMS
OP_serializer_settable_ctx_params OSSL_FUNC_SERIALIZER_SETTABLE_CTX_PARAMS
OP_serializer_serialize_data OSSL_FUNC_SERIALIZER_SERIALIZE_DATA
OP_serializer_serialize_object OSSL_FUNC_SERIALIZER_SERIALIZE_OBJECT
=head2 Names and properties
The name of an implementation should match the type of object it
handles. For example, an implementation that serializes an RSA key
should be named accordingly.
To be able to specify exactly what serialization format and what type
of data a serializer implementation is expected to handle, two
additional properties may be given:
=over 4
=item format
This property is used to specify what kind of output format the
implementation produces. Currently known formats are:
=over 4
=item text
An implementation with that format property value outputs human
readable text, making that implementation suitable for C<-text> output
in diverse L<openssl(1)> commands.
=item pem
An implementation with that format property value outputs PEM
formatted data.
=item der
An implementation with that format property value outputs DER
formatted data.
=back
=item type
With objects that have multiple purposes, this can be used to specify
the purpose type. The currently known use cases are asymmetric keys
and domain parameters, where the type can be one of:
=over 4
=item private
An implementation with that format property value outputs a private
key.
=item public
An implementation with that format property value outputs a public
key.
=item domainparams
An implementation with that format property value outputs domain
parameters.
=back
=back
The possible values of both these properties is open ended. A
provider may very well specify other formats that libcrypto doesn't
know anything about.
=head2 Context functions
OP_serializer_newctx() returns a context to be used with the rest of
the functions.
OP_serializer_freectx() frees the given I<ctx>, if it was created by
OP_serializer_newctx().
OP_serializer_set_ctx_params() sets context data according to
parameters from I<params> that it recognises. Unrecognised parameters
should be ignored.
OP_serializer_settable_ctx_params() returns a constant B<OSSL_PARAM>
array describing the parameters that OP_serializer_set_ctx_params()
can handle.
See L<OSSL_PARAM(3)> for further details on the parameters structure used
by OP_serializer_set_ctx_params() and OP_serializer_settable_ctx_params().
=head2 Serializing functions
=for comment There will be a "Deserializing functions" title as well
OP_serializer_serialize_data() should take an array of B<OSSL_PARAM>,
I<data>, and if it contains the data necessary for the object type
that the implementation handles, it should output the object in
serialized form to the B<BIO>.
OP_serializer_serialize_object() should take a pointer to an object
that it knows intimately, and output that object in serialized form to
the B<BIO>. The caller I<must> ensure that this function is called
with a pointer that the provider of this function is familiar with.
It is not suitable to use with object pointers coming from other
providers.
Both serialization functions also take an B<OSSL_PASSPHRASE_CALLBACK>
function pointer along with a pointer to application data I<cbarg>,
which should be used when a pass phrase prompt is needed.
=head2 Serializer parameters
Parameters currently recognised by built-in serializers are as
follows:
=over 4
=item "cipher" (B<OSSL_SERIALIZER_PARAM_CIPHER>) <UTF8 string>
The name of the encryption cipher to be used when generating encrypted
serialization. This is used when serializing private keys, as well as
other objects that need protection.
If this name is invalid for the serialization implementation, the
implementation should refuse to perform the serialization, i.e.
OP_serializer_serialize_data() and OP_serializer_serialize_object()
should return an error.
=item "properties" (B<OSSL_SERIALIZER_PARAM_PROPERTIES>) <UTF8 string>
The properties to be queried when trying to fetch the algorithm given
with the "cipher" parameter.
This must be given together with the "cipher" parameter to be
considered valid.
The serialization implementation isn't obligated to use this value.
However, it is recommended that implementations that do not handle
property strings return an error on receiving this parameter unless
its value NULL or the empty string.
=item "passphrase" (B<OSSL_SERIALIZER_PARAM_PASS>) <octet string>
A pass phrase provided by the application. When this is given, the
built-in serializers will not attempt to use the passphrase callback.
=back
Parameters currently recognised by the built-in pass phrase callback:
=over 4
=item "info" (B<OSSL_PASSPHRASE_PARAM_INFO>) <UTF8 string>
A string of information that will become part of the pass phrase
prompt. This could be used to give the user information on what kind
of object it's being prompted for.
=back
=head1 RETURN VALUES
OP_serializer_newctx() returns a pointer to a context, or NULL on
failure.
OP_serializer_set_ctx_params() returns 1, unless a recognised
parameters was invalid or caused an error, for which 0 is returned.
OP_serializer_settable_ctx_params() returns a pointer to an array of
constant B<OSSL_PARAM> elements.
OP_serializer_serialize_data() and OP_serializer_serialize_object()
return 1 on success, or 0 on failure.
=head1 SEE ALSO
L<provider(7)>
=head1 HISTORY
The SERIALIZER interface was introduced in OpenSSL 3.0.
=head1 COPYRIGHT
Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+2 -2
View File
@@ -112,7 +112,7 @@ structure for holding context information during a signature operation.
A pointer to this context will be passed back in a number of the other signature
operation function calls.
The parameter I<provctx> is the provider context generated during provider
initialisation (see L<provider(3)>).
initialisation (see L<provider(7)>).
OP_signature_freectx() is passed a pointer to the provider side signature
context in the I<ctx> parameter.
@@ -209,7 +209,7 @@ The length of the "digest-size" parameter should not exceed that of a B<size_t>.
=back
OP_signature_gettable_ctx_params() and OP_signature_settable_ctx_params() get a
constant B<OSSL_PARAM> array that decribes the gettable and settable parameters,
constant B<OSSL_PARAM> array that describes the gettable and settable parameters,
i.e. parameters that can be used with OP_signature_get_ctx_params() and
OP_signature_set_ctx_params() respectively.
See L<OSSL_PARAM(3)> for the use of B<OSSL_PARAM> as parameter descriptor.
+49 -64
View File
@@ -147,6 +147,14 @@ The number for this operation is B<OSSL_OP_KEYEXCH>.
The functions the provider can offer are described in
L<provider-keyexch(7)>
=item Serialization
In the OpenSSL libraries, the corresponding method object is
B<OSSL_SERIALIZER>.
The number for this operation is B<OSSL_OP_SERIALIZER>.
The functions the provider can offer are described in
L<provider-serializer(7)>
=back
=head2 Fetching algorithms
@@ -210,17 +218,44 @@ L<EVP_CipherInit_ex(3)>, the actual implementation to be used is
fetched implicitly using default search criteria.
Implicit fetching can also occur with functions such as
L<EVP_PKEY_CTX_derive_init_ex(3)> where a NULL algorithm parameter is
L<EVP_PKEY_derive_init_ex(3)> where a NULL algorithm parameter is
supplied.
In this case an algorithm implementation is implicitly fetched using
default search criteria and an algorithm name that is consistent with
the type of EVP_PKEY being used.
=head3 Algorithm naming
Algorithm names are case insensitive. Any particular algorithm can have multiple
aliases associated with it. The canonical OpenSSL naming scheme follows this
format:
ALGNAME[VERSION?][-SUBNAME[VERSION?]?][-SIZE?][-MODE?]
VERSION is only present if there are multiple versions of an algorithm (e.g.
MD2, MD4, MD5). It may be omitted if there is only one version.
SUBNAME may be present where multiple algorithms are combined together,
e.g. MD5-SHA1.
SIZE is only present if multiple versions of an algorithm exist with different
sizes (e.g. AES-128-CBC, AES-256-CBC)
MODE is only present where applicable.
Other aliases may exist for example where standards bodies or common practice
use alternative names or names that OpenSSL has used historically.
=head1 OPENSSL PROVIDERS
OpenSSL comes with a set of providers.
All the algorithm names mentioned can be used as an algorithm
identifier to the appropriate fetching function.
The algorithms available in each of these providers may vary due to build time
configuration options. The L<openssl-list(1)> command can be used to list the
currently available algorithms.
The names of the algorithms shown from L<openssl-list(1)> can be used as an
algorithm identifier to the appropriate fetching function.
=head2 Default provider
@@ -229,30 +264,6 @@ Should it be needed (if other providers are loaded and offer
implementations of the same algorithms), the property "default=yes"
can be used as a search criterion for these implementations.
It currently offers the following named algorithms:
=over 4
=item Digests
SHA1, SHA224, SHA256, SHA384, SHA512, SHA512-224, SHA512-256,
SHA3-224, SHA3-256, SHA3-384, SHA3-512, SHAKE128, SHAKE256, SM3,
BLAKE2b512, BLAKE2s256, KMAC128, KMAC256, MD5, MD5-SHA1
=item Symmetric ciphers
AES-256-ECB, AES-192-ECB, AES-128-ECB, AES-256-CBC, AES-192-CBC,
AES-128-CBC, AES-256-OFB, AES-192-OFB, AES-128-OFB, AES-256-CFB,
AES-192-CFB, AES-128-CFB, AES-256-CFB1, AES-192-CFB1, AES-128-CFB1,
AES-256-CFB8, AES-192-CFB8, AES-128-CFB8, AES-256-CTR, AES-192-CTR,
AES-128-CTR, id-aes256-GCM, id-aes192-GCM, id-aes128-GCM
=item Key Exchange
dhKeyAgreement
=back
=head2 FIPS provider
The FIPS provider is a dynamically loadable module, and must therefore
@@ -262,22 +273,6 @@ Should it be needed (if other providers are loaded and offer
implementations of the same algorithms), the property "fips=yes" can
be used as a search criterion for these implementations.
It currently offers the following FIPS approved named algorithms:
=over 4
=item Digests
SHA1, SHA224, SHA256, SHA384, SHA512, SHA512-224, SHA512-256,
SHA3-224, SHA3-256, SHA3-384, SHA3-512, KMAC128, KMAC256
=item Symmetric ciphers
AES-256-ECB, AES-192-ECB, AES-128-ECB, AES-256-CBC, AES-192-CBC,
AES-128-CBC, AES-256-CTR, AES-192-CTR, AES-128-CTR
=back
=head2 Legacy provider
The legacy provider is a dynamically loadable module, and must therefore
@@ -287,23 +282,13 @@ Should it be needed (if other providers are loaded and offer
implementations of the same algorithms), the property "legacy=yes" can be
used as a search criterion for these implementations.
It currently offers the following named algorithms:
=over 4
=item Digest algorithms:
RIPEMD160, MD2, MD4, MDC2, whirlpool.
=back
=head1 EXAMPLES
=head2 Fetching
Fetch any available implementation of SHA256 in the default context:
Fetch any available implementation of SHA2-256 in the default context:
EVP_MD *md = EVP_MD_fetch(NULL, "SHA256", NULL);
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", NULL);
...
EVP_MD_meth_free(md);
@@ -313,34 +298,34 @@ Fetch any available implementation of AES-128-CBC in the default context:
...
EVP_CIPHER_meth_free(cipher);
Fetch an implementation of SHA256 from the default provider in the default
Fetch an implementation of SHA2-256 from the default provider in the default
context:
EVP_MD *md = EVP_MD_fetch(NULL, "SHA256", "default=yes");
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", "default=yes");
...
EVP_MD_meth_free(md);
Fetch an implementation of SHA256 that is not from the default provider in the
Fetch an implementation of SHA2-256 that is not from the default provider in the
default context:
EVP_MD *md = EVP_MD_fetch(NULL, "SHA256", "default=no");
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", "default=no");
...
EVP_MD_meth_free(md);
Fetch an implementation of SHA256 from the default provider in the specified
Fetch an implementation of SHA2-256 from the default provider in the specified
context:
EVP_MD *md = EVP_MD_fetch(ctx, "SHA256", "default=yes");
EVP_MD *md = EVP_MD_fetch(ctx, "SHA2-256", "default=yes");
...
EVP_MD_meth_free(md);
Load the legacy provider into the default context and then fetch an
implementation of whirlpool from it:
implementation of WHIRLPOOL from it:
/* This only needs to be done once - usually at application start up */
OSSL_PROVIDER *legacy = OSSL_PROVIDER_load(NULL, "legacy");
EVP_MD *md = EVP_MD_fetch(NULL, "whirlpool", "legacy=yes");
EVP_MD *md = EVP_MD_fetch(NULL, "WHIRLPOOL", "legacy=yes");
...
EVP_MD_meth_free(md);
@@ -355,7 +340,7 @@ other providers:
OSSL_PROVIDER *default = OSSL_PROVIDER_load(NULL, "default");
EVP_MD *md_whirlpool = EVP_MD_fetch(NULL, "whirlpool", NULL);
EVP_MD *md_sha256 = EVP_MD_fetch(NULL, "SHA256", NULL);
EVP_MD *md_sha256 = EVP_MD_fetch(NULL, "SHA2-256", NULL);
...
EVP_MD_meth_free(md_whirlpool);
EVP_MD_meth_free(md_sha256);
+363
View File
@@ -0,0 +1,363 @@
=pod
=encoding UTF-8
=head1 NAME
proxy-certificates - Proxy certificates in OpenSSL
=head1 DESCRIPTION
Proxy certificates are defined in RFC 3820. They are used to
extend rights to some other entity (a computer process, typically, or
sometimes to the user itself). This allows the entity to perform
operations on behalf of the owner of the EE (End Entity) certificate.
The requirements for a valid proxy certificate are:
=over 4
=item *
They are issued by an End Entity, either a normal EE certificate, or
another proxy certificate.
=item *
They must not have the B<subjectAltName> or B<issuerAltName>
extensions.
=item *
They must have the B<proxyCertInfo> extension.
=item *
They must have the subject of their issuer, with one B<commonName>
added.
=back
=head2 Enabling proxy certificate verification
OpenSSL expects applications that want to use proxy certificates to be
specially aware of them, and make that explicit. This is done by
setting an X509 verification flag:
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
or
X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_ALLOW_PROXY_CERTS);
See L</NOTES> for a discussion on this requirement.
=head2 Creating proxy certificates
Creating proxy certificates can be done using the L<openssl-x509(1)>
command, with some extra extensions:
[ v3_proxy ]
# A proxy certificate MUST NEVER be a CA certificate.
basicConstraints=CA:FALSE
# Usual authority key ID
authorityKeyIdentifier=keyid,issuer:always
# The extension which marks this certificate as a proxy
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB
It's also possible to specify the proxy extension in a separate section:
proxyCertInfo=critical,@proxy_ext
[ proxy_ext ]
language=id-ppl-anyLanguage
pathlen=0
policy=text:BC
The policy value has a specific syntax, I<syntag>:I<string>, where the
I<syntag> determines what will be done with the string. The following
I<syntag>s are recognised:
=over 4
=item B<text>
indicates that the string is a byte sequence, without any encoding:
policy=text:räksmörgås
=item B<hex>
indicates the string is encoded hexadecimal encoded binary data, with
colons between each byte (every second hex digit):
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
=item B<file>
indicates that the text of the policy should be taken from a file.
The string is then a filename. This is useful for policies that are
large (more than a few lines, e.g. XML documents).
=back
I<NOTE: The proxy policy value is what determines the rights granted
to the process during the proxy certificate. It's up to the
application to interpret and combine these policies.>
With a proxy extension, creating a proxy certificate is a matter of
two commands:
openssl req -new -config proxy.cnf \
-out proxy.req -keyout proxy.key \
-subj "/DC=org/DC=openssl/DC=users/CN=proxy 1"
openssl x509 -req -CAcreateserial -in proxy.req -out proxy.crt \
-CA user.crt -CAkey user.key -days 7 \
-extfile proxy.cnf -extensions v3_proxy1
You can also create a proxy certificate using another proxy
certificate as issuer (note: using a different configuration
section for the proxy extensions):
openssl req -new -config proxy.cnf \
-out proxy2.req -keyout proxy2.key \
-subj "/DC=org/DC=openssl/DC=users/CN=proxy 1/CN=proxy 2"
openssl x509 -req -CAcreateserial -in proxy2.req -out proxy2.crt \
-CA proxy.crt -CAkey proxy.key -days 7 \
-extfile proxy.cnf -extensions v3_proxy2
=head2 Using proxy certs in applications
To interpret proxy policies, the application would normally start with
some default rights (perhaps none at all), then compute the resulting
rights by checking the rights against the chain of proxy certificates,
user certificate and CA certificates.
The complicated part is figuring out how to pass data between your
application and the certificate validation procedure.
The following ingredients are needed for such processing:
=over 4
=item *
a callback function that will be called for every certificate being
validated. The callback is called several times for each certificate,
so you must be careful to do the proxy policy interpretation at the
right time. You also need to fill in the defaults when the EE
certificate is checked.
=item *
a data structure that is shared between your application code and the
callback.
=item *
a wrapper function that sets it all up.
=item *
an ex_data index function that creates an index into the generic
ex_data store that is attached to an X509 validation context.
=back
The following skeleton code can be used as a starting point:
#include <string.h>
#include <netdb.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#define total_rights 25
/*
* In this example, I will use a view of granted rights as a bit
* array, one bit for each possible right.
*/
typedef struct your_rights {
unsigned char rights[(total_rights + 7) / 8];
} YOUR_RIGHTS;
/*
* The following procedure will create an index for the ex_data
* store in the X509 validation context the first time it's
* called. Subsequent calls will return the same index.
*/
static int get_proxy_auth_ex_data_idx(X509_STORE_CTX *ctx)
{
static volatile int idx = -1;
if (idx < 0) {
X509_STORE_lock(X509_STORE_CTX_get0_store(ctx));
if (idx < 0) {
idx = X509_STORE_CTX_get_ex_new_index(0,
"for verify callback",
NULL,NULL,NULL);
}
X509_STORE_unlock(X509_STORE_CTX_get0_store(ctx));
}
return idx;
}
/* Callback to be given to the X509 validation procedure. */
static int verify_callback(int ok, X509_STORE_CTX *ctx)
{
if (ok == 1) {
/*
* It's REALLY important you keep the proxy policy check
* within this section. It's important to know that when
* ok is 1, the certificates are checked from top to
* bottom. You get the CA root first, followed by the
* possible chain of intermediate CAs, followed by the EE
* certificate, followed by the possible proxy
* certificates.
*/
X509 *xs = X509_STORE_CTX_get_current_cert(ctx);
if (X509_get_extension_flags(xs) & EXFLAG_PROXY) {
YOUR_RIGHTS *rights =
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
get_proxy_auth_ex_data_idx(ctx));
PROXY_CERT_INFO_EXTENSION *pci =
X509_get_ext_d2i(xs, NID_proxyCertInfo, NULL, NULL);
switch (OBJ_obj2nid(pci->proxyPolicy->policyLanguage)) {
case NID_Independent:
/*
* Do whatever you need to grant explicit rights
* to this particular proxy certificate, usually
* by pulling them from some database. If there
* are none to be found, clear all rights (making
* this and any subsequent proxy certificate void
* of any rights).
*/
memset(rights->rights, 0, sizeof(rights->rights));
break;
case NID_id_ppl_inheritAll:
/*
* This is basically a NOP, we simply let the
* current rights stand as they are.
*/
break;
default:
/*
* This is usually the most complex section of
* code. You really do whatever you want as long
* as you follow RFC 3820. In the example we use
* here, the simplest thing to do is to build
* another, temporary bit array and fill it with
* the rights granted by the current proxy
* certificate, then use it as a mask on the
* accumulated rights bit array, and voilà, you
* now have a new accumulated rights bit array.
*/
{
int i;
YOUR_RIGHTS tmp_rights;
memset(tmp_rights.rights, 0,
sizeof(tmp_rights.rights));
/*
* process_rights() is supposed to be a
* procedure that takes a string and its
* length, interprets it and sets the bits
* in the YOUR_RIGHTS pointed at by the
* third argument.
*/
process_rights((char *) pci->proxyPolicy->policy->data,
pci->proxyPolicy->policy->length,
&tmp_rights);
for(i = 0; i < total_rights / 8; i++)
rights->rights[i] &= tmp_rights.rights[i];
}
break;
}
PROXY_CERT_INFO_EXTENSION_free(pci);
} else if (!(X509_get_extension_flags(xs) & EXFLAG_CA)) {
/* We have an EE certificate, let's use it to set default! */
YOUR_RIGHTS *rights =
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
get_proxy_auth_ex_data_idx(ctx));
/*
* The following procedure finds out what rights the
* owner of the current certificate has, and sets them
* in the YOUR_RIGHTS structure pointed at by the
* second argument.
*/
set_default_rights(xs, rights);
}
}
return ok;
}
static int my_X509_verify_cert(X509_STORE_CTX *ctx,
YOUR_RIGHTS *needed_rights)
{
int ok;
int (*save_verify_cb)(int ok,X509_STORE_CTX *ctx) =
X509_STORE_CTX_get_verify_cb(ctx);
YOUR_RIGHTS rights;
X509_STORE_CTX_set_verify_cb(ctx, verify_callback);
X509_STORE_CTX_set_ex_data(ctx, get_proxy_auth_ex_data_idx(ctx),
&rights);
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
ok = X509_verify_cert(ctx);
if (ok == 1) {
ok = check_needed_rights(rights, needed_rights);
}
X509_STORE_CTX_set_verify_cb(ctx, save_verify_cb);
return ok;
}
If you use SSL or TLS, you can easily set up a callback to have the
certificates checked properly, using the code above:
SSL_CTX_set_cert_verify_callback(s_ctx, my_X509_verify_cert,
&needed_rights);
=head1 NOTES
To this date, it seems that proxy certificates have only been used in
environments that are aware of them, and no one seems to have
investigated how they can be used or misused outside of such an
environment.
For that reason, OpenSSL requires that applications aware of proxy
certificates must also make that explicit.
B<subjectAltName> and B<issuerAltName> are forbidden in proxy
certificates, and this is enforced in OpenSSL. The subject must be
the same as the issuer, with one commonName added on.
=head1 SEE ALSO
L<X509_STORE_CTX_set_flags(3)>,
L<X509_STORE_CTX_set_verify_cb(3)>,
L<X509_VERIFY_PARAM_set_flags(3)>,
L<SSL_CTX_set_cert_verify_callback(3)>,
L<openssl-req(1)>, L<openssl-x509(1)>,
L<RFC 3820|https://tools.ietf.org/html/rfc3820>
=head1 COPYRIGHT
Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.
=cut
+11 -778
View File
@@ -10,9 +10,11 @@ See the individual manual pages for details.
=head1 DESCRIPTION
The OpenSSL B<ssl> library implements the Secure Sockets Layer (SSL v2/v3) and
Transport Layer Security (TLS v1) protocols. It provides a rich API which is
documented here.
The OpenSSL B<ssl> library implements several versions of the
Secure Sockets Layer, Transport Layer Security, and Datagram Transport Layer
Security protocols.
This page gives a brief overview of the extensive API and data types
provided by the library.
An B<SSL_CTX> object is created as a framework to establish
TLS/SSL enabled connections (see L<SSL_CTX_new(3)>).
@@ -35,8 +37,7 @@ TLS/SSL connection.
=head1 DATA STRUCTURES
Currently the OpenSSL B<ssl> library functions deals with the following data
structures:
Here are some of the main data structures in the library.
=over 4
@@ -73,7 +74,6 @@ links to mostly all other structures.
=back
=head1 HEADER FILES
Currently the OpenSSL B<ssl> library provides the following C header files
@@ -81,796 +81,29 @@ containing the prototypes for the data structures and functions:
=over 4
=item B<ssl.h>
=item F<< <openssl/ssl.h> >>
This is the common header file for the SSL/TLS API. Include it into your
program to make the API of the B<ssl> library available. It internally
includes both more private SSL headers and headers from the B<crypto> library.
Whenever you need hard-core details on the internals of the SSL API, look
inside this header file.
This file also includes the others listed below.
=item B<ssl2.h>
=item F<< <openssl/ssl2.h> >>
Unused. Present for backwards compatibility only.
=item B<ssl3.h>
=item F<< <openssl/ssl3.h> >>
This is the sub header file dealing with the SSLv3 protocol only.
I<Usually you don't have to include it explicitly because
it's already included by ssl.h>.
=item B<tls1.h>
=item F<< <openssl/tls1.h> >>
This is the sub header file dealing with the TLSv1 protocol only.
I<Usually you don't have to include it explicitly because
it's already included by ssl.h>.
=back
=head1 API FUNCTIONS
Currently the OpenSSL B<ssl> library exports 214 API functions.
They are documented in the following:
=head2 Dealing with Protocol Methods
Here we document the various API functions which deal with the SSL/TLS
protocol methods defined in B<SSL_METHOD> structures.
=over 4
=item const SSL_METHOD *B<TLS_method>(void);
Constructor for the I<version-flexible> SSL_METHOD structure for clients,
servers or both.
See L<SSL_CTX_new(3)> for details.
=item const SSL_METHOD *B<TLS_client_method>(void);
Constructor for the I<version-flexible> SSL_METHOD structure for clients.
Must be used to support the TLSv1.3 protocol.
=item const SSL_METHOD *B<TLS_server_method>(void);
Constructor for the I<version-flexible> SSL_METHOD structure for servers.
Must be used to support the TLSv1.3 protocol.
=item const SSL_METHOD *B<TLSv1_2_method>(void);
Constructor for the TLSv1.2 SSL_METHOD structure for clients, servers or both.
=item const SSL_METHOD *B<TLSv1_2_client_method>(void);
Constructor for the TLSv1.2 SSL_METHOD structure for clients.
=item const SSL_METHOD *B<TLSv1_2_server_method>(void);
Constructor for the TLSv1.2 SSL_METHOD structure for servers.
=item const SSL_METHOD *B<TLSv1_1_method>(void);
Constructor for the TLSv1.1 SSL_METHOD structure for clients, servers or both.
=item const SSL_METHOD *B<TLSv1_1_client_method>(void);
Constructor for the TLSv1.1 SSL_METHOD structure for clients.
=item const SSL_METHOD *B<TLSv1_1_server_method>(void);
Constructor for the TLSv1.1 SSL_METHOD structure for servers.
=item const SSL_METHOD *B<TLSv1_method>(void);
Constructor for the TLSv1 SSL_METHOD structure for clients, servers or both.
=item const SSL_METHOD *B<TLSv1_client_method>(void);
Constructor for the TLSv1 SSL_METHOD structure for clients.
=item const SSL_METHOD *B<TLSv1_server_method>(void);
Constructor for the TLSv1 SSL_METHOD structure for servers.
=item const SSL_METHOD *B<SSLv3_method>(void);
Constructor for the SSLv3 SSL_METHOD structure for clients, servers or both.
=item const SSL_METHOD *B<SSLv3_client_method>(void);
Constructor for the SSLv3 SSL_METHOD structure for clients.
=item const SSL_METHOD *B<SSLv3_server_method>(void);
Constructor for the SSLv3 SSL_METHOD structure for servers.
=back
=head2 Dealing with Ciphers
Here we document the various API functions which deal with the SSL/TLS
ciphers defined in B<SSL_CIPHER> structures.
=over 4
=item char *B<SSL_CIPHER_description>(SSL_CIPHER *cipher, char *buf, int len);
Write a string to I<buf> (with a maximum size of I<len>) containing a human
readable description of I<cipher>. Returns I<buf>.
=item int B<SSL_CIPHER_get_bits>(SSL_CIPHER *cipher, int *alg_bits);
Determine the number of bits in I<cipher>. Because of export crippled ciphers
there are two bits: The bits the algorithm supports in general (stored to
I<alg_bits>) and the bits which are actually used (the return value).
=item const char *B<SSL_CIPHER_get_name>(SSL_CIPHER *cipher);
Return the internal name of I<cipher> as a string. These are the various
strings defined by the I<SSL3_TXT_xxx> and I<TLS1_TXT_xxx>
definitions in the header files.
=item const char *B<SSL_CIPHER_get_version>(SSL_CIPHER *cipher);
Returns a string like "C<SSLv3>" or "C<TLSv1.2>" which indicates the
SSL/TLS protocol version to which I<cipher> belongs (i.e. where it was defined
in the specification the first time).
=back
=head2 Dealing with Protocol Contexts
Here we document the various API functions which deal with the SSL/TLS
protocol context defined in the B<SSL_CTX> structure.
=over 4
=item int B<SSL_CTX_add_client_CA>(SSL_CTX *ctx, X509 *x);
=item long B<SSL_CTX_add_extra_chain_cert>(SSL_CTX *ctx, X509 *x509);
=item int B<SSL_CTX_add_session>(SSL_CTX *ctx, SSL_SESSION *c);
=item int B<SSL_CTX_check_private_key>(const SSL_CTX *ctx);
=item long B<SSL_CTX_ctrl>(SSL_CTX *ctx, int cmd, long larg, char *parg);
=item void B<SSL_CTX_flush_sessions>(SSL_CTX *s, long t);
=item void B<SSL_CTX_free>(SSL_CTX *a);
=item char *B<SSL_CTX_get_app_data>(SSL_CTX *ctx);
=item X509_STORE *B<SSL_CTX_get_cert_store>(SSL_CTX *ctx);
=item STACK *B<SSL_CTX_get_ciphers>(const SSL_CTX *ctx);
=item STACK *B<SSL_CTX_get_client_CA_list>(const SSL_CTX *ctx);
=item int (*B<SSL_CTX_get_client_cert_cb>(SSL_CTX *ctx))(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
=item void B<SSL_CTX_get_default_read_ahead>(SSL_CTX *ctx);
=item char *B<SSL_CTX_get_ex_data>(const SSL_CTX *s, int idx);
=item int B<SSL_CTX_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
=item long B<SSL_CTX_get_extra_chain_certs>(SSL_CTX *ctx, STACK_OF(X509) **sk);
=item long B<SSL_CTX_get_extra_chain_certs_only>(SSL_CTX *ctx, STACK_OF(X509) **sk);
=item void (*B<SSL_CTX_get_info_callback>(SSL_CTX *ctx))(SSL *ssl, int cb, int ret);
=item int B<SSL_CTX_get_quiet_shutdown>(const SSL_CTX *ctx);
=item void B<SSL_CTX_get_read_ahead>(SSL_CTX *ctx);
=item int B<SSL_CTX_get_session_cache_mode>(SSL_CTX *ctx);
=item long B<SSL_CTX_get_timeout>(const SSL_CTX *ctx);
=item int (*B<SSL_CTX_get_verify_callback>(const SSL_CTX *ctx))(int ok, X509_STORE_CTX *ctx);
=item int B<SSL_CTX_get_verify_mode>(SSL_CTX *ctx);
=item int B<SSL_CTX_load_verify_locations>(SSL_CTX *ctx, const char *CAfile, const char *CApath);
=item SSL_CTX *B<SSL_CTX_new>(const SSL_METHOD *meth);
=item int SSL_CTX_up_ref(SSL_CTX *ctx);
=item int B<SSL_CTX_remove_session>(SSL_CTX *ctx, SSL_SESSION *c);
=item int B<SSL_CTX_sess_accept>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_accept_good>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_accept_renegotiate>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_cache_full>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_cb_hits>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_connect>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_connect_good>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_connect_renegotiate>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_get_cache_size>(SSL_CTX *ctx);
=item SSL_SESSION *(*B<SSL_CTX_sess_get_get_cb>(SSL_CTX *ctx))(SSL *ssl, unsigned char *data, int len, int *copy);
=item int (*B<SSL_CTX_sess_get_new_cb>(SSL_CTX *ctx)(SSL *ssl, SSL_SESSION *sess);
=item void (*B<SSL_CTX_sess_get_remove_cb>(SSL_CTX *ctx)(SSL_CTX *ctx, SSL_SESSION *sess);
=item int B<SSL_CTX_sess_hits>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_misses>(SSL_CTX *ctx);
=item int B<SSL_CTX_sess_number>(SSL_CTX *ctx);
=item void B<SSL_CTX_sess_set_cache_size>(SSL_CTX *ctx, t);
=item void B<SSL_CTX_sess_set_get_cb>(SSL_CTX *ctx, SSL_SESSION *(*cb)(SSL *ssl, unsigned char *data, int len, int *copy));
=item void B<SSL_CTX_sess_set_new_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, SSL_SESSION *sess));
=item void B<SSL_CTX_sess_set_remove_cb>(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess));
=item int B<SSL_CTX_sess_timeouts>(SSL_CTX *ctx);
=item LHASH *B<SSL_CTX_sessions>(SSL_CTX *ctx);
=item int B<SSL_CTX_set_app_data>(SSL_CTX *ctx, void *arg);
=item void B<SSL_CTX_set_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
=item void B<SSL_CTX_set1_cert_store>(SSL_CTX *ctx, X509_STORE *cs);
=item void B<SSL_CTX_set_cert_verify_cb>(SSL_CTX *ctx, int (*cb)(), char *arg)
=item int B<SSL_CTX_set_cipher_list>(SSL_CTX *ctx, char *str);
=item void B<SSL_CTX_set_client_CA_list>(SSL_CTX *ctx, STACK *list);
=item void B<SSL_CTX_set_client_cert_cb>(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey));
=item int B<SSL_CTX_set_ct_validation_callback>(SSL_CTX *ctx, ssl_ct_validation_cb callback, void *arg);
=item void B<SSL_CTX_set_default_passwd_cb>(SSL_CTX *ctx, int (*cb);(void))
=item void B<SSL_CTX_set_default_read_ahead>(SSL_CTX *ctx, int m);
=item int B<SSL_CTX_set_default_verify_paths>(SSL_CTX *ctx);
Use the default paths to locate trusted CA certificates. There is one default
directory path and one default file path. Both are set via this call.
=item int B<SSL_CTX_set_default_verify_dir>(SSL_CTX *ctx)
Use the default directory path to locate trusted CA certificates.
=item int B<SSL_CTX_set_default_verify_file>(SSL_CTX *ctx)
Use the file path to locate trusted CA certificates.
=item int B<SSL_CTX_set_ex_data>(SSL_CTX *s, int idx, char *arg);
=item void B<SSL_CTX_set_info_callback>(SSL_CTX *ctx, void (*cb)(SSL *ssl, int cb, int ret));
=item void B<SSL_CTX_set_msg_callback>(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
=item void B<SSL_CTX_set_msg_callback_arg>(SSL_CTX *ctx, void *arg);
=item unsigned long B<SSL_CTX_clear_options>(SSL_CTX *ctx, unsigned long op);
=item unsigned long B<SSL_CTX_get_options>(SSL_CTX *ctx);
=item unsigned long B<SSL_CTX_set_options>(SSL_CTX *ctx, unsigned long op);
=item void B<SSL_CTX_set_quiet_shutdown>(SSL_CTX *ctx, int mode);
=item void B<SSL_CTX_set_read_ahead>(SSL_CTX *ctx, int m);
=item void B<SSL_CTX_set_session_cache_mode>(SSL_CTX *ctx, int mode);
=item int B<SSL_CTX_set_srp_cb_arg>(SSL_CTX *ctx, void *arg);
=item int B<SSL_CTX_set_srp_client_pwd_callback>(SSL_CTX *ctx, char *(*cb)(SSL *ssl, void *arg));
=item int B<SSL_CTX_set_srp_password>(SSL_CTX *ctx, char *password);
=item int B<SSL_CTX_set_srp_strength>(SSL_CTX *ctx, int strength);
=item int B<SSL_CTX_set_srp_username>(SSL_CTX *ctx, char *name);
=item int B<SSL_CTX_set_srp_username_callback>(SSL_CTX *ctx, int (*cb)(SSL *ssl, int *ad, void *arg));
=item int B<SSL_CTX_set_srp_verify_param_callback>(SSL_CTX *ctx, int (*cb)(SSL *ssl, void *arg));
=item int B<SSL_CTX_set_ssl_version>(SSL_CTX *ctx, const SSL_METHOD *meth);
=item void B<SSL_CTX_set_timeout>(SSL_CTX *ctx, long t);
=item long B<SSL_CTX_set_tmp_dh>(SSL_CTX* ctx, DH *dh);
=item long B<SSL_CTX_set_tmp_dh_callback>(SSL_CTX *ctx, DH *(*cb)(void));
=item long B<SSL_CTX_set_tmp_ecdh>(SSL_CTX* ctx, const EC_KEY *ecdh);
=item void B<SSL_CTX_set_verify>(SSL_CTX *ctx, int mode, int (*cb);(void))
=item int B<SSL_CTX_use_PrivateKey>(SSL_CTX *ctx, EVP_PKEY *pkey);
=item int B<SSL_CTX_use_PrivateKey_ASN1>(int type, SSL_CTX *ctx, unsigned char *d, long len);
=item int B<SSL_CTX_use_PrivateKey_file>(SSL_CTX *ctx, const char *file, int type);
=item int B<SSL_CTX_use_RSAPrivateKey>(SSL_CTX *ctx, RSA *rsa);
=item int B<SSL_CTX_use_RSAPrivateKey_ASN1>(SSL_CTX *ctx, unsigned char *d, long len);
=item int B<SSL_CTX_use_RSAPrivateKey_file>(SSL_CTX *ctx, const char *file, int type);
=item int B<SSL_CTX_use_certificate>(SSL_CTX *ctx, X509 *x);
=item int B<SSL_CTX_use_certificate_ASN1>(SSL_CTX *ctx, int len, unsigned char *d);
=item int B<SSL_CTX_use_certificate_file>(SSL_CTX *ctx, const char *file, int type);
=item int B<SSL_CTX_use_cert_and_key>(SSL_CTX *ctx, X509 *x, EVP_PKEY *pkey, STACK_OF(X509) *chain, int override);
=item X509 *B<SSL_CTX_get0_certificate>(const SSL_CTX *ctx);
=item EVP_PKEY *B<SSL_CTX_get0_privatekey>(const SSL_CTX *ctx);
=item void B<SSL_CTX_set_psk_client_callback>(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));
=item int B<SSL_CTX_use_psk_identity_hint>(SSL_CTX *ctx, const char *hint);
=item void B<SSL_CTX_set_psk_server_callback>(SSL_CTX *ctx, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));
=back
=head2 Dealing with Sessions
Here we document the various API functions which deal with the SSL/TLS
sessions defined in the B<SSL_SESSION> structures.
=over 4
=item int B<SSL_SESSION_cmp>(const SSL_SESSION *a, const SSL_SESSION *b);
=item void B<SSL_SESSION_free>(SSL_SESSION *ss);
=item char *B<SSL_SESSION_get_app_data>(SSL_SESSION *s);
=item char *B<SSL_SESSION_get_ex_data>(const SSL_SESSION *s, int idx);
=item int B<SSL_SESSION_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
=item long B<SSL_SESSION_get_time>(const SSL_SESSION *s);
=item long B<SSL_SESSION_get_timeout>(const SSL_SESSION *s);
=item unsigned long B<SSL_SESSION_hash>(const SSL_SESSION *a);
=item SSL_SESSION *B<SSL_SESSION_new>(void);
=item int B<SSL_SESSION_print>(BIO *bp, const SSL_SESSION *x);
=item int B<SSL_SESSION_print_fp>(FILE *fp, const SSL_SESSION *x);
=item int B<SSL_SESSION_set_app_data>(SSL_SESSION *s, char *a);
=item int B<SSL_SESSION_set_ex_data>(SSL_SESSION *s, int idx, char *arg);
=item long B<SSL_SESSION_set_time>(SSL_SESSION *s, long t);
=item long B<SSL_SESSION_set_timeout>(SSL_SESSION *s, long t);
=back
=head2 Dealing with Connections
Here we document the various API functions which deal with the SSL/TLS
connection defined in the B<SSL> structure.
=over 4
=item int B<SSL_accept>(SSL *ssl);
=item int B<SSL_add_dir_cert_subjects_to_stack>(STACK *stack, const char *dir);
=item int B<SSL_add_file_cert_subjects_to_stack>(STACK *stack, const char *file);
=item int B<SSL_add_client_CA>(SSL *ssl, X509 *x);
=item char *B<SSL_alert_desc_string>(int value);
=item char *B<SSL_alert_desc_string_long>(int value);
=item char *B<SSL_alert_type_string>(int value);
=item char *B<SSL_alert_type_string_long>(int value);
=item int B<SSL_check_private_key>(const SSL *ssl);
=item void B<SSL_clear>(SSL *ssl);
=item long B<SSL_clear_num_renegotiations>(SSL *ssl);
=item int B<SSL_connect>(SSL *ssl);
=item int B<SSL_copy_session_id>(SSL *t, const SSL *f);
Sets the session details for B<t> to be the same as in B<f>. Returns 1 on
success or 0 on failure.
=item long B<SSL_ctrl>(SSL *ssl, int cmd, long larg, char *parg);
=item int B<SSL_do_handshake>(SSL *ssl);
=item SSL *B<SSL_dup>(SSL *ssl);
SSL_dup() allows applications to configure an SSL handle for use
in multiple SSL connections, and then duplicate it prior to initiating
each connection with the duplicated handle.
Use of SSL_dup() avoids the need to repeat the configuration of the
handles for each connection.
For SSL_dup() to work, the connection MUST be in its initial state
and MUST NOT have not yet have started the SSL handshake.
For connections that are not in their initial state SSL_dup() just
increments an internal reference count and returns the I<same>
handle.
It may be possible to use L<SSL_clear(3)> to recycle an SSL handle
that is not in its initial state for re-use, but this is best
avoided.
Instead, save and restore the session, if desired, and construct a
fresh handle for each connection.
=item STACK *B<SSL_dup_CA_list>(STACK *sk);
=item void B<SSL_free>(SSL *ssl);
=item SSL_CTX *B<SSL_get_SSL_CTX>(const SSL *ssl);
=item char *B<SSL_get_app_data>(SSL *ssl);
=item X509 *B<SSL_get_certificate>(const SSL *ssl);
=item const char *B<SSL_get_cipher>(const SSL *ssl);
=item int B<SSL_is_dtls>(const SSL *ssl);
=item int B<SSL_get_cipher_bits>(const SSL *ssl, int *alg_bits);
=item char *B<SSL_get_cipher_list>(const SSL *ssl, int n);
=item char *B<SSL_get_cipher_name>(const SSL *ssl);
=item char *B<SSL_get_cipher_version>(const SSL *ssl);
=item STACK *B<SSL_get_ciphers>(const SSL *ssl);
=item STACK *B<SSL_get_client_CA_list>(const SSL *ssl);
=item SSL_CIPHER *B<SSL_get_current_cipher>(SSL *ssl);
=item long B<SSL_get_default_timeout>(const SSL *ssl);
=item int B<SSL_get_error>(const SSL *ssl, int i);
=item char *B<SSL_get_ex_data>(const SSL *ssl, int idx);
=item int B<SSL_get_ex_data_X509_STORE_CTX_idx>(void);
=item int B<SSL_get_ex_new_index>(long argl, char *argp, int (*new_func);(void), int (*dup_func)(void), void (*free_func)(void))
=item int B<SSL_get_fd>(const SSL *ssl);
=item void (*B<SSL_get_info_callback>(const SSL *ssl);)()
=item int B<SSL_get_key_update_type>(SSL *s);
=item STACK *B<SSL_get_peer_cert_chain>(const SSL *ssl);
=item X509 *B<SSL_get_peer_certificate>(const SSL *ssl);
=item const STACK_OF(SCT) *B<SSL_get0_peer_scts>(SSL *s);
=item EVP_PKEY *B<SSL_get_privatekey>(const SSL *ssl);
=item int B<SSL_get_quiet_shutdown>(const SSL *ssl);
=item BIO *B<SSL_get_rbio>(const SSL *ssl);
=item int B<SSL_get_read_ahead>(const SSL *ssl);
=item SSL_SESSION *B<SSL_get_session>(const SSL *ssl);
=item char *B<SSL_get_shared_ciphers>(const SSL *ssl, char *buf, int size);
=item int B<SSL_get_shutdown>(const SSL *ssl);
=item BIGNUM *B<SSL_get_srp_g>(SSL *ssl);
=item BIGNUM *B<SSL_get_srp_N>(SSL *ssl);
=item char *B<SSL_get_srp_userinfo>(SSL *ssl);
=item char *B<SSL_get_srp_username>(SSL *ssl);
=item const SSL_METHOD *B<SSL_get_ssl_method>(SSL *ssl);
=item int B<SSL_get_state>(const SSL *ssl);
=item long B<SSL_get_time>(const SSL *ssl);
=item long B<SSL_get_timeout>(const SSL *ssl);
=item int (*B<SSL_get_verify_callback>(const SSL *ssl))(int, X509_STORE_CTX *)
=item int B<SSL_get_verify_mode>(const SSL *ssl);
=item long B<SSL_get_verify_result>(const SSL *ssl);
=item char *B<SSL_get_version>(const SSL *ssl);
=item BIO *B<SSL_get_wbio>(const SSL *ssl);
=item int B<SSL_in_accept_init>(SSL *ssl);
=item int B<SSL_in_before>(SSL *ssl);
=item int B<SSL_in_connect_init>(SSL *ssl);
=item int B<SSL_in_init>(SSL *ssl);
=item int B<SSL_is_init_finished>(SSL *ssl);
=item int B<SSL_key_update>(SSL *s, int updatetype);
=item STACK *B<SSL_load_client_CA_file>(const char *file);
=item SSL *B<SSL_new>(SSL_CTX *ctx);
=item int SSL_up_ref(SSL *s);
=item long B<SSL_num_renegotiations>(SSL *ssl);
=item int B<SSL_peek>(SSL *ssl, void *buf, int num);
=item int B<SSL_pending>(const SSL *ssl);
=item int B<SSL_read>(SSL *ssl, void *buf, int num);
=item int B<SSL_renegotiate>(SSL *ssl);
=item char *B<SSL_rstate_string>(SSL *ssl);
=item char *B<SSL_rstate_string_long>(SSL *ssl);
=item long B<SSL_session_reused>(SSL *ssl);
=item void B<SSL_set_accept_state>(SSL *ssl);
=item void B<SSL_set_app_data>(SSL *ssl, char *arg);
=item void B<SSL_set_bio>(SSL *ssl, BIO *rbio, BIO *wbio);
=item int B<SSL_set_cipher_list>(SSL *ssl, char *str);
=item void B<SSL_set_client_CA_list>(SSL *ssl, STACK *list);
=item void B<SSL_set_connect_state>(SSL *ssl);
=item int B<SSL_set_ct_validation_callback>(SSL *ssl, ssl_ct_validation_cb callback, void *arg);
=item int B<SSL_set_ex_data>(SSL *ssl, int idx, char *arg);
=item int B<SSL_set_fd>(SSL *ssl, int fd);
=item void B<SSL_set_info_callback>(SSL *ssl, void (*cb);(void))
=item void B<SSL_set_msg_callback>(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
=item void B<SSL_set_msg_callback_arg>(SSL *ctx, void *arg);
=item unsigned long B<SSL_clear_options>(SSL *ssl, unsigned long op);
=item unsigned long B<SSL_get_options>(SSL *ssl);
=item unsigned long B<SSL_set_options>(SSL *ssl, unsigned long op);
=item void B<SSL_set_quiet_shutdown>(SSL *ssl, int mode);
=item void B<SSL_set_read_ahead>(SSL *ssl, int yes);
=item int B<SSL_set_rfd>(SSL *ssl, int fd);
=item int B<SSL_set_session>(SSL *ssl, SSL_SESSION *session);
=item void B<SSL_set_shutdown>(SSL *ssl, int mode);
=item int B<SSL_set_srp_server_param>(SSL *ssl, const BIGNUM *N, const BIGNUM *g, BIGNUM *sa, BIGNUM *v, char *info);
=item int B<SSL_set_srp_server_param_pw>(SSL *ssl, const char *user, const char *pass, const char *grp);
=item int B<SSL_set_ssl_method>(SSL *ssl, const SSL_METHOD *meth);
=item void B<SSL_set_time>(SSL *ssl, long t);
=item void B<SSL_set_timeout>(SSL *ssl, long t);
=item long B<SSL_set_tmp_dh>(SSL *ssl, DH *dh);
=item long B<SSL_set_tmp_dh_callback>(SSL *ssl, DH *(*cb)(void));
=item long B<SSL_set_tmp_ecdh>(SSL *ssl, const EC_KEY *ecdh);
=item void B<SSL_set_verify>(SSL *ssl, int mode, int (*callback);(void))
=item void B<SSL_set_verify_result>(SSL *ssl, long arg);
=item int B<SSL_set_wfd>(SSL *ssl, int fd);
=item int B<SSL_shutdown>(SSL *ssl);
=item OSSL_HANDSHAKE_STATE B<SSL_get_state>(const SSL *ssl);
Returns the current handshake state.
=item char *B<SSL_state_string>(const SSL *ssl);
=item char *B<SSL_state_string_long>(const SSL *ssl);
=item long B<SSL_total_renegotiations>(SSL *ssl);
=item int B<SSL_use_PrivateKey>(SSL *ssl, EVP_PKEY *pkey);
=item int B<SSL_use_PrivateKey_ASN1>(int type, SSL *ssl, unsigned char *d, long len);
=item int B<SSL_use_PrivateKey_file>(SSL *ssl, const char *file, int type);
=item int B<SSL_use_RSAPrivateKey>(SSL *ssl, RSA *rsa);
=item int B<SSL_use_RSAPrivateKey_ASN1>(SSL *ssl, unsigned char *d, long len);
=item int B<SSL_use_RSAPrivateKey_file>(SSL *ssl, const char *file, int type);
=item int B<SSL_use_certificate>(SSL *ssl, X509 *x);
=item int B<SSL_use_certificate_ASN1>(SSL *ssl, int len, unsigned char *d);
=item int B<SSL_use_certificate_file>(SSL *ssl, const char *file, int type);
=item int B<SSL_use_cert_and_key>(SSL *ssl, X509 *x, EVP_PKEY *pkey, STACK_OF(X509) *chain, int override);
=item int B<SSL_version>(const SSL *ssl);
=item int B<SSL_want>(const SSL *ssl);
=item int B<SSL_want_nothing>(const SSL *ssl);
=item int B<SSL_want_read>(const SSL *ssl);
=item int B<SSL_want_write>(const SSL *ssl);
=item int B<SSL_want_x509_lookup>(const SSL *ssl);
=item int B<SSL_write>(SSL *ssl, const void *buf, int num);
=item void B<SSL_set_psk_client_callback>(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len));
=item int B<SSL_use_psk_identity_hint>(SSL *ssl, const char *hint);
=item void B<SSL_set_psk_server_callback>(SSL *ssl, unsigned int (*callback)(SSL *ssl, const char *identity, unsigned char *psk, int max_psk_len));
=item const char *B<SSL_get_psk_identity_hint>(SSL *ssl);
=item const char *B<SSL_get_psk_identity>(SSL *ssl);
=back
=head1 RETURN VALUES
See the individual manual pages for details.
=head1 SEE ALSO
L<openssl(1)>, L<crypto(7)>,
L<CRYPTO_get_ex_new_index(3)>,
L<SSL_accept(3)>, L<SSL_clear(3)>,
L<SSL_connect(3)>,
L<SSL_CIPHER_get_name(3)>,
L<SSL_COMP_add_compression_method(3)>,
L<SSL_CTX_add_extra_chain_cert(3)>,
L<SSL_CTX_add_session(3)>,
L<SSL_CTX_ctrl(3)>,
L<SSL_CTX_flush_sessions(3)>,
L<SSL_CTX_get_verify_mode(3)>,
L<SSL_CTX_load_verify_locations(3)>
L<SSL_CTX_new(3)>,
L<SSL_CTX_sess_number(3)>,
L<SSL_CTX_sess_set_cache_size(3)>,
L<SSL_CTX_sess_set_get_cb(3)>,
L<SSL_CTX_sessions(3)>,
L<SSL_CTX_set_cert_store(3)>,
L<SSL_CTX_set_cert_verify_callback(3)>,
L<SSL_CTX_set_cipher_list(3)>,
L<SSL_CTX_set_client_CA_list(3)>,
L<SSL_CTX_set_client_cert_cb(3)>,
L<SSL_CTX_set_default_passwd_cb(3)>,
L<SSL_CTX_set_generate_session_id(3)>,
L<SSL_CTX_set_info_callback(3)>,
L<SSL_CTX_set_max_cert_list(3)>,
L<SSL_CTX_set_mode(3)>,
L<SSL_CTX_set_msg_callback(3)>,
L<SSL_CTX_set_options(3)>,
L<SSL_CTX_set_quiet_shutdown(3)>,
L<SSL_CTX_set_read_ahead(3)>,
L<SSL_CTX_set_security_level(3)>,
L<SSL_CTX_set_session_cache_mode(3)>,
L<SSL_CTX_set_session_id_context(3)>,
L<SSL_CTX_set_srp_password(3)>,
L<SSL_CTX_set_ssl_version(3)>,
L<SSL_CTX_set_timeout(3)>,
L<SSL_CTX_set_tmp_dh_callback(3)>,
L<SSL_CTX_set_tmp_ecdh(3)>,
L<SSL_CTX_set_verify(3)>,
L<SSL_CTX_use_certificate(3)>,
L<SSL_alert_type_string(3)>,
L<SSL_do_handshake(3)>,
L<SSL_enable_ct(3)>,
L<SSL_get_SSL_CTX(3)>,
L<SSL_get_ciphers(3)>,
L<SSL_get_client_CA_list(3)>,
L<SSL_get_default_timeout(3)>,
L<SSL_get_error(3)>,
L<SSL_get_ex_data_X509_STORE_CTX_idx(3)>,
L<SSL_get_fd(3)>,
L<SSL_get_peer_cert_chain(3)>,
L<SSL_get_rbio(3)>,
L<SSL_get_session(3)>,
L<SSL_get_verify_result(3)>,
L<SSL_get_version(3)>,
L<SSL_load_client_CA_file(3)>,
L<SSL_new(3)>,
L<SSL_pending(3)>,
L<SSL_read_ex(3)>,
L<SSL_read(3)>,
L<SSL_rstate_string(3)>,
L<SSL_session_reused(3)>,
L<SSL_set_bio(3)>,
L<SSL_set_connect_state(3)>,
L<SSL_set_fd(3)>,
L<SSL_set_session(3)>,
L<SSL_set_shutdown(3)>,
L<SSL_shutdown(3)>,
L<SSL_state_string(3)>,
L<SSL_want(3)>,
L<SSL_write_ex(3)>,
L<SSL_write(3)>,
L<SSL_SESSION_free(3)>,
L<SSL_SESSION_get_time(3)>,
L<d2i_SSL_SESSION(3)>,
L<SSL_CTX_set_psk_client_callback(3)>,
L<SSL_CTX_use_psk_identity_hint(3)>,
L<SSL_get_psk_identity(3)>,
L<DTLSv1_listen(3)>
=head1 HISTORY
B<SSLv2_client_method>, B<SSLv2_server_method> and B<SSLv2_method> were removed
in OpenSSL 1.1.0.
The return type of B<SSL_copy_session_id> was changed from void to int in
OpenSSL 1.1.0.
=head1 COPYRIGHT
Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.