Juergen Christ 42f111ad41 s390: Add new machine generation 2 years ago
..
aes 9c140a3366 disable 5x interleave on buffers shorter than 512 bytes: 3% speedup on Graviton2 2 years ago
aria 1287dabd0b fix some code with obvious wrong coding style 3 years ago
asn1 0176fc78d0 asn1_string_to_time_t: Use timegm on FreeBSD. 2 years ago
async 43ed242956 async_posix: Make ASYNC_set_mem_functions threadsafe 2 years ago
bf 33388b44b6 Update copyright year 4 years ago
bio 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
bn bc6bac8561 Fix failure to check result of bn_rshift_fixed_top 2 years ago
buffer 38fc02a708 Update copyright year 3 years ago
camellia a12a71fafb Fix declaration inconsistency (Camellia) 2 years ago
cast 670ff08e77 Fix logic error for building x86 CAST assembly 4 years ago
chacha 7e1f3ffcc5 Fixed conditional statement testing 64 and 256 bytes 2 years ago
cmac 6d77473251 EVP_Cipher: fix the incomplete return check 3 years ago
cmp c8c923454b OSSL_CMP_CTX_setup_CRM(): Fix handling of defaults from CSR and refcert 2 years ago
cms 07342bad1b CMS sign digest 2 years ago
comp 73a815defe Fix coverity 1493364 & 1493375: unchecked return value 3 years ago
conf d5f9166bac Move e_os.h to include/internal 2 years ago
crmf 2349d7ba57 Fix the return check of OBJ_obj2txt 3 years ago
ct 38fc02a708 Update copyright year 3 years ago
des d5f9166bac Move e_os.h to include/internal 2 years ago
dh 2c0f7d46b8 Replace size check with more meaningful pubkey check 2 years ago
dsa 944f822aad Fix EVP todata and fromdata when used with selection of EVP_PKEY_PUBLIC_KEY. 2 years ago
dso d5f9166bac Move e_os.h to include/internal 2 years ago
ec 766a7d4676 Fix Coverity 1498612 & 1503221: integer overflow 2 years ago
encode_decode 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
engine bd5c91c82c eng_dyn: Avoid spurious errors when checking for 1.1.x engine 2 years ago
err 07342bad1b CMS sign digest 2 years ago
ess b93f6c2db9 err: rename err_load_xxx_strings_int functions 3 years ago
evp 4908787f21 SM4 optimization for ARM by ASIMD 2 years ago
ffc d5f9166bac Move e_os.h to include/internal 2 years ago
hmac 21dfdbef49 Adapt other parts of the source to the changed EVP_Q_digest() and EVP_Q_mac() 3 years ago
http d5f9166bac Move e_os.h to include/internal 2 years ago
idea 3c2bdd7df9 Update copyright year 3 years ago
kdf 905b097fd5 Deprecate ERR_load_KDF_strings() 5 years ago
lhash 77d7b6eebb Remove statistics tracking from LHASH 2 years ago
md2 33388b44b6 Update copyright year 4 years ago
md4 33388b44b6 Update copyright year 4 years ago
md5 54b4053130 Update copyright year 3 years ago
mdc2 33388b44b6 Update copyright year 4 years ago
modes 3b5b91992c Fix incorrect comments in aes-gcm-armv8-unroll8_64.pl 2 years ago
objects 065442165a Add testing of OBJ_find_sigid_by_algs() 2 years ago
ocsp 79b2a2f2ee add OSSL_STACK_OF_X509_free() for commonly used pattern 2 years ago
pem 2823e2e1d3 crypto/pem/pem_lib.c: Add check for BIO_read 2 years ago
perlasm 224ea84b40 aes-gcm-avx512.pl: Fixed mingw64 build 2 years ago
pkcs12 cfd24cde81 Add support for mac-less password-base PKCS12 files to PKCS12_parse API. 2 years ago
pkcs7 04bc3c1277 Fix malloc failure handling of X509_ALGOR_set0() 2 years ago
poly1305 40c24d74de Don't use __ARMEL__/__ARMEB__ in aarch64 assembly 2 years ago
property 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
rand 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
rc2 aff636a489 Update copyright year 3 years ago
rc4 572e6df7db rename md5_block_asm_data_order to ossl_md5_block_asm_data_order 4 years ago
rc5 33388b44b6 Update copyright year 4 years ago
ripemd 848af5e8fe Drop libimplementations.a 3 years ago
rsa aefbcde291 rsa: add check after calling BN_BLINDING_lock 2 years ago
seed 38fc02a708 Update copyright year 3 years ago
sha 1cc94e2fa7 Fix outdated comments 2 years ago
siphash 5db682733d Fix a TODO(3.0) in the siphash code 3 years ago
sm2 e81c81c9af Add missing check according to SM2 Digital Signature generation algorithm 3 years ago
sm3 bca6cc53d4 Fix sm3ss1 translation issue in sm3-armv8.pl 2 years ago
sm4 4908787f21 SM4 optimization for ARM by ASIMD 2 years ago
srp 1287dabd0b fix some code with obvious wrong coding style 3 years ago
stack 7cc5738a56 Fix Coverity 1493746: constant expression result 3 years ago
store 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
ts d5f9166bac Move e_os.h to include/internal 2 years ago
txt_db 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
ui d5f9166bac Move e_os.h to include/internal 2 years ago
whrlpool 202cbdd2fc A few cleanups of the provider build.infos 3 years ago
x509 1753559230 Avoid potential memory leak 2 years ago
LPdir_nyi.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
LPdir_unix.c 1287dabd0b fix some code with obvious wrong coding style 3 years ago
LPdir_vms.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
LPdir_win.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
LPdir_win32.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
LPdir_wince.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
README-sparse_array.md 1dc1ea182b Fix many MarkDown issues in {NOTES*,README*,HACKING,LICENSE}.md files 4 years ago
alphacpuid.pl 33388b44b6 Update copyright year 4 years ago
arm64cpuid.pl 3a23f01268 aarch64: fix branch target indications in arm64cpuid.pl and keccak1600 2 years ago
arm_arch.h 954f45ba4c Optimize AES-GCM for uarchs with unroll and new instructions 2 years ago
armcap.c 954f45ba4c Optimize AES-GCM for uarchs with unroll and new instructions 2 years ago
armv4cpuid.pl 33388b44b6 Update copyright year 4 years ago
asn1_dsa.c 3c2bdd7df9 Update copyright year 3 years ago
bsearch.c 5c3f1e34b5 ossl_bsearch(): New generic internal binary search utility function 5 years ago
build.info 7ee992a5d9 Statically link the legacy provider to endecode_test 2 years ago
c64xpluscpuid.pl 33388b44b6 Update copyright year 4 years ago
context.c ed7c64fc54 Remove unused libctx functions (runonce, onfree) 2 years ago
core_algorithm.c cfce50f791 CORE: add a provider argument to ossl_method_construct() 3 years ago
core_fetch.c dc010ca6ec CORE: Encure that cached fetches can be done per provider 3 years ago
core_namemap.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
cpt_err.c 826da1451b err: add additional errors 2 years ago
cpuid.c d5f9166bac Move e_os.h to include/internal 2 years ago
cryptlib.c d5f9166bac Move e_os.h to include/internal 2 years ago
ctype.c 6229815ab8 Use <> for #include openssl/xxx 3 years ago
cversion.c 26b7cc0d20 Cleanup include/openssl/opensslv.h.in 5 years ago
der_writer.c a55b00bdbc der: _ossl prefix DER functions 4 years ago
dllmain.c d5f9166bac Move e_os.h to include/internal 2 years ago
ebcdic.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
ex_data.c a16d21744d Add the ability for ex_data to have a priority 3 years ago
getenv.c d5f9166bac Move e_os.h to include/internal 2 years ago
ia64cpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
info.c d5f9166bac Move e_os.h to include/internal 2 years ago
init.c d5f9166bac Move e_os.h to include/internal 2 years ago
initthread.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
mem.c d5f9166bac Move e_os.h to include/internal 2 years ago
mem_clr.c 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
mem_sec.c d5f9166bac Move e_os.h to include/internal 2 years ago
mips_arch.h ae4186b004 Fix header file include guard names 5 years ago
o_dir.c d5f9166bac Move e_os.h to include/internal 2 years ago
o_fopen.c d5f9166bac Move e_os.h to include/internal 2 years ago
o_init.c d5f9166bac Move e_os.h to include/internal 2 years ago
o_str.c 28e141c45d Change `strlen' argument name to `strlength' to avoid c++ reserved words. 2 years ago
o_time.c 8020d79b40 Update copyright year 3 years ago
packet.c 38fc02a708 Update copyright year 3 years ago
param_build.c 17898ec601 Add support for signed BIGNUMs in the OSSL_PARAM_BLD API 2 years ago
param_build_set.c 3ee3a2bd1e param build set: add errors to failure returns 2 years ago
params.c 327a720d5d OSSL_PARAM_get_*_ptr: Drop errors from ptr/string mismatch 2 years ago
params_dup.c d5f9166bac Move e_os.h to include/internal 2 years ago
params_from_text.c 946bc0e3ec Allow sign extension in OSSL_PARAM_allocate_from_text() 3 years ago
pariscid.pl 33388b44b6 Update copyright year 4 years ago
passphrase.c 59ccb72cd5 Fix invalid malloc failures in PEM_write_bio_PKCS8PrivateKey() 2 years ago
ppccap.c f596bbe4da chacha20 performance optimizations for ppc64le with 8x lanes, 2 years ago
ppccpuid.pl f596bbe4da chacha20 performance optimizations for ppc64le with 8x lanes, 2 years ago
provider.c 1e8ed3e596 Correctly activate the provider in OSSL_PROVIDER_try_load 3 years ago
provider_child.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
provider_conf.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
provider_core.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
provider_local.h b7248964a4 make struct provider_info_st a full type 3 years ago
provider_predefined.c b7248964a4 make struct provider_info_st a full type 3 years ago
punycode.c af16097feb Move more general parts of internal/cryptlib.h to new internal/common.h 3 years ago
s390x_arch.h 37816ef575 s390x: Hide internal cpuid symbol and function 2 years ago
s390xcap.c 42f111ad41 s390: Add new machine generation 2 years ago
s390xcpuid.pl 33388b44b6 Update copyright year 4 years ago
self_test_core.c 927d0566de Refactor OSSL_LIB_CTX to avoid using CRYPTO_EX_DATA 2 years ago
sparccpuid.S 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
sparcv9cap.c 52f7e44ec8 Split bignum code out of the sparcv9cap.c 3 years ago
sparse_array.c 514bd51a8c sparse array: reduces the block size 2 years ago
threads_lib.c c739222b5a Fix no-threads 3 years ago
threads_none.c 3c2bdd7df9 Update copyright year 3 years ago
threads_pthread.c 5979596247 Some platforms don't have pthread_atfork 2 years ago
threads_win.c eeb612021e Explicitly #include <synchapi.h> is unnecessary 3 years ago
trace.c d5f9166bac Move e_os.h to include/internal 2 years ago
uid.c 3a1fa0116a Openssl fails to compile on Debian with kfreebsd kernels 3 years ago
vms_rms.h 0e9725bcb9 Following the license change, modify the boilerplates in crypto/ 6 years ago
x86_64cpuid.pl 3c2bdd7df9 Update copyright year 3 years ago
x86cpuid.pl 33388b44b6 Update copyright year 4 years ago

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.