openssl/crypto
Bernd Edlinger 9d079f2744 Add some missing cfi frame info in x25519-x86_64.pl
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/10676)
2019-12-23 17:01:55 +01:00
..
aes Fix aesni_cbc_sha256_enc_avx2 backtrace info 2019-12-23 16:57:42 +01:00
aria
asn1 ASN1: Adapt ASN.1 output routines to use BIO_f_prefix() 2019-12-18 19:42:44 +01:00
async Explicitly test against NULL; do not use !p or similar 2019-10-09 21:32:15 +02:00
bf
bio BIO: Add BIO_f_prefix(), a text line prefixing filter 2019-12-18 19:42:44 +01:00
bn Add some missing cfi frame info in rsaz-x86_64 2019-12-20 23:05:42 +01:00
buffer Rework how our providers are built 2019-10-10 14:12:15 +02:00
camellia Add some missing cfi frame info in camellia-x86_64.pl 2019-12-20 22:41:32 +01:00
cast
chacha chacha/asm/chacha-armv8.pl: preserve FP registers d8 and d9 correctly 2019-11-28 16:40:43 +01:00
cmac [KDF] Add feedback-mode and CMAC support to KBKDF 2019-10-17 12:45:03 +10:00
cmp chunk 6 of CMP contribution to OpenSSL 2019-12-12 10:57:25 +00:00
cms PEM: constify PEM_write_ routines 2019-11-18 02:34:12 +01:00
comp
conf Fix an uninitialised read in conf_def.c 2019-11-14 10:42:45 +00:00
crmf chunk 6 of CMP contribution to OpenSSL 2019-12-12 10:57:25 +00:00
ct Replace BUF_ string function calls with OPENSSL_ ones 2019-10-17 23:19:59 +02:00
des CRYPTO: split cipher_platform.h into algorithm specific headers 2019-12-19 13:31:29 +01:00
dh Update source files for pre-3.0 deprecation 2019-11-07 11:37:25 +01:00
dsa Update source files for pre-3.0 deprecation 2019-11-07 11:37:25 +01:00
dso
ec Add some missing cfi frame info in x25519-x86_64.pl 2019-12-23 17:01:55 +01:00
engine Engine: Add NULL check. 2019-11-21 14:31:58 +10:00
err chunk 6 of CMP contribution to OpenSSL 2019-12-12 10:57:25 +00:00
ess
evp EVP & PROV: Fix all platform inclusions 2019-12-19 13:33:35 +01:00
hmac Update source files for pre-3.0 deprecation 2019-11-07 11:37:25 +01:00
idea
kdf Deprecate ERR_load_KDF_strings() 2019-11-12 13:30:35 +01:00
lhash Rework how our providers are built 2019-10-10 14:12:15 +02:00
md2
md4 md4/md5: macros should not include the line following them 2019-11-01 15:58:00 +01:00
md5 md4/md5: macros should not include the line following them 2019-11-01 15:58:00 +01:00
mdc2
modes Optimize AES-GCM implementation on aarch64 2019-12-19 12:36:07 +10:00
objects Deprecate most of debug-memory 2019-12-14 20:57:35 +01:00
ocsp Explicitly test against NULL; do not use !p or similar 2019-10-09 21:32:15 +02:00
pem PROV SERIALIZER: add common functionality to serialize keys 2019-11-29 20:55:16 +01:00
perlasm crypto/perlasm/ppc-xlate.pl: add linux64v2 flavour 2019-12-11 18:31:32 +01:00
pkcs7 Explicitly test against NULL; do not use !p or similar 2019-10-09 21:32:15 +02:00
pkcs12 Update source files for pre-3.0 deprecation 2019-11-07 11:37:25 +01:00
poly1305 s390x assembly pack: perlasm module update 2019-11-05 10:05:27 +01:00
property Fix some typos 2019-12-11 19:04:01 +01:00
rand rand_lib.c: fix null pointer dereferences after RAND_get_rand_method() failure 2019-12-12 07:41:00 +10:00
rc2
rc4 s390x assembly pack: enable clang build 2019-11-03 11:25:31 +01:00
rc5
ripemd Fix missing Assembler defines 2019-10-16 16:10:39 +10:00
rsa Remove asn1 module dependency from RSASSA-PKCS1-v1_5 implementation. 2019-12-22 09:37:17 +10:00
seed
serializer Fix some typos 2019-12-11 19:04:01 +01:00
sha Add some missing cfi frame info in aesni-sha and sha-x86_64.pl 2019-12-20 23:14:37 +01:00
siphash
sm2
sm3 Cleanup legacy digest methods. 2019-12-18 14:46:01 +10:00
sm4
srp Update source files for pre-3.0 deprecation 2019-11-07 11:37:25 +01:00
stack Rework how our providers are built 2019-10-10 14:12:15 +02:00
store OSSL_STORE: add tracing 2019-11-03 18:38:23 +01:00
ts Fix typo and create compatibility macro 2019-10-16 12:37:20 +02:00
txt_db
ui UI_UTIL_wrap_read_pem_callback(): when |cb| is NULL, use PEM_def_callback 2019-11-22 15:19:19 +01:00
whrlpool Fix missing Assembler defines 2019-10-16 16:10:39 +10:00
x509 Add support for otherName:NAIRealm in output 2019-12-11 22:29:19 +03:00
alphacpuid.pl
arm64cpuid.pl
arm_arch.h
armcap.c
armv4cpuid.pl
asn1_dsa.c Fix some typos 2019-12-11 19:04:01 +01:00
bsearch.c
build.info Optimize AES-GCM implementation on aarch64 2019-12-19 12:36:07 +10:00
c64xpluscpuid.pl
context.c
core_algorithm.c
core_fetch.c CORE: pass the full algorithm definition to the method constructor 2019-11-29 20:42:12 +01:00
core_namemap.c CORE: ossl_namemap_add_names(): new function to add multiple names 2019-11-29 20:42:12 +01:00
cpt_err.c CORE: ossl_namemap_add_names(): new function to add multiple names 2019-11-29 20:42:12 +01:00
cryptlib.c
ctype.c
cversion.c Cleanup include/openssl/opensslv.h.in 2019-11-08 16:12:57 +01:00
dllmain.c
ebcdic.c
ex_data.c Deprecate most of debug-memory 2019-12-14 20:57:35 +01:00
getenv.c
ia64cpuid.S
info.c
init.c
initthread.c Thread: Avoid a NULL dereference after failed initialisation. 2019-11-22 15:26:33 +10:00
LPdir_nyi.c
LPdir_unix.c Fix a -Warray-bounds gcc warning in OPENSSL_DIR_read 2019-11-09 10:49:34 +01:00
LPdir_vms.c
LPdir_win32.c
LPdir_win.c
LPdir_wince.c
mem_clr.c
mem_sec.c
mem.c Fix build when enabling mdebug options. 2019-12-18 15:06:15 +10:00
mips_arch.h
o_dir.c
o_fips.c
o_fopen.c
o_init.c
o_str.c
o_time.c
packet.c
param_build.c
params_from_text.c
params.c Allow strings in params to be of zero length 2019-11-14 09:29:21 +00:00
pariscid.pl
ppc_arch.h
ppccap.c
ppccpuid.pl
provider_conf.c
provider_core.c Deprecate most of debug-memory 2019-12-14 20:57:35 +01:00
provider_local.h
provider_predefined.c
provider.c
README.sparse_array
s390x_arch.h
s390xcap.c crypto/s390xcap.c: Add guards around the GETAUXVAL checks 2019-10-21 15:14:09 +02:00
s390xcpuid.pl s390x assembly pack: enable clang build 2019-11-03 11:25:31 +01:00
sparc_arch.h
sparccpuid.S
sparcv9cap.c
sparse_array.c
threads_none.c
threads_pthread.c
threads_win.c
trace.c OSSL_STORE: add tracing 2019-11-03 18:38:23 +01:00
uid.c
vms_rms.h
x86_64cpuid.pl Fix unwind info for some trivial functions 2019-12-18 14:26:50 +01:00
x86cpuid.pl

The sparse_array.c file contains an implementation of a sparse array that
attempts to be both space and time efficient.

The sparse array is represented using a tree structure.  Each node in the
tree contains a block of pointers to either the user supplied leaf values or
to another node.

There are a number of parameters used to define the block size:

    OPENSSL_SA_BLOCK_BITS   Specifies the number of bits covered by each block
    SA_BLOCK_MAX            Specifies the number of pointers in each block
    SA_BLOCK_MASK           Specifies a bit mask to perform modulo block size
    SA_BLOCK_MAX_LEVELS     Indicates the maximum possible height of the tree

These constants are inter-related:
    SA_BLOCK_MAX        = 2 ^ OPENSSL_SA_BLOCK_BITS
    SA_BLOCK_MASK       = SA_BLOCK_MAX - 1
    SA_BLOCK_MAX_LEVELS = number of bits in size_t divided by
                          OPENSSL_SA_BLOCK_BITS rounded up to the next multiple
                          of OPENSSL_SA_BLOCK_BITS

OPENSSL_SA_BLOCK_BITS can be defined at compile time and this overrides the
built in setting.

As a space and performance optimisation, the height of the tree is usually
less than the maximum possible height.  Only sufficient height is allocated to
accommodate the largest index added to the data structure.

The largest index used to add a value to the array determines the tree height:

        +----------------------+---------------------+
        | Largest Added Index  |   Height of Tree    |
        +----------------------+---------------------+
        | SA_BLOCK_MAX     - 1 |          1          |
        | SA_BLOCK_MAX ^ 2 - 1 |          2          |
        | SA_BLOCK_MAX ^ 3 - 1 |          3          |
        | ...                  |          ...        |
        | size_t max           | SA_BLOCK_MAX_LEVELS |
        +----------------------+---------------------+

The tree height is dynamically increased as needed based on additions.

An empty tree is represented by a NULL root pointer.  Inserting a value at
index 0 results in the allocation of a top level node full of null pointers
except for the single pointer to the user's data (N = SA_BLOCK_MAX for
brevity):

        +----+
        |Root|
        |Node|
        +-+--+
          |
          |
          |
          v
        +-+-+---+---+---+---+
        | 0 | 1 | 2 |...|N-1|
        |   |nil|nil|...|nil|
        +-+-+---+---+---+---+
          |
          |
          |
          v
        +-+--+
        |User|
        |Data|
        +----+
    Index 0


Inserting at element 2N+1 creates a new root node and pushes down the old root
node.  It then creates a second second level node to hold the pointer to the
user's new data:

        +----+
        |Root|
        |Node|
        +-+--+
          |
          |
          |
          v
        +-+-+---+---+---+---+
        | 0 | 1 | 2 |...|N-1|
        |   |nil|   |...|nil|
        +-+-+---+-+-+---+---+
          |       |
          |       +------------------+
          |                          |
          v                          v
        +-+-+---+---+---+---+      +-+-+---+---+---+---+
        | 0 | 1 | 2 |...|N-1|      | 0 | 1 | 2 |...|N-1|
        |nil|   |nil|...|nil|      |nil|   |nil|...|nil|
        +-+-+---+---+---+---+      +---+-+-+---+---+---+
          |                              |
          |                              |
          |                              |
          v                              v
        +-+--+                         +-+--+
        |User|                         |User|
        |Data|                         |Data|
        +----+                         +----+
    Index 0                       Index 2N+1


The nodes themselves are allocated in a sparse manner.  Only nodes which exist
along a path from the root of the tree to an added leaf will be allocated.
The complexity is hidden and nodes are allocated on an as needed basis.
Because the data is expected to be sparse this doesn't result in a large waste
of space.

Values can be removed from the sparse array by setting their index position to
NULL.  The data structure does not attempt to reclaim nodes or reduce the
height of the tree on removal.  For example, now setting index 0 to NULL would
result in:

        +----+
        |Root|
        |Node|
        +-+--+
          |
          |
          |
          v
        +-+-+---+---+---+---+
        | 0 | 1 | 2 |...|N-1|
        |   |nil|   |...|nil|
        +-+-+---+-+-+---+---+
          |       |
          |       +------------------+
          |                          |
          v                          v
        +-+-+---+---+---+---+      +-+-+---+---+---+---+
        | 0 | 1 | 2 |...|N-1|      | 0 | 1 | 2 |...|N-1|
        |nil|nil|nil|...|nil|      |nil|   |nil|...|nil|
        +---+---+---+---+---+      +---+-+-+---+---+---+
                                         |
                                         |
                                         |
                                         v
                                       +-+--+
                                       |User|
                                       |Data|
                                       +----+
                                  Index 2N+1


Accesses to elements in the sparse array take O(log n) time where n is the
largest element.  The base of the logarithm is SA_BLOCK_MAX, so for moderately
small indices (e.g. NIDs), single level (constant time) access is achievable.
Space usage is O(minimum(m, n log(n)) where m is the number of elements in the
array.

Note: sparse arrays only include pointers to types.  Thus, SPARSE_ARRAY_OF(char)
can be used to store a string.