Latest update.

This commit is contained in:
2019-05-23 12:02:56 +09:00
parent a7bf77581f
commit 64d458de91
185 changed files with 5859 additions and 2853 deletions
+8 -6
View File
@@ -15,10 +15,10 @@ ossl_method_store_cache_get, ossl_method_store_cache_set
typedef struct ossl_method_store_st OSSL_METHOD_STORE;
OSSL_METHOD_STORE *ossl_method_store_new(void);
OSSL_METHOD_STORE *ossl_method_store_new(OPENSSL_CTX *ctx);
void ossl_method_store_free(OSSL_METHOD_STORE *store);
int ossl_method_store_init(void);
void ossl_method_store_cleanup(void);
int ossl_method_store_init(OPENSSL_CTX *ctx);
void ossl_method_store_cleanup(OPENSSL_CTX *ctx);
int ossl_method_store_add(OSSL_METHOD_STORE *store,
int nid, const char *properties,
void *method, void (*method_destruct)(void *));
@@ -51,12 +51,14 @@ separately (see L</Cache Functions> below).
=head2 Store Functions
ossl_method_store_init() initialises the method store subsystem.
ossl_method_store_init() initialises the method store subsystem in the scope of
the library context B<ctx>.
ossl_method_store_cleanup() cleans up and shuts down the implementation method
store subsystem.
store subsystem in the scope of the library context B<ctx>.
ossl_method_store_new() create a new empty method store.
ossl_method_store_new() create a new empty method store using the supplied
B<ctx> to allow access to the required underlying property data.
ossl_method_store_free() frees resources allocated to B<store>.
+20 -17
View File
@@ -10,17 +10,16 @@ evp_generic_fetch - generic algorithm fetcher and method creator for EVP
#include "evp_locl.h"
void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
const char *algorithm, const char *properties,
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
const char *name, const char *properties,
void *(*new_method)(const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov),
int (*upref_method)(void *),
void (*free_method)(void *),
int (*nid_method)(void *));
void (*free_method)(void *));
=head1 DESCRIPTION
evp_generic_fetch() calls ossl_method_construct() with the given
C<libctx>, C<operation_id>, C<algorithm>, and C<properties> and uses
C<libctx>, C<operation_id>, C<name>, and C<properties> and uses
it to create an EVP method with the help of the functions
C<new_method>, C<upref_method>, and C<free_method>.
@@ -42,10 +41,6 @@ one.
frees the given method.
=item nid_method()
returns the nid associated with the given method.
=back
=head1 RETURN VALUES
@@ -80,7 +75,6 @@ And here's the implementation of the FOO method fetcher:
/* typedef struct evp_foo_st EVP_FOO */
struct evp_foo_st {
OSSL_PROVIDER *prov;
int nid;
CRYPTO_REF_COUNT refcnt;
OSSL_OP_foo_newctx_fn *newctx;
OSSL_OP_foo_init_fn *init;
@@ -93,7 +87,7 @@ And here's the implementation of the FOO method fetcher:
* In this example, we have a public method creator and destructor.
* It's not absolutely necessary, but is in the spirit of OpenSSL.
*/
EVP_FOO *EVP_FOO_meth_from_dispatch(int foo_type, const OSSL_DISPATCH *fns,
EVP_FOO *EVP_FOO_meth_from_dispatch(const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
EVP_FOO *foo = NULL;
@@ -120,7 +114,6 @@ And here's the implementation of the FOO method fetcher:
break;
}
}
foo->nid = foo_type;
foo->prov = prov;
if (prov)
ossl_provider_upref(prov);
@@ -138,10 +131,10 @@ And here's the implementation of the FOO method fetcher:
}
}
static void *foo_from_dispatch(int nid, const OSSL_DISPATCH *fns,
static void *foo_from_dispatch(const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov)
{
return EVP_FOO_meth_from_dispatch(nid, fns, prov);
return EVP_FOO_meth_from_dispatch(fns, prov);
}
static int foo_upref(void *vfoo)
@@ -159,11 +152,21 @@ And here's the implementation of the FOO method fetcher:
}
EVP_FOO *EVP_FOO_fetch(OPENSSL_CTX *ctx,
const char *algorithm,
const char *name,
const char *properties)
{
return evp_generic_fetch(ctx, OSSL_OP_FOO, algorithm, properties,
foo_from_dispatch, foo_upref, foo_free);
EVP_FOO *foo =
evp_generic_fetch(ctx, OSSL_OP_FOO, name, properties,
foo_from_dispatch, foo_upref, foo_free);
/*
* If this method exists in legacy form, with a constant NID for the
* given |name|, this is the spot to find that NID and set it in
* the newly constructed EVP_FOO instance.
*/
return foo;
}
And finally, the library functions:
+60 -30
View File
@@ -2,7 +2,8 @@
=head1 NAME
openssl_ctx_new_index, openssl_ctx_get_data - internal OPENSSL_CTX routines
openssl_ctx_get_data, openssl_ctx_run_once, openssl_ctx_onfree
- internal OPENSSL_CTX routines
=head1 SYNOPSIS
@@ -10,12 +11,16 @@ openssl_ctx_new_index, openssl_ctx_get_data - internal OPENSSL_CTX routines
#include "internal/cryptlib.h"
typedef struct openssl_ctx_method {
void *(*new_func)(void);
void *(*new_func)(OPENSSL_CTX *ctx);
void (*free_func)(void *);
} OPENSSL_CTX_METHOD;
int openssl_ctx_new_index(const OPENSSL_CTX_METHOD *meth);
void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index);
void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,
const OPENSSL_CTX_METHOD *meth);
int openssl_ctx_run_once(OPENSSL_CTX *ctx, unsigned int idx,
openssl_ctx_run_once_fn run_once_fn);
int openssl_ctx_onfree(OPENSSL_CTX *ctx, openssl_ctx_onfree_fn onfreefn);
=head1 DESCRIPTION
@@ -23,27 +28,33 @@ Internally, the OpenSSL library context C<OPENSSL_CTX> is implemented
as a C<CRYPTO_EX_DATA>, which allows data from diverse parts of the
library to be added and removed dynamically.
Each such data item must have a corresponding CRYPTO_EX_DATA index
associated with it.
associated with it. Unlike normal CRYPTO_EX_DATA objects we use static indexes
to identify data items. These are mapped transparetnly to CRYPTO_EX_DATA dynamic
indexes internally to the implementation.
See the example further down to see how that's done.
openssl_ctx_new_index() allocates a new library context index, and
associates it with the functions given through C<meth>.
The functions given through that method are used to create or free
items that are stored at that index whenever a library context is
created or freed, meaning that the code that use a data item of that
openssl_ctx_get_data() is used to retrieve a pointer to the data in
the library context C<ctx> associated with the given C<index>. An
OPENSSL_CTX_METHOD must be defined and given in the C<meth> parameter. The index
for it should be defined in cryptlib.h. The functions through the method are
used to create or free items that are stored at that index whenever a library
context is created or freed, meaning that the code that use a data item of that
index doesn't have to worry about that, just use the data available.
Deallocation of an index happens automatically when the library
context is freed.
openssl_ctx_get_data() is used to retrieve a pointer to the data in
the library context C<ctx> associated with the given C<index>.
openssl_ctx_run_once is used to run some initialisation routine C<run_once_fn>
exactly once per library context C<ctx> object. Each initialisation routine
should be allocate a unique run once index in cryptlib.h.
Any resources allocated via a run once initialisation routine can be cleaned up
using openssl_ctx_onfree. This associates an "on free" routine C<onfreefn> with
the library context C<ctx>. When C<ctx> is freed all associated "on free"
routines are called.
=head1 RETURN VALUES
openssl_ctx_new_index() returns -1 on error, otherwise the allocated
index number.
openssl_ctx_get_data() returns a pointer on success, or C<NULL> on
failure.
@@ -53,17 +64,14 @@ failure.
For a type C<FOO> that should end up in the OpenSSL library context, a
small bit of initialization is needed, i.e. to associate a constructor
and a destructor to a new index.
/* The index will always be entirely global, and dynamically allocated */
static int foo_index = -1;
and a destructor to an index.
typedef struct foo_st {
int i;
void *data;
} FOO;
static void *foo_new(void)
static void *foo_new(OPENSSL_CTX *ctx)
{
FOO *ptr = OPENSSL_zalloc(sizeof(*foo));
if (ptr != NULL)
@@ -74,27 +82,49 @@ and a destructor to a new index.
{
OPENSSL_free(ptr);
}
static const OPENSSL_CTX_METHOD foo_method = {
/*
* Include a reference to this in the methods table in context.c
* OPENSSL_CTX_FOO_INDEX should be added to internal/cryptlib.h
*/
const OPENSSL_CTX_METHOD foo_method = {
foo_new,
foo_free
};
static int foo_init(void)
{
foo_index = openssl_ctx_new_index(foo_method);
return foo_index != -1;
}
=head2 Usage
To get and use the data stored in the library context, simply do this:
/*
* ctx is received from a caller,
* foo_index comes from the example above
*/
FOO *data = openssl_ctx_get_data(ctx, foo_index);
FOO *data = openssl_ctx_get_data(ctx, OPENSSL_CTX_FOO_INDEX, &foo_method);
=head2 Run Once
void foo_cleanup(OPENSSL_CTX *ctx)
{
/* Free foo resources associated with ctx */
}
static openssl_ctx_run_once_fn do_foo_init;
static int do_foo_init(OPENSSL_CTX *ctx)
{
/* Allocate and initialise some foo resources and associated with ctx */
return openssl_ctx_onfree(ctx, &foo_cleanup)
}
int foo_some_function(OPENSSL_CTX *ctx)
{
if (!openssl_ctx_run_once(ctx,
OPENSSL_CTX_FOO_RUN_ONCE_INDEX,
do_foo_init))
return 0;
/* Do some work using foo resources in ctx */
}
=head1 SEE ALSO
+15 -13
View File
@@ -11,17 +11,17 @@ OSSL_METHOD_CONSTRUCT_METHOD, ossl_method_construct
struct ossl_method_construct_method_st {
/* Create store */
void *(*alloc_tmp_store)(void);
void *(*alloc_tmp_store)(OPENSSL_CTX *ctx);
/* Remove a store */
void (*dealloc_tmp_store)(void *store);
/* Get an already existing method from a store */
void *(*get)(OPENSSL_CTX *libctx, void *store, const char *propquery,
void *data);
void *(*get)(OPENSSL_CTX *libctx, void *store, const char *name,
const char *propquery, void *data);
/* Store a method in a store */
int (*put)(OPENSSL_CTX *libctx, void *store, const char *propdef,
void *method, void *data);
int (*put)(OPENSSL_CTX *libctx, void *store, void *method,
const char *name, const char *propdef, void *data);
/* Construct a new method */
void *(*construct)(const char *algorithm_name, const OSSL_DISPATCH *fns,
void *(*construct)(const char *name, const OSSL_DISPATCH *fns,
OSSL_PROVIDER *prov, void *data);
/* Destruct a method */
void (*destruct)(void *method);
@@ -33,6 +33,7 @@ OSSL_METHOD_CONSTRUCT_METHOD, ossl_method_construct
int force_cache,
OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data);
=head1 DESCRIPTION
All libcrypto sub-systems that want to create their own methods based
@@ -65,7 +66,7 @@ function pointers:
=item alloc_tmp_store()
Create a temporary method store.
Create a temporary method store in the scope of the library context C<ctx>.
This store is used to temporarily store methods for easier lookup, for
when the provider doesn't want its dispatch table stored in a longer
term cache.
@@ -76,14 +77,15 @@ Remove a temporary store.
=item get()
Look up an already existing method from a store.
Look up an already existing method from a store by name.
The store may be given with C<store>.
B<NULL> is a valid value and means that a sub-system default store
must be used.
This default store should be stored in the library context C<libctx>.
The method to be looked up should be identified with data from C<data>
The method to be looked up should be identified with the given C<name> and
data from C<data>
(which is the C<mcm_data> that was passed to ossl_construct_method())
and the provided property query C<propquery>.
@@ -99,15 +101,15 @@ B<NULL> is a valid value and means that a sub-system default store
must be used.
This default store should be stored in the library context C<libctx>.
The method should be associated with the given property definition
C<propdef> and any identification data given through C<data> (which is
The method should be associated with the given C<name> and property definition
C<propdef> as well as any identification data given through C<data> (which is
the C<mcm_data> that was passed to ossl_construct_method()).
This function is expected to increment the C<method>'s reference count.
=item construct()
Constructs a sub-system method for the given C<algorithm_name> and the given
Constructs a sub-system method for the given C<name> and the given
dispatch table C<fns>.
The associated I<provider object> C<prov> is passed as well, to make
@@ -132,7 +134,7 @@ B<NULL> on error.
=head1 HISTORY
This functionality was added to OpenSSL 3.0.0.
This functionality was added to OpenSSL 3.0.
=head1 COPYRIGHT
+74
View File
@@ -0,0 +1,74 @@
=pod
=head1 NAME
ossl_namemap_new, ossl_namemap_free, ossl_namemap_stored,
ossl_namemap_add, ossl_namemap_name, ossl_namemap_number
- internal number E<lt>-E<gt> name map
=head1 SYNOPSIS
#include "internal/cryptlib.h"
OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx);
OSSL_NAMEMAP *ossl_namemap_new(void);
void ossl_namemap_free(OSSL_NAMEMAP *namemap);
int ossl_namemap_add(OSSL_NAMEMAP *namemap, const char *name);
const char *ossl_namemap_name(const OSSL_NAMEMAP *namemap, int number);
int ossl_namemap_number(const OSSL_NAMEMAP *namemap, const char *name);
=head1 DESCRIPTION
A B<OSSL_NAMEMAP> is a simple number E<lt>-E<gt> name map, which can
be used to give any arbitrary name (any string) a unique dynamic
identity that is valid throughout the lifetime of the associated
library context.
ossl_namemap_new() and ossl_namemap_free() construct and destruct a
new B<OSSL_NAMEMAP>.
This is suitable to use when the B<OSSL_NAMEMAP> is embedded in other
structures, or should be independent for any reason.
ossl_namemap_stored() finds or auto-creates the default namemap in the
given library context.
The returned B<OSSL_NAMEMAP> can't be destructed using
ossl_namemap_free().
ossl_namemap_add() adds a new name to the namemap if it's not already
present.
ossl_namemap_name() finds the name corresponding to the given number.
ossl_namemap_number() finds the number corresponding to the given
name.
=head1 RETURN VALUES
ossl_namemap_new() and ossl_namemap_stored() return the pointer to a
B<OSSL_NAMEMAP>, or NULL on error.
ossl_namemap_add() returns the number associated with the added
string, or zero on error.
ossl_namemap_name() returns a pointer to the name corresponding to the
given number, or NULL if it's undefined in the given B<OSSL_NAMEMAP>.
ossl_namemap_number() returns the number corresponding to the given
name, or 0 if it's undefined in the given B<OSSL_NAMEMAP>.
=head1 HISTORY
The functions described here were all 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
+8 -1
View File
@@ -5,7 +5,7 @@
ossl_provider_find, ossl_provider_new, ossl_provider_upref,
ossl_provider_free, ossl_provider_add_module_location,
ossl_provider_set_fallback, ossl_provider_activate,
ossl_provider_forall_loaded,
ossl_provider_ctx, ossl_provider_forall_loaded,
ossl_provider_name, ossl_provider_dso,
ossl_provider_module_name, ossl_provider_module_path,
ossl_provider_teardown, ossl_provider_get_param_types,
@@ -29,6 +29,9 @@ ossl_provider_get_params, ossl_provider_query_operation
/* Load and initialize the Provider */
int ossl_provider_activate(OSSL_PROVIDER *prov);
/* Return pointer to the provider's context */
void *ossl_provider_ctx(const OSSL_PROVIDER *prov);
/* Iterate over all loaded providers */
int ossl_provider_forall_loaded(OPENSSL_CTX *,
int (*cb)(OSSL_PROVIDER *provider,
@@ -121,6 +124,10 @@ be located in that module, and called.
=back
ossl_provider_ctx() returns a context created by the provider.
Outside of the provider, it's completely opaque, but it needs to be
passed back to some of the provider functions.
ossl_provider_forall_loaded() iterates over all the currently
"activated" providers, and calls C<cb> for each of them.
If no providers have been "activated" yet, it tries to activate all
+11 -6
View File
@@ -20,6 +20,7 @@ B<openssl dsaparam>
[B<-writerand file>]
[B<-genkey>]
[B<-engine id>]
[B<-verbose>]
[B<numbits>]
=head1 DESCRIPTION
@@ -89,12 +90,6 @@ all others.
Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.
=item B<numbits>
This option specifies that a parameter set should be generated of size
B<numbits>. It must be the last option. If this option is included then
the input file (if any) is ignored.
=item B<-engine id>
Specifying an engine (by its unique B<id> string) will cause B<dsaparam>
@@ -102,6 +97,16 @@ to attempt to obtain a functional reference to the specified engine,
thus initialising it if needed. The engine will then be set as the default
for all available algorithms.
=item B<-verbose>
Print extra details about the operations being performed.
=item B<numbits>
This option specifies that a parameter set should be generated of size
B<numbits>. It must be the last option. If this option is included then
the input file (if any) is ignored.
=back
=head1 NOTES
+5
View File
@@ -25,6 +25,7 @@ B<openssl> B<gendsa>
[B<-rand file...>]
[B<-writerand file>]
[B<-engine id>]
[B<-verbose>]
[B<paramfile>]
=head1 DESCRIPTION
@@ -71,6 +72,10 @@ to attempt to obtain a functional reference to the specified engine,
thus initialising it if needed. The engine will then be set as the default
for all available algorithms.
=item B<-verbose>
Print extra details about the operations being performed.
=item B<paramfile>
This option specifies the DSA parameter file to use. The parameters in this
+4 -4
View File
@@ -118,7 +118,7 @@ or ED448 algorithms.
=item B<rsa_keygen_bits:numbits>
The number of bits in the generated key. If not specified 1024 is used.
The number of bits in the generated key. If not specified 2048 is used.
=item B<rsa_keygen_primes:numprimes>
@@ -185,12 +185,12 @@ below.
=item B<dsa_paramgen_bits:numbits>
The number of bits in the generated prime. If not specified 1024 is used.
The number of bits in the generated prime. If not specified 2048 is used.
=item B<dsa_paramgen_q_bits:numbits>
The number of bits in the q parameter. Must be one of 160, 224 or 256. If not
specified 160 is used.
specified 224 is used.
=item B<dsa_paramgen_md:digest>
@@ -209,7 +209,7 @@ or B<sha256> if it is 256.
=item B<dh_paramgen_prime_len:numbits>
The number of bits in the prime parameter B<p>. The default is 1024.
The number of bits in the prime parameter B<p>. The default is 2048.
=item B<dh_paramgen_subprime_len:numbits>
+5
View File
@@ -29,6 +29,7 @@ B<openssl> B<genrsa>
[B<-writerand file>]
[B<-engine id>]
[B<-primes num>]
[B<-verbose>]
[B<numbits>]
=head1 DESCRIPTION
@@ -91,6 +92,10 @@ parameter must be a positive integer that is greater than 1 and less than 16.
If B<num> is greater than 2, then the generated key is called a 'multi-prime'
RSA key, which is defined in RFC 8017.
=item B<-verbose>
Print extra details about the operations being performed.
=item B<numbits>
The size of the private key to generate in bits. This must be the last option
+6
View File
@@ -184,6 +184,7 @@ B<openssl> B<s_server>
[B<-early_data>]
[B<-anti_replay>]
[B<-no_anti_replay>]
[B<-http_server_binmode>]
=head1 DESCRIPTION
@@ -743,6 +744,11 @@ has been negotiated, and early data is enabled on the server. A full handshake
is forced if a session ticket is used a second or subsequent time. Any early
data that was sent will be rejected.
=item B<-http_server_binmode>
When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
by the client in binary mode.
=back
=head1 CONNECTED COMMANDS
+3 -1
View File
@@ -412,7 +412,9 @@ The following I<ctrl>s are supported in CCM mode.
This call is made to set the expected B<CCM> tag value when decrypting or
the length of the tag (with the C<tag> parameter set to NULL) when encrypting.
The tag length is often referred to as B<M>. If not set a default value is
used (12 for AES).
used (12 for AES). When decrypting, the tag needs to be set before passing
in data to be decrypted, but as in GCM and OCB mode, it can be set after
passing additional authenticated data (see L<AEAD Interface>).
=item EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_L, ivlen, NULL)
+61 -16
View File
@@ -2,17 +2,21 @@
=head1 NAME
EVP_KDF_CTX, EVP_KDF_CTX_new_id, EVP_KDF_CTX_free, EVP_KDF_reset,
EVP_KDF_ctrl, EVP_KDF_vctrl, EVP_KDF_ctrl_str, EVP_KDF_size,
EVP_KDF_derive - EVP KDF routines
EVP_KDF, EVP_KDF_CTX, EVP_KDF_CTX_new, EVP_KDF_CTX_new_id, EVP_KDF_CTX_free,
EVP_KDF_CTX_kdf, EVP_KDF_reset, EVP_KDF_ctrl, EVP_KDF_vctrl, EVP_KDF_ctrl_str,
EVP_KDF_size, EVP_KDF_derive, EVP_KDF_nid, EVP_KDF_name,
EVP_get_kdfbyname, EVP_get_kdfbynid, EVP_get_kdfbyobj - EVP KDF routines
=head1 SYNOPSIS
#include <openssl/kdf.h>
typedef struct evp_kdf_st EVP_KDF;
typedef struct evp_kdf_ctx_st EVP_KDF_CTX;
EVP_KDF_CTX *EVP_KDF_CTX_new_id(int id);
EVP_KDF_CTX *EVP_KDF_CTX_new(const EVP_KDF *kdf);
EVP_KDF_CTX *EVP_KDF_CTX_new_id(int nid);
const EVP_KDF *EVP_KDF_CTX_kdf(EVP_KDF_CTX *ctx);
void EVP_KDF_CTX_free(EVP_KDF_CTX *ctx);
void EVP_KDF_reset(EVP_KDF_CTX *ctx);
int EVP_KDF_ctrl(EVP_KDF_CTX *ctx, int cmd, ...);
@@ -20,29 +24,40 @@ EVP_KDF_derive - EVP KDF routines
int EVP_KDF_ctrl_str(EVP_KDF_CTX *ctx, const char *type, const char *value);
size_t EVP_KDF_size(EVP_KDF_CTX *ctx);
int EVP_KDF_derive(EVP_KDF_CTX *ctx, unsigned char *key, size_t keylen);
int EVP_KDF_nid(const EVP_KDF *kdf);
const char *EVP_KDF_name(const EVP_KDF *kdf);
const EVP_KDF *EVP_get_kdfbyname(const char *name);
const EVP_KDF *EVP_get_kdfbynid(int nid);
const EVP_KDF *EVP_get_kdfbyobj(const ASN1_OBJECT *o);
=head1 DESCRIPTION
The EVP KDF routines are a high level interface to Key Derivation Function
algorithms and should be used instead of algorithm-specific functions.
After creating a C<EVP_KDF_CTX> for the required algorithm using
EVP_KDF_CTX_new_id(), inputs to the algorithm are supplied using calls to
EVP_KDF_ctrl(), EVP_KDF_vctrl() or EVP_KDF_ctrl_str() before calling
EVP_KDF_derive() to derive the key.
After creating a C<EVP_KDF_CTX> for the required algorithm using either
EVP_KDF_CTX_new() or EVP_KDF_CTX_new_id(), inputs to the algorithm are supplied
using calls to EVP_KDF_ctrl(), EVP_KDF_vctrl() or EVP_KDF_ctrl_str() before
calling EVP_KDF_derive() to derive the key.
=head2 Types
B<EVP_KDF> is a type that holds the implementation of a KDF.
B<EVP_KDF_CTX> is a context type that holds the algorithm inputs.
=head2 Context manipulation functions
EVP_KDF_CTX_new_id() creates a KDF context for the algorithm identified by the
specified NID.
EVP_KDF_CTX_new() creates a new context for the KDF type C<kdf>.
EVP_KDF_CTX_new_id() creates a new context for the numerical KDF identity C<nid>.
EVP_KDF_CTX_free() frees up the context C<ctx>. If C<ctx> is C<NULL>, nothing
is done.
EVP_KDF_CTX_kdf() returns the B<EVP_KDF> associated with the context
C<ctx>.
=head2 Computing functions
EVP_KDF_reset() resets the context to the default state as if the context
@@ -61,15 +76,32 @@ EVP_KDF_ctrl_str() allows an application to send an algorithm specific control
operation to a context C<ctx> in string form. This is intended to be used for
options specified on the command line or in text files.
EVP_KDF_derive() derives C<keylen> bytes of key material and places it in the
C<key> buffer. If the algorithm produces a fixed amount of output then an
error will occur unless the C<keylen> parameter is equal to that output size,
as returned by EVP_KDF_size().
=head2 Information functions
EVP_KDF_size() returns the output size if the algorithm produces a fixed amount
of output and C<SIZE_MAX> otherwise. If an error occurs then 0 is returned.
For some algorithms an error may result if input parameters necessary to
calculate a fixed output size have not yet been supplied.
EVP_KDF_derive() derives C<keylen> bytes of key material and places it in the
C<key> buffer. If the algorithm produces a fixed amount of output then an
error will occur unless the C<keylen> parameter is equal to that output size,
as returned by EVP_KDF_size().
EVP_KDF_nid() returns the numeric identity of the given KDF implementation.
EVP_KDF_name() returns the name of the given KDF implementation.
=head2 Object database functions
EVP_get_kdfbyname() fetches a KDF implementation from the object
database by name.
EVP_get_kdfbynid() fetches a KDF implementation from the object
database by numeric identity.
EVP_get_kdfbyobj() fetches a KDF implementation from the object
database by ASN.1 OBJECT (i.e. an encoded OID).
=head1 CONTROLS
@@ -213,14 +245,26 @@ The value string is expected to be a decimal number.
=head1 RETURN VALUES
EVP_KDF_CTX_new_id() returns either the newly allocated C<EVP_KDF_CTX>
structure or C<NULL> if an error occurred.
EVP_KDF_CTX_new() and EVP_KDF_CTX_new_id() return either the newly allocated
C<EVP_KDF_CTX> structure or C<NULL> if an error occurred.
EVP_KDF_CTX_free() and EVP_KDF_reset() do not return a value.
EVP_KDF_size() returns the output size. C<SIZE_MAX> is returned to indicate
that the algorithm produces a variable amount of output; 0 to indicate failure.
EVP_KDF_nid() returns the numeric identity for the given C<kdf>.
EVP_KDF_name() returns the name for the given C<kdf>, if it has been
added to the object database.
EVP_add_kdf() returns 1 if the given C<kdf> was successfully added to
the object database, otherwise 0.
EVP_get_kdfbyname(), EVP_get_kdfbynid() and EVP_get_kdfbyobj() return
the requested KDF implementation, if it exists in the object database,
otherwise B<NULL>.
The remaining functions return 1 for success and 0 or a negative value for
failure. In particular, a return value of -2 indicates the operation is not
supported by the KDF algorithm.
@@ -233,6 +277,7 @@ L<EVP_KDF_PBKDF2(7)>
L<EVP_KDF_HKDF(7)>
L<EVP_KDF_SS(7)>
L<EVP_KDF_SSHKDF(7)>
L<EVP_KDF_X963(7)>
=head1 HISTORY
+4 -4
View File
@@ -286,7 +286,7 @@ L<EVP_PKEY_verify_recover_init(3)> and L<EVP_PKEY_verify_recover(3)>.
The signctx_init() and signctx() methods are used to sign a digest present by
a B<EVP_MD_CTX> object. They are called by the EVP_DigestSign functions. See
L<EVP_DigestSignInit(3)> for detail.
L<EVP_DigestSignInit(3)> for details.
int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
@@ -294,7 +294,7 @@ L<EVP_DigestSignInit(3)> for detail.
The verifyctx_init() and verifyctx() methods are used to verify a signature
against the data in a B<EVP_MD_CTX> object. They are called by the various
EVP_DigestVerify functions. See L<EVP_DigestVerifyInit(3)> for detail.
EVP_DigestVerify functions. See L<EVP_DigestVerifyInit(3)> for details.
int (*encrypt_init) (EVP_PKEY_CTX *ctx);
int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
@@ -321,7 +321,7 @@ L<EVP_PKEY_derive_init(3)> and L<EVP_PKEY_derive(3)>.
int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
The ctrl() and ctrl_str() methods are used to adjust algorithm-specific
settings. See L<EVP_PKEY_CTX_ctrl(3)> and related functions for detail.
settings. See L<EVP_PKEY_CTX_ctrl(3)> and related functions for details.
int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
const unsigned char *tbs, size_t tbslen);
@@ -330,7 +330,7 @@ settings. See L<EVP_PKEY_CTX_ctrl(3)> and related functions for detail.
size_t tbslen);
The digestsign() and digestverify() methods are used to generate or verify
a signature in a one-shot mode. They could be called by L<EVP_DigetSign(3)>
a signature in a one-shot mode. They could be called by L<EVP_DigestSign(3)>
and L<EVP_DigestVerify(3)>.
int (*check) (EVP_PKEY *pkey);
+2 -1
View File
@@ -250,7 +250,8 @@ All other functions return B<1> on success and B<0> on failure.
=head1 NOTES
Integral types will be widened and sign extended as required.
Native types will be converted as required only if the value is exactly
representable by the target type or parameter.
Apart from that, the functions must be used appropriately for the
expected type of the parameter.
+6
View File
@@ -55,6 +55,11 @@ The content of B<buf> cannot be recovered from subsequent random generator outpu
Applications that intend to save and restore random state in an external file
should consider using L<RAND_load_file(3)> instead.
NOTE: In FIPS mode, random data provided by the application is not considered to
be a trusted entropy source. It is mixed into the internal state of the RNG as
additional data only and this does not count as a full reseed.
For more details, see L<RAND_DRBG(7)>.
RAND_seed() is equivalent to RAND_add() with B<randomness> set to B<num>.
RAND_keep_random_devices_open() is used to control file descriptor
@@ -86,6 +91,7 @@ L<RAND_bytes(3)>,
L<RAND_egd(3)>,
L<RAND_load_file(3)>,
L<RAND(7)>
L<RAND_DRBG(7)>
=head1 HISTORY
+1 -1
View File
@@ -8,7 +8,7 @@ SSL_session_reused - query whether a reused session was negotiated during handsh
#include <openssl/ssl.h>
int SSL_session_reused(SSL *ssl);
int SSL_session_reused(const SSL *ssl);
=head1 DESCRIPTION
+29 -2
View File
@@ -2,12 +2,13 @@
=head1 NAME
SSL_write_ex, SSL_write - write bytes to a TLS/SSL connection
SSL_write_ex, SSL_write, SSL_sendfile - write bytes to a TLS/SSL connection
=head1 SYNOPSIS
#include <openssl/ssl.h>
ossl_ssize_t SSL_sendfile(SSL *s, int fd, off_t offset, size_t size, int flags);
int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written);
int SSL_write(SSL *ssl, const void *buf, int num);
@@ -17,6 +18,14 @@ SSL_write_ex() and SSL_write() write B<num> bytes from the buffer B<buf> into
the specified B<ssl> connection. On success SSL_write_ex() will store the number
of bytes written in B<*written>.
SSL_sendfile() writes B<size> bytes from offset B<offset> in the file
descriptor B<fd> to the specified SSL connection B<s>. This function provides
efficient zero-copy semantics. SSL_sendfile() is available only when
Kernel TLS is enabled, which can be checked by calling BIO_get_ktls_send().
It is provided here to allow users to maintain the same interface.
The meaning of B<flags> is platform dependent.
Currently, under Linux it is ignored.
=head1 NOTES
In the paragraphs below a "write function" is defined as one of either
@@ -104,17 +113,35 @@ You should instead call SSL_get_error() to find out if it's retryable.
=back
For SSL_sendfile(), the following return values can occur:
=over 4
=item Z<>>= 0
The write operation was successful, the return value is the number
of bytes of the file written to the TLS/SSL connection.
=item E<lt> 0
The write operation was not successful, because either the connection was
closed, an error occured or action must be taken by the calling process.
Call SSL_get_error() with the return value to find out the reason.
=back
=head1 SEE ALSO
L<SSL_get_error(3)>, L<SSL_read_ex(3)>, L<SSL_read(3)>
L<SSL_CTX_set_mode(3)>, L<SSL_CTX_new(3)>,
L<SSL_connect(3)>, L<SSL_accept(3)>
L<SSL_set_connect_state(3)>,
L<SSL_set_connect_state(3)>, L<BIO_ctrl(3)>,
L<ssl(7)>, L<bio(7)>
=head1 HISTORY
The SSL_write_ex() function was added in OpenSSL 1.1.1.
The SSL_sendfile() function was added in OpenSSL 3.0.0.
=head1 COPYRIGHT
+136
View File
@@ -0,0 +1,136 @@
=pod
=head1 NAME
EVP_KDF_X963 - The X9.63-2001 EVP_KDF implementation
=head1 DESCRIPTION
The EVP_KDF_X963 algorithm implements the key derivation function (X963KDF).
X963KDF is used by Cryptographic Message Syntax (CMS) for EC KeyAgreement, to
derive a key using input such as a shared secret key and shared info.
=head2 Numeric identity
B<EVP_KDF_X963> is the numeric identity for this implementation; it
can be used with the EVP_KDF_CTX_new_id() function.
=head2 Supported controls
The supported controls are:
=over 4
=item B<EVP_KDF_CTRL_SET_MD>
This control works as described in L<EVP_KDF_CTX(3)/CONTROLS>.
=item B<EVP_KDF_CTRL_SET_KEY>
This control expects two arguments: C<unsigned char *secret>, C<size_t secretlen>
The shared secret used for key derivation. This control sets the secret.
EVP_KDF_ctrl_str() takes two type strings for this control:
=over 4
=item "secret"
The value string is used as is.
=item "hexsecret"
The value string is expected to be a hexadecimal number, which will be
decoded before being passed on as the control value.
=back
=item B<EVP_KDF_CTRL_SET_SHARED_INFO>
This control expects two arguments: C<unsigned char *info>, C<size_t infolen>
An optional value for shared info. This control sets the shared info.
EVP_KDF_ctrl_str() takes two type strings for this control:
=over 4
=item "info"
The value string is used as is.
=item "hexinfo"
The value string is expected to be a hexadecimal number, which will be
decoded before being passed on as the control value.
=back
=back
=head1 NOTES
X963KDF is very similar to the SSKDF that uses a digest as the auxilary function,
X963KDF appends the counter to the secret, whereas SSKDF prepends the counter.
A context for X963KDF can be obtained by calling:
EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_X963);
The output length of an X963KDF is specified via the C<keylen>
parameter to the L<EVP_KDF_derive(3)> function.
=head1 EXAMPLE
This example derives 10 bytes, with the secret key "secret" and sharedinfo
value "label":
EVP_KDF_CTX *kctx;
unsigned char out[10];
kctx = EVP_KDF_CTX_new_id(EVP_KDF_X963);
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) {
error("EVP_KDF_CTRL_SET_MD");
}
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", (size_t)6) <= 0) {
error("EVP_KDF_CTRL_SET_KEY");
}
if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SHARED_INFO, "label", (size_t)5) <= 0) {
error("EVP_KDF_CTRL_SET_SHARED_INFO");
}
if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) {
error("EVP_KDF_derive");
}
EVP_KDF_CTX_free(kctx);
=head1 CONFORMING TO
"SEC 1: Elliptic Curve Cryptography"
=head1 SEE ALSO
L<EVP_KDF_CTX>,
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_CTX(3)/CONTROLS>
=head1 HISTORY
This functionality was added to OpenSSL 3.0.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
+7
View File
@@ -264,6 +264,13 @@ from the trusted entropy sources.
=back
NOTE: Manual reseeding is *not allowed* in FIPS mode, because
[NIST SP-800-90Ar1] mandates that entropy *shall not* be provided by
the consuming application for instantiation (Section 9.1) or
reseeding (Section 9.2). For that reason, the B<randomness>
argument is ignored and the random bytes provided by the L<RAND_add(3)> and
L<RAND_seed(3)> calls are treated as additional data.
=head2 Reseeding the master DRBG with automatic seeding disabled
Calling RAND_poll() will always fail.