Matt Caswell 31625a6b4f Copyright year updates 3 maanden geleden
..
aes aad5c78403 Copyright year updates 8 maanden geleden
aria 3c2bdd7df9 Update copyright year 3 jaren geleden
asn1 31625a6b4f Copyright year updates 3 maanden geleden
async ee71383a8d Update copyright year 2 jaren geleden
bf 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
bio cb224f4e27 Update copyright year 1 jaar geleden
bn bde822724f Avoid an infinite loop in BN_GF2m_mod_inv 5 maanden geleden
buffer 38fc02a708 Update copyright year 2 jaren geleden
camellia 6cfbb4b30f Rename x86-32 assembly files from .s to .S. 2 jaren geleden
cast 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
chacha aad5c78403 Copyright year updates 8 maanden geleden
cmac 36bbaa8b05 Update copyright year 1 jaar geleden
cmp aad5c78403 Copyright year updates 8 maanden geleden
cms 31625a6b4f Copyright year updates 3 maanden geleden
comp 8c5016e65d Fix coverity 1493364 & 1493375: unchecked return value 2 jaren geleden
conf dd073c426a Detect and prevent recursive config parsing 5 maanden geleden
crmf bdb66dd4c5 Fix the check of EVP_PKEY_decrypt_init 1 jaar geleden
ct 36bbaa8b05 Update copyright year 1 jaar geleden
des 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
dh ddeb4b6c6d Make DH_check_pub_key() and DH_generate_key() safer yet 6 maanden geleden
dsa e6e6113ebb Copyright year updates 7 maanden geleden
dso 967f201440 Update copyright year 1 jaar geleden
ec 31625a6b4f Copyright year updates 3 maanden geleden
encode_decode aad5c78403 Copyright year updates 8 maanden geleden
engine e6e6113ebb Copyright year updates 7 maanden geleden
err dd073c426a Detect and prevent recursive config parsing 5 maanden geleden
ess b93f6c2db9 err: rename err_load_xxx_strings_int functions 3 jaren geleden
evp 31625a6b4f Copyright year updates 3 maanden geleden
ffc 3cf88328a9 DH_check_pub_key() should not fail when setting result code 7 maanden geleden
hmac 21dfdbef49 Adapt other parts of the source to the changed EVP_Q_digest() and EVP_Q_mac() 2 jaren geleden
http f437288d5f Fix some invalid use of sscanf 5 maanden geleden
idea 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
kdf 905b097fd5 Deprecate ERR_load_KDF_strings() 4 jaren geleden
lhash e6e6113ebb Copyright year updates 7 maanden geleden
md2 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
md4 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
md5 3fcaf6b647 Enable BTI feature for md5 on aarch64 5 maanden geleden
mdc2 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
modes 99630a1b08 aes-gcm-avx512.pl: fix non-reproducibility issue 7 maanden geleden
objects 31625a6b4f Copyright year updates 3 maanden geleden
ocsp cb224f4e27 Update copyright year 1 jaar geleden
pem aad5c78403 Copyright year updates 8 maanden geleden
perlasm 612119b388 x86_64-xlate.pl: Fix build with icx and nvc compilers 6 maanden geleden
pkcs12 31625a6b4f Copyright year updates 3 maanden geleden
pkcs7 31625a6b4f Copyright year updates 3 maanden geleden
poly1305 31625a6b4f Copyright year updates 3 maanden geleden
property b861ae7e65 Add overflow checks to parse_number/parse_hex/parse_oct 5 maanden geleden
rand e6e6113ebb Copyright year updates 7 maanden geleden
rc2 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
rc4 0cfbef388f Set RC4 defines on libcrypto/liblegacy 11 maanden geleden
rc5 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
ripemd 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
rsa 31625a6b4f Copyright year updates 3 maanden geleden
seed 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
sha aad5c78403 Copyright year updates 8 maanden geleden
siphash 2c54276e89 crypto/*: Fix various typos, repeated words, align some spelling to LDP. 1 jaar geleden
sm2 597a8a7bcf Update copyright year 1 jaar geleden
sm3 e265fe3ad2 Copyright year updates 10 maanden geleden
sm4 b38f4029be Use armv8 .quad instead of .dword 8 maanden geleden
srp aad5c78403 Copyright year updates 8 maanden geleden
stack 6c366417f7 Errors raised from OPENSSL_sk_set should have ERR_LIB_CRYPTO 1 jaar geleden
store aad5c78403 Copyright year updates 8 maanden geleden
ts 967f201440 Update copyright year 1 jaar geleden
txt_db 967f201440 Update copyright year 1 jaar geleden
ui 597a8a7bcf Update copyright year 1 jaar geleden
whrlpool 58e8162e73 Avoid duplicating symbols in legacy.a with some build options 1 jaar geleden
x509 31625a6b4f Copyright year updates 3 maanden geleden
LPdir_nyi.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
LPdir_unix.c e265fe3ad2 Copyright year updates 10 maanden geleden
LPdir_vms.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
LPdir_win.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
LPdir_win32.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
LPdir_wince.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
README-sparse_array.md 1dc1ea182b Fix many MarkDown issues in {NOTES*,README*,HACKING,LICENSE}.md files 3 jaren geleden
alphacpuid.pl 33388b44b6 Update copyright year 4 jaren geleden
arm64cpuid.pl 967f201440 Update copyright year 1 jaar geleden
arm_arch.h aad5c78403 Copyright year updates 8 maanden geleden
armcap.c e7bb35e0c3 Backport crypto/armcap.c from master branch 10 maanden geleden
armv4cpuid.pl aad5c78403 Copyright year updates 8 maanden geleden
asn1_dsa.c 3c2bdd7df9 Update copyright year 3 jaren geleden
bsearch.c 5c3f1e34b5 ossl_bsearch(): New generic internal binary search utility function 5 jaren geleden
build.info a959bf8d9e Do not include sparse_array.o in libssl 8 maanden geleden
c64xpluscpuid.pl 33388b44b6 Update copyright year 4 jaren geleden
context.c 597a8a7bcf Update copyright year 1 jaar geleden
core_algorithm.c ddb81a94ac "Reserve" the method store when constructing methods 1 jaar geleden
core_fetch.c ddb81a94ac "Reserve" the method store when constructing methods 1 jaar geleden
core_namemap.c e265fe3ad2 Copyright year updates 10 maanden geleden
cpt_err.c a99bc33130 err: add additional errors 1 jaar geleden
cpuid.c 967f201440 Update copyright year 1 jaar geleden
cryptlib.c 967f201440 Update copyright year 1 jaar geleden
ctype.c 27e8f212d8 tolower: refine the tolower code to avoid a memory access 2 jaren geleden
cversion.c 26b7cc0d20 Cleanup include/openssl/opensslv.h.in 4 jaren geleden
der_writer.c 0202f1d49e Update copyright year 1 jaar geleden
dllmain.c 967f201440 Update copyright year 1 jaar geleden
ebcdic.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
ex_data.c 8edc82a9f4 Fix error handling in CRYPTO_get_ex_new_index 8 maanden geleden
getenv.c 967f201440 Update copyright year 1 jaar geleden
ia64cpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
info.c cb224f4e27 Update copyright year 1 jaar geleden
init.c 97477bb6c4 Move e_os.h to include/internal 1 jaar geleden
initthread.c e6e6113ebb Copyright year updates 7 maanden geleden
loongarch64cpuid.pl e5a5a194fa Add LoongArch64 cpuid and OPENSSL_loongarchcap_P 1 jaar geleden
loongarch_arch.h a2699c422d Resolve assembler complains when including loongarch_arch.h 9 maanden geleden
loongarchcap.c e265fe3ad2 Copyright year updates 10 maanden geleden
mem.c 77ce9ea496 Windows: use srand() instead of srandom() 7 maanden geleden
mem_clr.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
mem_sec.c 0d96d00f1f Add locking to CRYPTO_secure_used 5 maanden geleden
mips_arch.h ae4186b004 Fix header file include guard names 4 jaren geleden
o_dir.c 967f201440 Update copyright year 1 jaar geleden
o_fopen.c 967f201440 Update copyright year 1 jaar geleden
o_init.c 967f201440 Update copyright year 1 jaar geleden
o_str.c 97477bb6c4 Move e_os.h to include/internal 1 jaar geleden
o_time.c 8020d79b40 Update copyright year 3 jaren geleden
packet.c 4b20cbbe1c Update copyright year 1 jaar geleden
param_build.c d41b267124 ossl-params: check length returned by strlen() 5 maanden geleden
param_build_set.c e6e6113ebb Copyright year updates 7 maanden geleden
params.c 7dfbf277e9 crypto/params: drop float for UEFI 11 maanden geleden
params_dup.c 4c4ac7c7dd param dup: add errors to failure returns 1 jaar geleden
params_from_text.c 31625a6b4f Copyright year updates 3 maanden geleden
pariscid.pl 33388b44b6 Update copyright year 4 jaren geleden
passphrase.c ee71383a8d Update copyright year 2 jaren geleden
ppccap.c 967f201440 Update copyright year 1 jaar geleden
ppccpuid.pl 967f201440 Update copyright year 1 jaar geleden
provider.c 5ab06d33e6 Correctly activate the provider in OSSL_PROVIDER_try_load 2 jaren geleden
provider_child.c cb224f4e27 Update copyright year 1 jaar geleden
provider_conf.c dd073c426a Detect and prevent recursive config parsing 5 maanden geleden
provider_core.c 538f9d2d28 After initializing a provider, check if its output dispatch table is NULL 5 maanden geleden
provider_local.h b7248964a4 make struct provider_info_st a full type 2 jaren geleden
provider_predefined.c b7248964a4 make struct provider_info_st a full type 2 jaren geleden
punycode.c 967f201440 Update copyright year 1 jaar geleden
riscv32cpuid.pl 2f97366e46 Add RISC-V 32 cpuid support 1 jaar geleden
riscv64cpuid.pl 8448432a3b Add basic RISC-V cpuid and OPENSSL_riscvcap 1 jaar geleden
riscvcap.c 8448432a3b Add basic RISC-V cpuid and OPENSSL_riscvcap 1 jaar geleden
s390x_arch.h 1b08f849cb Update copyright year 2 jaren geleden
s390xcap.c e265fe3ad2 Copyright year updates 10 maanden geleden
s390xcpuid.pl 33388b44b6 Update copyright year 4 jaren geleden
self_test_core.c 967f201440 Update copyright year 1 jaar geleden
sparccpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
sparcv9cap.c 52f7e44ec8 Split bignum code out of the sparcv9cap.c 2 jaren geleden
sparse_array.c 4f1f3e1472 Coverity 1507376: Dereference after null check 1 jaar geleden
threads_lib.c 19e1bc0e97 Update copyright year 1 jaar geleden
threads_none.c 3c2bdd7df9 Update copyright year 3 jaren geleden
threads_pthread.c aad5c78403 Copyright year updates 8 maanden geleden
threads_win.c 597a8a7bcf Update copyright year 1 jaar geleden
trace.c cb224f4e27 Update copyright year 1 jaar geleden
uid.c a0bbd4be5a Openssl fails to compile on Debian with kfreebsd kernels 2 jaren geleden
vms_rms.h 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 5 jaren geleden
x86_64cpuid.pl 3c2bdd7df9 Update copyright year 3 jaren geleden
x86cpuid.pl 33388b44b6 Update copyright year 4 jaren geleden

README-sparse_array.md

Sparse Arrays

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.